Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: Source/core/dom/NodeIterator.cpp

Issue 48803004: Have Document::nodeWillBeRemoved() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/NodeIterator.h ('k') | Source/core/dom/Range.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/NodeIterator.cpp
diff --git a/Source/core/dom/NodeIterator.cpp b/Source/core/dom/NodeIterator.cpp
index 173edc48900ddcc66bce28b988310c92323c6fe6..0770aa15d939e2f6e86a3898c364e701f6ad2379 100644
--- a/Source/core/dom/NodeIterator.cpp
+++ b/Source/core/dom/NodeIterator.cpp
@@ -153,43 +153,42 @@ void NodeIterator::detach()
m_referenceNode.node.clear();
}
-void NodeIterator::nodeWillBeRemoved(Node* removedNode)
+void NodeIterator::nodeWillBeRemoved(Node& removedNode)
{
updateForNodeRemoval(removedNode, m_candidateNode);
updateForNodeRemoval(removedNode, m_referenceNode);
}
-void NodeIterator::updateForNodeRemoval(Node* removedNode, NodePointer& referenceNode) const
+void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenceNode) const
{
ASSERT(!m_detached);
- ASSERT(removedNode);
- ASSERT(root()->document() == removedNode->document());
+ ASSERT(root()->document() == removedNode.document());
// Iterator is not affected if the removed node is the reference node and is the root.
// or if removed node is not the reference node, or the ancestor of the reference node.
- if (!removedNode->isDescendantOf(root()))
+ if (!removedNode.isDescendantOf(root()))
return;
bool willRemoveReferenceNode = removedNode == referenceNode.node;
- bool willRemoveReferenceNodeAncestor = referenceNode.node && referenceNode.node->isDescendantOf(removedNode);
+ bool willRemoveReferenceNodeAncestor = referenceNode.node && referenceNode.node->isDescendantOf(&removedNode);
if (!willRemoveReferenceNode && !willRemoveReferenceNodeAncestor)
return;
if (referenceNode.isPointerBeforeNode) {
- Node* node = NodeTraversal::next(removedNode, root());
+ Node* node = NodeTraversal::next(&removedNode, root());
if (node) {
// Move out from under the node being removed if the new reference
// node is a descendant of the node being removed.
- while (node && node->isDescendantOf(removedNode))
+ while (node && node->isDescendantOf(&removedNode))
node = NodeTraversal::next(node, root());
if (node)
referenceNode.node = node;
} else {
- node = NodeTraversal::previous(removedNode, root());
+ node = NodeTraversal::previous(&removedNode, root());
if (node) {
// Move out from under the node being removed if the reference node is
// a descendant of the node being removed.
if (willRemoveReferenceNodeAncestor) {
- while (node && node->isDescendantOf(removedNode))
+ while (node && node->isDescendantOf(&removedNode))
node = NodeTraversal::previous(node, root());
}
if (node) {
@@ -202,23 +201,23 @@ void NodeIterator::updateForNodeRemoval(Node* removedNode, NodePointer& referenc
}
}
} else {
- Node* node = NodeTraversal::previous(removedNode, root());
+ Node* node = NodeTraversal::previous(&removedNode, root());
if (node) {
// Move out from under the node being removed if the reference node is
// a descendant of the node being removed.
if (willRemoveReferenceNodeAncestor) {
- while (node && node->isDescendantOf(removedNode))
+ while (node && node->isDescendantOf(&removedNode))
node = NodeTraversal::previous(node, root());
}
if (node)
referenceNode.node = node;
} else {
// FIXME: This branch doesn't appear to have any LayoutTests.
- node = NodeTraversal::next(removedNode, root());
+ node = NodeTraversal::next(&removedNode, root());
// Move out from under the node being removed if the reference node is
// a descendant of the node being removed.
if (willRemoveReferenceNodeAncestor) {
- while (node && node->isDescendantOf(removedNode))
+ while (node && node->isDescendantOf(&removedNode))
node = NodeTraversal::previous(node, root());
}
if (node)
« no previous file with comments | « Source/core/dom/NodeIterator.h ('k') | Source/core/dom/Range.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698