commit 1a8c62b86277005f907151bc5389cf5c5091e76f
parent 99f4a5f490e2489a7df61436d255e692c0bec9b4
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Sun, 2 Nov 2025 10:34:21 +0000
Bug 1997771 - Simplify nsPresContext::GetNearestWidget. r=layout-reviewers,TYLin
It's not correct for popups since bug 1933181. Just forward to
PresShell's version which deals with it correctly.
Differential Revision: https://phabricator.services.mozilla.com/D270956
Diffstat:
3 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp
@@ -12129,11 +12129,9 @@ Maybe<MobileViewportManager::ManagerType> UseMobileViewportManager(
PresShell* aPresShell, Document* aDocument) {
// If we're not using APZ, we won't be able to zoom, so there is no
// point in having an MVM.
- if (nsPresContext* presContext = aPresShell->GetPresContext()) {
- if (nsIWidget* widget = presContext->GetNearestWidget()) {
- if (!widget->AsyncPanZoomEnabled()) {
- return Nothing();
- }
+ if (nsIWidget* widget = aPresShell->GetNearestWidget()) {
+ if (!widget->AsyncPanZoomEnabled()) {
+ return Nothing();
}
}
if (nsLayoutUtils::ShouldHandleMetaViewport(aDocument)) {
diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp
@@ -1170,13 +1170,8 @@ nsPresContext* nsPresContext::GetInProcessRootContentDocumentPresContext() {
}
}
-nsIWidget* nsPresContext::GetNearestWidget(nsPoint* aOffset) {
- NS_ENSURE_TRUE(mPresShell, nullptr);
- nsViewManager* vm = mPresShell->GetViewManager();
- NS_ENSURE_TRUE(vm, nullptr);
- nsView* rootView = vm->GetRootView();
- NS_ENSURE_TRUE(rootView, nullptr);
- return rootView->GetNearestWidget(aOffset);
+nsIWidget* nsPresContext::GetNearestWidget() const {
+ return mPresShell ? mPresShell->GetNearestWidget() : nullptr;
}
nsIWidget* nsPresContext::GetRootWidget() const {
diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h
@@ -227,13 +227,8 @@ class nsPresContext : public nsISupports,
/**
* Returns the nearest widget for the root frame or view of this.
- *
- * @param aOffset If non-null the offset from the origin of the root
- * frame's view to the widget's origin (usually positive)
- * expressed in appunits of this will be returned in
- * aOffset.
*/
- nsIWidget* GetNearestWidget(nsPoint* aOffset = nullptr);
+ nsIWidget* GetNearestWidget() const;
/**
* Returns the root widget for this.