Title: [161306] trunk/Source/WebCore
Revision
161306
Author
[email protected]
Date
2014-01-03 19:55:23 -0800 (Fri, 03 Jan 2014)

Log Message

Clean up the means of committing the scrolling state tree
https://bugs.webkit.org/show_bug.cgi?id=126482

Reviewed by Tim Horton.

ScrollingStateNodes would manually call scrollingStateTree().setHasChangedProperties()
after setPropertyChanged() in lots of places, which was repetitive, and
AsyncScrollingCoordinator manually called scheduleTreeStateCommit() in many places.

Clean up both of these with a clearer trigger for state tree commits.
ScrollingStateNodes::setPropertyChanged() calls ScrollingStateTree::setHasChangedProperties(),
which turns around and tells the ScrollingCoordinator that the state tree became dirty.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::AsyncScrollingCoordinator):
(WebCore::AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged):
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::updateScrollingNode):
(WebCore::AsyncScrollingCoordinator::updateViewportConstrainedNode):
(WebCore::AsyncScrollingCoordinator::setScrollLayerForNode):
(WebCore::AsyncScrollingCoordinator::setCounterScrollingLayerForNode):
(WebCore::AsyncScrollingCoordinator::setHeaderLayerForNode):
(WebCore::AsyncScrollingCoordinator::setFooterLayerForNode):
(WebCore::AsyncScrollingCoordinator::setNonFastScrollableRegionForNode):
(WebCore::AsyncScrollingCoordinator::setWheelEventHandlerCountForNode):
(WebCore::AsyncScrollingCoordinator::setScrollBehaviorForFixedElementsForNode):
(WebCore::AsyncScrollingCoordinator::setScrollbarPaintersFromScrollbarsForNode):
(WebCore::AsyncScrollingCoordinator::setSynchronousScrollingReasons):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingStateFixedNode.cpp:
(WebCore::ScrollingStateFixedNode::updateConstraints):
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::setPropertyChanged):
(WebCore::ScrollingStateNode::setLayer):
* page/scrolling/ScrollingStateNode.h:
* page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::setViewportRect):
(WebCore::ScrollingStateScrollingNode::setTotalContentsSize):
(WebCore::ScrollingStateScrollingNode::setScrollOrigin):
(WebCore::ScrollingStateScrollingNode::setScrollableAreaParameters):
(WebCore::ScrollingStateScrollingNode::setFrameScaleFactor):
(WebCore::ScrollingStateScrollingNode::setNonFastScrollableRegion):
(WebCore::ScrollingStateScrollingNode::setWheelEventHandlerCount):
(WebCore::ScrollingStateScrollingNode::setSynchronousScrollingReasons):
(WebCore::ScrollingStateScrollingNode::setScrollBehaviorForFixedElements):
(WebCore::ScrollingStateScrollingNode::setRequestedScrollPosition):
(WebCore::ScrollingStateScrollingNode::setHeaderHeight):
(WebCore::ScrollingStateScrollingNode::setFooterHeight):
(WebCore::ScrollingStateScrollingNode::setCounterScrollingLayer):
(WebCore::ScrollingStateScrollingNode::setHeaderLayer):
(WebCore::ScrollingStateScrollingNode::setFooterLayer):
* page/scrolling/ScrollingStateStickyNode.cpp:
(WebCore::ScrollingStateStickyNode::updateConstraints):
* page/scrolling/ScrollingStateTree.cpp:
(WebCore::ScrollingStateTree::create):
(WebCore::ScrollingStateTree::ScrollingStateTree):
(WebCore::ScrollingStateTree::setHasChangedProperties):
(WebCore::ScrollingStateTree::didRemoveNode):
* page/scrolling/ScrollingStateTree.h:
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit):
* page/scrolling/mac/ScrollingStateScrollingNodeMac.mm:
(WebCore::ScrollingStateScrollingNode::setScrollbarPaintersFromScrollbars):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161305 => 161306)


--- trunk/Source/WebCore/ChangeLog	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/ChangeLog	2014-01-04 03:55:23 UTC (rev 161306)
@@ -1,5 +1,72 @@
 2014-01-03  Simon Fraser  <[email protected]>
 
