Title: [252742] trunk/Source/WebCore
- Revision
- 252742
- Author
- [email protected]
- Date
- 2019-11-21 11:31:40 -0800 (Thu, 21 Nov 2019)
Log Message
Tighten ScrollingTreeNode tree mutations
https://bugs.webkit.org/show_bug.cgi?id=204451
Reviewed by Simon Fraser.
- Use plain Vector instead of std::unique_ptr<Vector> for children
- Use Vector<Ref> instead of Vector<RefPtr>
- Remove non-const ScrollingTreeNode::children() accessor
- Add relase assert that all mutations happen during ScrollingTree::commitTreeState
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::commitTreeState):
(WebCore::ScrollingTree::updateTreeFromStateNode):
(WebCore::ScrollingTree::applyLayerPositionsRecursive):
(WebCore::ScrollingTree::notifyRelatedNodesRecursive):
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::inCommitTreeState const):
* page/scrolling/ScrollingTreeNode.cpp:
(WebCore::ScrollingTreeNode::appendChild):
(WebCore::ScrollingTreeNode::removeChild):
(WebCore::ScrollingTreeNode::removeAllChildren):
Encapsulate mutations to these functions.
(WebCore::ScrollingTreeNode::dump const):
(WebCore::ScrollingTreeNode::scrollingNodeForPoint const):
* page/scrolling/ScrollingTreeNode.h:
(WebCore::ScrollingTreeNode::children const):
(WebCore::ScrollingTreeNode::children): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (252741 => 252742)
--- trunk/Source/WebCore/ChangeLog 2019-11-21 18:53:59 UTC (rev 252741)
+++ trunk/Source/WebCore/ChangeLog 2019-11-21 19:31:40 UTC (rev 252742)
@@ -1,3 +1,35 @@
+2019-11-21 Antti Koivisto <[email protected]>
+
+ Tighten ScrollingTreeNode tree mutations
+ https://bugs.webkit.org/show_bug.cgi?id=204451
+
+ Reviewed by Simon Fraser.
+
+ - Use plain Vector instead of std::unique_ptr<Vector> for children
+ - Use Vector<Ref> instead of Vector<RefPtr>
+ - Remove non-const ScrollingTreeNode::children() accessor
+ - Add relase assert that all mutations happen during ScrollingTree::commitTreeState
+
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::commitTreeState):
+ (WebCore::ScrollingTree::updateTreeFromStateNode):
+ (WebCore::ScrollingTree::applyLayerPositionsRecursive):
+ (WebCore::ScrollingTree::notifyRelatedNodesRecursive):
+ * page/scrolling/ScrollingTree.h:
+ (WebCore::ScrollingTree::inCommitTreeState const):
+ * page/scrolling/ScrollingTreeNode.cpp:
+ (WebCore::ScrollingTreeNode::appendChild):
+ (WebCore::ScrollingTreeNode::removeChild):
+ (WebCore::ScrollingTreeNode::removeAllChildren):
+
+ Encapsulate mutations to these functions.
+
+ (WebCore::ScrollingTreeNode::dump const):
+ (WebCore::ScrollingTreeNode::scrollingNodeForPoint const):
+ * page/scrolling/ScrollingTreeNode.h:
+ (WebCore::ScrollingTreeNode::children const):
+ (WebCore::ScrollingTreeNode::children): Deleted.
+
2019-11-21 Kenneth Russell <[email protected]>
Implement accelerated video-to-texture upload path for ANGLE backend for WebGL on desktop
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (252741 => 252742)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2019-11-21 18:53:59 UTC (rev 252741)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2019-11-21 19:31:40 UTC (rev 252742)
@@ -140,6 +140,7 @@
void ScrollingTree::commitTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree)
{
+ SetForScope inCommitTreeState(m_inCommitTreeState, true);
LockHolder locker(m_treeMutex);
bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode();
@@ -244,13 +245,11 @@
node->commitStateBeforeChildren(*stateNode);
// Move all children into the orphanNodes map. Live ones will get added back as we recurse over children.
- if (auto nodeChildren = node->children()) {
- for (auto& childScrollingNode : *nodeChildren) {
- childScrollingNode->setParent(nullptr);
- orphanNodes.add(childScrollingNode->scrollingNodeID(), childScrollingNode.get());
- }
- nodeChildren->clear();
+ for (auto& childScrollingNode : node->children()) {
+ childScrollingNode->setParent(nullptr);
+ orphanNodes.add(childScrollingNode->scrollingNodeID(), childScrollingNode.ptr());
}
+ node->removeAllChildren();
// Now update the children if we have any.
if (auto children = stateNode->children()) {
@@ -286,14 +285,12 @@
LOG(Scrolling, "ScrollingTree %p applyLayerPositions - done\n", this);
}
-void ScrollingTree::applyLayerPositionsRecursive(ScrollingTreeNode& currNode)
+void ScrollingTree::applyLayerPositionsRecursive(ScrollingTreeNode& node)
{
- currNode.applyLayerPositions();
+ node.applyLayerPositions();
- if (auto children = currNode.children()) {
- for (auto& child : *children)
- applyLayerPositionsRecursive(*child);
- }
+ for (auto& child : node.children())
+ applyLayerPositionsRecursive(child.get());
}
ScrollingTreeNode* ScrollingTree::nodeForID(ScrollingNodeID nodeID) const
@@ -324,15 +321,12 @@
{
node.applyLayerPositions();
- if (!node.children())
- return;
-
- for (auto& child : *node.children()) {
+ for (auto& child : node.children()) {
// Never need to cross frame boundaries, since scroll layer adjustments are isolated to each document.
if (is<ScrollingTreeFrameScrollingNode>(child))
continue;
- notifyRelatedNodesRecursive(*child);
+ notifyRelatedNodesRecursive(child.get());
}
}
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (252741 => 252742)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2019-11-21 18:53:59 UTC (rev 252741)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2019-11-21 19:31:40 UTC (rev 252742)
@@ -159,6 +159,7 @@
WEBCORE_EXPORT String scrollingTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal);
bool isMonitoringWheelEvents() const { return m_isMonitoringWheelEvents; }
+ bool inCommitTreeState() const { return m_inCommitTreeState; }
protected:
void setMainFrameScrollPosition(FloatPoint);
@@ -217,6 +218,7 @@
bool m_scrollingPerformanceLoggingEnabled { false };
bool m_asyncFrameOrOverflowScrollingEnabled { false };
bool m_wasScrolledByDelegatedScrollingSincePreviousCommit { false };
+ bool m_inCommitTreeState { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp (252741 => 252742)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp 2019-11-21 18:53:59 UTC (rev 252741)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp 2019-11-21 19:31:40 UTC (rev 252742)
@@ -47,31 +47,39 @@
void ScrollingTreeNode::appendChild(Ref<ScrollingTreeNode>&& childNode)
{
+ RELEASE_ASSERT(m_scrollingTree.inCommitTreeState());
+
childNode->setParent(this);
- if (!m_children)
- m_children = makeUnique<Vector<RefPtr<ScrollingTreeNode>>>();
- m_children->append(WTFMove(childNode));
+ m_children.append(WTFMove(childNode));
}
void ScrollingTreeNode::removeChild(ScrollingTreeNode& node)
{
- if (!m_children)
- return;
+ RELEASE_ASSERT(m_scrollingTree.inCommitTreeState());
- size_t index = m_children->find(&node);
+ size_t index = m_children.findMatching([&](auto& child) {
+ return &node == child.ptr();
+ });
// The index will be notFound if the node to remove is a deeper-than-1-level descendant or
// if node is the root state node.
if (index != notFound) {
- m_children->remove(index);
+ m_children.remove(index);
return;
}
- for (auto& child : *m_children)
+ for (auto& child : m_children)
child->removeChild(node);
}
+void ScrollingTreeNode::removeAllChildren()
+{
+ RELEASE_ASSERT(m_scrollingTree.inCommitTreeState());
+
+ m_children.clear();
+}
+
bool ScrollingTreeNode::isRootNode() const
{
return m_scrollingTree.rootNode() == this;
@@ -105,11 +113,9 @@
{
dumpProperties(ts, behavior);
- if (m_children) {
- for (auto& child : *m_children) {
- TextStream::GroupScope scope(ts);
- child->dump(ts, behavior);
- }
+ for (auto& child : m_children) {
+ TextStream::GroupScope scope(ts);
+ child->dump(ts, behavior);
}
}
@@ -118,11 +124,9 @@
LayoutPoint localPoint = parentToLocalPoint(parentPoint);
LayoutPoint contentsPoint = localToContentsPoint(localPoint);
- if (children()) {
- for (auto iterator = children()->rbegin(), end = children()->rend(); iterator != end; iterator++) {
- if (auto node = (**iterator).scrollingNodeForPoint(contentsPoint))
- return node;
- }
+ for (auto& child : WTF::makeReversedRange(m_children)) {
+ if (auto* node = child->scrollingNodeForPoint(contentsPoint))
+ return node;
}
return nullptr;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h (252741 => 252742)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h 2019-11-21 18:53:59 UTC (rev 252741)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h 2019-11-21 19:31:40 UTC (rev 252742)
@@ -66,11 +66,11 @@
WEBCORE_EXPORT bool isRootNode() const;
- Vector<RefPtr<ScrollingTreeNode>>* children() { return m_children.get(); }
- const Vector<RefPtr<ScrollingTreeNode>>* children() const { return m_children.get(); }
+ const Vector<Ref<ScrollingTreeNode>>& children() const { return m_children; }
void appendChild(Ref<ScrollingTreeNode>&&);
void removeChild(ScrollingTreeNode&);
+ void removeAllChildren();
WEBCORE_EXPORT ScrollingTreeFrameScrollingNode* enclosingFrameNodeIncludingSelf();
WEBCORE_EXPORT ScrollingTreeScrollingNode* enclosingScrollingNodeIncludingSelf();
@@ -89,7 +89,7 @@
WEBCORE_EXPORT virtual void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const;
- std::unique_ptr<Vector<RefPtr<ScrollingTreeNode>>> m_children;
+ Vector<Ref<ScrollingTreeNode>> m_children;
private:
ScrollingTree& m_scrollingTree;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes