Scrolling when zoomed doesn't always use the correct layout viewport
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2016 02:19:27 +0000 (02:19 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2016 02:19:27 +0000 (02:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164756

Reviewed by Dean Jackson.

The scrolling thread was always using the layout viewport rect pushed onto it and
never computing a new one, so when scrolling around after zooming position:fixed
elements would not get the expected visual viewport behavior.

Fix by having ScrollingTreeFrameScrollingNode updating its notion of the layout viewport
on scrolls.

Not testable because we can't dump the scrolling tree on Mac (yet).

* page/scrolling/ScrollingTreeFrameScrollingNode.h:
(WebCore::ScrollingTreeFrameScrollingNode::setLayoutViewport):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208722 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

index 7257fb7..7663ec9 100644 (file)
@@ -1,3 +1,24 @@
+2016-11-14  Simon Fraser  <simon.fraser@apple.com>
+
+        Scrolling when zoomed doesn't always use the correct layout viewport
+        https://bugs.webkit.org/show_bug.cgi?id=164756
+
+        Reviewed by Dean Jackson.
+
+        The scrolling thread was always using the layout viewport rect pushed onto it and
+        never computing a new one, so when scrolling around after zooming position:fixed
+        elements would not get the expected visual viewport behavior.
+
+        Fix by having ScrollingTreeFrameScrollingNode updating its notion of the layout viewport
+        on scrolls.
+
+        Not testable because we can't dump the scrolling tree on Mac (yet).
+
+        * page/scrolling/ScrollingTreeFrameScrollingNode.h:
+        (WebCore::ScrollingTreeFrameScrollingNode::setLayoutViewport):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
+
 2016-11-14  Ryosuke Niwa  <rniwa@webkit.org>
 
         document.createElementNS doesn't construct a custom element
index 59147ea..43488c4 100644 (file)
@@ -70,11 +70,13 @@ protected:
     float topContentInset() const { return m_topContentInset; }
 
     FloatRect layoutViewport() const { return m_layoutViewport; };
+    void setLayoutViewport(const FloatRect& r) { m_layoutViewport = r; };
+
     FloatPoint minLayoutViewportOrigin() const { return m_minLayoutViewportOrigin; }
     FloatPoint maxLayoutViewportOrigin() const { return m_maxLayoutViewportOrigin; }
 
     ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
-    
+
 private:
     void dumpProperties(TextStream&, ScrollingStateTreeAsTextBehavior) const override;
 
index 22c6122..ce16759 100644 (file)
@@ -388,14 +388,14 @@ void ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeCons
 {
     updateMainFramePinState(scrollPosition);
 
-    FloatRect layoutViewport;
     Optional<FloatPoint> layoutViewportOrigin;
     if (scrollingTree().visualViewportEnabled()) {
         FloatPoint visibleContentOrigin = scrollPosition;
         float counterScale = 1 / frameScaleFactor();
         visibleContentOrigin.scale(counterScale, counterScale);
-        layoutViewport = layoutViewportForScrollPosition(visibleContentOrigin, frameScaleFactor());
-        layoutViewportOrigin = layoutViewport.location();
+        FloatRect newLayoutViewport = layoutViewportForScrollPosition(visibleContentOrigin, frameScaleFactor());
+        setLayoutViewport(newLayoutViewport);
+        layoutViewportOrigin = newLayoutViewport.location();
     }
 
     if (shouldUpdateScrollLayerPositionSynchronously()) {
@@ -404,7 +404,7 @@ void ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeCons
         return;
     }
 
-    setScrollLayerPosition(scrollPosition, layoutViewport);
+    setScrollLayerPosition(scrollPosition, layoutViewport());
     scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, layoutViewportOrigin);
 }