зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1813148 - Don't return already_AddRefed in nsPresContext::GetRootWidget. r=dholbert
Let the caller addref it if needed. I wrote this because I wanted to make some code dealing with it thread-safe, but I ended up writing a less sketchy solution. However I still think this is worth it. It seems this only returns an already_AddRefed because before it used to be an XPCOM-ish thing where the widget was returned as an out-param. For now it doesn't change behavior but there are some callers that would benefit from having less addref/release calls if they only need to read simple stuff from the widget. Differential Revision: https://phabricator.services.mozilla.com/D168141
This commit is contained in:
Родитель
11c961f7d3
Коммит
61b953b167
|
@ -81,7 +81,10 @@ class TextComposition final {
|
|||
TextRangeArray* GetRanges() const { return mRanges; }
|
||||
// Returns the widget which is proper to call NotifyIME().
|
||||
already_AddRefed<nsIWidget> GetWidget() const {
|
||||
return mPresContext ? mPresContext->GetRootWidget() : nullptr;
|
||||
if (!mPresContext) {
|
||||
return nullptr;
|
||||
}
|
||||
return do_AddRef(mPresContext->GetRootWidget());
|
||||
}
|
||||
// Returns the tab parent which has this composition in its remote process.
|
||||
BrowserParent* GetBrowserParent() const { return mBrowserParent; }
|
||||
|
|
|
@ -356,7 +356,7 @@ already_AddRefed<nsPIDOMWindowOuter> BrowserParent::GetParentWindowOuter() {
|
|||
already_AddRefed<nsIWidget> BrowserParent::GetTopLevelWidget() {
|
||||
if (RefPtr<Element> element = mFrameElement) {
|
||||
if (PresShell* presShell = element->OwnerDoc()->GetPresShell()) {
|
||||
return presShell->GetViewManager()->GetRootWidget();
|
||||
return do_AddRef(presShell->GetViewManager()->GetRootWidget());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -1167,13 +1167,12 @@ nsIWidget* nsPresContext::GetNearestWidget(nsPoint* aOffset) {
|
|||
return rootView->GetNearestWidget(aOffset);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIWidget> nsPresContext::GetRootWidget() const {
|
||||
nsIWidget* nsPresContext::GetRootWidget() const {
|
||||
NS_ENSURE_TRUE(mPresShell, nullptr);
|
||||
nsViewManager* vm = mPresShell->GetViewManager();
|
||||
if (!vm) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return vm->GetRootWidget();
|
||||
}
|
||||
|
||||
|
|
|
@ -238,13 +238,13 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
|
|||
/**
|
||||
* Returns the root widget for this.
|
||||
*/
|
||||
already_AddRefed<nsIWidget> GetRootWidget() const;
|
||||
nsIWidget* GetRootWidget() const;
|
||||
|
||||
/**
|
||||
* Returns the widget which may have native focus and handles text input
|
||||
* like keyboard input, IME, etc.
|
||||
*/
|
||||
already_AddRefed<nsIWidget> GetTextInputHandlingWidget() const {
|
||||
nsIWidget* GetTextInputHandlingWidget() const {
|
||||
// Currently, root widget for each PresContext handles text input.
|
||||
return GetRootWidget();
|
||||
}
|
||||
|
|
|
@ -895,16 +895,17 @@ void nsViewManager::DecrementDisableRefreshCount() {
|
|||
NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!");
|
||||
}
|
||||
|
||||
already_AddRefed<nsIWidget> nsViewManager::GetRootWidget() {
|
||||
nsCOMPtr<nsIWidget> rootWidget;
|
||||
if (mRootView) {
|
||||
if (mRootView->HasWidget()) {
|
||||
rootWidget = mRootView->GetWidget();
|
||||
} else if (mRootView->GetParent()) {
|
||||
rootWidget = mRootView->GetParent()->GetViewManager()->GetRootWidget();
|
||||
}
|
||||
nsIWidget* nsViewManager::GetRootWidget() const {
|
||||
if (!mRootView) {
|
||||
return nullptr;
|
||||
}
|
||||
return rootWidget.forget();
|
||||
if (mRootView->HasWidget()) {
|
||||
return mRootView->GetWidget();
|
||||
}
|
||||
if (mRootView->GetParent()) {
|
||||
return mRootView->GetParent()->GetViewManager()->GetRootWidget();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LayoutDeviceIntRect nsViewManager::ViewToWidget(nsView* aView,
|
||||
|
|
|
@ -282,7 +282,7 @@ class nsViewManager final {
|
|||
* Retrieve the widget at the root of the nearest enclosing
|
||||
* view manager whose root view has a widget.
|
||||
*/
|
||||
already_AddRefed<nsIWidget> GetRootWidget();
|
||||
nsIWidget* GetRootWidget() const;
|
||||
|
||||
/**
|
||||
* Indicate whether the viewmanager is currently painting
|
||||
|
|
Загрузка…
Ссылка в новой задаче