6 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,10 @@ class TextComposition final {
81
81
TextRangeArray* GetRanges () const { return mRanges ; }
82
82
// Returns the widget which is proper to call NotifyIME().
83
83
already_AddRefed<nsIWidget> GetWidget () const {
84
- return mPresContext ? mPresContext ->GetRootWidget () : nullptr ;
84
+ if (!mPresContext ) {
85
+ return nullptr ;
86
+ }
87
+ return do_AddRef (mPresContext ->GetRootWidget ());
85
88
}
86
89
// Returns the tab parent which has this composition in its remote process.
87
90
BrowserParent* GetBrowserParent () const { return mBrowserParent ; }
Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ already_AddRefed<nsPIDOMWindowOuter> BrowserParent::GetParentWindowOuter() {
356
356
already_AddRefed<nsIWidget> BrowserParent::GetTopLevelWidget () {
357
357
if (RefPtr<Element> element = mFrameElement ) {
358
358
if (PresShell* presShell = element->OwnerDoc ()->GetPresShell ()) {
359
- return presShell->GetViewManager ()->GetRootWidget ();
359
+ return do_AddRef ( presShell->GetViewManager ()->GetRootWidget () );
360
360
}
361
361
}
362
362
return nullptr ;
Original file line number Diff line number Diff line change @@ -1167,13 +1167,12 @@ nsIWidget* nsPresContext::GetNearestWidget(nsPoint* aOffset) {
1167
1167
return rootView->GetNearestWidget (aOffset);
1168
1168
}
1169
1169
1170
- already_AddRefed< nsIWidget> nsPresContext::GetRootWidget () const {
1170
+ nsIWidget* nsPresContext::GetRootWidget () const {
1171
1171
NS_ENSURE_TRUE (mPresShell , nullptr );
1172
1172
nsViewManager* vm = mPresShell ->GetViewManager ();
1173
1173
if (!vm) {
1174
1174
return nullptr ;
1175
1175
}
1176
-
1177
1176
return vm->GetRootWidget ();
1178
1177
}
1179
1178
Original file line number Diff line number Diff line change @@ -238,13 +238,13 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
238
238
/* *
239
239
* Returns the root widget for this.
240
240
*/
241
- already_AddRefed< nsIWidget> GetRootWidget () const ;
241
+ nsIWidget* GetRootWidget () const ;
242
242
243
243
/* *
244
244
* Returns the widget which may have native focus and handles text input
245
245
* like keyboard input, IME, etc.
246
246
*/
247
- already_AddRefed< nsIWidget> GetTextInputHandlingWidget () const {
247
+ nsIWidget* GetTextInputHandlingWidget () const {
248
248
// Currently, root widget for each PresContext handles text input.
249
249
return GetRootWidget ();
250
250
}
Original file line number Diff line number Diff line change @@ -895,16 +895,17 @@ void nsViewManager::DecrementDisableRefreshCount() {
895
895
NS_ASSERTION (mRefreshDisableCount >= 0 , " Invalid refresh disable count!" );
896
896
}
897
897
898
- already_AddRefed<nsIWidget> nsViewManager::GetRootWidget () {
899
- nsCOMPtr<nsIWidget> rootWidget;
900
- if (mRootView ) {
901
- if (mRootView ->HasWidget ()) {
902
- rootWidget = mRootView ->GetWidget ();
903
- } else if (mRootView ->GetParent ()) {
904
- rootWidget = mRootView ->GetParent ()->GetViewManager ()->GetRootWidget ();
905
- }
898
+ nsIWidget* nsViewManager::GetRootWidget () const {
899
+ if (!mRootView ) {
900
+ return nullptr ;
901
+ }
902
+ if (mRootView ->HasWidget ()) {
903
+ return mRootView ->GetWidget ();
904
+ }
905
+ if (mRootView ->GetParent ()) {
906
+ return mRootView ->GetParent ()->GetViewManager ()->GetRootWidget ();
906
907
}
907
- return rootWidget. forget () ;
908
+ return nullptr ;
908
909
}
909
910
910
911
LayoutDeviceIntRect nsViewManager::ViewToWidget (nsView* aView,
Original file line number Diff line number Diff line change @@ -282,7 +282,7 @@ class nsViewManager final {
282
282
* Retrieve the widget at the root of the nearest enclosing
283
283
* view manager whose root view has a widget.
284
284
*/
285
- already_AddRefed< nsIWidget> GetRootWidget ();
285
+ nsIWidget* GetRootWidget () const ;
286
286
287
287
/* *
288
288
* Indicate whether the viewmanager is currently painting
0 commit comments