|
Lines 82-88
ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol
a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec1
|
| 82 |
return newNodeID; |
82 |
return newNodeID; |
| 83 |
|
83 |
|
| 84 |
// The node is being re-parented. To do that, we'll remove it, and then re-create a new node. |
84 |
// The node is being re-parented. To do that, we'll remove it, and then re-create a new node. |
| 85 |
removeNodeAndAllDescendants(node); |
85 |
removeNodeAndAllDescendants(node, OrphanSubframeNodes); |
| 86 |
} |
86 |
} |
| 87 |
|
87 |
|
| 88 |
ScrollingStateNode* newNode = nullptr; |
88 |
ScrollingStateNode* newNode = nullptr; |
|
Lines 98-128
ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol
a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec2
|
| 98 |
if (!parent) |
98 |
if (!parent) |
| 99 |
return 0; |
99 |
return 0; |
| 100 |
|
100 |
|
| 101 |
switch (nodeType) { |
101 |
if (nodeType == FrameScrollingNode && parentID) { |
| 102 |
case FixedNode: { |
102 |
if (RefPtr<ScrollingStateNode> orphanedNode = m_orphanedSubframeNodes.take(newNodeID)) { |
| 103 |
RefPtr<ScrollingStateFixedNode> fixedNode = ScrollingStateFixedNode::create(*this, newNodeID); |
103 |
newNode = orphanedNode.get(); |
| 104 |
newNode = fixedNode.get(); |
104 |
parent->appendChild(orphanedNode.release()); |
| 105 |
parent->appendChild(fixedNode.release()); |
105 |
} |
| 106 |
break; |
|
|
| 107 |
} |
| 108 |
case StickyNode: { |
| 109 |
RefPtr<ScrollingStateStickyNode> stickyNode = ScrollingStateStickyNode::create(*this, newNodeID); |
| 110 |
newNode = stickyNode.get(); |
| 111 |
parent->appendChild(stickyNode.release()); |
| 112 |
break; |
| 113 |
} |
| 114 |
case FrameScrollingNode: { |
| 115 |
RefPtr<ScrollingStateFrameScrollingNode> scrollingNode = ScrollingStateFrameScrollingNode::create(*this, newNodeID); |
| 116 |
newNode = scrollingNode.get(); |
| 117 |
parent->appendChild(scrollingNode.release()); |
| 118 |
break; |
| 119 |
} |
| 120 |
case OverflowScrollingNode: { |
| 121 |
RefPtr<ScrollingStateOverflowScrollingNode> scrollingNode = ScrollingStateOverflowScrollingNode::create(*this, newNodeID); |
| 122 |
newNode = scrollingNode.get(); |
| 123 |
parent->appendChild(scrollingNode.release()); |
| 124 |
break; |
| 125 |
} |
106 |
} |
|
|
107 |
|
| 108 |
if (!newNode) { |
| 109 |
switch (nodeType) { |
| 110 |
case FixedNode: { |
| 111 |
RefPtr<ScrollingStateFixedNode> fixedNode = ScrollingStateFixedNode::create(*this, newNodeID); |
| 112 |
newNode = fixedNode.get(); |
| 113 |
parent->appendChild(fixedNode.release()); |
| 114 |
break; |
| 115 |
} |
| 116 |
case StickyNode: { |
| 117 |
RefPtr<ScrollingStateStickyNode> stickyNode = ScrollingStateStickyNode::create(*this, newNodeID); |
| 118 |
newNode = stickyNode.get(); |
| 119 |
parent->appendChild(stickyNode.release()); |
| 120 |
break; |
| 121 |
} |
| 122 |
case FrameScrollingNode: { |
| 123 |
RefPtr<ScrollingStateFrameScrollingNode> scrollingNode = ScrollingStateFrameScrollingNode::create(*this, newNodeID); |
| 124 |
newNode = scrollingNode.get(); |
| 125 |
parent->appendChild(scrollingNode.release()); |
| 126 |
break; |
| 127 |
} |
| 128 |
case OverflowScrollingNode: { |
| 129 |
RefPtr<ScrollingStateOverflowScrollingNode> scrollingNode = ScrollingStateOverflowScrollingNode::create(*this, newNodeID); |
| 130 |
newNode = scrollingNode.get(); |
| 131 |
parent->appendChild(scrollingNode.release()); |
| 132 |
break; |
| 133 |
} |
| 134 |
} |
| 126 |
} |
135 |
} |
| 127 |
} |
136 |
} |
| 128 |
|
137 |
|
|
Lines 141-158
void ScrollingStateTree::detachNode(ScrollingNodeID nodeID)
a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec3
|
| 141 |
if (!node) |
150 |
if (!node) |
| 142 |
return; |
151 |
return; |
| 143 |
|
152 |
|
| 144 |
removeNodeAndAllDescendants(node); |
153 |
removeNodeAndAllDescendants(node, OrphanSubframeNodes); |
| 145 |
} |
154 |
} |
| 146 |
|
155 |
|
| 147 |
void ScrollingStateTree::clear() |
156 |
void ScrollingStateTree::clear() |
| 148 |
{ |
157 |
{ |
| 149 |
removeNodeAndAllDescendants(rootStateNode()); |
158 |
if (rootStateNode()) |
|
|
159 |
removeNodeAndAllDescendants(rootStateNode()); |
| 160 |
|
| 150 |
ASSERT(m_stateNodeMap.isEmpty()); |
161 |
ASSERT(m_stateNodeMap.isEmpty()); |
| 151 |
m_stateNodeMap.clear(); |
162 |
m_stateNodeMap.clear(); |
|
|
163 |
m_orphanedSubframeNodes.clear(); |
| 152 |
} |
164 |
} |
| 153 |
|
165 |
|
| 154 |
PassOwnPtr<ScrollingStateTree> ScrollingStateTree::commit(LayerRepresentation::Type preferredLayerRepresentation) |
166 |
PassOwnPtr<ScrollingStateTree> ScrollingStateTree::commit(LayerRepresentation::Type preferredLayerRepresentation) |
| 155 |
{ |
167 |
{ |
|
|
168 |
m_orphanedSubframeNodes.clear(); |
| 169 |
|
| 156 |
// This function clones and resets the current state tree, but leaves the tree structure intact. |
170 |
// This function clones and resets the current state tree, but leaves the tree structure intact. |
| 157 |
OwnPtr<ScrollingStateTree> treeStateClone = ScrollingStateTree::create(); |
171 |
OwnPtr<ScrollingStateTree> treeStateClone = ScrollingStateTree::create(); |
| 158 |
treeStateClone->setPreferredLayerRepresentation(preferredLayerRepresentation); |
172 |
treeStateClone->setPreferredLayerRepresentation(preferredLayerRepresentation); |
|
Lines 178-193
void ScrollingStateTree::addNode(ScrollingStateNode* node)
a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec4
|
| 178 |
m_stateNodeMap.add(node->scrollingNodeID(), node); |
192 |
m_stateNodeMap.add(node->scrollingNodeID(), node); |
| 179 |
} |
193 |
} |
| 180 |
|
194 |
|
| 181 |
void ScrollingStateTree::removeNodeAndAllDescendants(ScrollingStateNode* node) |
195 |
void ScrollingStateTree::removeNodeAndAllDescendants(ScrollingStateNode* node, SubframeNodeRemoval subframeNodeRemoval) |
| 182 |
{ |
196 |
{ |
| 183 |
if (!node) |
197 |
ScrollingStateNode* parent = node->parent(); |
| 184 |
return; |
|
|
| 185 |
|
198 |
|
| 186 |
recursiveNodeWillBeRemoved(node); |
199 |
recursiveNodeWillBeRemoved(node, subframeNodeRemoval); |
| 187 |
|
200 |
|
| 188 |
if (node == m_rootStateNode) |
201 |
if (node == m_rootStateNode) |
| 189 |
m_rootStateNode = nullptr; |
202 |
m_rootStateNode = nullptr; |
| 190 |
else if (ScrollingStateNode* parent = node->parent()) { |
203 |
else if (parent) { |
| 191 |
ASSERT(parent->children() && parent->children()->find(node) != notFound); |
204 |
ASSERT(parent->children() && parent->children()->find(node) != notFound); |
| 192 |
if (auto children = parent->children()) { |
205 |
if (auto children = parent->children()) { |
| 193 |
size_t index = children->find(node); |
206 |
size_t index = children->find(node); |
|
Lines 197-209
void ScrollingStateTree::removeNodeAndAllDescendants(ScrollingStateNode* node)
a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec5
|
| 197 |
} |
210 |
} |
| 198 |
} |
211 |
} |
| 199 |
|
212 |
|
| 200 |
void ScrollingStateTree::recursiveNodeWillBeRemoved(ScrollingStateNode* currNode) |
213 |
void ScrollingStateTree::recursiveNodeWillBeRemoved(ScrollingStateNode* currNode, SubframeNodeRemoval subframeNodeRemoval) |
| 201 |
{ |
214 |
{ |
|
|
215 |
currNode->setParent(nullptr); |
| 216 |
if (subframeNodeRemoval == OrphanSubframeNodes && currNode != m_rootStateNode && currNode->isFrameScrollingNode()) { |
| 217 |
m_orphanedSubframeNodes.add(currNode->scrollingNodeID(), currNode); |
| 218 |
return; |
| 219 |
} |
| 220 |
|
| 202 |
willRemoveNode(currNode); |
221 |
willRemoveNode(currNode); |
| 203 |
|
222 |
|
| 204 |
if (auto children = currNode->children()) { |
223 |
if (auto children = currNode->children()) { |
| 205 |
for (auto& child : *children) |
224 |
for (auto& child : *children) |
| 206 |
recursiveNodeWillBeRemoved(child.get()); |
225 |
recursiveNodeWillBeRemoved(child.get(), subframeNodeRemoval); |
| 207 |
} |
226 |
} |
| 208 |
} |
227 |
} |
| 209 |
|
228 |
|