Pass the viewport rect and scroll origin independently into the scrolling tree, and...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Feb 2014 03:57:48 +0000 (03:57 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Feb 2014 03:57:48 +0000 (03:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128032

Reviewed by Tim Horton.

Pass the viewport rect and scroll offset independently into the ScrollingTree
via the ScrollingStateScrollingNode, since on iOS the scroll offset doesn't
always correspond to the viewport rect.

Make the viewport rect and the scroll origin be float-based, since on
Retina screens and with zooming these can both be non-integral.

Source/WebCore:

No behavior change.

* WebCore.exp.in:
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
(WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
* page/scrolling/AsyncScrollingCoordinator.h:
(WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::ScheduledScrollUpdate):
* page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
(WebCore::ScrollingStateScrollingNode::setViewportConstrainedObjectRect):
(WebCore::ScrollingStateScrollingNode::setScrollPosition):
(WebCore::ScrollingStateScrollingNode::dumpProperties):
* page/scrolling/ScrollingStateScrollingNode.h:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
(WebCore::ScrollingTree::commitNewTreeState):
(WebCore::ScrollingTree::mainFrameScrollPosition):
(WebCore::ScrollingTree::setMainFrameScrollPosition):
* page/scrolling/ScrollingTree.h:
* page/scrolling/ScrollingTreeNode.h:
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::updateBeforeChildren):
* page/scrolling/ScrollingTreeScrollingNode.h:
(WebCore::ScrollingTreeScrollingNode::scrollPosition):
(WebCore::ScrollingTreeScrollingNode::viewportConstrainedObjectRect):
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/ios/ScrollingTreeIOS.cpp:
(WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll):
* page/scrolling/ios/ScrollingTreeIOS.h:
* page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
* page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:
(WebCore::ScrollingTreeScrollingNodeIOS::scrollPosition):
(WebCore::ScrollingTreeScrollingNodeIOS::setScrollPosition):
(WebCore::ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints):
(WebCore::ScrollingTreeScrollingNodeIOS::setScrollLayerPosition):
(WebCore::ScrollingTreeScrollingNodeIOS::minimumScrollPosition):
(WebCore::ScrollingTreeScrollingNodeIOS::maximumScrollPosition):
* page/scrolling/mac/ScrollingTreeFixedNode.h:
* page/scrolling/mac/ScrollingTreeFixedNode.mm:
(WebCore::ScrollingTreeFixedNode::parentScrollPositionDidChange):
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::updateAfterChildren):
(WebCore::ScrollingTreeScrollingNodeMac::absoluteScrollPosition):
(WebCore::ScrollingTreeScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary):
(WebCore::ScrollingTreeScrollingNodeMac::scrollPosition):
(WebCore::ScrollingTreeScrollingNodeMac::setScrollPosition):
(WebCore::ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
(WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):
(WebCore::ScrollingTreeScrollingNodeMac::minimumScrollPosition):
(WebCore::ScrollingTreeScrollingNodeMac::maximumScrollPosition):
(WebCore::ScrollingTreeScrollingNodeMac::updateMainFramePinState):
(WebCore::ScrollingTreeScrollingNodeMac::logExposedUnfilledArea):
* page/scrolling/mac/ScrollingTreeStickyNode.h:
* page/scrolling/mac/ScrollingTreeStickyNode.mm:
(WebCore::ScrollingTreeStickyNode::parentScrollPositionDidChange):
* platform/graphics/FloatPoint.h:
(WebCore::FloatPoint::shrunkTo):

Source/WebKit2:

* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(ArgumentCoder<ScrollingStateScrollingNode>::encode):
(ArgumentCoder<ScrollingStateScrollingNode>::decode):
* UIProcess/Scrolling/RemoteScrollingTree.cpp:
(WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll):
* UIProcess/Scrolling/RemoteScrollingTree.h:

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

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ScrollingTreeNode.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
Source/WebCore/page/scrolling/ThreadedScrollingTree.h
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h
Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h
Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.h
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm
Source/WebCore/platform/graphics/FloatPoint.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.h

index 714f9db..18cd416 100644 (file)
@@ -1,3 +1,80 @@
+2014-01-31  Simon Fraser  <simon.fraser@apple.com>
+
+        Pass the viewport rect and scroll origin independently into the scrolling tree, and make things floats
+        https://bugs.webkit.org/show_bug.cgi?id=128032
+
+        Reviewed by Tim Horton.
+
+        Pass the viewport rect and scroll offset independently into the ScrollingTree
+        via the ScrollingStateScrollingNode, since on iOS the scroll offset doesn't
+        always correspond to the viewport rect.
+        
+        Make the viewport rect and the scroll origin be float-based, since on
+        Retina screens and with zooming these can both be non-integral.
+
+        No behavior change.
+        
+        * WebCore.exp.in:
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
+        (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
+        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        (WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::ScheduledScrollUpdate):
+        * page/scrolling/ScrollingStateScrollingNode.cpp:
+        (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
+        (WebCore::ScrollingStateScrollingNode::setViewportConstrainedObjectRect):
+        (WebCore::ScrollingStateScrollingNode::setScrollPosition):
+        (WebCore::ScrollingStateScrollingNode::dumpProperties):
+        * page/scrolling/ScrollingStateScrollingNode.h:
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
+        (WebCore::ScrollingTree::commitNewTreeState):
+        (WebCore::ScrollingTree::mainFrameScrollPosition):
+        (WebCore::ScrollingTree::setMainFrameScrollPosition):
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/ScrollingTreeNode.h:
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::updateBeforeChildren):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        (WebCore::ScrollingTreeScrollingNode::scrollPosition):
+        (WebCore::ScrollingTreeScrollingNode::viewportConstrainedObjectRect):
+        * page/scrolling/ThreadedScrollingTree.cpp:
+        (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
+        * page/scrolling/ThreadedScrollingTree.h:
+        * page/scrolling/ios/ScrollingTreeIOS.cpp:
+        (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll):
+        * page/scrolling/ios/ScrollingTreeIOS.h:
+        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
+        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:
+        (WebCore::ScrollingTreeScrollingNodeIOS::scrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeIOS::setScrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints):
+        (WebCore::ScrollingTreeScrollingNodeIOS::setScrollLayerPosition):
+        (WebCore::ScrollingTreeScrollingNodeIOS::minimumScrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeIOS::maximumScrollPosition):
+        * page/scrolling/mac/ScrollingTreeFixedNode.h:
+        * page/scrolling/mac/ScrollingTreeFixedNode.mm:
+        (WebCore::ScrollingTreeFixedNode::parentScrollPositionDidChange):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeMac::updateAfterChildren):
+        (WebCore::ScrollingTreeScrollingNodeMac::absoluteScrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary):
+        (WebCore::ScrollingTreeScrollingNodeMac::scrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeMac::setScrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
+        (WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):
+        (WebCore::ScrollingTreeScrollingNodeMac::minimumScrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeMac::maximumScrollPosition):
+        (WebCore::ScrollingTreeScrollingNodeMac::updateMainFramePinState):
+        (WebCore::ScrollingTreeScrollingNodeMac::logExposedUnfilledArea):
+        * page/scrolling/mac/ScrollingTreeStickyNode.h:
+        * page/scrolling/mac/ScrollingTreeStickyNode.mm:
+        (WebCore::ScrollingTreeStickyNode::parentScrollPositionDidChange):
+        * platform/graphics/FloatPoint.h:
+        (WebCore::FloatPoint::shrunkTo):
+
 2014-01-30  Andy Estes  <aestes@apple.com>
 
         [Cocoa] Add NEFilterSource support to ContentFilterMac
index 1803b28..aa244af 100644 (file)
@@ -3017,7 +3017,7 @@ __ZN7WebCore25AsyncScrollingCoordinator29updateViewportConstrainedNodeEyRKNS_19V
 __ZN7WebCore25AsyncScrollingCoordinator30setSynchronousScrollingReasonsEj
 __ZN7WebCore25AsyncScrollingCoordinator37scrollableAreaScrollbarLayerDidChangeEPNS_14ScrollableAreaENS_20ScrollbarOrientationE
 __ZN7WebCore25AsyncScrollingCoordinator43recomputeWheelEventHandlerCountForFrameViewEPNS_9FrameViewE
-__ZN7WebCore25AsyncScrollingCoordinator44scheduleUpdateScrollPositionAfterAsyncScrollEyRKNS_8IntPointEbNS_31SetOrSyncScrollingLayerPositionE
+__ZN7WebCore25AsyncScrollingCoordinator44scheduleUpdateScrollPositionAfterAsyncScrollEyRKNS_10FloatPointEbNS_31SetOrSyncScrollingLayerPositionE
 __ZN7WebCore25AsyncScrollingCoordinatorC2EPNS_4PageE
 __ZN7WebCore25AsyncScrollingCoordinatorD2Ev
 __ZN7WebCore27ScrollingStateScrollingNode14setFooterLayerERKNS_19LayerRepresentationE
@@ -3025,7 +3025,8 @@ __ZN7WebCore27ScrollingStateScrollingNode14setHeaderLayerERKNS_19LayerRepresenta
 __ZN7WebCore27ScrollingStateScrollingNode15setFooterHeightEi
 __ZN7WebCore27ScrollingStateScrollingNode15setHeaderHeightEi
 __ZN7WebCore27ScrollingStateScrollingNode15setScrollOriginERKNS_8IntPointE
-__ZN7WebCore27ScrollingStateScrollingNode15setViewportRectERKNS_7IntRectE
+__ZN7WebCore27ScrollingStateScrollingNode17setScrollPositionERKNS_10FloatPointE
+__ZN7WebCore27ScrollingStateScrollingNode32setViewportConstrainedObjectRectERKNS_9FloatRectE
 __ZN7WebCore27ScrollingStateScrollingNode19setFrameScaleFactorEf
 __ZN7WebCore27ScrollingStateScrollingNode20setTotalContentsSizeERKNS_7IntSizeE
 __ZN7WebCore27ScrollingStateScrollingNode24setCounterScrollingLayerERKNS_19LayerRepresentationE
index 273861c..67d7109 100644 (file)
@@ -91,7 +91,7 @@ void AsyncScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
     node->setFooterHeight(frameView->footerHeight());
 
     node->setScrollOrigin(frameView->scrollOrigin());
-    node->setViewportRect(IntRect(IntPoint(), frameView->visibleContentRect().size()));
+    node->setViewportConstrainedObjectRect(FloatRect(FloatPoint(), frameView->visibleContentRect().size()));
     node->setTotalContentsSize(frameView->totalContentsSize());
 
     ScrollableAreaParameters scrollParameters;
@@ -151,7 +151,7 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView
     return true;
 }
 
-void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
 {
     ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, programmaticScroll, scrollingLayerPositionAction);
     
@@ -177,7 +177,7 @@ void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired(T
     updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);
 }
 
-void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
 {
     ASSERT(isMainThread());
 
@@ -192,7 +192,7 @@ void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNo
     frameView->setInProgrammaticScroll(programmaticScroll);
 
     frameView->setConstrainsScrollingToContentEdge(false);
-    frameView->notifyScrollPositionChanged(scrollPosition);
+    frameView->notifyScrollPositionChanged(roundedIntPoint(scrollPosition));
     frameView->setConstrainsScrollingToContentEdge(true);
 
     frameView->setInProgrammaticScroll(oldProgrammaticScroll);
index 4b723d4..49517af 100644 (file)
@@ -57,7 +57,7 @@ public:
 
     void scrollingStateTreePropertiesChanged();
 
-    void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
+    void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
 
 protected:
     AsyncScrollingCoordinator(Page*);
@@ -68,7 +68,7 @@ protected:
 
     PassRefPtr<ScrollingTree> releaseScrollingTree() { return m_scrollingTree.release(); }
 
-    void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
+    void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
 
 private:
     virtual bool isAsyncScrollingCoordinator() const override { return true; }
@@ -123,7 +123,7 @@ private:
             , updateLayerPositionAction(SyncScrollingLayerPosition)
         { }
 
-        ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, IntPoint point, bool isProgrammatic, SetOrSyncScrollingLayerPosition udpateAction)
+        ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, FloatPoint point, bool isProgrammatic, SetOrSyncScrollingLayerPosition udpateAction)
             : nodeID(scrollingNodeID)
             , scrollPosition(point)
             , isProgrammaticScroll(isProgrammatic)
@@ -131,7 +131,7 @@ private:
         { }
 
         ScrollingNodeID nodeID;
-        IntPoint scrollPosition;
+        FloatPoint scrollPosition;
         bool isProgrammaticScroll;
         SetOrSyncScrollingLayerPosition updateLayerPositionAction;
         
index 8ef8ff6..7b2f799 100644 (file)
@@ -61,8 +61,9 @@ ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScr
     , m_verticalScrollbarPainter(stateNode.verticalScrollbarPainter())
     , m_horizontalScrollbarPainter(stateNode.horizontalScrollbarPainter())
 #endif
-    , m_viewportRect(stateNode.viewportRect())
+    , m_viewportConstrainedObjectRect(stateNode.viewportConstrainedObjectRect())
     , m_totalContentsSize(stateNode.totalContentsSize())
+    , m_scrollPosition(stateNode.scrollPosition())
     , m_scrollOrigin(stateNode.scrollOrigin())
     , m_scrollableAreaParameters(stateNode.scrollableAreaParameters())
     , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion())
