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

Side by Side 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-28T16:44:17 Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc.
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 wrappingStyle->collapseTextDecorationProperties(); 1109 wrappingStyle->collapseTextDecorationProperties();
1110 1110
1111 return wrappingStyle; 1111 return wrappingStyle;
1112 } 1112 }
1113 1113
1114 EditingStyle* EditingStyle::wrappingStyleForSerialization(ContainerNode* context ) 1114 EditingStyle* EditingStyle::wrappingStyleForSerialization(ContainerNode* context )
1115 { 1115 {
1116 EditingStyle* wrappingStyle = EditingStyle::create(); 1116 EditingStyle* wrappingStyle = EditingStyle::create();
1117 1117
1118 // When not annotating for interchange, we only preserve inline style declar ations. 1118 // When not annotating for interchange, we only preserve inline style declar ations.
1119 for (ContainerNode* node = context; node && !node->isDocumentNode(); node = node->parentNode()) { 1119 for (Node& node : NodeTraversal::ancestorsOrSelfOf(context)) {
1120 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) { 1120 if (node.isDocumentNode())
1121 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues, 1121 break;
1122 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) {
1123 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node) , EditingStyle::DoNotOverrideValues,
1122 EditingStyle::EditingPropertiesInEffect); 1124 EditingStyle::EditingPropertiesInEffect);
1123 } 1125 }
1124 } 1126 }
1125 1127
1126 return wrappingStyle; 1128 return wrappingStyle;
1127 } 1129 }
1128 1130
1129 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL ist* valueToMerge) 1131 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL ist* valueToMerge)
1130 { 1132 {
1131 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create Identifier(CSSValueUnderline))); 1133 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create Identifier(CSSValueUnderline)));
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 return direction; 1392 return direction;
1391 } 1393 }
1392 node = selection.visibleStart().deepEquivalent().anchorNode(); 1394 node = selection.visibleStart().deepEquivalent().anchorNode();
1393 } 1395 }
1394 1396
1395 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position 1397 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position
1396 // to decide. 1398 // to decide.
1397 Node* block = enclosingBlock(node); 1399 Node* block = enclosingBlock(node);
1398 WritingDirection foundDirection = NaturalWritingDirection; 1400 WritingDirection foundDirection = NaturalWritingDirection;
1399 1401
1400 for (; node != block; node = node->parentNode()) { 1402 for (Node& node : NodeTraversal::ancestorsOrSelfOf(node)) {
1401 if (!node->isStyledElement()) 1403 if (node == block)
1404 break;
1405 if (!node.isStyledElement())
1402 continue; 1406 continue;
1403 1407
1404 Element* element = toElement(node); 1408 Element* element = &toElement(node);
1405 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create (element); 1409 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create (element);
1406 CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBid i); 1410 CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBid i);
1407 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1411 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1408 continue; 1412 continue;
1409 1413
1410 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue ID(); 1414 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue ID();
1411 if (unicodeBidiValue == CSSValueNormal) 1415 if (unicodeBidiValue == CSSValueNormal)
1412 continue; 1416 continue;
1413 1417
1414 if (unicodeBidiValue == CSSValueBidiOverride) 1418 if (unicodeBidiValue == CSSValueBidiOverride)
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 { 1725 {
1722 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1726 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1723 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration ::create(ancestor); 1727 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration ::create(ancestor);
1724 if (!hasTransparentBackgroundColor(ancestorStyle)) 1728 if (!hasTransparentBackgroundColor(ancestorStyle))
1725 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1729 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1726 } 1730 }
1727 return nullptr; 1731 return nullptr;
1728 } 1732 }
1729 1733
1730 } // namespace blink 1734 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698