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

Unified Diff: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T18:38:12 Created 4 years, 8 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
Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
index 508435f23434981504fc276acd3a0e2da0d978b6..7d076998f7c48dce565b47c5d1c17459d2607a61 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1076,8 +1076,11 @@ void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start,
HeapVector<Member<Node>> ancestors;
// Insert each node from innerNode to outerNode (excluded) in a list.
- for (Node* n = start.anchorNode(); n && n != outerNode; n = n->parentNode())
- ancestors.append(n);
+ for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*start.anchorNode())) {
+ if (runner == outerNode)
+ break;
+ ancestors.append(runner);
+ }
// Clone every node between start.anchorNode() and outerBlock.

Powered by Google App Engine
This is Rietveld 408576698