Bug 1593708 - Part 2: Get inRDMPane value from BrowsingContext instead of Document. r=smaug
authorMicah Tigley <mtigley@mozilla.com>
Thu, 14 Nov 2019 20:32:02 +0000
changeset 502464 157248203e4a53a0f04055c7ee875eeb0c55f11c
parent 502463 8dd6e18ae2af4006d2d72e160bcd8a12541f5ef6
child 502465 33d4fb0808c9f786038a318eb87ddcec3e69b97c
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1593708
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/Document.cpp
dom/base/Document.h
dom/base/nsGlobalWindowOuter.cpp
dom/ipc/BrowserChild.cpp
layout/base/nsLayoutUtils.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -13610,16 +13610,22 @@ bool Document::SetOrientationPendingProm
   if (mIsGoingAway) {
     return false;
   }
 
   mOrientationPendingPromise = 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;
   }
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
       new AsyncEventDispatcher(aTarget, NS_LITERAL_STRING("pointerlockchange"),
                                CanBubble::eYes, ChromeOnlyDispatch::eNo);
@@ -15919,18 +15925,19 @@ void Document::RemoveToplevelLoadingDocu
         idleScheduler->SendPrioritizedOperationDone();
       }
     }
   }
 }
 
 // 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() {
   if (!sLoadingForegroundTopLevelContentDocument) {
     return false;
   }
 
   for (size_t i = 0; i < sLoadingForegroundTopLevelContentDocument->Length();
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -2279,21 +2279,17 @@ class Document : public nsINode,
     return mCurrentOrientationType;
   }
   void ClearOrientationPendingPromise();
   bool SetOrientationPendingPromise(Promise* aPromise);
   Promise* GetOrientationPendingPromise() const {
     return mOrientationPendingPromise;
   }
 
-  void SetRDMPaneOrientation(OrientationType aType, uint16_t aAngle) {
-    if (mInRDMPane) {
-      SetCurrentOrientation(aType, aAngle);
-    }
-  }
+  void SetRDMPaneOrientation(OrientationType aType, uint16_t aAngle);
 
   //----------------------------------------------------------------------
 
   // Document notification API's
 
   /**
    * Add a new observer of document change notifications. Whenever
    * content is changed, appended, inserted or removed the observers are
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -3617,17 +3617,18 @@ Maybe<CSSIntSize> nsGlobalWindowOuter::G
   // and divide by the full zoom. "Unscaled" in this case means unscaled
   // from device to screen but it has been affected (multipled) by the
   // full zoom and we need to compensate for that.
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   // 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();
       if (presContext) {
         nsCOMPtr<nsIBrowserChild> child = docShell->GetBrowserChild();
         if (child) {
           // We intentionally use GetFullZoom here instead of
           // GetDeviceFullZoom, because the unscaledInnerSize is based
--- a/dom/ipc/BrowserChild.cpp
+++ b/dom/ipc/BrowserChild.cpp
@@ -1264,17 +1264,18 @@ mozilla::ipc::IPCResult BrowserChild::Re
                         screenRect.y + mClientOffset.y + mChromeOffset.y,
                         screenSize.width, screenSize.height, true);
 
   // For our devtools Responsive Design Mode, we need to send a special
   // event to indicate that we've finished processing a frame size change.
   // This is used by RDM to respond correctly to changes to full zoom,
   // which also change the window size.
   RefPtr<Document> doc = GetTopLevelDocument();
-  if (doc && doc->InRDMPane()) {
+  BrowsingContext* bc = doc ? doc->GetBrowsingContext() : nullptr;
+  if (bc && bc->InRDMPane()) {
     RefPtr<AsyncEventDispatcher> dispatcher = new AsyncEventDispatcher(
         doc, NS_LITERAL_STRING("mozupdatedremoteframedimensions"),
         CanBubble::eYes, ChromeOnlyDispatch::eYes);
     dispatcher->PostDOMEvent();
   }
 
   return IPC_OK();
 }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -694,18 +694,19 @@ bool nsLayoutUtils::AsyncPanZoomEnabled(
   return widget->AsyncPanZoomEnabled();
 }
 
 bool nsLayoutUtils::AllowZoomingForDocument(
     const mozilla::dom::Document* aDocument) {
   // 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));
 }
 
 float nsLayoutUtils::GetCurrentAPZResolutionScale(PresShell* aPresShell) {
   return aPresShell ? aPresShell->GetCumulativeNonRootScaleResolution() : 1.0;
 }
 
 // Return the maximum displayport size, based on the LayerManager's maximum