Title: [183655] trunk/Source
Revision
183655
Author
simon.fra...@apple.com
Date
2015-04-30 16:44:49 -0700 (Thu, 30 Apr 2015)

Log Message

Fixed elements end up in the middle of the view with pageScale < 1
https://bugs.webkit.org/show_bug.cgi?id=144428
rdar://problem/20404982

Reviewed by Tim Horton.

Source/WebCore:

When pageScale is < 1, we used fixed layout mode, and FrameView::fixedElementsLayoutRelativeToFrame()
returns true. However, the scrolling thread was calling the static scrollOffsetForFixedPosition()
hardcoding 'false' for this parameter.

Fix by sending the value of fixedElementsLayoutRelativeToFrame over to the scrolling thread,
so we can use it when doing scrolling-thread fixed position stuff.

Not testable.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
* page/scrolling/ScrollingStateFrameScrollingNode.cpp:
(WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
(WebCore::ScrollingStateFrameScrollingNode::setFixedElementsLayoutRelativeToFrame):
* page/scrolling/ScrollingStateFrameScrollingNode.h:
* page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
(WebCore::ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode):
(WebCore::ScrollingTreeFrameScrollingNode::updateBeforeChildren):
* page/scrolling/ScrollingTreeFrameScrollingNode.h:
(WebCore::ScrollingTreeFrameScrollingNode::fixedElementsLayoutRelativeToFrame):
(WebCore::ScrollingTreeFrameScrollingNode::shouldUpdateScrollLayerPositionSynchronously): Deleted.
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition):

Source/WebKit2:

Encode/decode fixedElementsLayoutRelativeToFrame.

* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
(ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183654 => 183655)


--- trunk/Source/WebCore/ChangeLog	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/ChangeLog	2015-04-30 23:44:49 UTC (rev 183655)
@@ -1,3 +1,35 @@
+2015-04-30  Simon Fraser  <simon.fra...@apple.com>
+
+        Fixed elements end up in the middle of the view with pageScale < 1
+        https://bugs.webkit.org/show_bug.cgi?id=144428
+        rdar://problem/20404982
+
+        Reviewed by Tim Horton.
+
+        When pageScale is < 1, we used fixed layout mode, and FrameView::fixedElementsLayoutRelativeToFrame()
+        returns true. However, the scrolling thread was calling the static scrollOffsetForFixedPosition()
+        hardcoding 'false' for this parameter.
+        
+        Fix by sending the value of fixedElementsLayoutRelativeToFrame over to the scrolling thread,
+        so we can use it when doing scrolling-thread fixed position stuff.
+
+        Not testable.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
+        * page/scrolling/ScrollingStateFrameScrollingNode.cpp:
+        (WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
+        (WebCore::ScrollingStateFrameScrollingNode::setFixedElementsLayoutRelativeToFrame):
+        * page/scrolling/ScrollingStateFrameScrollingNode.h:
+        * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
+        (WebCore::ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode):
+        (WebCore::ScrollingTreeFrameScrollingNode::updateBeforeChildren):
+        * page/scrolling/ScrollingTreeFrameScrollingNode.h:
+        (WebCore::ScrollingTreeFrameScrollingNode::fixedElementsLayoutRelativeToFrame):
+        (WebCore::ScrollingTreeFrameScrollingNode::shouldUpdateScrollLayerPositionSynchronously): Deleted.
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition):
+
 2015-04-30  Beth Dakin  <bda...@apple.com>
 
         Remove invalid assertion from MouseEvent::create()

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (183654 => 183655)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2015-04-30 23:44:49 UTC (rev 183655)
@@ -136,6 +136,7 @@
     node->setScrollableAreaSize(frameView.visibleContentRect().size());
     node->setTotalContentsSize(frameView.totalContentsSize());
     node->setReachableContentsSize(frameView.totalContentsSize());
+    node->setFixedElementsLayoutRelativeToFrame(frameView.fixedElementsLayoutRelativeToFrame());
 
 #if ENABLE(CSS_SCROLL_SNAP)
     frameView.updateSnapOffsets();

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp (183654 => 183655)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp	2015-04-30 23:44:49 UTC (rev 183655)
@@ -40,17 +40,6 @@
 
 ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
     : ScrollingStateScrollingNode(stateTree, FrameScrollingNode, nodeID)
-#if PLATFORM(MAC)
-    , m_verticalScrollbarPainter(0)
-    , m_horizontalScrollbarPainter(0)
-#endif
-    , m_frameScaleFactor(1)
-    , m_synchronousScrollingReasons(0)
-    , m_behaviorForFixed(StickToDocumentBounds)
-    , m_headerHeight(0)
-    , m_footerHeight(0)
-    , m_requestedScrollPositionRepresentsProgrammaticScroll(false)
-    , m_topContentInset(0)
 {
 }
 
