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

Unified Diff: third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.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/SimplifyMarkupCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.cpp b/third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.cpp
index 7dcce8f6114cb023d986163d4379988352b7a274..5c40b7b74eea57a569252b84fd6aa51cae17c37e 100644
--- a/third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.cpp
@@ -51,7 +51,7 @@ void SimplifyMarkupCommand::doApply(EditingState* editingState)
if (node->hasChildren() || (node->isTextNode() && node->nextSibling()))
continue;
- ContainerNode* startingNode = node->parentNode();
+ ContainerNode* const startingNode = node->parentNode();
if (!startingNode)
continue;
const ComputedStyle* startingStyle = startingNode->computedStyle();
@@ -80,8 +80,11 @@ void SimplifyMarkupCommand::doApply(EditingState* editingState)
}
if (topNodeWithStartingStyle) {
- for (ContainerNode* node = startingNode; node != topNodeWithStartingStyle; node = node->parentNode())
- nodesToRemove.append(node);
+ for (Node& node : NodeTraversal::inclusiveAncestorsOf(*startingNode)) {
+ if (node == topNodeWithStartingStyle)
+ break;
+ nodesToRemove.append(static_cast<ContainerNode*>(&node));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698