OLD | NEW |
---|---|
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 #include "core/editing/FrameSelection.h" | 48 #include "core/editing/FrameSelection.h" |
49 #include "core/editing/HTMLInterchange.h" | 49 #include "core/editing/HTMLInterchange.h" |
50 #include "core/editing/htmlediting.h" | 50 #include "core/editing/htmlediting.h" |
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 // FIXME: Text decoration property to be used based on runtime feature check. | |
59 // Needs to be removed when CSS3 Text Decoration is no longer experimental. | |
Julien - ping for review
2013/08/02 23:22:13
I don't think this comment adds much value: it's f
abinader
2013/08/05 22:51:14
Ack.
| |
60 static const CSSPropertyID& runtimeTextDecorationProperty() | |
Julien - ping for review
2013/08/02 23:22:13
How about textDecorationLine()? (this matches what
abinader
2013/08/05 22:51:14
Right, textDecorationPropertyForEditing() sounds g
| |
61 { | |
62 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; | |
63 return property; | |
64 } | |
65 | |
58 // Editing style properties must be preserved during editing operation. | 66 // 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. | 67 // 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. | 68 // NOTE: Use editingProperties() to respect runtime enabling of properties. |
61 static const unsigned nonInheritedStaticPropertiesCount = 2; | 69 static const unsigned nonInheritedStaticPropertiesCount = 2; |
62 | 70 |
63 static const CSSPropertyID staticEditingProperties[] = { | 71 static const CSSPropertyID staticEditingProperties[] = { |
64 // NOTE: inheritableEditingProperties depends on these two properties being first. | 72 // NOTE: inheritableEditingProperties depends on these properties being firs t. |
65 // If you change this list, make sure to update nonInheritedPropertyCount. | 73 // If you change this list, make sure to update nonInheritedPropertyCount. |
Julien - ping for review
2013/08/02 23:22:13
I missed that: nonInheritPropertyCount should stil
abinader
2013/08/05 22:51:14
I wasn't planning on modifying the nonInheritedSta
| |
66 CSSPropertyBackgroundColor, | 74 CSSPropertyBackgroundColor, |
75 // FIXME: CSSPropertyTextDecoration needs to be removed when CSS3 Text | |
76 // Decoration feature is no longer experimental. | |
67 CSSPropertyTextDecoration, | 77 CSSPropertyTextDecoration, |
78 CSSPropertyTextDecorationLine, | |
68 | 79 |
69 // CSS inheritable properties | 80 // CSS inheritable properties |
70 CSSPropertyColor, | 81 CSSPropertyColor, |
71 CSSPropertyFontFamily, | 82 CSSPropertyFontFamily, |
72 CSSPropertyFontSize, | 83 CSSPropertyFontSize, |
73 CSSPropertyFontStyle, | 84 CSSPropertyFontStyle, |
74 CSSPropertyFontVariant, | 85 CSSPropertyFontVariant, |
75 CSSPropertyFontWeight, | 86 CSSPropertyFontWeight, |
76 CSSPropertyLetterSpacing, | 87 CSSPropertyLetterSpacing, |
77 CSSPropertyLineHeight, | 88 CSSPropertyLineHeight, |
78 CSSPropertyOrphans, | 89 CSSPropertyOrphans, |
79 CSSPropertyTextAlign, | 90 CSSPropertyTextAlign, |
80 CSSPropertyTextIndent, | 91 CSSPropertyTextIndent, |
81 CSSPropertyTextTransform, | 92 CSSPropertyTextTransform, |
82 CSSPropertyWhiteSpace, | 93 CSSPropertyWhiteSpace, |
83 CSSPropertyWidows, | 94 CSSPropertyWidows, |
84 CSSPropertyWordSpacing, | 95 CSSPropertyWordSpacing, |
85 CSSPropertyWebkitTextDecorationsInEffect, | 96 CSSPropertyWebkitTextDecorationsInEffect, |
86 CSSPropertyWebkitTextFillColor, | 97 CSSPropertyWebkitTextFillColor, |
87 CSSPropertyWebkitTextStrokeColor, | 98 CSSPropertyWebkitTextStrokeColor, |
88 CSSPropertyWebkitTextStrokeWidth, | 99 CSSPropertyWebkitTextStrokeWidth, |
89 }; | 100 }; |
90 | 101 |
91 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies }; | 102 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies }; |
92 | 103 |
93 static const Vector<CSSPropertyID>& allEditingProperties() | 104 static const Vector<CSSPropertyID>& allEditingProperties() |
94 { | 105 { |
95 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 106 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
96 if (properties.isEmpty()) | 107 if (properties.isEmpty()) { |
97 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); | 108 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); |
109 // This ensures we have only one of these properties on the vector. | |
110 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | |
111 properties.remove(properties.find(CSSPropertyTextDecoration)); | |
112 else | |
113 properties.remove(properties.find(CSSPropertyTextDecorationLine)); | |
114 } | |
115 ASSERT((RuntimeEnabledFeatures::css3TextDecorationsEnabled() && !properties. contains(CSSPropertyTextDecoration)) | |
116 || (!RuntimeEnabledFeatures::css3TextDecorationsEnabled() && properties. contains(CSSPropertyTextDecoration))); | |
Julien - ping for review
2013/08/02 23:22:13
This would be better off written:
#ifndef NDEBUG
abinader
2013/08/05 22:51:14
I guess you're right, this looks too trivial and t
| |
98 return properties; | 117 return properties; |
99 } | 118 } |
100 | 119 |
101 static const Vector<CSSPropertyID>& inheritableEditingProperties() | 120 static const Vector<CSSPropertyID>& inheritableEditingProperties() |
102 { | 121 { |
103 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 122 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
104 if (properties.isEmpty()) | 123 if (properties.isEmpty()) |
105 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties); | 124 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties); |
106 return properties; | 125 return properties; |
107 } | 126 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName )); | 215 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName )); |
197 } | 216 } |
198 virtual bool propertyExistsInStyle(const StylePropertySet*) const; | 217 virtual bool propertyExistsInStyle(const StylePropertySet*) const; |
199 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; | 218 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; |
200 | 219 |
201 private: | 220 private: |
202 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName); | 221 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName); |
203 }; | 222 }; |
204 | 223 |
205 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName) | 224 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName) |
206 : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) | 225 : HTMLElementEquivalent(runtimeTextDecorationProperty(), primitiveValue, tag Name) |
207 // m_propertyID is used in HTMLElementEquivalent::addToStyle | 226 // m_propertyID is used in HTMLElementEquivalent::addToStyle |
208 { | 227 { |
209 } | 228 } |
210 | 229 |
211 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const | 230 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const |
212 { | 231 { |
213 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration); | 232 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) |
233 || style->getPropertyCSSValue(runtimeTextDecorationProperty()); | |
214 } | 234 } |
215 | 235 |
216 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style PropertySet* style) const | 236 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style PropertySet* style) const |
217 { | 237 { |
218 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect); | 238 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect); |
219 if (!styleValue) | 239 if (!styleValue) |
220 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration); | 240 styleValue = style->getPropertyCSSValue(runtimeTextDecorationProperty()) ; |
221 return matches(element) && styleValue && styleValue->isValueList() && static _cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get()); | 241 return matches(element) && styleValue && styleValue->isValueList() && static _cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get()); |
222 } | 242 } |
223 | 243 |
224 class HTMLAttributeEquivalent : public HTMLElementEquivalent { | 244 class HTMLAttributeEquivalent : public HTMLElementEquivalent { |
225 public: | 245 public: |
226 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName) | 246 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName) |
227 { | 247 { |
228 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam e)); | 248 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam e)); |
229 } | 249 } |
230 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) | 250 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 void EditingStyle::collapseTextDecorationProperties() | 664 void EditingStyle::collapseTextDecorationProperties() |
645 { | 665 { |
646 if (!m_mutableStyle) | 666 if (!m_mutableStyle) |
647 return; | 667 return; |
648 | 668 |
649 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect); | 669 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect); |
650 if (!textDecorationsInEffect) | 670 if (!textDecorationsInEffect) |
651 return; | 671 return; |
652 | 672 |
653 if (textDecorationsInEffect->isValueList()) | 673 if (textDecorationsInEffect->isValueList()) |
654 m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecorationsIn Effect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecoration )); | 674 m_mutableStyle->setProperty(runtimeTextDecorationProperty(), textDecorat ionsInEffect->cssText(), m_mutableStyle->propertyIsImportant(runtimeTextDecorati onProperty())); |
655 else | 675 else |
656 m_mutableStyle->removeProperty(CSSPropertyTextDecoration); | 676 m_mutableStyle->removeProperty(runtimeTextDecorationProperty()); |
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. | |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 return false; | 752 return false; |
730 | 753 |
731 unsigned propertyCount = m_mutableStyle->propertyCount(); | 754 unsigned propertyCount = m_mutableStyle->propertyCount(); |
732 for (unsigned i = 0; i < propertyCount; ++i) { | 755 for (unsigned i = 0; i < propertyCount; ++i) { |
733 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); | 756 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); |
734 | 757 |
735 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space. | 758 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space. |
736 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) | 759 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) |
737 continue; | 760 continue; |
738 | 761 |
739 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(CSSPropertyTextDecoration)) { | 762 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(runtimeTextDecorationProperty())) { |
740 if (!conflictingProperties) | 763 if (!conflictingProperties) |
741 return true; | 764 return true; |
742 conflictingProperties->append(CSSPropertyTextDecoration); | 765 conflictingProperties->append(CSSPropertyTextDecoration); |
766 // Because text-decoration expands to text-decoration-line when CSS3 | |
767 // Text Decoration is enabled, we also state it as conflicting. | |
768 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | |
769 conflictingProperties->append(CSSPropertyTextDecorationLine); | |
743 if (extractedStyle) | 770 if (extractedStyle) |
744 extractedStyle->setProperty(CSSPropertyTextDecoration, inlineSty le->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportan t(CSSPropertyTextDecoration)); | 771 extractedStyle->setProperty(runtimeTextDecorationProperty(), inl ineStyle->getPropertyValue(runtimeTextDecorationProperty()), inlineStyle->proper tyIsImportant(runtimeTextDecorationProperty())); |
745 continue; | 772 continue; |
746 } | 773 } |
747 | 774 |
748 if (!inlineStyle->getPropertyCSSValue(propertyID)) | 775 if (!inlineStyle->getPropertyCSSValue(propertyID)) |
749 continue; | 776 continue; |
750 | 777 |
751 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV alue(CSSPropertyDirection)) { | 778 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV alue(CSSPropertyDirection)) { |
752 if (!conflictingProperties) | 779 if (!conflictingProperties) |
753 return true; | 780 return true; |
754 conflictingProperties->append(CSSPropertyDirection); | 781 conflictingProperties->append(CSSPropertyDirection); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1075 m_mutableStyle = style->mutableCopy(); | 1102 m_mutableStyle = style->mutableCopy(); |
1076 return; | 1103 return; |
1077 } | 1104 } |
1078 | 1105 |
1079 unsigned propertyCount = style->propertyCount(); | 1106 unsigned propertyCount = style->propertyCount(); |
1080 for (unsigned i = 0; i < propertyCount; ++i) { | 1107 for (unsigned i = 0; i < propertyCount; ++i) { |
1081 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1108 StylePropertySet::PropertyReference property = style->propertyAt(i); |
1082 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ()); | 1109 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ()); |
1083 | 1110 |
1084 // text decorations never override values | 1111 // text decorations never override values |
1085 if ((property.id() == CSSPropertyTextDecoration || property.id() == CSSP ropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && valu e) { | 1112 if ((property.id() == runtimeTextDecorationProperty() || property.id() = = CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() & & value) { |
1086 if (value->isValueList()) { | 1113 if (value->isValueList()) { |
1087 mergeTextDecorationValues(static_cast<CSSValueList*>(value.get() ), static_cast<CSSValueList*>(property.value())); | 1114 mergeTextDecorationValues(static_cast<CSSValueList*>(value.get() ), static_cast<CSSValueList*>(property.value())); |
1088 continue; | 1115 continue; |
1089 } | 1116 } |
1090 value = 0; // text-decoration: none is equivalent to not having the property | 1117 value = 0; // text-decoration: none is equivalent to not having the property |
1091 } | 1118 } |
1092 | 1119 |
1093 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) | 1120 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) |
1094 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); | 1121 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); |
1095 } | 1122 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1330 | 1357 |
1331 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; | 1358 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; |
1332 } | 1359 } |
1333 hasNestedOrMultipleEmbeddings = false; | 1360 hasNestedOrMultipleEmbeddings = false; |
1334 return foundDirection; | 1361 return foundDirection; |
1335 } | 1362 } |
1336 | 1363 |
1337 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) | 1364 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
1338 { | 1365 { |
1339 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect); | 1366 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect); |
1340 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration); | 1367 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(runtimeTextDeco rationProperty()); |
1341 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. | 1368 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. |
1342 ASSERT(!textDecorationsInEffect || !textDecoration); | 1369 ASSERT(!textDecorationsInEffect || !textDecoration); |
1343 if (textDecorationsInEffect) { | 1370 if (textDecorationsInEffect) { |
1344 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->c ssText()); | 1371 style->setProperty(runtimeTextDecorationProperty(), textDecorationsInEff ect->cssText()); |
1345 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1372 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
1346 textDecoration = textDecorationsInEffect; | 1373 textDecoration = textDecorationsInEffect; |
1347 } | 1374 } |
1348 | 1375 |
1349 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". | 1376 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". |
1350 if (textDecoration && !textDecoration->isValueList()) | 1377 if (textDecoration && !textDecoration->isValueList()) |
1351 style->removeProperty(CSSPropertyTextDecoration); | 1378 style->removeProperty(runtimeTextDecorationProperty()); |
1352 } | 1379 } |
1353 | 1380 |
1354 StyleChange::StyleChange(EditingStyle* style, const Position& position) | 1381 StyleChange::StyleChange(EditingStyle* style, const Position& position) |
1355 : m_applyBold(false) | 1382 : m_applyBold(false) |
1356 , m_applyItalic(false) | 1383 , m_applyItalic(false) |
1357 , m_applyUnderline(false) | 1384 , m_applyUnderline(false) |
1358 , m_applyLineThrough(false) | 1385 , m_applyLineThrough(false) |
1359 , m_applySubscript(false) | 1386 , m_applySubscript(false) |
1360 , m_applySuperscript(false) | 1387 , m_applySuperscript(false) |
1361 { | 1388 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1405 } | 1432 } |
1406 | 1433 |
1407 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1434 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
1408 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1435 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
1409 style->removeProperty(CSSPropertyFontStyle); | 1436 style->removeProperty(CSSPropertyFontStyle); |
1410 m_applyItalic = true; | 1437 m_applyItalic = true; |
1411 } | 1438 } |
1412 | 1439 |
1413 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect | 1440 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect |
1414 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList. | 1441 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList. |
1415 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration); | 1442 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(runtimeTextDeco rationProperty()); |
1416 if (textDecoration && textDecoration->isValueList()) { | 1443 if (textDecoration && textDecoration->isValueList()) { |
1417 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV alue::createIdentifier(CSSValueUnderline))); | 1444 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV alue::createIdentifier(CSSValueUnderline))); |
1418 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv eValue::createIdentifier(CSSValueLineThrough))); | 1445 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv eValue::createIdentifier(CSSValueLineThrough))); |
1419 | 1446 |
1420 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(text Decoration.get())->copy(); | 1447 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(text Decoration.get())->copy(); |
1421 if (newTextDecoration->removeAll(underline.get())) | 1448 if (newTextDecoration->removeAll(underline.get())) |
1422 m_applyUnderline = true; | 1449 m_applyUnderline = true; |
1423 if (newTextDecoration->removeAll(lineThrough.get())) | 1450 if (newTextDecoration->removeAll(lineThrough.get())) |
1424 m_applyLineThrough = true; | 1451 m_applyLineThrough = true; |
1425 | 1452 |
1426 // If trimTextDecorations, delete underline and line-through | 1453 // If trimTextDecorations, delete underline and line-through |
1427 setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTex tDecoration); | 1454 setTextDecorationProperty(style, newTextDecoration.get(), runtimeTextDec orationProperty()); |
1428 } | 1455 } |
1429 | 1456 |
1430 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); | 1457 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); |
1431 switch (verticalAlign) { | 1458 switch (verticalAlign) { |
1432 case CSSValueSub: | 1459 case CSSValueSub: |
1433 style->removeProperty(CSSPropertyVerticalAlign); | 1460 style->removeProperty(CSSPropertyVerticalAlign); |
1434 m_applySubscript = true; | 1461 m_applySubscript = true; |
1435 break; | 1462 break; |
1436 case CSSValueSuper: | 1463 case CSSValueSuper: |
1437 style->removeProperty(CSSPropertyVerticalAlign); | 1464 style->removeProperty(CSSPropertyVerticalAlign); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1522 | 1549 |
1523 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) | 1550 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) |
1524 { | 1551 { |
1525 ASSERT(styleWithRedundantProperties); | 1552 ASSERT(styleWithRedundantProperties); |
1526 ASSERT(baseStyle); | 1553 ASSERT(baseStyle); |
1527 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); | 1554 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); |
1528 | 1555 |
1529 result->removeEquivalentProperties(baseStyle); | 1556 result->removeEquivalentProperties(baseStyle); |
1530 | 1557 |
1531 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1558 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
1532 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat ionsInEffect.get()); | 1559 diffTextDecorations(result.get(), runtimeTextDecorationProperty(), baseTextD ecorationsInEffect.get()); |
1533 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); | 1560 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); |
1534 | 1561 |
1535 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) | 1562 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) |
1536 result->removeProperty(CSSPropertyFontWeight); | 1563 result->removeProperty(CSSPropertyFontWeight); |
1537 | 1564 |
1538 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) | 1565 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) |
1539 result->removeProperty(CSSPropertyColor); | 1566 result->removeProperty(CSSPropertyColor); |
1540 | 1567 |
1541 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1568 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
1542 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) | 1569 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1620 { | 1647 { |
1621 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1648 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1622 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); | 1649 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); |
1623 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1650 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1624 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); | 1651 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); |
1625 } | 1652 } |
1626 return 0; | 1653 return 0; |
1627 } | 1654 } |
1628 | 1655 |
1629 } | 1656 } |
OLD | NEW |