Diff
Modified: trunk/Source/WebCore/ChangeLog (238897 => 238898)
--- trunk/Source/WebCore/ChangeLog 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/ChangeLog 2018-12-05 18:20:56 UTC (rev 238898)
@@ -1,3 +1,42 @@
+2018-12-05 Frederic Wang <[email protected]>
+
+ Minor refactoring of the scrolling code
+ https://bugs.webkit.org/show_bug.cgi?id=192398
+
+ Reviewed by Simon Fraser.
+
+ Based on an earlier patch by Simon Fraser.
+
+ This patch performs some minor refactoring of the scrolling code:
+ - Rename ScrollingCoordinator::uniqueScrollLayerID() to uniqueScrollingNodeID() since it
+ is really a node id.
+ - Inline ScrollingStateTree::setRootStateNode() so we only need to forward declare
+ ScrollingStateFrameScrollingNode in headers.
+ - Pass argument to ScrollingStateTree::addNode() as a reference rather than a pointer.
+ - Initialize ScrollingStateTree::m_changedProperties and ScrollingStateTree::m_parent in
+ the header file.
+ - Remove obsolete comment about ScrollingCoordinatorMac.
+
+ No new tests, behavior unchanged.
+
+ * page/scrolling/ScrollingCoordinator.cpp:
+ (WebCore::ScrollingCoordinator::uniqueScrollingNodeID):
+ (WebCore::ScrollingCoordinator::uniqueScrollLayerID): Deleted.
+ * page/scrolling/ScrollingCoordinator.h:
+ * page/scrolling/ScrollingStateNode.cpp:
+ (WebCore::ScrollingStateNode::ScrollingStateNode):
+ * page/scrolling/ScrollingStateNode.h:
+ * page/scrolling/ScrollingStateTree.cpp:
+ (WebCore::ScrollingStateTree::attachNode):
+ (WebCore::ScrollingStateTree::setRootStateNode):
+ (WebCore::ScrollingStateTree::addNode):
+ * page/scrolling/ScrollingStateTree.h:
+ (WebCore::ScrollingStateTree::setRootStateNode): Deleted.
+ * page/scrolling/ScrollingTree.cpp:
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::attachScrollingNode):
+
2018-12-05 Wenson Hsieh <[email protected]>
Turn WritingDirection into an enum class
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2018-12-05 18:20:56 UTC (rev 238898)
@@ -361,10 +361,10 @@
return true;
}
-ScrollingNodeID ScrollingCoordinator::uniqueScrollLayerID()
+ScrollingNodeID ScrollingCoordinator::uniqueScrollingNodeID()
{
- static ScrollingNodeID uniqueScrollLayerID = 1;
- return uniqueScrollLayerID++;
+ static ScrollingNodeID uniqueScrollingNodeID = 1;
+ return uniqueScrollingNodeID++;
}
String ScrollingCoordinator::scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior) const
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h 2018-12-05 18:20:56 UTC (rev 238898)
@@ -161,7 +161,6 @@
WEBCORE_EXPORT void setForceSynchronousScrollLayerPositionUpdates(bool);
// These virtual functions are currently unique to the threaded scrolling architecture.
- // Their meaningful implementations are in ScrollingCoordinatorMac.
virtual void commitTreeStateIfNeeded() { }
virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; }
virtual bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return true; }
@@ -198,8 +197,8 @@
virtual void updateScrollSnapPropertiesWithFrameView(const FrameView&) { }
virtual void setScrollPinningBehavior(ScrollPinningBehavior) { }
- // Generated a unique id for scroll layers.
- ScrollingNodeID uniqueScrollLayerID();
+ // Generated a unique id for scrolling nodes.
+ ScrollingNodeID uniqueScrollingNodeID();
enum MainThreadScrollingReasonFlags {
ForcedOnMainThread = 1 << 0,
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp 2018-12-05 18:20:56 UTC (rev 238898)
@@ -39,9 +39,7 @@
ScrollingStateNode::ScrollingStateNode(ScrollingNodeType nodeType, ScrollingStateTree& scrollingStateTree, ScrollingNodeID nodeID)
: m_nodeType(nodeType)
, m_nodeID(nodeID)
- , m_changedProperties(0)
, m_scrollingStateTree(scrollingStateTree)
- , m_parent(nullptr)
{
}
@@ -52,11 +50,10 @@
, m_nodeID(stateNode.scrollingNodeID())
, m_changedProperties(stateNode.changedProperties())
, m_scrollingStateTree(adoptiveTree)
- , m_parent(nullptr)
{
if (hasChangedProperty(ScrollLayer))
setLayer(stateNode.layer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
- scrollingStateTree().addNode(this);
+ scrollingStateTree().addNode(*this);
}
ScrollingStateNode::~ScrollingStateNode() = default;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h 2018-12-05 18:20:56 UTC (rev 238898)
@@ -248,12 +248,12 @@
void dump(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const;
const ScrollingNodeType m_nodeType;
- ScrollingNodeID m_nodeID;
- ChangedProperties m_changedProperties;
+ const ScrollingNodeID m_nodeID;
+ ChangedProperties m_changedProperties { 0 };
ScrollingStateTree& m_scrollingStateTree;
- ScrollingStateNode* m_parent;
+ ScrollingStateNode* m_parent { nullptr };
std::unique_ptr<Vector<RefPtr<ScrollingStateNode>>> m_children;
LayerRepresentation m_layer;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp 2018-12-05 18:20:56 UTC (rev 238898)
@@ -105,7 +105,7 @@
#if ENABLE(ASYNC_SCROLLING)
// If the type has changed, we need to destroy and recreate the node with a new ID.
if (nodeType != node->nodeType())
- newNodeID = m_scrollingCoordinator->uniqueScrollLayerID();
+ newNodeID = m_scrollingCoordinator->uniqueScrollingNodeID();
#endif
// The node is being re-parented. To do that, we'll remove it, and then create a new node.
@@ -196,11 +196,16 @@
return treeStateClone;
}
-void ScrollingStateTree::addNode(ScrollingStateNode* node)
+void ScrollingStateTree::setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&& rootStateNode)
{
- m_stateNodeMap.add(node->scrollingNodeID(), node);
+ m_rootStateNode = WTFMove(rootStateNode);
}
+void ScrollingStateTree::addNode(ScrollingStateNode& node)
+{
+ m_stateNodeMap.add(node.scrollingNodeID(), &node);
+}
+
void ScrollingStateTree::removeNodeAndAllDescendants(ScrollingStateNode* node, SubframeNodeRemoval subframeNodeRemoval)
{
auto* parent = node->parent();
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h 2018-12-05 18:20:56 UTC (rev 238898)
@@ -27,12 +27,14 @@
#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-#include "ScrollingStateFrameScrollingNode.h"
+#include "ScrollingCoordinator.h"
+#include "ScrollingStateNode.h"
#include <wtf/RefPtr.h>
namespace WebCore {
class AsyncScrollingCoordinator;
+class ScrollingStateFrameScrollingNode;
// 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
@@ -74,8 +76,8 @@
void setPreferredLayerRepresentation(LayerRepresentation::Type representation) { m_preferredLayerRepresentation = representation; }
private:
- void setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&& rootStateNode) { m_rootStateNode = WTFMove(rootStateNode); }
- void addNode(ScrollingStateNode*);
+ void setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&&);
+ void addNode(ScrollingStateNode&);
Ref<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2018-12-05 18:20:56 UTC (rev 238898)
@@ -31,6 +31,7 @@
#include "EventNames.h"
#include "Logging.h"
#include "PlatformWheelEvent.h"
+#include "ScrollingStateFrameScrollingNode.h"
#include "ScrollingStateTree.h"
#include "ScrollingTreeFrameScrollingNode.h"
#include "ScrollingTreeNode.h"
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (238897 => 238898)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h 2018-12-05 18:20:56 UTC (rev 238898)
@@ -29,6 +29,7 @@
#include "ScrollController.h"
#include "ScrollbarThemeMac.h"
+#include "ScrollingStateFrameScrollingNode.h"
#include "ScrollingTreeFrameScrollingNode.h"
#include <wtf/RetainPtr.h>
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (238897 => 238898)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-12-05 18:14:26 UTC (rev 238897)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-12-05 18:20:56 UTC (rev 238898)
@@ -3835,7 +3835,7 @@
LayerScrollCoordinationRole role = scrollCoordinationRoleForNodeType(nodeType);
ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(role);
if (!nodeID)
- nodeID = scrollingCoordinator->uniqueScrollLayerID();
+ nodeID = scrollingCoordinator->uniqueScrollingNodeID();
nodeID = scrollingCoordinator->attachToStateTree(nodeType, nodeID, parentNodeID);
if (!nodeID)