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