@@ -61,14 +50,15 @@
     , m_horizontalScrollbarPainter(stateNode.horizontalScrollbarPainter())
 #endif
     , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion())
+    , m_requestedScrollPosition(stateNode.requestedScrollPosition())
     , m_frameScaleFactor(stateNode.frameScaleFactor())
-    , m_synchronousScrollingReasons(stateNode.synchronousScrollingReasons())
-    , m_behaviorForFixed(stateNode.scrollBehaviorForFixedElements())
+    , m_topContentInset(stateNode.topContentInset())
     , m_headerHeight(stateNode.headerHeight())
     , m_footerHeight(stateNode.footerHeight())
-    , m_requestedScrollPosition(stateNode.requestedScrollPosition())
+    , m_synchronousScrollingReasons(stateNode.synchronousScrollingReasons())
+    , m_behaviorForFixed(stateNode.scrollBehaviorForFixedElements())
     , m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll())
-    , m_topContentInset(stateNode.topContentInset())
+    , m_fixedElementsLayoutRelativeToFrame(stateNode.fixedElementsLayoutRelativeToFrame())
 {
     if (hasChangedProperty(ScrolledContentsLayer))
         setScrolledContentsLayer(stateNode.scrolledContentsLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
@@ -216,6 +206,15 @@
     setPropertyChanged(FooterLayer);
 }
 
+void ScrollingStateFrameScrollingNode::setFixedElementsLayoutRelativeToFrame(bool fixedElementsLayoutRelativeToFrame)
+{
+    if (fixedElementsLayoutRelativeToFrame == m_fixedElementsLayoutRelativeToFrame)
+        return;
+    
+    m_fixedElementsLayoutRelativeToFrame = fixedElementsLayoutRelativeToFrame;
+    setPropertyChanged(FixedElementsLayoutRelativeToFrame);
+}
+
 #if !PLATFORM(MAC)
 void ScrollingStateFrameScrollingNode::setScrollbarPaintersFromScrollbars(Scrollbar*, Scrollbar*)
 {

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h (183654 => 183655)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h	2015-04-30 23:44:49 UTC (rev 183655)
@@ -60,7 +60,8 @@
         FooterLayer,
         PainterForScrollbar,
         BehaviorForFixedElements,
-        TopContentInset
+        TopContentInset,
+        FixedElementsLayoutRelativeToFrame,
     };
 
     float frameScaleFactor() const { return m_frameScaleFactor; }
@@ -109,6 +110,9 @@
     const LayerRepresentation& footerLayer() const { return m_footerLayer; }
     WEBCORE_EXPORT void setFooterLayer(const LayerRepresentation&);
 
+    bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; }
+    WEBCORE_EXPORT void setFixedElementsLayoutRelativeToFrame(bool);
+
 #if PLATFORM(MAC)
     ScrollbarPainter verticalScrollbarPainter() const { return m_verticalScrollbarPainter.get(); }
     ScrollbarPainter horizontalScrollbarPainter() const { return m_horizontalScrollbarPainter.get(); }
@@ -134,14 +138,15 @@
 #endif
 
     Region m_nonFastScrollableRegion;
-    float m_frameScaleFactor;
-    SynchronousScrollingReasons m_synchronousScrollingReasons;
-    ScrollBehaviorForFixedElements m_behaviorForFixed;
-    int m_headerHeight;
-    int m_footerHeight;
     FloatPoint m_requestedScrollPosition;
-    bool m_requestedScrollPositionRepresentsProgrammaticScroll;
-    float m_topContentInset;
+    float m_frameScaleFactor { 1 };
+    float m_topContentInset { 0 };
+    int m_headerHeight { 0 };
+    int m_footerHeight { 0 };
+    SynchronousScrollingReasons m_synchronousScrollingReasons { 0 };
+    ScrollBehaviorForFixedElements m_behaviorForFixed { StickToDocumentBounds };
+    bool m_requestedScrollPositionRepresentsProgrammaticScroll { false };
+    bool m_fixedElementsLayoutRelativeToFrame { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (183654 => 183655)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp	2015-04-30 23:44:49 UTC (rev 183655)
@@ -35,12 +35,6 @@
 
 ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : ScrollingTreeScrollingNode(scrollingTree, FrameScrollingNode, nodeID)
-    , m_frameScaleFactor(1)
-    , m_headerHeight(0)
-    , m_footerHeight(0)
-    , m_topContentInset(0)
-    , m_synchronousScrollingReasons(0)
-    , m_behaviorForFixed(StickToDocumentBounds)
 {
 }
 
@@ -71,6 +65,9 @@
 
     if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::TopContentInset))
         m_topContentInset = state.topContentInset();
+
+    if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame))
+        m_fixedElementsLayoutRelativeToFrame = state.fixedElementsLayoutRelativeToFrame();
 }
 
 void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& offset)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h (183654 => 183655)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h	2015-04-30 23:44:49 UTC (rev 183655)