+        Clean up the means of committing the scrolling state tree
+        https://bugs.webkit.org/show_bug.cgi?id=126482
+
+        Reviewed by Tim Horton.
+
+        ScrollingStateNodes would manually call scrollingStateTree().setHasChangedProperties()
+        after setPropertyChanged() in lots of places, which was repetitive, and
+        AsyncScrollingCoordinator manually called scheduleTreeStateCommit() in many places.
+        
+        Clean up both of these with a clearer trigger for state tree commits.
+        ScrollingStateNodes::setPropertyChanged() calls ScrollingStateTree::setHasChangedProperties(),
+        which turns around and tells the ScrollingCoordinator that the state tree became dirty.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::AsyncScrollingCoordinator):
+        (WebCore::AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged):
+        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
+        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
+        (WebCore::AsyncScrollingCoordinator::updateScrollingNode):
+        (WebCore::AsyncScrollingCoordinator::updateViewportConstrainedNode):
+        (WebCore::AsyncScrollingCoordinator::setScrollLayerForNode):
+        (WebCore::AsyncScrollingCoordinator::setCounterScrollingLayerForNode):
+        (WebCore::AsyncScrollingCoordinator::setHeaderLayerForNode):
+        (WebCore::AsyncScrollingCoordinator::setFooterLayerForNode):
+        (WebCore::AsyncScrollingCoordinator::setNonFastScrollableRegionForNode):
+        (WebCore::AsyncScrollingCoordinator::setWheelEventHandlerCountForNode):
+        (WebCore::AsyncScrollingCoordinator::setScrollBehaviorForFixedElementsForNode):
+        (WebCore::AsyncScrollingCoordinator::setScrollbarPaintersFromScrollbarsForNode):
+        (WebCore::AsyncScrollingCoordinator::setSynchronousScrollingReasons):
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        * page/scrolling/ScrollingStateFixedNode.cpp:
+        (WebCore::ScrollingStateFixedNode::updateConstraints):
+        * page/scrolling/ScrollingStateNode.cpp:
+        (WebCore::ScrollingStateNode::setPropertyChanged):
+        (WebCore::ScrollingStateNode::setLayer):
+        * page/scrolling/ScrollingStateNode.h:
+        * page/scrolling/ScrollingStateScrollingNode.cpp:
+        (WebCore::ScrollingStateScrollingNode::setViewportRect):
+        (WebCore::ScrollingStateScrollingNode::setTotalContentsSize):
+        (WebCore::ScrollingStateScrollingNode::setScrollOrigin):
+        (WebCore::ScrollingStateScrollingNode::setScrollableAreaParameters):
+        (WebCore::ScrollingStateScrollingNode::setFrameScaleFactor):
+        (WebCore::ScrollingStateScrollingNode::setNonFastScrollableRegion):
+        (WebCore::ScrollingStateScrollingNode::setWheelEventHandlerCount):
+        (WebCore::ScrollingStateScrollingNode::setSynchronousScrollingReasons):
+        (WebCore::ScrollingStateScrollingNode::setScrollBehaviorForFixedElements):
+        (WebCore::ScrollingStateScrollingNode::setRequestedScrollPosition):
+        (WebCore::ScrollingStateScrollingNode::setHeaderHeight):
+        (WebCore::ScrollingStateScrollingNode::setFooterHeight):
+        (WebCore::ScrollingStateScrollingNode::setCounterScrollingLayer):
+        (WebCore::ScrollingStateScrollingNode::setHeaderLayer):
+        (WebCore::ScrollingStateScrollingNode::setFooterLayer):
+        * page/scrolling/ScrollingStateStickyNode.cpp:
+        (WebCore::ScrollingStateStickyNode::updateConstraints):
+        * page/scrolling/ScrollingStateTree.cpp:
+        (WebCore::ScrollingStateTree::create):
+        (WebCore::ScrollingStateTree::ScrollingStateTree):
+        (WebCore::ScrollingStateTree::setHasChangedProperties):
+        (WebCore::ScrollingStateTree::didRemoveNode):
+        * page/scrolling/ScrollingStateTree.h:
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit):
+        * page/scrolling/mac/ScrollingStateScrollingNodeMac.mm:
+        (WebCore::ScrollingStateScrollingNode::setScrollbarPaintersFromScrollbars):
+
+2014-01-03  Simon Fraser  <[email protected]>
+
         Try to fix CoordinatedGraphics build after r161303. Remove implementations
         which are now in the cross-platform file.
 

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2014-01-04 03:55:23 UTC (rev 161306)
@@ -43,7 +43,7 @@
 
 AsyncScrollingCoordinator::AsyncScrollingCoordinator(Page* page)
     : ScrollingCoordinator(page)
-    , m_scrollingStateTree(ScrollingStateTree::create())
+    , m_scrollingStateTree(ScrollingStateTree::create(this))
 {
 }
 
@@ -51,6 +51,11 @@
 {
 }
 
