diff options
Diffstat (limited to 'Source/WebCore/page/scrolling/ScrollingStateNode.cpp')
-rw-r--r-- | Source/WebCore/page/scrolling/ScrollingStateNode.cpp | 72 |
1 files changed, 19 insertions, 53 deletions
diff --git a/Source/WebCore/page/scrolling/ScrollingStateNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateNode.cpp index 0b60c5acb..61da58a9d 100644 --- a/Source/WebCore/page/scrolling/ScrollingStateNode.cpp +++ b/Source/WebCore/page/scrolling/ScrollingStateNode.cpp @@ -41,7 +41,7 @@ ScrollingStateNode::ScrollingStateNode(ScrollingNodeType nodeType, ScrollingStat , m_nodeID(nodeID) , m_changedProperties(0) , m_scrollingStateTree(scrollingStateTree) - , m_parent(0) + , m_parent(nullptr) { } @@ -52,7 +52,7 @@ ScrollingStateNode::ScrollingStateNode(const ScrollingStateNode& stateNode, Scro , m_nodeID(stateNode.scrollingNodeID()) , m_changedProperties(stateNode.changedProperties()) , m_scrollingStateTree(adoptiveTree) - , m_parent(0) + , m_parent(nullptr) { if (hasChangedProperty(ScrollLayer)) setLayer(stateNode.layer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); @@ -72,15 +72,16 @@ void ScrollingStateNode::setPropertyChanged(unsigned propertyBit) m_scrollingStateTree.setHasChangedProperties(); } -PassOwnPtr<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree) +Ref<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree) { - OwnPtr<ScrollingStateNode> clone = this->clone(adoptiveTree); + auto clone = this->clone(adoptiveTree); // Now that this node is cloned, reset our change properties. resetChangedProperties(); - cloneAndResetChildren(*clone, adoptiveTree); - return clone.release(); + cloneAndResetChildren(clone.get(), adoptiveTree); + + return clone; } void ScrollingStateNode::cloneAndResetChildren(ScrollingStateNode& clone, ScrollingStateTree& adoptiveTree) @@ -88,51 +89,17 @@ void ScrollingStateNode::cloneAndResetChildren(ScrollingStateNode& clone, Scroll if (!m_children) return; - size_t size = m_children->size(); - for (size_t i = 0; i < size; ++i) - clone.appendChild(m_children->at(i)->cloneAndReset(adoptiveTree)); + for (auto& child : *m_children) + clone.appendChild(child->cloneAndReset(adoptiveTree)); } -void ScrollingStateNode::appendChild(PassOwnPtr<ScrollingStateNode> childNode) +void ScrollingStateNode::appendChild(Ref<ScrollingStateNode>&& childNode) { childNode->setParent(this); if (!m_children) - m_children = adoptPtr(new Vector<OwnPtr<ScrollingStateNode>>); - - m_children->append(childNode); -} - -void ScrollingStateNode::removeChild(ScrollingStateNode* node) -{ - if (!m_children) - return; - - size_t index = m_children->find(node); - - // 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) { - node->willBeRemovedFromStateTree(); - m_children->remove(index); - return; - } - - size_t size = m_children->size(); - for (size_t i = 0; i < size; ++i) - m_children->at(i)->removeChild(node); -} - -void ScrollingStateNode::willBeRemovedFromStateTree() -{ - scrollingStateTree().didRemoveNode(scrollingNodeID()); - - if (!m_children) - return; - - size_t size = m_children->size(); - for (size_t i = 0; i < size; ++i) - m_children->at(i)->willBeRemovedFromStateTree(); + m_children = std::make_unique<Vector<RefPtr<ScrollingStateNode>>>(); + m_children->append(WTFMove(childNode)); } void ScrollingStateNode::setLayer(const LayerRepresentation& layerRepresentation) @@ -145,18 +112,17 @@ void ScrollingStateNode::setLayer(const LayerRepresentation& layerRepresentation setPropertyChanged(ScrollLayer); } -void ScrollingStateNode::dump(TextStream& ts, int indent) const +void ScrollingStateNode::dump(TextStream& ts, int indent, ScrollingStateTreeAsTextBehavior behavior) const { writeIndent(ts, indent); - dumpProperties(ts, indent); + dumpProperties(ts, indent, behavior); if (m_children) { writeIndent(ts, indent + 1); - size_t size = children()->size(); - ts << "(children " << size << "\n"; + ts << "(children " << children()->size() << "\n"; - for (size_t i = 0; i < size; i++) - m_children->at(i)->dump(ts, indent + 2); + for (auto& child : *m_children) + child->dump(ts, indent + 2, behavior); writeIndent(ts, indent + 1); ts << ")\n"; } @@ -167,9 +133,9 @@ void ScrollingStateNode::dump(TextStream& ts, int indent) const String ScrollingStateNode::scrollingStateTreeAsText() const { - TextStream ts; + TextStream ts(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect); - dump(ts, 0); + dump(ts, 0, ScrollingStateTreeAsTextBehaviorNormal); return ts.release(); } |