@@ -94,13 +95,13 @@ PassOwnPtr<ScrollingStateNode> ScrollingStateScrollingNode::clone(ScrollingState
     return adoptPtr(new ScrollingStateScrollingNode(*this, adoptiveTree));
 }
 
-void ScrollingStateScrollingNode::setViewportRect(const IntRect& viewportRect)
+void ScrollingStateScrollingNode::setViewportConstrainedObjectRect(const FloatRect& viewportConstrainedObjectRect)
 {
-    if (m_viewportRect == viewportRect)
+    if (m_viewportConstrainedObjectRect == viewportConstrainedObjectRect)
         return;
 
-    m_viewportRect = viewportRect;
-    setPropertyChanged(ViewportRect);
+    m_viewportConstrainedObjectRect = viewportConstrainedObjectRect;
+    setPropertyChanged(ViewportConstrainedObjectRect);
 }
 
 void ScrollingStateScrollingNode::setTotalContentsSize(const IntSize& totalContentsSize)
@@ -112,6 +113,15 @@ void ScrollingStateScrollingNode::setTotalContentsSize(const IntSize& totalConte
     setPropertyChanged(TotalContentsSize);
 }
 
+void ScrollingStateScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
+{
+    if (m_scrollPosition == scrollPosition)
+        return;
+
+    m_scrollPosition = scrollPosition;
+    setPropertyChanged(ScrollPosition);
+}
+
 void ScrollingStateScrollingNode::setScrollOrigin(const IntPoint& scrollOrigin)
 {
     if (m_scrollOrigin == scrollOrigin)
@@ -242,9 +252,20 @@ void ScrollingStateScrollingNode::dumpProperties(TextStream& ts, int indent) con
 {
     ts << "(" << "Scrolling node" << "\n";
 
-    if (!m_viewportRect.isEmpty()) {
+    if (!m_viewportConstrainedObjectRect.isEmpty()) {
+        writeIndent(ts, indent + 1);
+        ts << "(viewport rect "
+            << TextStream::FormatNumberRespectingIntegers(m_viewportConstrainedObjectRect.x()) << " "
+            << TextStream::FormatNumberRespectingIntegers(m_viewportConstrainedObjectRect.y()) << " "
+            << TextStream::FormatNumberRespectingIntegers(m_viewportConstrainedObjectRect.width()) << " "
+            << TextStream::FormatNumberRespectingIntegers(m_viewportConstrainedObjectRect.height()) << ")\n";
+    }
+
+    if (m_scrollPosition != FloatPoint()) {
         writeIndent(ts, indent + 1);
-        ts << "(viewport rect " << m_viewportRect.x() << " " << m_viewportRect.y() << " " << m_viewportRect.width() << " " << m_viewportRect.height() << ")\n";
+        ts << "(scroll position "
+            << TextStream::FormatNumberRespectingIntegers(m_scrollPosition.x()) << " "
+            << TextStream::FormatNumberRespectingIntegers(m_scrollPosition.y()) << ")\n";
     }
 
     if (!m_totalContentsSize.isEmpty()) {
index 14be04b..8efeaeb 100644 (file)
@@ -50,8 +50,9 @@ public:
     virtual ~ScrollingStateScrollingNode();
 
     enum ChangedProperty {
-        ViewportRect = NumStateNodeBits,
+        ViewportConstrainedObjectRect = NumStateNodeBits,
         TotalContentsSize,
+        ScrollPosition,
         ScrollOrigin,
         ScrollableAreaParams,
         FrameScaleFactor,
@@ -68,12 +69,15 @@ public:
         BehaviorForFixedElements
     };
 
-    const IntRect& viewportRect() const { return m_viewportRect; }
-    void setViewportRect(const IntRect&);
+    const FloatRect& viewportConstrainedObjectRect() const { return m_viewportConstrainedObjectRect; }
+    void setViewportConstrainedObjectRect(const FloatRect&);
 
     const IntSize& totalContentsSize() const { return m_totalContentsSize; }
     void setTotalContentsSize(const IntSize&);
 
+    const FloatPoint& scrollPosition() const { return m_scrollPosition; }
+    void setScrollPosition(const FloatPoint&);
+
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
     void setScrollOrigin(const IntPoint&);
 
@@ -139,8 +143,9 @@ private:
     RetainPtr<ScrollbarPainter> m_horizontalScrollbarPainter;
 #endif
 
-    IntRect m_viewportRect;
+    FloatRect m_viewportConstrainedObjectRect;
     IntSize m_totalContentsSize;
+    FloatPoint m_scrollPosition;
     IntPoint m_scrollOrigin;
     
     ScrollableAreaParameters m_scrollableAreaParameters;
index 9da5a8e..6c452bc 100644 (file)
@@ -93,9 +93,9 @@ bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent
     
     if (!m_nonFastScrollableRegion.isEmpty()) {
         // FIXME: This is not correct for non-default scroll origins.
-        IntPoint position = wheelEvent.position();
+        FloatPoint position = wheelEvent.position();
         position.moveBy(m_mainFrameScrollPosition);
-        if (m_nonFastScrollableRegion.contains(position))
+        if (m_nonFastScrollableRegion.contains(roundedIntPoint(position)))
             return true;
     }
     return false;
@@ -140,7 +140,7 @@ void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingS
         MutexLocker lock(m_mutex);
 
         if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
-            m_mainFrameScrollPosition = IntPoint();
+            m_mainFrameScrollPosition = FloatPoint();
         if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount))
             m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount();
         if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion))
