Bug 1519607 - Use GetScrollPortRect() size for the root scroll frame in nsLayoutUtils::GetRootMetadata. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sun, 13 Jan 2019 01:27:15 +0000
changeset 510754 173e847312e084faeb13ab2f3c3985b4c85a924c
parent 510753 d924b4e44ff4fb07b310bcd5ec76e24d4687cd80
child 510771 1218e374fbc71f64a3e671731004294053df2e22
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1519607
milestone66.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 1519607 - Use GetScrollPortRect() size for the root scroll frame in nsLayoutUtils::GetRootMetadata. r=botond Differential Revision: https://phabricator.services.mozilla.com/D16384
gfx/layers/apz/test/mochitest/helper_zoomed_pan.html
layout/base/nsLayoutUtils.cpp
--- a/gfx/layers/apz/test/mochitest/helper_zoomed_pan.html
+++ b/gfx/layers/apz/test/mochitest/helper_zoomed_pan.html
@@ -21,45 +21,43 @@
 </head>
 <body>
   <div id="content"></div>
   <script type="application/javascript">
     const RESOLUTION = 4;
     const OFFSET_SCREEN_PX = 50;
     const OFFSET_CSS_PX = OFFSET_SCREEN_PX / RESOLUTION;
 
-    // Measure scrollbar widths before zooming.
-    const verticalScrollbarWidth = window.innerWidth - document.scrollingElement.clientWidth;
-    const horizontalScrollbarWidth = window.innerHeight - document.scrollingElement.clientHeight;
-
-    function computeDelta(visual, scrollbarWidth) {
+    function computeDelta(visual) {
       // Compute the distance from the right/bottom edge of the visual
       // viewport to the same edge of the layout viewport and add the desired
       // offset to that.
-      const layout = (visual + scrollbarWidth);
-      return layout - (visual / RESOLUTION) + OFFSET_CSS_PX;
+      // We can ignore scrollbar width here since the scrollbar is layouted at
+      // the right/bottom edge of this content, not of this window in the case
+      // of containerful scrolling.
+      return visual - (visual / RESOLUTION) + OFFSET_CSS_PX;
     }
 
     function* test(testDriver) {
       const cases = [
         {
           x: 0,
           y: 0,
-          dx: (width) => -computeDelta(width, verticalScrollbarWidth),
+          dx: (width) => -computeDelta(width),
           dy: (height) => 0,
           expected: {
             x: [OFFSET_CSS_PX, "x-offset was adjusted"],
             y: [0, "y-offset was not affected"],
           },
         },
         {
           x: OFFSET_CSS_PX,
           y: 0,
           dx: (width) => 0,
-          dy: (height) => -computeDelta(height, horizontalScrollbarWidth),
+          dy: (height) => -computeDelta(height),
           expected: {
             x: [OFFSET_CSS_PX, "x-offset was not affected"],
             y: [OFFSET_CSS_PX, "y-offset was adjusted"],
           },
         },
       ];
 
       for (let c of cases) {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9018,16 +9018,21 @@ static void MaybeReflowForInflationScree
       ensureMetricsForRootId = false;
     }
   }
 
   if (addMetrics || ensureMetricsForRootId) {
     bool isRootContent = presContext->IsRootContentDocument();
 
     nsRect viewport(aBuilder->ToReferenceFrame(frame), frame->GetSize());
+    if (isRootContent && rootScrollFrame) {
+      nsIScrollableFrame* scrollableFrame =
+          rootScrollFrame->GetScrollTargetFrame();
+      viewport.SizeTo(scrollableFrame->GetScrollPortRect().Size());
+    }
     return Some(nsLayoutUtils::ComputeScrollMetadata(
         frame, rootScrollFrame, content, aBuilder->FindReferenceFrameFor(frame),
         aLayerManager, ScrollableLayerGuid::NULL_SCROLL_ID, viewport, Nothing(),
         isRootContent, Some(aContainerParameters)));
   }
 
   return Nothing();
 }