Changeset 170118 in webkit
- Timestamp:
- Jun 18, 2014, 2:43:30 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r170113 r170118 1 2014-06-18 Simon Fraser <simon.fraser@apple.com> 2 3 Make ScrollingStateNodes refcounted, and other minor cleanup 4 https://bugs.webkit.org/show_bug.cgi?id=134040 5 6 Reviewed by Beth Dakin. 7 8 Prepare for future scrolling frame gyrations by making 9 ScrollingStateNodes refcounted. 10 11 Rename ScrollingStateNode::removeChild() to removeDescendant() 12 since that's what it does. Also rename didRemoveNode() to willRemoveNode() 13 to better match the behavior. 14 15 Use 'auto' in more places. 16 17 * page/scrolling/AsyncScrollingCoordinator.cpp: 18 (WebCore::AsyncScrollingCoordinator::syncChildPositions): 19 * page/scrolling/ScrollingStateFixedNode.cpp: 20 (WebCore::ScrollingStateFixedNode::create): 21 (WebCore::ScrollingStateFixedNode::clone): 22 * page/scrolling/ScrollingStateFixedNode.h: 23 * page/scrolling/ScrollingStateFrameScrollingNode.cpp: 24 (WebCore::ScrollingStateFrameScrollingNode::create): 25 (WebCore::ScrollingStateFrameScrollingNode::clone): 26 * page/scrolling/ScrollingStateFrameScrollingNode.h: 27 * page/scrolling/ScrollingStateNode.cpp: 28 (WebCore::ScrollingStateNode::cloneAndReset): 29 (WebCore::ScrollingStateNode::appendChild): 30 (WebCore::ScrollingStateNode::removeDescendant): 31 (WebCore::ScrollingStateNode::willBeRemovedFromStateTree): 32 (WebCore::ScrollingStateNode::removeChild): Deleted. 33 * page/scrolling/ScrollingStateNode.h: 34 (WebCore::ScrollingStateNode::children): 35 * page/scrolling/ScrollingStateOverflowScrollingNode.cpp: 36 (WebCore::ScrollingStateOverflowScrollingNode::create): 37 (WebCore::ScrollingStateOverflowScrollingNode::clone): 38 * page/scrolling/ScrollingStateOverflowScrollingNode.h: 39 * page/scrolling/ScrollingStateStickyNode.cpp: 40 (WebCore::ScrollingStateStickyNode::create): 41 (WebCore::ScrollingStateStickyNode::clone): 42 * page/scrolling/ScrollingStateStickyNode.h: 43 * page/scrolling/ScrollingStateTree.cpp: 44 (WebCore::ScrollingStateTree::attachNode): 45 (WebCore::ScrollingStateTree::removeNode): 46 (WebCore::ScrollingStateTree::willRemoveNode): 47 (WebCore::ScrollingStateTree::didRemoveNode): Deleted. 48 * page/scrolling/ScrollingStateTree.h: 49 (WebCore::ScrollingStateTree::setRootStateNode): 50 * page/scrolling/ScrollingTree.cpp: 51 (WebCore::ScrollingTree::updateTreeFromStateNode): 52 1 53 2014-06-18 Anders Carlsson <andersca@apple.com> 2 54 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r169913 r170118 345 345 return; 346 346 347 Vector<OwnPtr<ScrollingStateNode>>*children = m_scrollingStateTree->rootStateNode()->children();347 auto children = m_scrollingStateTree->rootStateNode()->children(); 348 348 if (!children) 349 349 return; -
trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp
r161315 r170118 36 36 namespace WebCore { 37 37 38 Pass OwnPtr<ScrollingStateFixedNode> ScrollingStateFixedNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)38 PassRefPtr<ScrollingStateFixedNode> ScrollingStateFixedNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID) 39 39 { 40 return adopt Ptr(new ScrollingStateFixedNode(stateTree, nodeID));40 return adoptRef(new ScrollingStateFixedNode(stateTree, nodeID)); 41 41 } 42 42 … … 56 56 } 57 57 58 Pass OwnPtr<ScrollingStateNode> ScrollingStateFixedNode::clone(ScrollingStateTree& adoptiveTree)58 PassRefPtr<ScrollingStateNode> ScrollingStateFixedNode::clone(ScrollingStateTree& adoptiveTree) 59 59 { 60 return adopt Ptr(new ScrollingStateFixedNode(*this, adoptiveTree));60 return adoptRef(new ScrollingStateFixedNode(*this, adoptiveTree)); 61 61 } 62 62 -
trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h
r166293 r170118 40 40 class ScrollingStateFixedNode final : public ScrollingStateNode { 41 41 public: 42 static Pass OwnPtr<ScrollingStateFixedNode> create(ScrollingStateTree&, ScrollingNodeID);42 static PassRefPtr<ScrollingStateFixedNode> create(ScrollingStateTree&, ScrollingNodeID); 43 43 44 virtual Pass OwnPtr<ScrollingStateNode> clone(ScrollingStateTree&);44 virtual PassRefPtr<ScrollingStateNode> clone(ScrollingStateTree&); 45 45 46 46 virtual ~ScrollingStateFixedNode(); -
trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
r169123 r170118 35 35 namespace WebCore { 36 36 37 Pass OwnPtr<ScrollingStateFrameScrollingNode> ScrollingStateFrameScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)38 { 39 return adopt Ptr(new ScrollingStateFrameScrollingNode(stateTree, nodeID));37 PassRefPtr<ScrollingStateFrameScrollingNode> ScrollingStateFrameScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID) 38 { 39 return adoptRef(new ScrollingStateFrameScrollingNode(stateTree, nodeID)); 40 40 } 41 41 … … 97 97 } 98 98 99 Pass OwnPtr<ScrollingStateNode> ScrollingStateFrameScrollingNode::clone(ScrollingStateTree& adoptiveTree)100 { 101 return adopt Ptr(new ScrollingStateFrameScrollingNode(*this, adoptiveTree));99 PassRefPtr<ScrollingStateNode> ScrollingStateFrameScrollingNode::clone(ScrollingStateTree& adoptiveTree) 100 { 101 return adoptRef(new ScrollingStateFrameScrollingNode(*this, adoptiveTree)); 102 102 } 103 103 -
trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h
r169123 r170118 34 34 #include "ScrollingCoordinator.h" 35 35 #include "ScrollingStateScrollingNode.h" 36 #include <wtf/PassOwnPtr.h>37 36 38 37 namespace WebCore { … … 42 41 class ScrollingStateFrameScrollingNode final : public ScrollingStateScrollingNode { 43 42 public: 44 static Pass OwnPtr<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeID);43 static PassRefPtr<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeID); 45 44 46 virtual Pass OwnPtr<ScrollingStateNode> clone(ScrollingStateTree&);45 virtual PassRefPtr<ScrollingStateNode> clone(ScrollingStateTree&); 47 46 48 47 virtual ~ScrollingStateFrameScrollingNode(); -
trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp
r169773 r170118 73 73 } 74 74 75 Pass OwnPtr<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree)75 PassRefPtr<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree) 76 76 { 77 OwnPtr<ScrollingStateNode> clone = this->clone(adoptiveTree);77 RefPtr<ScrollingStateNode> clone = this->clone(adoptiveTree); 78 78 79 79 // Now that this node is cloned, reset our change properties. … … 93 93 } 94 94 95 void ScrollingStateNode::appendChild(Pass OwnPtr<ScrollingStateNode> childNode)95 void ScrollingStateNode::appendChild(PassRefPtr<ScrollingStateNode> childNode) 96 96 { 97 97 childNode->setParent(this); 98 98 99 99 if (!m_children) 100 m_children = adoptPtr(new Vector< OwnPtr<ScrollingStateNode>>);100 m_children = adoptPtr(new Vector<RefPtr<ScrollingStateNode>>); 101 101 102 102 m_children->append(childNode); 103 103 } 104 104 105 void ScrollingStateNode::remove Child(ScrollingStateNode* node)105 void ScrollingStateNode::removeDescendant(ScrollingStateNode* node) 106 106 { 107 107 if (!m_children) … … 109 109 110 110 size_t index = m_children->find(node); 111 112 // The index will be notFound if the node to remove is a deeper-than-1-level descendant or113 // if node is the root state node.114 111 if (index != notFound) { 115 112 node->willBeRemovedFromStateTree(); … … 119 116 120 117 for (auto& child : *m_children) 121 child->remove Child(node);118 child->removeDescendant(node); 122 119 } 123 120 124 121 void ScrollingStateNode::willBeRemovedFromStateTree() 125 122 { 126 scrollingStateTree().didRemoveNode(scrollingNodeID()); 127 123 scrollingStateTree().willRemoveNode(this); 128 124 if (!m_children) 129 125 return; -
trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h
r169063 r170118 32 32 #include "ScrollingCoordinator.h" 33 33 #include <wtf/OwnPtr.h> 34 #include <wtf/ PassOwnPtr.h>34 #include <wtf/RefCounted.h> 35 35 #include <wtf/Vector.h> 36 36 … … 151 151 }; 152 152 153 class ScrollingStateNode {153 class ScrollingStateNode : public RefCounted<ScrollingStateNode> { 154 154 WTF_MAKE_FAST_ALLOCATED; 155 155 public: … … 165 165 bool isOverflowScrollingNode() const { return m_nodeType == OverflowScrollingNode; } 166 166 167 virtual Pass OwnPtr<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0;168 Pass OwnPtr<ScrollingStateNode> cloneAndReset(ScrollingStateTree& adoptiveTree);167 virtual PassRefPtr<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0; 168 PassRefPtr<ScrollingStateNode> cloneAndReset(ScrollingStateTree& adoptiveTree); 169 169 void cloneAndResetChildren(ScrollingStateNode&, ScrollingStateTree& adoptiveTree); 170 170 … … 196 196 ScrollingNodeID parentNodeID() const { return m_parent ? m_parent->scrollingNodeID() : 0; } 197 197 198 Vector< OwnPtr<ScrollingStateNode>>* children() const { return m_children.get(); }199 200 void appendChild(Pass OwnPtr<ScrollingStateNode>);201 void remove Child(ScrollingStateNode*);198 Vector<RefPtr<ScrollingStateNode>>* children() const { return m_children.get(); } 199 200 void appendChild(PassRefPtr<ScrollingStateNode>); 201 void removeDescendant(ScrollingStateNode*); 202 202 203 203 String scrollingStateTreeAsText() const; … … 219 219 220 220 ScrollingStateNode* m_parent; 221 OwnPtr<Vector< OwnPtr<ScrollingStateNode>>> m_children;221 OwnPtr<Vector<RefPtr<ScrollingStateNode>>> m_children; 222 222 223 223 LayerRepresentation m_layer; -
trunk/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp
r169063 r170118 35 35 namespace WebCore { 36 36 37 Pass OwnPtr<ScrollingStateOverflowScrollingNode> ScrollingStateOverflowScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)37 PassRefPtr<ScrollingStateOverflowScrollingNode> ScrollingStateOverflowScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID) 38 38 { 39 return adopt Ptr(new ScrollingStateOverflowScrollingNode(stateTree, nodeID));39 return adoptRef(new ScrollingStateOverflowScrollingNode(stateTree, nodeID)); 40 40 } 41 41 … … 56 56 } 57 57 58 Pass OwnPtr<ScrollingStateNode> ScrollingStateOverflowScrollingNode::clone(ScrollingStateTree& adoptiveTree)58 PassRefPtr<ScrollingStateNode> ScrollingStateOverflowScrollingNode::clone(ScrollingStateTree& adoptiveTree) 59 59 { 60 return adopt Ptr(new ScrollingStateOverflowScrollingNode(*this, adoptiveTree));60 return adoptRef(new ScrollingStateOverflowScrollingNode(*this, adoptiveTree)); 61 61 } 62 62 -
trunk/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h
r169063 r170118 35 35 class ScrollingStateOverflowScrollingNode : public ScrollingStateScrollingNode { 36 36 public: 37 static Pass OwnPtr<ScrollingStateOverflowScrollingNode> create(ScrollingStateTree&, ScrollingNodeID);37 static PassRefPtr<ScrollingStateOverflowScrollingNode> create(ScrollingStateTree&, ScrollingNodeID); 38 38 39 virtual Pass OwnPtr<ScrollingStateNode> clone(ScrollingStateTree&);39 virtual PassRefPtr<ScrollingStateNode> clone(ScrollingStateTree&); 40 40 41 41 virtual ~ScrollingStateOverflowScrollingNode(); -
trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp
r169745 r170118 36 36 namespace WebCore { 37 37 38 Pass OwnPtr<ScrollingStateStickyNode> ScrollingStateStickyNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)38 PassRefPtr<ScrollingStateStickyNode> ScrollingStateStickyNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID) 39 39 { 40 return adopt Ptr(new ScrollingStateStickyNode(stateTree, nodeID));40 return adoptRef(new ScrollingStateStickyNode(stateTree, nodeID)); 41 41 } 42 42 … … 56 56 } 57 57 58 Pass OwnPtr<ScrollingStateNode> ScrollingStateStickyNode::clone(ScrollingStateTree& adoptiveTree)58 PassRefPtr<ScrollingStateNode> ScrollingStateStickyNode::clone(ScrollingStateTree& adoptiveTree) 59 59 { 60 return adopt Ptr(new ScrollingStateStickyNode(*this, adoptiveTree));60 return adoptRef(new ScrollingStateStickyNode(*this, adoptiveTree)); 61 61 } 62 62 -
trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h
r166293 r170118 40 40 class ScrollingStateStickyNode final : public ScrollingStateNode { 41 41 public: 42 static Pass OwnPtr<ScrollingStateStickyNode> create(ScrollingStateTree&, ScrollingNodeID);42 static PassRefPtr<ScrollingStateStickyNode> create(ScrollingStateTree&, ScrollingNodeID); 43 43 44 virtual Pass OwnPtr<ScrollingStateNode> clone(ScrollingStateTree&);44 virtual PassRefPtr<ScrollingStateNode> clone(ScrollingStateTree&); 45 45 46 46 virtual ~ScrollingStateStickyNode(); -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
r169063 r170118 73 73 74 74 if (ScrollingStateNode* node = stateNodeForID(newNodeID)) { 75 if (!parentID) 76 return newNodeID; 77 75 78 ScrollingStateNode* parent = stateNodeForID(parentID); 76 79 if (!parent) 77 80 return newNodeID; 81 78 82 if (node->parent() == parent) 79 83 return newNodeID; … … 83 87 } 84 88 85 ScrollingStateNode* newNode = 0;89 ScrollingStateNode* newNode = nullptr; 86 90 if (!parentID) { 87 91 // If we're resetting the root node, we should clear the HashMap and destroy the current children. … … 98 102 switch (nodeType) { 99 103 case FixedNode: { 100 OwnPtr<ScrollingStateFixedNode> fixedNode = ScrollingStateFixedNode::create(*this, newNodeID);104 RefPtr<ScrollingStateFixedNode> fixedNode = ScrollingStateFixedNode::create(*this, newNodeID); 101 105 newNode = fixedNode.get(); 102 106 parent->appendChild(fixedNode.release()); … … 104 108 } 105 109 case StickyNode: { 106 OwnPtr<ScrollingStateStickyNode> stickyNode = ScrollingStateStickyNode::create(*this, newNodeID);110 RefPtr<ScrollingStateStickyNode> stickyNode = ScrollingStateStickyNode::create(*this, newNodeID); 107 111 newNode = stickyNode.get(); 108 112 parent->appendChild(stickyNode.release()); … … 110 114 } 111 115 case FrameScrollingNode: { 112 OwnPtr<ScrollingStateFrameScrollingNode> scrollingNode = ScrollingStateFrameScrollingNode::create(*this, newNodeID);116 RefPtr<ScrollingStateFrameScrollingNode> scrollingNode = ScrollingStateFrameScrollingNode::create(*this, newNodeID); 113 117 newNode = scrollingNode.get(); 114 118 parent->appendChild(scrollingNode.release()); … … 116 120 } 117 121 case OverflowScrollingNode: { 118 OwnPtr<ScrollingStateOverflowScrollingNode> scrollingNode = ScrollingStateOverflowScrollingNode::create(*this, newNodeID);122 RefPtr<ScrollingStateOverflowScrollingNode> scrollingNode = ScrollingStateOverflowScrollingNode::create(*this, newNodeID); 119 123 newNode = scrollingNode.get(); 120 124 parent->appendChild(scrollingNode.release()); … … 180 184 181 185 if (node == m_rootStateNode) { 182 didRemoveNode(node->scrollingNodeID());186 willRemoveNode(node); 183 187 m_rootStateNode = nullptr; 184 188 return; … … 186 190 187 191 ASSERT(m_rootStateNode); 188 m_rootStateNode->remove Child(node);189 190 // ScrollingStateTree::remove Node() will destroy children, so we have to make sure we remove those children192 m_rootStateNode->removeDescendant(node); 193 194 // ScrollingStateTree::removeDescendant() will destroy children, so we have to make sure we remove those children 191 195 // from the HashMap. 192 size_t size = m_nodesRemovedSinceLastCommit.size(); 193 for (size_t i = 0; i < size; ++i) 194 m_stateNodeMap.remove(m_nodesRemovedSinceLastCommit[i]); 195 } 196 197 void ScrollingStateTree::didRemoveNode(ScrollingNodeID nodeID) 198 { 199 m_nodesRemovedSinceLastCommit.append(nodeID); 196 for (auto removedNodeID : m_nodesRemovedSinceLastCommit) 197 m_stateNodeMap.remove(removedNodeID); 198 } 199 200 void ScrollingStateTree::willRemoveNode(ScrollingStateNode* node) 201 { 202 m_nodesRemovedSinceLastCommit.append(node->scrollingNodeID()); 200 203 setHasChangedProperties(); 201 204 } -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h
r169063 r170118 80 80 ScrollingStateTree(AsyncScrollingCoordinator*); 81 81 82 void setRootStateNode(Pass OwnPtr<ScrollingStateFrameScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; }82 void setRootStateNode(PassRefPtr<ScrollingStateFrameScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; } 83 83 void addNode(ScrollingStateNode*); 84 84 void removeNode(ScrollingStateNode*); 85 void didRemoveNode(ScrollingNodeID);85 void willRemoveNode(ScrollingStateNode*); 86 86 87 87 AsyncScrollingCoordinator* m_scrollingCoordinator; 88 88 StateNodeMap m_stateNodeMap; 89 OwnPtr<ScrollingStateFrameScrollingNode> m_rootStateNode;89 RefPtr<ScrollingStateFrameScrollingNode> m_rootStateNode; 90 90 Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit; 91 91 bool m_hasChangedProperties; -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r169410 r170118 198 198 199 199 // Now update the children if we have any. 200 Vector<OwnPtr<ScrollingStateNode>>* stateNodeChildren = stateNode->children(); 201 if (stateNodeChildren) { 202 size_t size = stateNodeChildren->size(); 203 for (size_t i = 0; i < size; ++i) 204 updateTreeFromStateNode(stateNodeChildren->at(i).get()); 200 if (auto children = stateNode->children()) { 201 for (auto& child : *children) 202 updateTreeFromStateNode(child.get()); 205 203 } 206 204 node->updateAfterChildren(*stateNode); -
trunk/Source/WebKit2/ChangeLog
r170116 r170118 1 2014-06-18 Simon Fraser <simon.fraser@apple.com> 2 3 Make ScrollingStateNodes refcounted, and other minor cleanup 4 https://bugs.webkit.org/show_bug.cgi?id=134040 5 6 Reviewed by Beth Dakin. 7 8 * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp: 9 (WebKit::encodeNodeAndDescendants): 10 1 11 2014-06-18 Benjamin Poulain <benjamin@webkit.org> 2 12 -
trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
r169123 r170118 338 338 return; 339 339 340 for (size_t i = 0; i < stateNode.children()->size(); ++i) { 341 const OwnPtr<ScrollingStateNode>& child = stateNode.children()->at(i); 340 for (const auto& child : *stateNode.children()) 342 341 encodeNodeAndDescendants(encoder, *child.get()); 343 }344 342 } 345 343
Note:
See TracChangeset
for help on using the changeset viewer.