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

Unified Diff: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.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/ApplyStyleCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
index a6d7681154c611431395919258c129995256b25a..c31c47101e6e5fc78eb3614689ed91ef82f38f3e 100644
--- a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
@@ -481,12 +481,14 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b
ContainerNode* highestAncestorWithUnicodeBidi = nullptr;
ContainerNode* nextHighestAncestorWithUnicodeBidi = nullptr;
int highestAncestorUnicodeBidi = 0;
- for (ContainerNode* n = node->parentNode(); n != block; n = n->parentNode()) {
- int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create(n), CSSPropertyUnicodeBidi);
+ for (Node& runner : NodeTraversal::ancestorsOf(*node)) {
+ if (runner == block)
+ break;
+ int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create(&runner), CSSPropertyUnicodeBidi);
if (unicodeBidi && unicodeBidi != CSSValueNormal) {
highestAncestorUnicodeBidi = unicodeBidi;
nextHighestAncestorWithUnicodeBidi = highestAncestorWithUnicodeBidi;
- highestAncestorWithUnicodeBidi = n;
+ highestAncestorWithUnicodeBidi = static_cast<ContainerNode*>(&runner);
}
}
@@ -527,11 +529,13 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, HTMLElemen
if (!block)
return;
- for (ContainerNode* n = node->parentNode(); n != block && n != unsplitAncestor; n = n->parentNode()) {
- if (!n->isStyledElement())
+ for (Node& runner : NodeTraversal::ancestorsOf(*node)) {
+ if (runner == block || runner == unsplitAncestor)
+ break;
+ if (!runner.isStyledElement())
continue;
- Element* element = toElement(n);
+ Element* element = toElement(&runner);
int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create(element), CSSPropertyUnicodeBidi);
if (!unicodeBidi || unicodeBidi == CSSValueNormal)
continue;

Powered by Google App Engine
This is Rietveld 408576698