@@ -242,13 +242,13 @@ void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheR
     m_mainFramePinnedToTheBottom = pinnedToTheBottom;
 }
 
-IntPoint ScrollingTree::mainFrameScrollPosition()
+FloatPoint ScrollingTree::mainFrameScrollPosition()
 {
     MutexLocker lock(m_mutex);
     return m_mainFrameScrollPosition;
 }
 
-void ScrollingTree::setMainFrameScrollPosition(IntPoint position)
+void ScrollingTree::setMainFrameScrollPosition(FloatPoint position)
 {
     MutexLocker lock(m_mutex);
     m_mainFrameScrollPosition = position;
index 8c14a45..e88f64a 100644 (file)
@@ -73,8 +73,8 @@ public:
 
     void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
 
-    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
-    IntPoint mainFrameScrollPosition();
+    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
+    FloatPoint mainFrameScrollPosition();
 
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0;
@@ -107,7 +107,7 @@ public:
     void setOrClearLatchedNode(const PlatformWheelEvent&, ScrollingNodeID);
     
 protected:
-    void setMainFrameScrollPosition(IntPoint);
+    void setMainFrameScrollPosition(FloatPoint);
     virtual void handleWheelEvent(const PlatformWheelEvent&);
 
 private:
@@ -125,7 +125,7 @@ private:
 
     Mutex m_mutex;
     Region m_nonFastScrollableRegion;
-    IntPoint m_mainFrameScrollPosition;
+    FloatPoint m_mainFrameScrollPosition;
     bool m_hasWheelEventHandlers;
 
     Mutex m_swipeStateMutex;
index 27475b8..384d3b9 100644 (file)
@@ -49,7 +49,7 @@ public:
     virtual void updateBeforeChildren(const ScrollingStateNode&) = 0;
     virtual void updateAfterChildren(const ScrollingStateNode&) { }
 
-    virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) = 0;
+    virtual void parentScrollPositionDidChange(const FloatRect& viewportRect, const FloatSize& cumulativeDelta) = 0;
 
     ScrollingTreeNode* parent() const { return m_parent; }
     void setParent(ScrollingTreeNode* parent) { m_parent = parent; }
