Title: [210059] trunk
Revision
210059
Author
[email protected]
Date
2016-12-21 09:33:05 -0800 (Wed, 21 Dec 2016)

Log Message

Fixed bars are positioned incorrectly when there are header and footer banners
https://bugs.webkit.org/show_bug.cgi?id=166302
rdar://problem/29727145

Reviewed by Tim Horton.

Source/WebCore:

The computation of the visual viewport was wrong in the presence of header and footer
banners. It needs to take into account the fact that "visibleContentRect" applies to the
scroll view contents, which includes header and footer (unscaled), and the potentially scaled
document, and we need to return a rectangle in unscaled document coordinates.

Make a static method in FrameView to do this computation, and call it from FrameView::visualViewportRect()
and ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition().

layoutViewportForScrollPosition() is only called on Mac, so remove the #ifdeffing related to scaling,
and pass in an unscaled scroll position.

Test: fast/visual-viewport/zoomed-fixed-header-and-footer.html

* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutViewport):
(WebCore::FrameView::maxStableLayoutViewportOrigin):
(WebCore::FrameView::visibleDocumentRect):
(WebCore::FrameView::visualViewportRect):
* page/FrameView.h:
* page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
(WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):

LayoutTests:

* fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Added.
* fast/visual-viewport/zoomed-fixed-header-and-footer.html: Added.
* platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Added.
* tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210058 => 210059)


--- trunk/LayoutTests/ChangeLog	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/LayoutTests/ChangeLog	2016-12-21 17:33:05 UTC (rev 210059)
@@ -1,3 +1,16 @@
+2016-12-21  Simon Fraser  <[email protected]>
+
+        Fixed bars are positioned incorrectly when there are header and footer banners
+        https://bugs.webkit.org/show_bug.cgi?id=166302
+        rdar://problem/29727145
+
+        Reviewed by Tim Horton.
+        
+        * fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Added.
+        * fast/visual-viewport/zoomed-fixed-header-and-footer.html: Added.
+        * platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Added.
+        * tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt:
+
 2016-12-20  Myles C. Maxfield  <[email protected]>
 
         Skia lighter wght variation looks bolder than regular

Added: trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt (0 => 210059)


--- trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt	2016-12-21 17:33:05 UTC (rev 210059)
@@ -0,0 +1,55 @@
+This test zooms and scrolls the page and checks the positions of fixed-position objects.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":785,"bottom":585,"left":0,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":392.5,"bottom":271,"left":0,"width":392.5,"height":271}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":785,"bottom":100,"left":0,"width":785,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":485,"right":785,"bottom":585,"left":0,"width":785,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":100,"bottom":585,"left":0,"width":100,"height":585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":785,"bottom":585,"left":685,"width":100,"height":585}
+
+Scrolled to 475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":211,"right":867.5,"bottom":796,"left":82.5,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":503.5,"right":867.5,"bottom":796,"left":475,"width":392.5,"height":292.5}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-314,"right":392.5,"bottom":-214,"left":-392.5,"width":785,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":171,"right":392.5,"bottom":271,"left":-392.5,"width":785,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-314,"right":-292.5,"bottom":271,"left":-392.5,"width":100,"height":585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-314,"right":392.5,"bottom":271,"left":292.5,"width":100,"height":585}
+
+Scrolled to 100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":462,"right":867.5,"bottom":1047,"left":82.5,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":754.5,"right":492.5,"bottom":1047,"left":100,"width":392.5,"height":292.5}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-314,"right":767.5,"bottom":-214,"left":-17.5,"width":785,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":171,"right":767.5,"bottom":271,"left":-17.5,"width":785,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-314,"right":82.5,"bottom":271,"left":-17.5,"width":100,"height":585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-314,"right":767.5,"bottom":271,"left":667.5,"width":100,"height":585}
+
+Scrolled to 50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":278.5,"right":835,"bottom":863.5,"left":50,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":278.5,"right":442.5,"bottom":571,"left":50,"width":392.5,"height":292.5}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-21.5,"right":785,"bottom":78.5,"left":0,"width":785,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":463.5,"right":785,"bottom":563.5,"left":0,"width":785,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-21.5,"right":100,"bottom":563.5,"left":0,"width":100,"height":585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-21.5,"right":785,"bottom":563.5,"left":685,"width":100,"height":585}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html (0 => 210059)


--- trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html	2016-12-21 17:33:05 UTC (rev 210059)
@@ -0,0 +1,137 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 2000px;
+        }
+        
+        .fixed {
+            position: fixed;
+            background-color: gray;
+        }
+        
+        #top, #bottom {
+            width: 100%;
+            left: 0;
+            height: 100px;
+        }
+
+        #left, #right {
+            width: 100px;
+            top: 0;
+            height: 100%;
+        }
+
+        #top { top: 0; }
+        #bottom { bottom: 0; }
+
+        #left { left: 0; }
+        #right { right: 0; }
+    </style>
+    <script src=""
+    <script>
+        description("This test zooms and scrolls the page and checks the positions of fixed-position objects.");
+
+        if (window.internals) {
+            internals.setHeaderHeight(43);
+            internals.setFooterHeight(56);
+            internals.settings.setVisualViewportEnabled(true);
+        }
+
+        window.jsTestIsAsync = true;
+
+        var fixedElement;
+        function logFixedObject(objectID)
+        {
+            debug('client rect of ' + objectID + ':');
+            fixedElement = document.getElementById(objectID);
+            evalAndLogResult("JSON.stringify(fixedElement.getBoundingClientRect())");
+        }
+        
+        function doAfterZooming()
+        {
+            // Zooming may scroll the view away from the origin.
+            window.scrollTo(0, 0);
+
+            evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+            evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            debug('');
+            window.scrollTo(475, 525);
+            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+            evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+            evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            debug('');
+            window.scrollTo(100, 776);
+            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+            evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+            evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            debug('');
+            window.scrollTo(50, 300);
+            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+            evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+            evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            window.scrollTo(0, 0);
+
+            finishJSTest();
+        }
+
+        function getUIScript()
+        {
+            return `(function() {
+                uiController.zoomToScale(2, function() {
+                    uiController.uiScriptComplete(uiController.zoomScale);
+                });
+            })();`;
+        }
+
+        function doTest()
+        {
+            if (!window.testRunner)
+                return;
+
+            testRunner.runUIScript(getUIScript(), function(zoomScale) {
+                doAfterZooming();
+            });
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div id="top" class="fixed"></div>
+    <div id="bottom" class="fixed"></div>
+    <div id="left" class="fixed"></div>
+    <div id="right" class="fixed"></div>
+    <script src=""
+</body>
+</html>

Added: trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt (0 => 210059)


--- trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt	2016-12-21 17:33:05 UTC (rev 210059)
@@ -0,0 +1,55 @@
+This test zooms and scrolls the page and checks the positions of fixed-position objects.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":400,"bottom":257,"left":0,"width":400,"height":257}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":800,"bottom":100,"left":0,"width":800,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":500,"right":800,"bottom":600,"left":0,"width":800,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":100,"bottom":600,"left":0,"width":100,"height":600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":800,"bottom":600,"left":700,"width":100,"height":600}
+
+Scrolled to 475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":482,"right":875,"bottom":782,"left":475,"width":400,"height":300}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-525,"right":325,"bottom":-425,"left":-475,"width":800,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-25,"right":325,"bottom":75,"left":-475,"width":800,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-525,"right":-375,"bottom":75,"left":-475,"width":100,"height":600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-525,"right":325,"bottom":75,"left":225,"width":100,"height":600}
+
+Scrolled to 100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":733,"right":500,"bottom":1033,"left":100,"width":400,"height":300}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-776,"right":700,"bottom":-676,"left":-100,"width":800,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-276,"right":700,"bottom":-176,"left":-100,"width":800,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-776,"right":0,"bottom":-176,"left":-100,"width":100,"height":600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-776,"right":700,"bottom":-176,"left":600,"width":100,"height":600}
+
+Scrolled to 50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":257,"right":450,"bottom":557,"left":50,"width":400,"height":300}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-300,"right":750,"bottom":-200,"left":-50,"width":800,"height":100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":200,"right":750,"bottom":300,"left":-50,"width":800,"height":100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-300,"right":50,"bottom":300,"left":-50,"width":100,"height":600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-300,"right":750,"bottom":300,"left":650,"width":100,"height":600}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt (210058 => 210059)


--- trunk/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt	2016-12-21 17:33:05 UTC (rev 210059)
@@ -2,29 +2,29 @@
   (scrollable area size 785 600)
   (contents size 785 2421)
   (requested scroll position 0 200)
-  (layout viewport at (0,200) size 785x600)
+  (layout viewport at (0,100) size 785x600)
   (min layout viewport origin (0,0))
-  (max layout viewport origin (0,1821))
+  (max layout viewport origin (0,1621))
   (children 4
     (Fixed node
       (anchor edges: AnchorEdgeLeft AnchorEdgeTop)
-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 0.00 200.00)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 0.00 100.00)
     )
     (Fixed node
       (anchor edges: AnchorEdgeLeft AnchorEdgeTop)
-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 6.00 396.00)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 6.00 296.00)
     )
     (Fixed node
       (anchor edges: AnchorEdgeRight AnchorEdgeTop)
-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 597.00 396.00)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 597.00 296.00)
     )
     (Fixed node
       (anchor edges: AnchorEdgeLeft AnchorEdgeBottom)
-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 0.00 712.00)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 0.00 612.00)
     )
   )
 )

