Bug 1572840 Part 4: Change nsGlobalWindowOuter::GetRDMDeviceSize to divide out full zoom levels. r=Ehsan
authorBrad Werth <bwerth@mozilla.com>
Fri, 30 Aug 2019 18:45:29 +0000
changeset 554701 db42ac54835f8ea7a11738252efbdf6d0f17e447
parent 554700 8cd803e497e700233742053f9fd663ab1c5e95ee
child 554702 466e8f97c54f14584c6c23d8a8057255e5957abb
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1572840
milestone70.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 1572840 Part 4: Change nsGlobalWindowOuter::GetRDMDeviceSize to divide out full zoom levels. r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D43716
dom/base/nsGlobalWindowOuter.cpp
dom/ipc/BrowserChild.h
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -3721,35 +3721,45 @@ nsRect nsGlobalWindowOuter::GetInnerScre
 
   return rootFrame->GetScreenRectInAppUnits();
 }
 
 Maybe<CSSIntSize> nsGlobalWindowOuter::GetRDMDeviceSize(
     const Document& aDocument) {
   // RDM device size should reflect the simulated device resolution, and
   // be independent of any full zoom or resolution zoom applied to the
-  // content. To get this value, we get the unscaled browser child size.
+  // content. To get this value, we get the "unscaled" browser child size,
+  // 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());
 
-  Maybe<CSSIntSize> deviceSize;
-
   // Bug 1576256: This does not work for cross-process subframes.
   const Document* topInProcessContentDoc =
       aDocument.GetTopLevelContentDocument();
   if (topInProcessContentDoc && topInProcessContentDoc->InRDMPane()) {
     nsIDocShell* docShell = topInProcessContentDoc->GetDocShell();
     if (docShell) {
-      nsCOMPtr<nsIBrowserChild> child = docShell->GetBrowserChild();
-      if (child) {
-        BrowserChild* bc = static_cast<BrowserChild*>(child.get());
-        deviceSize = Some(bc->GetUnscaledInnerSize());
+      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
+          // on the full zoom and not the device full zoom (which is
+          // rounded to result in integer device pixels).
+          float zoom = presContext->GetFullZoom();
+          BrowserChild* bc = static_cast<BrowserChild*>(child.get());
+          CSSSize unscaledSize = bc->GetUnscaledInnerSize();
+          return Some(CSSIntSize(gfx::RoundedToInt(unscaledSize / zoom)));
+        }
       }
     }
   }
-  return deviceSize;
+  return Nothing();
 }
 
 float nsGlobalWindowOuter::GetMozInnerScreenXOuter(CallerType aCallerType) {
   // When resisting fingerprinting, always return 0.
   if (nsContentUtils::ResistFingerprinting(aCallerType)) {
     return 0.0;
   }
 
--- a/dom/ipc/BrowserChild.h
+++ b/dom/ipc/BrowserChild.h
@@ -541,17 +541,17 @@ class BrowserChild final : public nsMess
   bool IPCOpen() const { return mIPCOpen; }
 
   bool ParentIsActive() const { return mParentIsActive; }
 
   const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
   bool AsyncPanZoomEnabled() const;
 
   ScreenIntSize GetInnerSize();
-  CSSIntSize GetUnscaledInnerSize() { return RoundedToInt(mUnscaledInnerSize); }
+  CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; }
 
   Maybe<LayoutDeviceIntRect> GetVisibleRect() const;
 
   // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
   void DoFakeShow(const ShowInfo& aShowInfo);
 
   void ContentReceivedInputBlock(uint64_t aInputBlockId,
                                  bool aPreventDefault) const;