index 6a21fff..3872aec 100644 (file)
@@ -51,8 +51,8 @@ void ScrollingTreeScrollingNode::updateBeforeChildren(const ScrollingStateNode&
 {
     const ScrollingStateScrollingNode& state = toScrollingStateScrollingNode(stateNode);
 
-    if (state.hasChangedProperty(ScrollingStateScrollingNode::ViewportRect))
-        m_viewportRect = state.viewportRect();
+    if (state.hasChangedProperty(ScrollingStateScrollingNode::ViewportConstrainedObjectRect))
+        m_viewportConstrainedObjectRect = state.viewportConstrainedObjectRect();
 
     if (state.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
         if (scrollingTree().isRubberBandInProgress())
@@ -62,6 +62,9 @@ void ScrollingTreeScrollingNode::updateBeforeChildren(const ScrollingStateNode&
         m_totalContentsSize = state.totalContentsSize();
     }
 
+    if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition))
+        m_scrollPosition = state.scrollPosition();
+
     if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin))
         m_scrollOrigin = state.scrollOrigin();
 
index ac9151e..e922c7e 100644 (file)
@@ -47,10 +47,10 @@ public:
     virtual void updateBeforeChildren(const ScrollingStateNode&) override;
 
     // FIXME: We should implement this when we support ScrollingTreeScrollingNodes as children.
-    virtual void parentScrollPositionDidChange(const IntRect& /*viewportRect*/, const FloatSize& /*cumulativeDelta*/) override { }
+    virtual void parentScrollPositionDidChange(const FloatRect& /*viewportRect*/, const FloatSize& /*cumulativeDelta*/) override { }
 
     virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
-    virtual void setScrollPosition(const IntPoint&) = 0;
+    virtual void setScrollPosition(const FloatPoint&) = 0;
 
     SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
     bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; }
@@ -58,7 +58,8 @@ public:
 protected:
     ScrollingTreeScrollingNode(ScrollingTree&, ScrollingNodeID);
 
-    const IntRect& viewportRect() const { return m_viewportRect; }
+    const FloatPoint& scrollPosition() const { return m_scrollPosition; }
+    const FloatRect& viewportConstrainedObjectRect() const { return m_viewportConstrainedObjectRect; }
     const IntSize& totalContentsSize() const { return m_totalContentsSize; }
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
 
@@ -84,9 +85,10 @@ protected:
     ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
 
 private:
-    IntRect m_viewportRect;
+    FloatRect m_viewportConstrainedObjectRect;
     IntSize m_totalContentsSize;
     IntSize m_totalContentsSizeForRubberBand;