Modified: trunk/Source/WebCore/ChangeLog (210058 => 210059)


--- trunk/Source/WebCore/ChangeLog	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/Source/WebCore/ChangeLog	2016-12-21 17:33:05 UTC (rev 210059)
@@ -1,3 +1,35 @@
+2016-12-21  Simon Fraser  <[email protected]>
+
+        Fixed bars are positioned incorrectly when there are header and footer banners
+        https://bugs.webkit.org/show_bug.cgi?id=166302
+        rdar://problem/29727145
+
+        Reviewed by Tim Horton.
+        
+        The computation of the visual viewport was wrong in the presence of header and footer
+        banners. It needs to take into account the fact that "visibleContentRect" applies to the
+        scroll view contents, which includes header and footer (unscaled), and the potentially scaled
+        document, and we need to return a rectangle in unscaled document coordinates.
+        
+        Make a static method in FrameView to do this computation, and call it from FrameView::visualViewportRect()
+        and ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition().
+        
+        layoutViewportForScrollPosition() is only called on Mac, so remove the #ifdeffing related to scaling, 
+        and pass in an unscaled scroll position.
+
+        Test: fast/visual-viewport/zoomed-fixed-header-and-footer.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateLayoutViewport):
+        (WebCore::FrameView::maxStableLayoutViewportOrigin):
+        (WebCore::FrameView::visibleDocumentRect):
+        (WebCore::FrameView::visualViewportRect):
+        * page/FrameView.h:
+        * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
+        (WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
+
 2016-12-21  Carlos Alberto Lopez Perez  <[email protected]>
 
         [CMake] Remove remaining INDIE_UI related entries.

Modified: trunk/Source/WebCore/page/FrameView.cpp (210058 => 210059)


--- trunk/Source/WebCore/page/FrameView.cpp	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/Source/WebCore/page/FrameView.cpp	2016-12-21 17:33:05 UTC (rev 210059)
@@ -1876,7 +1876,7 @@
 
     LayoutRect layoutViewport = layoutViewportRect();
 
-    LOG_WITH_STREAM(Scrolling, stream << "\nFrameView " << this << " updateLayoutViewport()");
+    LOG_WITH_STREAM(Scrolling, stream << "\nFrameView " << this << " updateLayoutViewport() totalContentSize " << totalContentsSize() << " unscaledDocumentRect " << (renderView() ? renderView()->unscaledDocumentRect() : IntRect()) << " header height " << headerHeight() << " footer height " << footerHeight());
     LOG_WITH_STREAM(Scrolling, stream << "layoutViewport: " << layoutViewport);
     LOG_WITH_STREAM(Scrolling, stream << "visualViewport: " << visualViewportRect());
     LOG_WITH_STREAM(Scrolling, stream << "scroll positions: min: " << unscaledMinimumScrollPosition() << " max: "<< unscaledMaximumScrollPosition());
@@ -1895,7 +1895,9 @@
 
 LayoutPoint FrameView::maxStableLayoutViewportOrigin() const
 {
-    return unscaledMaximumScrollPosition();
+    LayoutPoint maxPosition = unscaledMaximumScrollPosition();
+    maxPosition = (maxPosition - LayoutSize(0, headerHeight() + footerHeight())).expandedTo({ });
+    return maxPosition;
 }
 
 IntPoint FrameView::unscaledScrollOrigin() const
@@ -1915,12 +1917,29 @@
     return LayoutRect(m_layoutViewportOrigin, renderView() ? renderView()->size() : size());
 }
 
+// visibleContentRect is in the bounds of the scroll view content. That consists of an
+// optional header, the document, and an optional footer. Only the document is scaled,
+// so we have to compute the visible part of the document in unscaled document coordinates.
+// On iOS, pageScaleFactor is always 1 here, and we never have headers and footers.
+LayoutRect FrameView::visibleDocumentRect(const FloatRect& visibleContentRect, float headerHeight, float footerHeight, const FloatSize& totalContentsSize, float pageScaleFactor)
+{
+    FloatRect visibleDocumentRect = visibleContentRect;
+
+    float contentsHeight = totalContentsSize.height() - headerHeight - footerHeight;
+
+    float visibleScaledDocumentTop = std::max<float>(visibleContentRect.y() - headerHeight, 0);
+    float visibleScaledDocumentBottom = std::min<float>(visibleContentRect.maxY() - headerHeight, contentsHeight);
+
+    visibleDocumentRect.setY(visibleScaledDocumentTop);
+    visibleDocumentRect.setHeight(std::max<float>(visibleScaledDocumentBottom - visibleScaledDocumentTop, 0));
+    visibleDocumentRect.scale(1 / pageScaleFactor);
+    return LayoutRect(visibleDocumentRect);
+}
+
 LayoutRect FrameView::visualViewportRect() const
 {
-    // This isn't visibleContentRect(), because that uses a scaled scroll origin. Confused? Me too.
     FloatRect visibleContentRect = this->visibleContentRect(LegacyIOSDocumentVisibleRect);
-    visibleContentRect.scale(1 / frameScaleFactor()); // Note that frameScaleFactor() returns 1 for delegated scrolling (e.g. iOS WK2)
-    return LayoutRect(visibleContentRect);
+    return visibleDocumentRect(visibleContentRect, headerHeight(), footerHeight(), totalContentsSize(), frameScaleFactor());
 }
 
 LayoutRect FrameView::viewportConstrainedVisibleContentRect() const