+void AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged()
+{
+    scheduleTreeStateCommit();
+}
+
 void AsyncScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
 {
     ASSERT(isMainThread());
@@ -97,7 +102,6 @@
     scrollParameters.verticalScrollbarMode = frameView->verticalScrollbarMode();
 
     node->setScrollableAreaParameters(scrollParameters);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
@@ -143,7 +147,6 @@
         return false;
 
     stateNode->setRequestedScrollPosition(scrollPosition, frameView->inProgrammaticScroll());
-    scheduleTreeStateCommit();
     return true;
 }
 
@@ -208,7 +211,6 @@
 
     node->setLayer(scrollLayer);
     node->setCounterScrollingLayer(counterScrollingLayer);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::updateViewportConstrainedNode(ScrollingNodeID nodeID, const ViewportConstraints& constraints, GraphicsLayer* graphicsLayer)
@@ -233,63 +235,51 @@
         break;
     }
     }
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setScrollLayerForNode(GraphicsLayer* scrollLayer, ScrollingStateNode* node)
 {
     node->setLayer(scrollLayer);
-    // FIXME: only schedule a commit if something changed.
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setCounterScrollingLayerForNode(GraphicsLayer* layer, ScrollingStateScrollingNode* node)
 {
     node->setCounterScrollingLayer(layer);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setHeaderLayerForNode(GraphicsLayer* headerLayer, ScrollingStateScrollingNode* node)
 {
     // Headers and footers are only supported on the root node.
     ASSERT(node == m_scrollingStateTree->rootStateNode());
-
     node->setHeaderLayer(headerLayer);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setFooterLayerForNode(GraphicsLayer* footerLayer, ScrollingStateScrollingNode* node)
 {
     // Headers and footers are only supported on the root node.
     ASSERT(node == m_scrollingStateTree->rootStateNode());
-
     node->setFooterLayer(footerLayer);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setNonFastScrollableRegionForNode(const Region& region, ScrollingStateScrollingNode* node)
 {
     node->setNonFastScrollableRegion(region);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setWheelEventHandlerCountForNode(unsigned wheelEventHandlerCount, ScrollingStateScrollingNode* node)
 {
     node->setWheelEventHandlerCount(wheelEventHandlerCount);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setScrollBehaviorForFixedElementsForNode(ScrollBehaviorForFixedElements behaviorForFixed, ScrollingStateScrollingNode* node)
 {
     node->setScrollBehaviorForFixedElements(behaviorForFixed);
-    scheduleTreeStateCommit();
 }
 
 // FIXME: not sure if this belongs here.
 void AsyncScrollingCoordinator::setScrollbarPaintersFromScrollbarsForNode(Scrollbar* verticalScrollbar, Scrollbar* horizontalScrollbar, ScrollingStateScrollingNode* node)
 {
     node->setScrollbarPaintersFromScrollbars(verticalScrollbar, horizontalScrollbar);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::setSynchronousScrollingReasons(SynchronousScrollingReasons reasons)
@@ -303,7 +293,6 @@
     if (reasons)
         updateMainFrameScrollLayerPosition();
     m_scrollingStateTree->rootStateNode()->setSynchronousScrollingReasons(reasons);
-    scheduleTreeStateCommit();
 }
 
 void AsyncScrollingCoordinator::updateMainFrameScrollLayerPosition()

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2014-01-04 03:55:23 UTC (rev 161306)
@@ -54,6 +54,8 @@
 
     virtual PassOwnPtr<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) = 0;
 
+    void scrollingStateTreePropertiesChanged();
+
 protected:
     AsyncScrollingCoordinator(Page*);
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp	2014-01-04 03:55:23 UTC (rev 161306)
@@ -67,7 +67,6 @@
 
     m_constraints = constraints;
     setPropertyChanged(ViewportConstraints);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateFixedNode::syncLayerPositionForViewportRect(const LayoutRect& viewportRect)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp	2014-01-04 03:55:23 UTC (rev 161306)
@@ -64,6 +64,15 @@
 {
 }
 
+void ScrollingStateNode::setPropertyChanged(unsigned propertyBit)
+{
+    if (m_changedProperties & (1 << propertyBit))
+        return;
+
+    m_changedProperties |= (1 << propertyBit);
+    m_scrollingStateTree.setHasChangedProperties();
+}
+
 PassOwnPtr<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree)
 {
     OwnPtr<ScrollingStateNode> clone = this->clone(adoptiveTree);
@@ -135,7 +144,6 @@
     m_layer = layerRepresentation;
 
     setPropertyChanged(ScrollLayer);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateNode::dump(TextStream& ts, int indent) const

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2014-01-04 03:55:23 UTC (rev 161306)
@@ -160,7 +160,7 @@
     bool hasChangedProperties() const { return m_changedProperties; }
     bool hasChangedProperty(unsigned propertyBit) const { return m_changedProperties & (1 << propertyBit); }
     void resetChangedProperties() { m_changedProperties = 0; }
-    void setPropertyChanged(unsigned propertyBit) { m_changedProperties |= (1 << propertyBit); }
+    void setPropertyChanged(unsigned propertyBit);
 
     virtual void syncLayerPositionForViewportRect(const LayoutRect& /*viewportRect*/) { }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp	2014-01-04 03:55:23 UTC (rev 161306)
@@ -98,7 +98,6 @@
 
     m_viewportRect = viewportRect;
     setPropertyChanged(ViewportRect);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setTotalContentsSize(const IntSize& totalContentsSize)
@@ -108,7 +107,6 @@
 
     m_totalContentsSize = totalContentsSize;
     setPropertyChanged(TotalContentsSize);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setScrollOrigin(const IntPoint& scrollOrigin)
@@ -118,7 +116,6 @@
 
     m_scrollOrigin = scrollOrigin;
     setPropertyChanged(ScrollOrigin);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setScrollableAreaParameters(const ScrollableAreaParameters& parameters)
@@ -128,7 +125,6 @@
 
     m_scrollableAreaParameters = parameters;
     setPropertyChanged(ScrollableAreaParams);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setFrameScaleFactor(float scaleFactor)
@@ -139,7 +135,6 @@
     m_frameScaleFactor = scaleFactor;
 
     setPropertyChanged(FrameScaleFactor);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setNonFastScrollableRegion(const Region& nonFastScrollableRegion)
@@ -149,7 +144,6 @@
 
     m_nonFastScrollableRegion = nonFastScrollableRegion;
     setPropertyChanged(NonFastScrollableRegion);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setWheelEventHandlerCount(unsigned wheelEventHandlerCount)
@@ -159,7 +153,6 @@
 
     m_wheelEventHandlerCount = wheelEventHandlerCount;
     setPropertyChanged(WheelEventHandlerCount);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setSynchronousScrollingReasons(SynchronousScrollingReasons reasons)
@@ -169,7 +162,6 @@
 
     m_synchronousScrollingReasons = reasons;
     setPropertyChanged(ReasonsForSynchronousScrolling);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements behaviorForFixed)
@@ -179,7 +171,6 @@
 
     m_behaviorForFixed = behaviorForFixed;
     setPropertyChanged(BehaviorForFixedElements);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setRequestedScrollPosition(const IntPoint& requestedScrollPosition, bool representsProgrammaticScroll)
@@ -187,7 +178,6 @@
     m_requestedScrollPosition = requestedScrollPosition;
     m_requestedScrollPositionRepresentsProgrammaticScroll = representsProgrammaticScroll;
     setPropertyChanged(RequestedScrollPosition);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setHeaderHeight(int headerHeight)
@@ -197,7 +187,6 @@
 
     m_headerHeight = headerHeight;
     setPropertyChanged(HeaderHeight);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setFooterHeight(int footerHeight)
@@ -207,7 +196,6 @@
 
     m_footerHeight = footerHeight;
     setPropertyChanged(FooterHeight);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setCounterScrollingLayer(const LayerRepresentation& layerRepresentation)
@@ -218,7 +206,6 @@
     m_counterScrollingLayer = layerRepresentation;
 
     setPropertyChanged(CounterScrollingLayer);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::setHeaderLayer(const LayerRepresentation& layerRepresentation)
@@ -229,7 +216,6 @@
     m_headerLayer = layerRepresentation;
 
     setPropertyChanged(HeaderLayer);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 
@@ -241,7 +227,6 @@
     m_footerLayer = layerRepresentation;
 
     setPropertyChanged(FooterLayer);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateScrollingNode::dumpProperties(TextStream& ts, int indent) const

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp	2014-01-04 03:55:23 UTC (rev 161306)
@@ -67,7 +67,6 @@
 
     m_constraints = constraints;
     setPropertyChanged(ViewportConstraints);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 void ScrollingStateStickyNode::syncLayerPositionForViewportRect(const LayoutRect& viewportRect)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp	2014-01-04 03:55:23 UTC (rev 161306)
@@ -28,19 +28,21 @@
 
 #if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
 
+#include "AsyncScrollingCoordinator.h"
 #include "ScrollingStateFixedNode.h"
 #include "ScrollingStateScrollingNode.h"
 #include "ScrollingStateStickyNode.h"
 
 namespace WebCore {
 
-PassOwnPtr<ScrollingStateTree> ScrollingStateTree::create()
+PassOwnPtr<ScrollingStateTree> ScrollingStateTree::create(AsyncScrollingCoordinator* scrollingCoordinator)
 {
-    return adoptPtr(new ScrollingStateTree);
+    return adoptPtr(new ScrollingStateTree(scrollingCoordinator));
 }
 
-ScrollingStateTree::ScrollingStateTree()
-    : m_hasChangedProperties(false)
+ScrollingStateTree::ScrollingStateTree(AsyncScrollingCoordinator* scrollingCoordinator)
+    : m_scrollingCoordinator(scrollingCoordinator)
+    , m_hasChangedProperties(false)
     , m_hasNewRootStateNode(false)
 {
 }
@@ -49,6 +51,16 @@
 {
 }
 
+void ScrollingStateTree::setHasChangedProperties(bool changedProperties)
+{
+    bool gainedChangedProperties = !m_hasChangedProperties && changedProperties;
+
+    m_hasChangedProperties = changedProperties;
+
+    if (gainedChangedProperties && m_scrollingCoordinator)
+        m_scrollingCoordinator->scrollingStateTreePropertiesChanged();
+}
+
 ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
 {
     ASSERT(newNodeID);
@@ -173,7 +185,7 @@
 void ScrollingStateTree::didRemoveNode(ScrollingNodeID nodeID)
 {
     m_nodesRemovedSinceLastCommit.append(nodeID);
-    m_hasChangedProperties = true;
+    setHasChangedProperties();
 }
 
 ScrollingStateNode* ScrollingStateTree::stateNodeForID(ScrollingNodeID scrollLayerID)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h	2014-01-04 03:55:23 UTC (rev 161306)
@@ -34,7 +34,9 @@
 #include <wtf/RefPtr.h>
  
 namespace WebCore {
- 
+
+class AsyncScrollingCoordinator;
+
 // The ScrollingStateTree is a tree that managed ScrollingStateNodes. The nodes keep track of the current
 // state of scrolling related properties. Whenever any properties change, the scrolling coordinator
 // will be informed and will schedule a timer that will clone the new state tree and send it over to
@@ -44,7 +46,7 @@
     friend class ScrollingStateNode;
 public:
     
-    static PassOwnPtr<ScrollingStateTree> create();
+    static PassOwnPtr<ScrollingStateTree> create(AsyncScrollingCoordinator* = 0);
     ~ScrollingStateTree();
 
     ScrollingStateScrollingNode* rootStateNode() const { return m_rootStateNode.get(); }
@@ -59,19 +61,20 @@
     // Copies the current tree state and clears the changed properties mask in the original.
     PassOwnPtr<ScrollingStateTree> commit();
 
-    void setHasChangedProperties(bool changedProperties) { m_hasChangedProperties = changedProperties; }
+    void setHasChangedProperties(bool = true);
     bool hasChangedProperties() const { return m_hasChangedProperties; }
 
     bool hasNewRootStateNode() const { return m_hasNewRootStateNode; }
 
 private:
-    ScrollingStateTree();
+    ScrollingStateTree(AsyncScrollingCoordinator*);
 
     void setRootStateNode(PassOwnPtr<ScrollingStateScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; }
     void addNode(ScrollingStateNode*);
     void removeNode(ScrollingStateNode*);
     void didRemoveNode(ScrollingNodeID);
 
+    AsyncScrollingCoordinator* m_scrollingCoordinator;
     HashMap<ScrollingNodeID, ScrollingStateNode*> m_stateNodeMap;
     OwnPtr<ScrollingStateScrollingNode> m_rootStateNode;
     Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit;

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2014-01-04 03:55:23 UTC (rev 161306)
@@ -93,12 +93,11 @@
 
 void ScrollingCoordinatorMac::scheduleTreeStateCommit()
 {
+    ASSERT(scrollingStateTree()->hasChangedProperties());
+
     if (m_scrollingStateTreeCommitterTimer.isActive())
         return;
 
-    if (!scrollingStateTree()->hasChangedProperties())
-        return;
-
     m_scrollingStateTreeCommitterTimer.startOneShot(0);
 }
 

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingStateScrollingNodeMac.mm (161305 => 161306)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingStateScrollingNodeMac.mm	2014-01-04 03:41:25 UTC (rev 161305)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingStateScrollingNodeMac.mm	2014-01-04 03:55:23 UTC (rev 161306)
@@ -53,7 +53,6 @@
     m_horizontalScrollbarPainter = horizontalPainter;
 
     setPropertyChanged(PainterForScrollbar);
-    scrollingStateTree().setHasChangedProperties(true);
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to