+    FloatPoint m_scrollPosition;
     IntPoint m_scrollOrigin;
     
     ScrollableAreaParameters m_scrollableAreaParameters;
index 8314de3..a5a4fb9 100644 (file)
@@ -100,7 +100,7 @@ void ThreadedScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> sc
     ScrollingTree::commitNewTreeState(scrollingStateTree);
 }
 
-void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
 {
     if (!m_scrollingCoordinator)
         return;
index d0c8b17..6b63b99 100644 (file)
@@ -64,7 +64,7 @@ private:
 
     virtual PassOwnPtr<ScrollingTreeNode> createNode(ScrollingNodeType, ScrollingNodeID) override;
 
-    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
+    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     virtual void handleWheelEventPhase(PlatformWheelEventPhase) override;
 #endif
index 147916a..49c0327 100644 (file)
@@ -81,7 +81,7 @@ void ScrollingTreeIOS::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrolli
     ScrollingTree::commitNewTreeState(scrollingStateTree);
 }
 
-void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
 {
     if (!m_scrollingCoordinator)
         return;
index 57601b8..639c554 100644 (file)
@@ -56,7 +56,7 @@ private:
 
     virtual PassOwnPtr<ScrollingTreeNode> createNode(ScrollingNodeType, ScrollingNodeID) override;
 
-    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
+    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
 
     RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator;
 };
index 859fa6f..f857fba 100644 (file)
@@ -48,14 +48,14 @@ private:
     virtual void updateAfterChildren(const ScrollingStateNode&) override;
     virtual void handleWheelEvent(const PlatformWheelEvent&) override { }
 
-    IntPoint scrollPosition() const;
-    void setScrollPosition(const IntPoint&);
-    void setScrollPositionWithoutContentEdgeConstraints(const IntPoint&);
+    FloatPoint scrollPosition() const;
+    virtual void setScrollPosition(const FloatPoint&) override;
+    void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&);
 
-    void setScrollLayerPosition(const IntPoint&);
+    void setScrollLayerPosition(const FloatPoint&);
 
-    IntPoint minimumScrollPosition() const;
-    IntPoint maximumScrollPosition() const;
+    FloatPoint minimumScrollPosition() const;
+    FloatPoint maximumScrollPosition() const;
 
     void scrollBy(const IntSize&);
     void scrollByWithoutContentEdgeConstraints(const IntSize&);
@@ -64,7 +64,7 @@ private:
     RetainPtr<CALayer> m_counterScrollingLayer;
     RetainPtr<CALayer> m_headerLayer;
     RetainPtr<CALayer> m_footerLayer;
-    IntPoint m_probableMainThreadScrollPosition;
+    FloatPoint m_probableMainThreadScrollPosition;
 };
 
 } // namespace WebCore
index 826ecd6..ae55b65 100644 (file)
@@ -96,7 +96,7 @@ void ScrollingTreeScrollingNodeIOS::updateAfterChildren(const ScrollingStateNode
         setScrollPosition(scrollingStateNode.requestedScrollPosition());
 }
 
-IntPoint ScrollingTreeScrollingNodeIOS::scrollPosition() const
+FloatPoint ScrollingTreeScrollingNodeIOS::scrollPosition() const
 {
     if (shouldUpdateScrollLayerPositionSynchronously())
         return m_probableMainThreadScrollPosition;
@@ -105,16 +105,16 @@ IntPoint ScrollingTreeScrollingNodeIOS::scrollPosition() const
     return IntPoint(-scrollLayerPosition.x + scrollOrigin().x(), -scrollLayerPosition.y + scrollOrigin().y());
 }
 
-void ScrollingTreeScrollingNodeIOS::setScrollPosition(const IntPoint& scrollPosition)
+void ScrollingTreeScrollingNodeIOS::setScrollPosition(const FloatPoint& scrollPosition)
 {
-    IntPoint newScrollPosition = scrollPosition;
+    FloatPoint newScrollPosition = scrollPosition;
     newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition());
     newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
 
     setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
 }
 
-void ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints(const IntPoint& scrollPosition)
+void ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints(const FloatPoint& scrollPosition)
 {
     if (shouldUpdateScrollLayerPositionSynchronously()) {
         m_probableMainThreadScrollPosition = scrollPosition;
@@ -126,14 +126,15 @@ void ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstrain
     scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition);
 }
 
-void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const IntPoint& position)
+void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const FloatPoint& position)
 {
     ASSERT(!shouldUpdateScrollLayerPositionSynchronously());
     m_scrollLayer.get().position = CGPointMake(-position.x() + scrollOrigin().x(), -position.y() + scrollOrigin().y());
 
     ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
-    IntPoint scrollOffset = position - toIntSize(scrollOrigin());
-    IntSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(viewportRect(), totalContentsSize(), scrollOffset, scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
+    FloatPoint scrollOffset = position - toIntSize(scrollOrigin());
+    // FIXME: scrollOffsetForFixedPosition() needs to do float math.
+    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
     if (m_counterScrollingLayer)
         m_counterScrollingLayer.get().position = FloatPoint(scrollOffsetForFixedChildren);
 
@@ -142,7 +143,7 @@ void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const IntPoint& posit
     // then we should recompute scrollOffsetForFixedChildren for the banner with a scale factor of 1.
     float horizontalScrollOffsetForBanner = scrollOffsetForFixedChildren.width();
     if (frameScaleFactor() != 1)
-        horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(viewportRect(), totalContentsSize(), scrollOffset, scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
+        horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
 
     if (m_headerLayer)
         m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, 0);
@@ -153,17 +154,17 @@ void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const IntPoint& posit
     if (!m_children)
         return;
 
-    IntRect viewportRect = this->viewportRect();
-    viewportRect.setLocation(IntPoint(scrollOffsetForFixedChildren));
+    FloatRect viewportRect = viewportConstrainedObjectRect();
+    viewportRect.setLocation(FloatPoint() + scrollOffsetForFixedChildren);
 
     size_t size = m_children->size();
     for (size_t i = 0; i < size; ++i)
         m_children->at(i)->parentScrollPositionDidChange(viewportRect, FloatSize());
 }
 
-IntPoint ScrollingTreeScrollingNodeIOS::minimumScrollPosition() const
+FloatPoint ScrollingTreeScrollingNodeIOS::minimumScrollPosition() const
 {
-    IntPoint position;
+    FloatPoint position;
     
     if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToBottom)
         position.setY(maximumScrollPosition().y());
@@ -171,12 +172,12 @@ IntPoint ScrollingTreeScrollingNodeIOS::minimumScrollPosition() const
     return position;
 }
 