Modified: trunk/Source/WebCore/page/FrameView.h (210058 => 210059)


--- trunk/Source/WebCore/page/FrameView.h	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/Source/WebCore/page/FrameView.h	2016-12-21 17:33:05 UTC (rev 210059)
@@ -268,6 +268,8 @@
     // These are in document coordinates, unaffected by zooming.
     WEBCORE_EXPORT LayoutRect layoutViewportRect() const;
     WEBCORE_EXPORT LayoutRect visualViewportRect() const;
+    
+    static LayoutRect visibleDocumentRect(const FloatRect& visibleContentRect, float headerHeight, float footerHeight, const FloatSize& totalContentsSize, float pageScaleFactor);
 
     // This is different than visibleContentRect() in that it ignores negative (or overly positive)
     // offsets from rubber-banding, and it takes zooming into account. 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (210058 => 210059)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp	2016-12-21 17:33:05 UTC (rev 210059)
@@ -102,21 +102,14 @@
 {
     ASSERT(scrollingTree().visualViewportEnabled());
 
-    FloatSize visibleContentSize = scrollableAreaSize();
-#if PLATFORM(MAC)
-    // On Mac, FrameView.visibleContentRect(), which was used to set scrollableAreaSize(), returns a rect with scale applied (so it's not really a "content rect"),
-    // so we have to convert back to unscaled coordinates here.
-    visibleContentSize.scale(1 / scale);
-#else
-    UNUSED_PARAM(scale);
-#endif
-    FloatRect visualViewport(visibleContentOrigin, visibleContentSize);
+    FloatRect visibleContentRect(visibleContentOrigin, scrollableAreaSize());
+    LayoutRect visualViewport(FrameView::visibleDocumentRect(visibleContentRect, headerHeight(), footerHeight(), totalContentsSize(), scale));
     LayoutRect layoutViewport(m_layoutViewport);
 
     LOG_WITH_STREAM(Scrolling, stream << "\nScrolling thread: " << "(visibleContentOrigin " << visibleContentOrigin << ")");
-    LOG_WITH_STREAM(Scrolling, stream << "layoutViewport: " << layoutViewport);
-    LOG_WITH_STREAM(Scrolling, stream << "visualViewport: " << visualViewport);
-    LOG_WITH_STREAM(Scrolling, stream << "scroll positions: min: " << minLayoutViewportOrigin() << " max: "<< maxLayoutViewportOrigin());
+    LOG_WITH_STREAM(Scrolling, stream << "  layoutViewport: " << layoutViewport);
+    LOG_WITH_STREAM(Scrolling, stream << "  visualViewport: " << visualViewport);
+    LOG_WITH_STREAM(Scrolling, stream << "  scroll positions: min: " << minLayoutViewportOrigin() << " max: "<< maxLayoutViewportOrigin());
 
     LayoutPoint newLocation = FrameView::computeLayoutViewportOrigin(LayoutRect(visualViewport), LayoutPoint(minLayoutViewportOrigin()), LayoutPoint(maxLayoutViewportOrigin()), layoutViewport);
 

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (210058 => 210059)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2016-12-21 16:42:11 UTC (rev 210058)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2016-12-21 17:33:05 UTC (rev 210059)
@@ -391,8 +391,6 @@
     std::optional<FloatPoint> layoutViewportOrigin;
     if (scrollingTree().visualViewportEnabled()) {
         FloatPoint visibleContentOrigin = scrollPosition;
-        float counterScale = 1 / frameScaleFactor();
-        visibleContentOrigin.scale(counterScale, counterScale);
         FloatRect newLayoutViewport = layoutViewportForScrollPosition(visibleContentOrigin, frameScaleFactor());
         setLayoutViewport(newLayoutViewport);
         layoutViewportOrigin = newLayoutViewport.location();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to