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

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

Issue 642973003: Introduce typed Node/Element iterators for range-based for loops of C++11. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename `from` to `fromNext`. Make some parameters const references. Created 6 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 | « no previous file | Source/core/dom/Document.cpp » ('j') | Source/core/dom/ElementTraversal.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 4a4ed7ed5617ce2f1c189894bac066a478c5e6ff..f0738fc165cdf7f905fa6d2bcd6e5570881f80db 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -794,14 +794,14 @@ void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
- for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
+ for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
// As an optimization we don't notify leaf nodes when when inserting
// into detached subtrees.
- if (!inDocument() && !node->isContainerNode())
+ if (!inDocument() && !node.isContainerNode())
continue;
- if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node->insertedInto(this))
- postInsertionNotificationTargets.append(node);
- for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
+ if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.insertedInto(this))
+ postInsertionNotificationTargets.append(&node);
+ for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTargets);
}
}
@@ -812,16 +812,16 @@ void ContainerNode::notifyNodeRemoved(Node& root)
EventDispatchForbiddenScope assertNoEventDispatch;
Document& document = root.document();
- for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
+ for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
// As an optimization we skip notifying Text nodes and other leaf nodes
// of removal when they're not in the Document tree since the virtual
// call to removedFrom is not needed.
- if (!node->inDocument() && !node->isContainerNode())
+ if (!node.inDocument() && !node.isContainerNode())
continue;
if (document.cssTarget() == node)
document.setCSSTarget(nullptr);
- node->removedFrom(this);
- for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
+ node.removedFrom(this);
+ for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
notifyNodeRemoved(*shadowRoot);
}
}
« no previous file with comments | « no previous file | Source/core/dom/Document.cpp » ('j') | Source/core/dom/ElementTraversal.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698