-IntPoint ScrollingTreeScrollingNodeIOS::maximumScrollPosition() const
+FloatPoint ScrollingTreeScrollingNodeIOS::maximumScrollPosition() const
 {
-    IntPoint position(totalContentsSizeForRubberBand().width() - viewportRect().width(),
-                      totalContentsSizeForRubberBand().height() - viewportRect().height());
+    FloatPoint position(totalContentsSizeForRubberBand().width() - viewportConstrainedObjectRect().width(),
+        totalContentsSizeForRubberBand().height() - viewportConstrainedObjectRect().height());
 
-    position.clampNegativeToZero();
+    position = position.expandedTo(FloatPoint());
 
     if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToTop)
         position.setY(minimumScrollPosition().y());
index 5ff92f2..8972fdf 100644 (file)
@@ -48,7 +48,7 @@ private:
     ScrollingTreeFixedNode(ScrollingTree&, ScrollingNodeID);
 
     virtual void updateBeforeChildren(const ScrollingStateNode&) override;
-    virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) override;
+    virtual void parentScrollPositionDidChange(const FloatRect& viewportRect, const FloatSize& cumulativeDelta) override;
 
     FixedPositionViewportConstraints m_constraints;
     RetainPtr<CALayer> m_layer;
index af932a4..e25af08 100644 (file)
@@ -64,7 +64,7 @@ static inline CGPoint operator*(CGPoint& a, const CGSize& b)
     return CGPointMake(a.x * b.width, a.y * b.height);
 }
 
-void ScrollingTreeFixedNode::parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta)
+void ScrollingTreeFixedNode::parentScrollPositionDidChange(const FloatRect& viewportRect, const FloatSize& cumulativeDelta)
 {
     FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(viewportRect);
     layerPosition -= cumulativeDelta;
index 3c10133..9aed48c 100644 (file)
@@ -65,19 +65,19 @@ private:
     virtual void stopSnapRubberbandTimer() override;
     virtual void adjustScrollPositionToBoundsIfNecessary() override;
 
-    IntPoint scrollPosition() const;
-    void setScrollPosition(const IntPoint&);
-    void setScrollPositionWithoutContentEdgeConstraints(const IntPoint&);
+    FloatPoint scrollPosition() const;
+    virtual void setScrollPosition(const FloatPoint&) override;
+    void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&);
 
-    void setScrollLayerPosition(const IntPoint&);
+    void setScrollLayerPosition(const FloatPoint&);
 
-    IntPoint minimumScrollPosition() const;
-    IntPoint maximumScrollPosition() const;
+    FloatPoint minimumScrollPosition() const;
+    FloatPoint maximumScrollPosition() const;
 
     void scrollBy(const IntSize&);
     void scrollByWithoutContentEdgeConstraints(const IntSize&);
 
-    void updateMainFramePinState(const IntPoint& scrollPosition);
+    void updateMainFramePinState(const FloatPoint& scrollPosition);
 
     void logExposedUnfilledArea();
 
@@ -90,7 +90,7 @@ private:
     RetainPtr<CALayer> m_footerLayer;
     RetainPtr<ScrollbarPainter> m_verticalScrollbarPainter;
     RetainPtr<ScrollbarPainter> m_horizontalScrollbarPainter;
-    IntPoint m_probableMainThreadScrollPosition;
+    FloatPoint m_probableMainThreadScrollPosition;
     bool m_lastScrollHadUnfilledPixels;
 };
 
index 07335e7..514bd8c 100644 (file)
@@ -124,7 +124,7 @@ void ScrollingTreeScrollingNodeMac::updateAfterChildren(const ScrollingStateNode
     if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition))
         setScrollPosition(scrollingStateNode.requestedScrollPosition());
 
-    if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::ScrollLayer) || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize) || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ViewportRect))
+    if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::ScrollLayer) || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize) || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ViewportConstrainedObjectRect))
         updateMainFramePinState(scrollPosition());
 }
 
@@ -237,7 +237,7 @@ bool ScrollingTreeScrollingNodeMac::shouldRubberBandInDirection(ScrollDirection)
 
 IntPoint ScrollingTreeScrollingNodeMac::absoluteScrollPosition()
 {
-    return scrollPosition();
+    return roundedIntPoint(scrollPosition());
 }
 
 void ScrollingTreeScrollingNodeMac::immediateScrollBy(const FloatSize& offset)
@@ -278,18 +278,18 @@ void ScrollingTreeScrollingNodeMac::stopSnapRubberbandTimer()
 
 void ScrollingTreeScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary()
 {
-    IntPoint currentScrollPosition = absoluteScrollPosition();
-    IntPoint minPosition = minimumScrollPosition();
-    IntPoint maxPosition = maximumScrollPosition();
+    FloatPoint currentScrollPosition = absoluteScrollPosition();
+    FloatPoint minPosition = minimumScrollPosition();
+    FloatPoint maxPosition = maximumScrollPosition();
 
-    int nearestXWithinBounds = std::max<int>(std::min<int>(currentScrollPosition.x(), maxPosition.x()), minPosition.x());
-    int nearestYWithinBounds = std::max<int>(std::min<int>(currentScrollPosition.y(), maxPosition.y()), minPosition.y());
+    float nearestXWithinBounds = std::max(std::min(currentScrollPosition.x(), maxPosition.x()), minPosition.x());
+    float nearestYWithinBounds = std::max(std::min(currentScrollPosition.y(), maxPosition.y()), minPosition.y());
 
-    IntPoint nearestPointWithinBounds(nearestXWithinBounds, nearestYWithinBounds);
+    FloatPoint nearestPointWithinBounds(nearestXWithinBounds, nearestYWithinBounds);
     immediateScrollBy(nearestPointWithinBounds - currentScrollPosition);
 }
 
