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

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-28T18:38:12 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 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType(f irstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement, CanCrossEditin gBoundary))); 1106 wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType(f irstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement, CanCrossEditin gBoundary)));
1107 1107
1108 // Call collapseTextDecorationProperties first or otherwise it'll copy the v alue over from in-effect to text-decorations. 1108 // Call collapseTextDecorationProperties first or otherwise it'll copy the v alue over from in-effect to text-decorations.
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 DCHECK(context);
1116 EditingStyle* wrappingStyle = EditingStyle::create(); 1117 EditingStyle* wrappingStyle = EditingStyle::create();
1117 1118
1118 // When not annotating for interchange, we only preserve inline style declar ations. 1119 // When not annotating for interchange, we only preserve inline style declar ations.
1119 for (ContainerNode* node = context; node && !node->isDocumentNode(); node = node->parentNode()) { 1120 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*context)) {
1120 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) { 1121 if (node.isDocumentNode())
1121 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues, 1122 break;
1123 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) {
1124 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node) , EditingStyle::DoNotOverrideValues,
1122 EditingStyle::EditingPropertiesInEffect); 1125 EditingStyle::EditingPropertiesInEffect);
1123 } 1126 }
1124 } 1127 }
1125 1128
1126 return wrappingStyle; 1129 return wrappingStyle;
1127 } 1130 }
1128 1131
1129 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL ist* valueToMerge) 1132 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL ist* valueToMerge)
1130 { 1133 {
1131 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create Identifier(CSSValueUnderline))); 1134 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create Identifier(CSSValueUnderline)));
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 } 1387 }
1385 1388
1386 if (selection.isCaret()) { 1389 if (selection.isCaret()) {
1387 WritingDirection direction; 1390 WritingDirection direction;
1388 if (typingStyle && typingStyle->textDirection(direction)) { 1391 if (typingStyle && typingStyle->textDirection(direction)) {
1389 hasNestedOrMultipleEmbeddings = false; 1392 hasNestedOrMultipleEmbeddings = false;
1390 return direction; 1393 return direction;
1391 } 1394 }
1392 node = selection.visibleStart().deepEquivalent().anchorNode(); 1395 node = selection.visibleStart().deepEquivalent().anchorNode();
1393 } 1396 }
1397 DCHECK(node);
1394 1398
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 1399 // 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. 1400 // to decide.
1397 Node* block = enclosingBlock(node); 1401 Node* block = enclosingBlock(node);
1398 WritingDirection foundDirection = NaturalWritingDirection; 1402 WritingDirection foundDirection = NaturalWritingDirection;
1399 1403
1400 for (; node != block; node = node->parentNode()) { 1404 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) {
1401 if (!node->isStyledElement()) 1405 if (runner == block)
1406 break;
1407 if (!runner.isStyledElement())
1402 continue; 1408 continue;
1403 1409
1404 Element* element = toElement(node); 1410 Element* element = &toElement(runner);
1405 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create (element); 1411 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create (element);
1406 CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBid i); 1412 CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBid i);
1407 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1413 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1408 continue; 1414 continue;
1409 1415
1410 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue ID(); 1416 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue ID();
1411 if (unicodeBidiValue == CSSValueNormal) 1417 if (unicodeBidiValue == CSSValueNormal)
1412 continue; 1418 continue;
1413 1419
1414 if (unicodeBidiValue == CSSValueBidiOverride) 1420 if (unicodeBidiValue == CSSValueBidiOverride)
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 { 1727 {
1722 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1728 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1723 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration ::create(ancestor); 1729 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration ::create(ancestor);
1724 if (!hasTransparentBackgroundColor(ancestorStyle)) 1730 if (!hasTransparentBackgroundColor(ancestorStyle))
1725 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1731 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1726 } 1732 }
1727 return nullptr; 1733 return nullptr;
1728 } 1734 }
1729 1735
1730 } // namespace blink 1736 } // namespace blink
OLDNEW
« 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