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

Side by Side Diff: Source/core/editing/EditingStyle.cpp

Issue 20262002: [css3-text] Implement text-decoration property shorthand (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Julien's 2nd round review fixes Created 7 years, 4 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 | Annotate | Revision Log
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "core/html/HTMLFontElement.h" 51 #include "core/html/HTMLFontElement.h"
52 #include "core/page/Frame.h" 52 #include "core/page/Frame.h"
53 #include "core/page/RuntimeCSSEnabled.h" 53 #include "core/page/RuntimeCSSEnabled.h"
54 #include "core/rendering/style/RenderStyle.h" 54 #include "core/rendering/style/RenderStyle.h"
55 55
56 namespace WebCore { 56 namespace WebCore {
57 57
58 // Editing style properties must be preserved during editing operation. 58 // Editing style properties must be preserved during editing operation.
59 // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph. 59 // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph.
60 // NOTE: Use editingProperties() to respect runtime enabling of properties. 60 // NOTE: Use editingProperties() to respect runtime enabling of properties.
61 static const unsigned nonInheritedStaticPropertiesCount = 2; 61 static const unsigned nonInheritedStaticPropertiesCount = 3;
62 62
63 static const CSSPropertyID staticEditingProperties[] = { 63 static const CSSPropertyID staticEditingProperties[] = {
64 // NOTE: inheritableEditingProperties depends on these two properties being first. 64 // NOTE: inheritableEditingProperties depends on these properties being firs t.
65 // If you change this list, make sure to update nonInheritedPropertyCount. 65 // If you change this list, make sure to update nonInheritedPropertyCount.
66 CSSPropertyBackgroundColor, 66 CSSPropertyBackgroundColor,
67 // FIXME: CSSPropertyTextDecoration needs to be removed when CSS3 Text
68 // Decoration feature is no longer experimental (behind a flag).
67 CSSPropertyTextDecoration, 69 CSSPropertyTextDecoration,
70 CSSPropertyTextDecorationLine,
68 71
69 // CSS inheritable properties 72 // CSS inheritable properties
70 CSSPropertyColor, 73 CSSPropertyColor,
71 CSSPropertyFontFamily, 74 CSSPropertyFontFamily,
72 CSSPropertyFontSize, 75 CSSPropertyFontSize,
73 CSSPropertyFontStyle, 76 CSSPropertyFontStyle,
74 CSSPropertyFontVariant, 77 CSSPropertyFontVariant,
75 CSSPropertyFontWeight, 78 CSSPropertyFontWeight,
76 CSSPropertyLetterSpacing, 79 CSSPropertyLetterSpacing,
77 CSSPropertyLineHeight, 80 CSSPropertyLineHeight,
78 CSSPropertyOrphans, 81 CSSPropertyOrphans,
79 CSSPropertyTextAlign, 82 CSSPropertyTextAlign,
80 CSSPropertyTextIndent, 83 CSSPropertyTextIndent,
81 CSSPropertyTextTransform, 84 CSSPropertyTextTransform,
82 CSSPropertyWhiteSpace, 85 CSSPropertyWhiteSpace,
83 CSSPropertyWidows, 86 CSSPropertyWidows,
84 CSSPropertyWordSpacing, 87 CSSPropertyWordSpacing,
85 CSSPropertyWebkitTextDecorationsInEffect, 88 CSSPropertyWebkitTextDecorationsInEffect,
86 CSSPropertyWebkitTextFillColor, 89 CSSPropertyWebkitTextFillColor,
87 CSSPropertyWebkitTextStrokeColor, 90 CSSPropertyWebkitTextStrokeColor,
88 CSSPropertyWebkitTextStrokeWidth, 91 CSSPropertyWebkitTextStrokeWidth,
89 }; 92 };
90 93
91 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies }; 94 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies };
92 95
93 static const Vector<CSSPropertyID>& allEditingProperties() 96 static const Vector<CSSPropertyID>& allEditingProperties()
94 { 97 {
95 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); 98 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
96 if (properties.isEmpty()) 99 if (properties.isEmpty()) {
97 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); 100 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties);
101 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
102 properties.remove(properties.find(CSSPropertyTextDecoration));
103 }
104 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled() && !properties.c ontains(CSSPropertyTextDecoration));
Julien - ping for review 2013/07/30 22:37:22 Won't this ASSERT will trigger on Chrome if you di
abinader 2013/07/31 21:24:03 Oh, dumb me. Indeed... I also need to make the oth
98 return properties; 105 return properties;
99 } 106 }
100 107
101 static const Vector<CSSPropertyID>& inheritableEditingProperties() 108 static const Vector<CSSPropertyID>& inheritableEditingProperties()
102 { 109 {
103 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); 110 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
104 if (properties.isEmpty()) 111 if (properties.isEmpty())
105 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties); 112 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties);
106 return properties; 113 return properties;
107 } 114 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName )); 203 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName ));
197 } 204 }
198 virtual bool propertyExistsInStyle(const StylePropertySet*) const; 205 virtual bool propertyExistsInStyle(const StylePropertySet*) const;
199 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; 206 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const;
200 207
201 private: 208 private:
202 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName); 209 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName);
203 }; 210 };
204 211
205 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName) 212 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName)
206 : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) 213 : HTMLElementEquivalent(RuntimeEnabledFeatures::css3TextDecorationsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration, primitiveValue, ta gName)
207 // m_propertyID is used in HTMLElementEquivalent::addToStyle 214 // m_propertyID is used in HTMLElementEquivalent::addToStyle
208 { 215 {
209 } 216 }
210 217
211 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const 218 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const
212 { 219 {
220 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
221 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffe ct) || style->getPropertyCSSValue(CSSPropertyTextDecorationLine);
213 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration); 222 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration);
214 } 223 }
215 224
216 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style PropertySet* style) const 225 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style PropertySet* style) const
217 { 226 {
218 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect); 227 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect);
219 if (!styleValue) 228 if (!styleValue) {
220 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration); 229 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
230 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecorationLin e);
231 else
232 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration);
233 }
221 return matches(element) && styleValue && styleValue->isValueList() && static _cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get()); 234 return matches(element) && styleValue && styleValue->isValueList() && static _cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get());
222 } 235 }
223 236
224 class HTMLAttributeEquivalent : public HTMLElementEquivalent { 237 class HTMLAttributeEquivalent : public HTMLElementEquivalent {
225 public: 238 public:
226 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName) 239 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName)
227 { 240 {
228 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam e)); 241 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam e));
229 } 242 }
230 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) 243 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName)
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 656
644 void EditingStyle::collapseTextDecorationProperties() 657 void EditingStyle::collapseTextDecorationProperties()
645 { 658 {
646 if (!m_mutableStyle) 659 if (!m_mutableStyle)
647 return; 660 return;
648 661
649 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect); 662 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect);
650 if (!textDecorationsInEffect) 663 if (!textDecorationsInEffect)
651 return; 664 return;
652 665
653 if (textDecorationsInEffect->isValueList()) 666 if (textDecorationsInEffect->isValueList()) {
654 m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecorationsIn Effect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecoration )); 667 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
655 else 668 m_mutableStyle->setProperty(CSSPropertyTextDecorationLine, textDecor ationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDe corationLine));
656 m_mutableStyle->removeProperty(CSSPropertyTextDecoration); 669 else
670 m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecoratio nsInEffect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecora tion));
671 } else {
672 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
673 m_mutableStyle->removeProperty(CSSPropertyTextDecorationLine);
674 else
675 m_mutableStyle->removeProperty(CSSPropertyTextDecoration);
676 }
657 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 677 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
658 } 678 }
659 679
660 // CSS properties that create a visual difference only when applied to text. 680 // CSS properties that create a visual difference only when applied to text.
661 static const CSSPropertyID textOnlyProperties[] = { 681 static const CSSPropertyID textOnlyProperties[] = {
682 // FIXME: CSSPropertyTextDecoration needs to be removed when CSS3 Text
683 // Decoration feature is no longer experimental (behind a runtime flag).
662 CSSPropertyTextDecoration, 684 CSSPropertyTextDecoration,
685 CSSPropertyTextDecorationLine,
663 CSSPropertyWebkitTextDecorationsInEffect, 686 CSSPropertyWebkitTextDecorationsInEffect,
664 CSSPropertyFontStyle, 687 CSSPropertyFontStyle,
665 CSSPropertyFontWeight, 688 CSSPropertyFontWeight,
666 CSSPropertyColor, 689 CSSPropertyColor,
667 }; 690 };
668 691
669 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const 692 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const
670 { 693 {
671 if (!style || !style->m_mutableStyle) 694 if (!style || !style->m_mutableStyle)
672 return FalseTriState; 695 return FalseTriState;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 return false; 748 return false;
726 749
727 unsigned propertyCount = m_mutableStyle->propertyCount(); 750 unsigned propertyCount = m_mutableStyle->propertyCount();
728 for (unsigned i = 0; i < propertyCount; ++i) { 751 for (unsigned i = 0; i < propertyCount; ++i) {
729 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); 752 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id();
730 753
731 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space. 754 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space.
732 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) 755 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
733 continue; 756 continue;
734 757
735 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(CSSPropertyTextDecoration)) { 758 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect) {
736 if (!conflictingProperties) 759 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
737 return true; 760 if (inlineStyle->getPropertyCSSValue(CSSPropertyTextDecorationLi ne)) {
738 conflictingProperties->append(CSSPropertyTextDecoration); 761 if (!conflictingProperties)
739 if (extractedStyle) 762 return true;
740 extractedStyle->setProperty(CSSPropertyTextDecoration, inlineSty le->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportan t(CSSPropertyTextDecoration)); 763 conflictingProperties->append(CSSPropertyTextDecoration);
741 continue; 764 conflictingProperties->append(CSSPropertyTextDecorationLine) ;
765 if (extractedStyle)
766 extractedStyle->setProperty(CSSPropertyTextDecorationLin e, inlineStyle->getPropertyValue(CSSPropertyTextDecorationLine), inlineStyle->pr opertyIsImportant(CSSPropertyTextDecorationLine));
767 continue;
768 }
769 } else {
770 if (inlineStyle->getPropertyCSSValue(CSSPropertyTextDecoration)) {
771 if (!conflictingProperties)
772 return true;
773 conflictingProperties->append(CSSPropertyTextDecoration);
774 if (extractedStyle)
775 extractedStyle->setProperty(CSSPropertyTextDecoration, i nlineStyle->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIs Important(CSSPropertyTextDecoration));
776 continue;
777 }
Julien - ping for review 2013/07/30 22:37:22 These 2 branches are really the same if you had a
abinader 2013/07/31 21:24:03 Sounds good, I thought about it but wanted to high
778 }
742 } 779 }
743 780
744 if (!inlineStyle->getPropertyCSSValue(propertyID)) 781 if (!inlineStyle->getPropertyCSSValue(propertyID))
745 continue; 782 continue;
746 783
747 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV alue(CSSPropertyDirection)) { 784 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV alue(CSSPropertyDirection)) {
748 if (!conflictingProperties) 785 if (!conflictingProperties)
749 return true; 786 return true;
750 conflictingProperties->append(CSSPropertyDirection); 787 conflictingProperties->append(CSSPropertyDirection);
751 if (extractedStyle) 788 if (extractedStyle)
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 m_mutableStyle = style->mutableCopy(); 1108 m_mutableStyle = style->mutableCopy();
1072 return; 1109 return;
1073 } 1110 }
1074 1111
1075 unsigned propertyCount = style->propertyCount(); 1112 unsigned propertyCount = style->propertyCount();
1076 for (unsigned i = 0; i < propertyCount; ++i) { 1113 for (unsigned i = 0; i < propertyCount; ++i) {
1077 StylePropertySet::PropertyReference property = style->propertyAt(i); 1114 StylePropertySet::PropertyReference property = style->propertyAt(i);
1078 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ()); 1115 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ());
1079 1116
1080 // text decorations never override values 1117 // text decorations never override values
1081 if ((property.id() == CSSPropertyTextDecoration || property.id() == CSSP ropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && valu e) { 1118 bool isPropertyTextDecorationEquivalent = property.id() == CSSPropertyWe bkitTextDecorationsInEffect;
1119 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
1120 isPropertyTextDecorationEquivalent |= property.id() == CSSPropertyTe xtDecorationLine;
1121 else
1122 isPropertyTextDecorationEquivalent |= property.id() == CSSPropertyTe xtDecoration;
1123 if (isPropertyTextDecorationEquivalent && property.value()->isValueList( ) && value) {
1082 if (value->isValueList()) { 1124 if (value->isValueList()) {
1083 mergeTextDecorationValues(static_cast<CSSValueList*>(value.get() ), static_cast<CSSValueList*>(property.value())); 1125 mergeTextDecorationValues(static_cast<CSSValueList*>(value.get() ), static_cast<CSSValueList*>(property.value()));
1084 continue; 1126 continue;
1085 } 1127 }
1086 value = 0; // text-decoration: none is equivalent to not having the property 1128 value = 0; // text-decoration: none is equivalent to not having the property
1087 } 1129 }
1088 1130
1089 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) 1131 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value))
1090 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); 1132 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant());
1091 } 1133 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; 1369 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection;
1328 } 1370 }
1329 hasNestedOrMultipleEmbeddings = false; 1371 hasNestedOrMultipleEmbeddings = false;
1330 return foundDirection; 1372 return foundDirection;
1331 } 1373 }
1332 1374
1333 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) 1375 static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
1334 { 1376 {
1335 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect); 1377 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect);
1336 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration); 1378 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration);
1379 RefPtr<CSSValue> textDecorationLine = style->getPropertyCSSValue(CSSProperty TextDecorationLine);
1337 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. 1380 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense.
1338 ASSERT(!textDecorationsInEffect || !textDecoration); 1381 ASSERT(!textDecorationsInEffect || (!textDecoration || !textDecorationLine)) ;
1339 if (textDecorationsInEffect) { 1382 if (textDecorationsInEffect) {
1340 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->c ssText()); 1383 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
1384 style->setProperty(CSSPropertyTextDecorationLine, textDecorationsInE ffect->cssText());
1385 textDecorationLine = textDecorationsInEffect;
1386 } else {
1387 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffec t->cssText());
1388 textDecoration = textDecorationsInEffect;
1389 }
1341 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 1390 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
1342 textDecoration = textDecorationsInEffect;
1343 } 1391 }
1344 1392
1345 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". 1393 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none".
1346 if (textDecoration && !textDecoration->isValueList()) 1394 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
1347 style->removeProperty(CSSPropertyTextDecoration); 1395 if (textDecorationLine && !textDecorationLine->isValueList())
1396 style->removeProperty(CSSPropertyTextDecorationLine);
1397 } else {
1398 if (textDecoration && !textDecoration->isValueList())
1399 style->removeProperty(CSSPropertyTextDecoration);
1400 }
1348 } 1401 }
1349 1402
1350 StyleChange::StyleChange(EditingStyle* style, const Position& position) 1403 StyleChange::StyleChange(EditingStyle* style, const Position& position)
1351 : m_applyBold(false) 1404 : m_applyBold(false)
1352 , m_applyItalic(false) 1405 , m_applyItalic(false)
1353 , m_applyUnderline(false) 1406 , m_applyUnderline(false)
1354 , m_applyLineThrough(false) 1407 , m_applyLineThrough(false)
1355 , m_applySubscript(false) 1408 , m_applySubscript(false)
1356 , m_applySuperscript(false) 1409 , m_applySuperscript(false)
1357 { 1410 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1454 }
1402 1455
1403 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); 1456 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle);
1404 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { 1457 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) {
1405 style->removeProperty(CSSPropertyFontStyle); 1458 style->removeProperty(CSSPropertyFontStyle);
1406 m_applyItalic = true; 1459 m_applyItalic = true;
1407 } 1460 }
1408 1461
1409 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect 1462 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect
1410 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList. 1463 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList.
1411 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration); 1464 CSSPropertyID textDecorationProperty = RuntimeEnabledFeatures::css3TextDecor ationsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration;
1465 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP roperty);
1412 if (textDecoration && textDecoration->isValueList()) { 1466 if (textDecoration && textDecoration->isValueList()) {
1413 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV alue::createIdentifier(CSSValueUnderline))); 1467 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV alue::createIdentifier(CSSValueUnderline)));
1414 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv eValue::createIdentifier(CSSValueLineThrough))); 1468 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv eValue::createIdentifier(CSSValueLineThrough)));
1415 1469
1416 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(text Decoration.get())->copy(); 1470 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(text Decoration.get())->copy();
1417 if (newTextDecoration->removeAll(underline.get())) 1471 if (newTextDecoration->removeAll(underline.get()))
1418 m_applyUnderline = true; 1472 m_applyUnderline = true;
1419 if (newTextDecoration->removeAll(lineThrough.get())) 1473 if (newTextDecoration->removeAll(lineThrough.get()))
1420 m_applyLineThrough = true; 1474 m_applyLineThrough = true;
1421 1475
1422 // If trimTextDecorations, delete underline and line-through 1476 // If trimTextDecorations, delete underline and line-through
1423 setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTex tDecoration); 1477 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration Property);
1424 } 1478 }
1425 1479
1426 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); 1480 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign);
1427 switch (verticalAlign) { 1481 switch (verticalAlign) {
1428 case CSSValueSub: 1482 case CSSValueSub:
1429 style->removeProperty(CSSPropertyVerticalAlign); 1483 style->removeProperty(CSSPropertyVerticalAlign);
1430 m_applySubscript = true; 1484 m_applySubscript = true;
1431 break; 1485 break;
1432 case CSSValueSuper: 1486 case CSSValueSuper:
1433 style->removeProperty(CSSPropertyVerticalAlign); 1487 style->removeProperty(CSSPropertyVerticalAlign);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 1572
1519 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) 1573 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle)
1520 { 1574 {
1521 ASSERT(styleWithRedundantProperties); 1575 ASSERT(styleWithRedundantProperties);
1522 ASSERT(baseStyle); 1576 ASSERT(baseStyle);
1523 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); 1577 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy();
1524 1578
1525 result->removeEquivalentProperties(baseStyle); 1579 result->removeEquivalentProperties(baseStyle);
1526 1580
1527 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); 1581 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect);
1528 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat ionsInEffect.get()); 1582 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
1583 diffTextDecorations(result.get(), CSSPropertyTextDecorationLine, baseTex tDecorationsInEffect.get());
1584 else
1585 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDec orationsInEffect.get());
1529 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); 1586 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
1530 1587
1531 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) 1588 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle))
1532 result->removeProperty(CSSPropertyFontWeight); 1589 result->removeProperty(CSSPropertyFontWeight);
1533 1590
1534 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) 1591 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle))
1535 result->removeProperty(CSSPropertyColor); 1592 result->removeProperty(CSSPropertyColor);
1536 1593
1537 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) 1594 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign)
1538 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) 1595 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle))
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 { 1673 {
1617 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1674 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1618 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); 1675 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1619 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1676 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1620 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1677 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1621 } 1678 }
1622 return 0; 1679 return 0;
1623 } 1680 }
1624 1681
1625 } 1682 }
OLDNEW
« Source/core/css/CSSParser-in.cpp ('K') | « Source/core/css/CSSShorthands.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698