-IntPoint ScrollingTreeScrollingNodeMac::scrollPosition() const
+FloatPoint ScrollingTreeScrollingNodeMac::scrollPosition() const
 {
     if (shouldUpdateScrollLayerPositionSynchronously())
         return m_probableMainThreadScrollPosition;
@@ -298,9 +298,9 @@ IntPoint ScrollingTreeScrollingNodeMac::scrollPosition() const
     return IntPoint(-scrollLayerPosition.x + scrollOrigin().x(), -scrollLayerPosition.y + scrollOrigin().y());
 }
 
-void ScrollingTreeScrollingNodeMac::setScrollPosition(const IntPoint& scrollPosition)
+void ScrollingTreeScrollingNodeMac::setScrollPosition(const FloatPoint& scrollPosition)
 {
-    IntPoint newScrollPosition = scrollPosition;
+    FloatPoint newScrollPosition = scrollPosition;
     newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition());
     newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
 
@@ -310,7 +310,7 @@ void ScrollingTreeScrollingNodeMac::setScrollPosition(const IntPoint& scrollPosi
         logExposedUnfilledArea();
 }
 
-void ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints(const IntPoint& scrollPosition)
+void ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints(const FloatPoint& scrollPosition)
 {
     updateMainFramePinState(scrollPosition);
 
@@ -324,14 +324,15 @@ void ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstrain
     scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition);
 }
 
-void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const IntPoint& position)
+void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const FloatPoint& position)
 {
     ASSERT(!shouldUpdateScrollLayerPositionSynchronously());
     m_scrollLayer.get().position = CGPointMake(-position.x() + scrollOrigin().x(), -position.y() + scrollOrigin().y());
 
     ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
-    IntPoint scrollOffset = position - toIntSize(scrollOrigin());
-    IntSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(viewportRect(), totalContentsSize(), scrollOffset, scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
+    FloatPoint scrollOffset = position - toFloatSize(scrollOrigin());
+    // FIXME: scrollOffsetForFixedPosition() needs to do float math.
+    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
     if (m_counterScrollingLayer)
         m_counterScrollingLayer.get().position = FloatPoint(scrollOffsetForFixedChildren);
 
@@ -340,7 +341,7 @@ void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const IntPoint& posit
     // then we should recompute scrollOffsetForFixedChildren for the banner with a scale factor of 1.
     float horizontalScrollOffsetForBanner = scrollOffsetForFixedChildren.width();
     if (frameScaleFactor() != 1)
-        horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(viewportRect(), totalContentsSize(), scrollOffset, scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
+        horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
 
     if (m_headerLayer)
         m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, 0);
@@ -348,7 +349,7 @@ void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const IntPoint& posit
     if (m_footerLayer)
         m_footerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, totalContentsSize().height() - footerHeight());
 
-    IntRect viewportRect = this->viewportRect();
+    FloatRect viewportRect = viewportConstrainedObjectRect();
 
     if (m_verticalScrollbarPainter || m_horizontalScrollbarPainter) {
         [CATransaction begin];
@@ -376,14 +377,14 @@ void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const IntPoint& posit
     if (!m_children)
         return;
 
-    viewportRect.setLocation(IntPoint(scrollOffsetForFixedChildren));
+    viewportRect.setLocation(FloatPoint() + scrollOffsetForFixedChildren);
 
     size_t size = m_children->size();
     for (size_t i = 0; i < size; ++i)
         m_children->at(i)->parentScrollPositionDidChange(viewportRect, FloatSize());
 }
 
-IntPoint ScrollingTreeScrollingNodeMac::minimumScrollPosition() const
+FloatPoint ScrollingTreeScrollingNodeMac::minimumScrollPosition() const
 {
     IntPoint position;
     
@@ -393,12 +394,12 @@ IntPoint ScrollingTreeScrollingNodeMac::minimumScrollPosition() const
     return position;
 }
 
-IntPoint ScrollingTreeScrollingNodeMac::maximumScrollPosition() const
+FloatPoint ScrollingTreeScrollingNodeMac::maximumScrollPosition() const
 {
-    IntPoint position(totalContentsSizeForRubberBand().width() - viewportRect().width(),
-                      totalContentsSizeForRubberBand().height() - viewportRect().height());
+    FloatPoint position(totalContentsSizeForRubberBand().width() - viewportConstrainedObjectRect().width(),
+        totalContentsSizeForRubberBand().height() - viewportConstrainedObjectRect().height());
 
-    position.clampNegativeToZero();
+    position = position.expandedTo(FloatPoint());
 
     if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToTop)
         position.setY(minimumScrollPosition().y());
@@ -416,7 +417,7 @@ void ScrollingTreeScrollingNodeMac::scrollByWithoutContentEdgeConstraints(const
     setScrollPositionWithoutContentEdgeConstraints(scrollPosition() + offset);
 }
 
-void ScrollingTreeScrollingNodeMac::updateMainFramePinState(const IntPoint& scrollPosition)
+void ScrollingTreeScrollingNodeMac::updateMainFramePinState(const FloatPoint& scrollPosition)
 {
     bool pinnedToTheLeft = scrollPosition.x() <= minimumScrollPosition().x();
     bool pinnedToTheRight = scrollPosition.x() >= maximumScrollPosition().x();
@@ -450,8 +451,8 @@ void ScrollingTreeScrollingNodeMac::logExposedUnfilledArea()
         [sublayers release];
     }
 
-    IntPoint scrollPosition = this->scrollPosition();
-    unsigned unfilledArea = TileController::blankPixelCountForTiles(tiles, viewportRect(), IntPoint(-scrollPosition.x(), -scrollPosition.y()));
+    FloatPoint scrollPosition = this->scrollPosition();
+    unsigned unfilledArea = TileController::blankPixelCountForTiles(tiles, viewportConstrainedObjectRect(), IntPoint(-scrollPosition.x(), -scrollPosition.y()));
 
     if (unfilledArea || m_lastScrollHadUnfilledPixels)
         WTFLogAlways("SCROLLING: Exposed tileless area. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), unfilledArea);
index 204e6cf..80e1dfa 100644 (file)
@@ -48,7 +48,7 @@ private:
     ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
 
     virtual void updateBeforeChildren(const ScrollingStateNode&) override;
-    virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) override;
+    virtual void parentScrollPositionDidChange(const FloatRect& viewportRect, const FloatSize& cumulativeDelta) override;
 
     StickyPositionViewportConstraints m_constraints;
     RetainPtr<CALayer> m_layer;
index 6ea4063..783051f 100644 (file)
@@ -64,7 +64,7 @@ static inline CGPoint operator*(CGPoint& a, const CGSize& b)
     return CGPointMake(a.x * b.width, a.y * b.height);
 }
 