@@ -54,6 +54,7 @@
 
     SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
     bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; }
+    bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; }
 
     FloatSize viewToContentsOffset(const FloatPoint& scrollOffset) const;
 
@@ -71,14 +72,16 @@
     ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
     
 private:
-    float m_frameScaleFactor;
+    float m_frameScaleFactor { 1 };
+    float m_topContentInset { 0 };
 
-    int m_headerHeight;
-    int m_footerHeight;
-    float m_topContentInset;
+    int m_headerHeight { 0 };
+    int m_footerHeight { 0 };
     
-    SynchronousScrollingReasons m_synchronousScrollingReasons;
-    ScrollBehaviorForFixedElements m_behaviorForFixed;
+    SynchronousScrollingReasons m_synchronousScrollingReasons { 0 };
+    ScrollBehaviorForFixedElements m_behaviorForFixed { StickToDocumentBounds };
+    
+    bool m_fixedElementsLayoutRelativeToFrame { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm (183654 => 183655)


--- trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm	2015-04-30 23:44:49 UTC (rev 183655)
@@ -148,7 +148,7 @@
     ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
     FloatPoint scrollOffset = scrollPosition - toIntSize(scrollOrigin());
     FloatRect viewportRect(FloatPoint(), scrollableAreaSize());
-    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
+    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight());
 
     [m_counterScrollingLayer setPosition:FloatPoint(scrollOffsetForFixedChildren)];
 
@@ -158,7 +158,7 @@
         // then we should recompute scrollOffsetForFixedChildren for the banner with a scale factor of 1.
         float horizontalScrollOffsetForBanner = scrollOffsetForFixedChildren.width();
         if (frameScaleFactor() != 1)
-            horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollOffset), scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
+            horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollOffset), scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).width();
 
         if (m_headerLayer)
             [m_headerLayer setPosition:FloatPoint(horizontalScrollOffsetForBanner, 0)];

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


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2015-04-30 23:44:49 UTC (rev 183655)
@@ -381,7 +381,7 @@
     FloatRect viewportRect(FloatPoint(), scrollableAreaSize());
     
     FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), scrollOffset, scrollOrigin(), frameScaleFactor(),
-        false, behaviorForFixed, headerHeight(), footerHeight());
+        fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight());
     
     if (m_counterScrollingLayer)
         m_counterScrollingLayer.get().position = FloatPoint(scrollOffsetForFixedChildren);
@@ -401,7 +401,7 @@
         // then we should recompute scrollOffsetForFixedChildren for the banner with a scale factor of 1.
         float horizontalScrollOffsetForBanner = scrollOffsetForFixedChildren.width();
         if (frameScaleFactor() != 1)
-            horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), scrollOffset, scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
+            horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), scrollOffset, scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).width();
 
         if (m_headerLayer)
             m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForHeaderLayer(position, topContentInset));

Modified: trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm (183654 => 183655)


--- trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm	2015-04-30 23:44:49 UTC (rev 183655)
@@ -134,8 +134,6 @@
 
 @end // implementation WebSimpleLayer
 
-// MARK: -
-
 #ifndef NDEBUG
 
 @implementation CALayer(ExtendedDescription)

Modified: trunk/Source/WebKit2/ChangeLog (183654 => 183655)


--- trunk/Source/WebKit2/ChangeLog	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-30 23:44:49 UTC (rev 183655)
@@ -1,3 +1,17 @@
+2015-04-30  Simon Fraser  <simon.fra...@apple.com>
+
+        Fixed elements end up in the middle of the view with pageScale < 1
+        https://bugs.webkit.org/show_bug.cgi?id=144428
+        rdar://problem/20404982
+
+        Reviewed by Tim Horton.
+
+        Encode/decode fixedElementsLayoutRelativeToFrame.
+
+        * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
+        (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
+        (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
+
 2015-04-30  Tim Horton  <timothy_hor...@apple.com>
 
         Asynchronous (or timed-out synchronous) resize flashes white instead of page background color

Modified: trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp (183654 => 183655)


--- trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp	2015-04-30 23:35:26 UTC (rev 183654)
+++ trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp	2015-04-30 23:44:49 UTC (rev 183655)
@@ -148,6 +148,7 @@
     SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::HeaderHeight, headerHeight)
     SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::FooterHeight, footerHeight)
     SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::TopContentInset, topContentInset)
+    SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame, fixedElementsLayoutRelativeToFrame)
 
     if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrolledContentsLayer))
         encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer());
@@ -230,6 +231,7 @@
     SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::HeaderHeight, int, setHeaderHeight);
     SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::FooterHeight, int, setFooterHeight);
     SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::TopContentInset, float, setTopContentInset);
+    SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame, bool, setFixedElementsLayoutRelativeToFrame);
 
     if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrolledContentsLayer)) {
         GraphicsLayer::PlatformLayerID layerID;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to