From 72a0d2c3308366686eb4025b20d8766388e86375 Mon Sep 17 00:00:00 2001 From: Micah Tigley Date: Thu, 14 Nov 2019 20:32:02 +0000 Subject: [PATCH] Bug 1593708 - Part 2: Get inRDMPane value from BrowsingContext instead of Document. r=smaug Depends on D52214 Differential Revision: https://phabricator.services.mozilla.com/D52216 --HG-- extra : moz-landing-system : lando --- dom/base/Document.cpp | 9 ++++++++- dom/base/Document.h | 6 +----- dom/base/nsGlobalWindowOuter.cpp | 3 ++- dom/ipc/BrowserChild.cpp | 3 ++- layout/base/nsLayoutUtils.cpp | 3 ++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 7efef1f79f8f..8ab85ace0bd0 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -13615,6 +13615,12 @@ bool Document::SetOrientationPendingPromise(Promise* aPromise) { return true; } +void Document::SetRDMPaneOrientation(OrientationType aType, uint16_t aAngle) { + if (GetBrowsingContext()->InRDMPane()) { + SetCurrentOrientation(aType, aAngle); + } +} + static void DispatchPointerLockChange(Document* aTarget) { if (!aTarget) { return; @@ -15924,8 +15930,9 @@ void Document::RemoveToplevelLoadingDocument(Document* aDoc) { // static bool Document::UseOverlayScrollbars(const Document* aDocument) { + BrowsingContext* bc = aDocument ? aDocument->GetBrowsingContext() : nullptr; return LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) || - (aDocument && aDocument->InRDMPane()); + (bc && bc->InRDMPane()); } bool Document::HasRecentlyStartedForegroundLoads() { diff --git a/dom/base/Document.h b/dom/base/Document.h index 00605687b3d2..02acdd531d4a 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -2284,11 +2284,7 @@ class Document : public nsINode, return mOrientationPendingPromise; } - void SetRDMPaneOrientation(OrientationType aType, uint16_t aAngle) { - if (mInRDMPane) { - SetCurrentOrientation(aType, aAngle); - } - } + void SetRDMPaneOrientation(OrientationType aType, uint16_t aAngle); //---------------------------------------------------------------------- diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 14e40877dca8..d87ebda63f43 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -3622,7 +3622,8 @@ Maybe nsGlobalWindowOuter::GetRDMDeviceSize( // Bug 1576256: This does not work for cross-process subframes. const Document* topInProcessContentDoc = aDocument.GetTopLevelContentDocument(); - if (topInProcessContentDoc && topInProcessContentDoc->InRDMPane()) { + BrowsingContext* bc = topInProcessContentDoc ? topInProcessContentDoc->GetBrowsingContext() : nullptr; + if (bc && bc->InRDMPane()) { nsIDocShell* docShell = topInProcessContentDoc->GetDocShell(); if (docShell) { nsPresContext* presContext = docShell->GetPresContext(); diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index ebafcf32395b..8948d1da9fe1 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -1269,7 +1269,8 @@ mozilla::ipc::IPCResult BrowserChild::RecvUpdateDimensions( // This is used by RDM to respond correctly to changes to full zoom, // which also change the window size. RefPtr doc = GetTopLevelDocument(); - if (doc && doc->InRDMPane()) { + BrowsingContext* bc = doc ? doc->GetBrowsingContext() : nullptr; + if (bc && bc->InRDMPane()) { RefPtr dispatcher = new AsyncEventDispatcher( doc, NS_LITERAL_STRING("mozupdatedremoteframedimensions"), CanBubble::eYes, ChromeOnlyDispatch::eYes); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 9f0daa3648bd..9a0614e11e20 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -699,8 +699,9 @@ bool nsLayoutUtils::AllowZoomingForDocument( // True if we allow zooming for all documents on this platform, or if we are // in RDM and handling meta viewports, which force zoom under some // circumstances. + BrowsingContext* bc = aDocument ? aDocument->GetBrowsingContext() : nullptr; return StaticPrefs::apz_allow_zooming() || - (aDocument && aDocument->InRDMPane() && + (bc && bc->InRDMPane() && nsLayoutUtils::ShouldHandleMetaViewport(aDocument)); }