-void ScrollingTreeStickyNode::parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta)
+void ScrollingTreeStickyNode::parentScrollPositionDidChange(const FloatRect& viewportRect, const FloatSize& cumulativeDelta)
 {
     FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(viewportRect);
 
index 62c37bd..103cfec 100644 (file)
@@ -116,6 +116,11 @@ public:
         return m_x * m_x + m_y * m_y;
     }
 
+    FloatPoint shrunkTo(const FloatPoint& other) const
+    {
+        return FloatPoint(std::min(m_x, other.m_x), std::min(m_y, other.m_y));
+    }
+
     FloatPoint expandedTo(const FloatPoint& other) const
     {
         return FloatPoint(std::max(m_x, other.m_x), std::max(m_y, other.m_y));
index 01c6a7b..d9596ce 100644 (file)
@@ -1,3 +1,24 @@
+2014-01-31  Simon Fraser  <simon.fraser@apple.com>
+
+        Pass the viewport rect and scroll origin independently into the scrolling tree, and make things floats
+        https://bugs.webkit.org/show_bug.cgi?id=128032
+
+        Reviewed by Tim Horton.
+
+        Pass the viewport rect and scroll offset independently into the ScrollingTree
+        via the ScrollingStateScrollingNode, since on iOS the scroll offset doesn't
+        always correspond to the viewport rect.
+        
+        Make the viewport rect and the scroll origin be float-based, since on
+        Retina screens and with zooming these can both be non-integral.
+
+        * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
+        (ArgumentCoder<ScrollingStateScrollingNode>::encode):
+        (ArgumentCoder<ScrollingStateScrollingNode>::decode):
+        * UIProcess/Scrolling/RemoteScrollingTree.cpp:
+        (WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll):
+        * UIProcess/Scrolling/RemoteScrollingTree.h:
+
 2014-01-31  Tim Horton  <timothy_horton@apple.com>
 
         WebKit2 View Gestures: Crash when pinch-zooming on a page that is just a frameset
index 2a8dd52..7e15773 100644 (file)
@@ -108,8 +108,9 @@ void ArgumentCoder<ScrollingStateScrollingNode>::encode(ArgumentEncoder& encoder
 {
     encoder << static_cast<const ScrollingStateNode&>(node);
     
-    SCROLLING_NODE_ENCODE(ViewportRect, viewportRect)
+    SCROLLING_NODE_ENCODE(ViewportConstrainedObjectRect, viewportConstrainedObjectRect)
     SCROLLING_NODE_ENCODE(TotalContentsSize, totalContentsSize)
+    SCROLLING_NODE_ENCODE(ScrollPosition, scrollPosition)
     SCROLLING_NODE_ENCODE(ScrollOrigin, scrollOrigin)
     SCROLLING_NODE_ENCODE(FrameScaleFactor, frameScaleFactor)
 //    SCROLLING_NODE_ENCODE(NonFastScrollableRegion, nonFastScrollableRegion) // FIXME: no encoder support for Region
@@ -143,8 +144,9 @@ bool ArgumentCoder<ScrollingStateScrollingNode>::decode(ArgumentDecoder& decoder
     if (!decoder.decode(static_cast<ScrollingStateNode&>(node)))
         return false;
 
-    SCROLLING_NODE_DECODE(ViewportRect, IntRect, setViewportRect);
+    SCROLLING_NODE_DECODE(ViewportConstrainedObjectRect, FloatRect, setViewportConstrainedObjectRect);
     SCROLLING_NODE_DECODE(TotalContentsSize, IntSize, setTotalContentsSize);
+    SCROLLING_NODE_DECODE(ScrollPosition, FloatPoint, setScrollPosition);
     SCROLLING_NODE_DECODE(ScrollOrigin, IntPoint, setScrollOrigin);
     SCROLLING_NODE_DECODE(FrameScaleFactor, float, setFrameScaleFactor);
 //    SCROLLING_NODE_DECODE(NonFastScrollableRegion, Region, setNonFastScrollableRegion); // FIXME: no decoder support for Region.
index 2317d15..7d05cd8 100644 (file)
@@ -76,7 +76,7 @@ void RemoteScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
 }
 #endif
 
-void RemoteScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition)
+void RemoteScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition)
 {
     m_scrollingCoordinatorProxy.scrollPositionChanged(nodeID, scrollPosition);
 }
index 268e5a2..dcc7d31 100644 (file)
@@ -52,7 +52,7 @@ private:
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     virtual void handleWheelEventPhase(WebCore::PlatformWheelEventPhase) override;
 #endif
-    virtual void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::IntPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
+    virtual void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
 
     virtual PassOwnPtr<WebCore::ScrollingTreeNode> createNode(WebCore::ScrollingNodeType, WebCore::ScrollingNodeID);