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

Unified Diff: third_party/WebKit/Source/core/editing/EditingStyle.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/EditingStyle.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingStyle.cpp b/third_party/WebKit/Source/core/editing/EditingStyle.cpp
index e8df5ce38b9eb7e09ad0e74912b09c443bcf1c88..fa51d948eec220864f9a409369247c6dfd6fd4cd 100644
--- a/third_party/WebKit/Source/core/editing/EditingStyle.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingStyle.cpp
@@ -1113,12 +1113,15 @@ EditingStyle* EditingStyle::wrappingStyleForAnnotatedSerialization(ContainerNode
EditingStyle* EditingStyle::wrappingStyleForSerialization(ContainerNode* context)
{
+ DCHECK(context);
EditingStyle* wrappingStyle = EditingStyle::create();
// When not annotating for interchange, we only preserve inline style declarations.
- for (ContainerNode* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
- if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) {
- wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues,
+ for (Node& node : NodeTraversal::inclusiveAncestorsOf(*context)) {
+ if (node.isDocumentNode())
+ break;
+ if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) {
+ wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node), EditingStyle::DoNotOverrideValues,
EditingStyle::EditingPropertiesInEffect);
}
}
@@ -1391,17 +1394,20 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
}
node = selection.visibleStart().deepEquivalent().anchorNode();
}
+ DCHECK(node);
// The selection is either a caret with no typing attributes or a range in which no embedding is added, so just use the start position
// to decide.
Node* block = enclosingBlock(node);
WritingDirection foundDirection = NaturalWritingDirection;
- for (; node != block; node = node->parentNode()) {
- if (!node->isStyledElement())
+ for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) {
+ if (runner == block)
+ break;
+ if (!runner.isStyledElement())
continue;
- Element* element = toElement(node);
+ Element* element = &toElement(runner);
CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(element);
CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.cpp ('k') | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698