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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 CSSPropertyTextDecoration, | 67 CSSPropertyTextDecoration, |
| 68 CSSPropertyTextDecorationLine, | |
| 68 | 69 |
| 69 // CSS inheritable properties | 70 // CSS inheritable properties |
| 70 CSSPropertyColor, | 71 CSSPropertyColor, |
| 71 CSSPropertyFontFamily, | 72 CSSPropertyFontFamily, |
| 72 CSSPropertyFontSize, | 73 CSSPropertyFontSize, |
| 73 CSSPropertyFontStyle, | 74 CSSPropertyFontStyle, |
| 74 CSSPropertyFontVariant, | 75 CSSPropertyFontVariant, |
| 75 CSSPropertyFontWeight, | 76 CSSPropertyFontWeight, |
| 76 CSSPropertyLetterSpacing, | 77 CSSPropertyLetterSpacing, |
| 77 CSSPropertyLineHeight, | 78 CSSPropertyLineHeight, |
| 78 CSSPropertyOrphans, | 79 CSSPropertyOrphans, |
| 79 CSSPropertyTextAlign, | 80 CSSPropertyTextAlign, |
| 80 CSSPropertyTextIndent, | 81 CSSPropertyTextIndent, |
| 81 CSSPropertyTextTransform, | 82 CSSPropertyTextTransform, |
| 82 CSSPropertyWhiteSpace, | 83 CSSPropertyWhiteSpace, |
| 83 CSSPropertyWidows, | 84 CSSPropertyWidows, |
| 84 CSSPropertyWordSpacing, | 85 CSSPropertyWordSpacing, |
| 85 CSSPropertyWebkitTextDecorationsInEffect, | 86 CSSPropertyWebkitTextDecorationsInEffect, |
| 86 CSSPropertyWebkitTextFillColor, | 87 CSSPropertyWebkitTextFillColor, |
| 87 CSSPropertyWebkitTextStrokeColor, | 88 CSSPropertyWebkitTextStrokeColor, |
| 88 CSSPropertyWebkitTextStrokeWidth, | 89 CSSPropertyWebkitTextStrokeWidth, |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies }; | 92 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies }; |
| 92 | 93 |
| 93 static const Vector<CSSPropertyID>& allEditingProperties() | 94 static const Vector<CSSPropertyID>& allEditingProperties() |
| 94 { | 95 { |
| 95 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 96 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
| 96 if (properties.isEmpty()) | 97 if (properties.isEmpty()) { |
| 97 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); | 98 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); |
| 99 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | |
| 100 properties.remove(properties.find(CSSPropertyTextDecoration)); | |
| 101 } | |
| 98 return properties; | 102 return properties; |
| 99 } | 103 } |
| 100 | 104 |
| 101 static const Vector<CSSPropertyID>& inheritableEditingProperties() | 105 static const Vector<CSSPropertyID>& inheritableEditingProperties() |
| 102 { | 106 { |
| 103 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 107 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
| 104 if (properties.isEmpty()) | 108 if (properties.isEmpty()) |
| 105 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties); | 109 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties); |
| 106 return properties; | 110 return properties; |
| 107 } | 111 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName )); | 200 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName )); |
| 197 } | 201 } |
| 198 virtual bool propertyExistsInStyle(const StylePropertySet*) const; | 202 virtual bool propertyExistsInStyle(const StylePropertySet*) const; |
| 199 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; | 203 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; |
| 200 | 204 |
| 201 private: | 205 private: |
| 202 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName); | 206 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName); |
| 203 }; | 207 }; |
| 204 | 208 |
| 205 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName) | 209 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName) |
| 206 : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) | 210 : HTMLElementEquivalent(RuntimeEnabledFeatures::css3TextDecorationsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration, primitiveValue, ta gName) |
| 207 // m_propertyID is used in HTMLElementEquivalent::addToStyle | 211 // m_propertyID is used in HTMLElementEquivalent::addToStyle |
| 208 { | 212 { |
| 209 } | 213 } |
| 210 | 214 |
| 211 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const | 215 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const |
| 212 { | 216 { |
| 217 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | |
| 218 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffe ct) || style->getPropertyCSSValue(CSSPropertyTextDecorationLine); | |
| 213 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration); | 219 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration); |
| 214 } | 220 } |
| 215 | 221 |
| 216 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style PropertySet* style) const | 222 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style PropertySet* style) const |
| 217 { | 223 { |
| 218 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect); | 224 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect); |
| 219 if (!styleValue) | 225 if (!styleValue) { |
| 220 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration); | 226 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
| 227 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecorationLin e); | |
| 228 else | |
| 229 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration); | |
| 230 } | |
| 221 return matches(element) && styleValue && styleValue->isValueList() && static _cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get()); | 231 return matches(element) && styleValue && styleValue->isValueList() && static _cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get()); |
| 222 } | 232 } |
| 223 | 233 |
| 224 class HTMLAttributeEquivalent : public HTMLElementEquivalent { | 234 class HTMLAttributeEquivalent : public HTMLElementEquivalent { |
| 225 public: | 235 public: |
| 226 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName) | 236 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName) |
| 227 { | 237 { |
| 228 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam e)); | 238 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam e)); |
| 229 } | 239 } |
| 230 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) | 240 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 node = tabSpanNode(node)->parentNode(); | 444 node = tabSpanNode(node)->parentNode(); |
| 435 else if (isTabSpanNode(node)) | 445 else if (isTabSpanNode(node)) |
| 436 node = node->parentNode(); | 446 node = node->parentNode(); |
| 437 | 447 |
| 438 RefPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CSSComputedSty leDeclaration::create(node); | 448 RefPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CSSComputedSty leDeclaration::create(node); |
| 439 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition); | 449 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition); |
| 440 | 450 |
| 441 if (propertiesToInclude == EditingPropertiesInEffect) { | 451 if (propertiesToInclude == EditingPropertiesInEffect) { |
| 442 if (RefPtr<CSSValue> value = backgroundColorInEffect(node)) | 452 if (RefPtr<CSSValue> value = backgroundColorInEffect(node)) |
| 443 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); | 453 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); |
| 444 if (RefPtr<CSSValue> value = computedStyleAtPosition->getPropertyCSSValu e(CSSPropertyWebkitTextDecorationsInEffect)) | 454 if (RefPtr<CSSValue> value = computedStyleAtPosition->getPropertyCSSValu e(CSSPropertyWebkitTextDecorationsInEffect)) { |
| 445 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); | 455 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); |
| 456 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | |
| 457 m_mutableStyle->setProperty(CSSPropertyTextDecorationLine, value ->cssText()); | |
| 458 } | |
| 446 } | 459 } |
| 447 | 460 |
| 448 if (node && node->computedStyle()) { | 461 if (node && node->computedStyle()) { |
| 449 RenderStyle* renderStyle = node->computedStyle(); | 462 RenderStyle* renderStyle = node->computedStyle(); |
| 450 removeTextFillAndStrokeColorsIfNeeded(renderStyle); | 463 removeTextFillAndStrokeColorsIfNeeded(renderStyle); |
| 451 replaceFontSizeByKeywordIfPossible(renderStyle, computedStyleAtPosition. get()); | 464 replaceFontSizeByKeywordIfPossible(renderStyle, computedStyleAtPosition. get()); |
| 452 } | 465 } |
| 453 | 466 |
| 454 m_shouldUseFixedDefaultFontSize = computedStyleAtPosition->useFixedFontDefau ltSize(); | 467 m_shouldUseFixedDefaultFontSize = computedStyleAtPosition->useFixedFontDefau ltSize(); |
| 455 extractFontSizeDelta(); | 468 extractFontSizeDelta(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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)); |
| 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); | |
| 656 m_mutableStyle->removeProperty(CSSPropertyTextDecoration); | 674 m_mutableStyle->removeProperty(CSSPropertyTextDecoration); |
| 675 } | |
| 657 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 676 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 658 } | 677 } |
| 659 | 678 |
| 660 // CSS properties that create a visual difference only when applied to text. | 679 // CSS properties that create a visual difference only when applied to text. |
| 661 static const CSSPropertyID textOnlyProperties[] = { | 680 static const CSSPropertyID textOnlyProperties[] = { |
| 662 CSSPropertyTextDecoration, | 681 CSSPropertyTextDecoration, |
| 682 CSSPropertyTextDecorationLine, | |
| 663 CSSPropertyWebkitTextDecorationsInEffect, | 683 CSSPropertyWebkitTextDecorationsInEffect, |
| 664 CSSPropertyFontStyle, | 684 CSSPropertyFontStyle, |
| 665 CSSPropertyFontWeight, | 685 CSSPropertyFontWeight, |
| 666 CSSPropertyColor, | 686 CSSPropertyColor, |
| 667 }; | 687 }; |
| 668 | 688 |
| 669 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const | 689 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const |
| 670 { | 690 { |
| 671 if (!style || !style->m_mutableStyle) | 691 if (!style || !style->m_mutableStyle) |
| 672 return FalseTriState; | 692 return FalseTriState; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 return false; | 745 return false; |
| 726 | 746 |
| 727 unsigned propertyCount = m_mutableStyle->propertyCount(); | 747 unsigned propertyCount = m_mutableStyle->propertyCount(); |
| 728 for (unsigned i = 0; i < propertyCount; ++i) { | 748 for (unsigned i = 0; i < propertyCount; ++i) { |
| 729 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); | 749 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); |
| 730 | 750 |
| 731 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space. | 751 // 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)) | 752 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) |
| 733 continue; | 753 continue; |
| 734 | 754 |
| 735 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(CSSPropertyTextDecoration)) { | 755 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect) { |
| 736 if (!conflictingProperties) | 756 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) { |
| 737 return true; | 757 RefPtr<CSSValue> textDecorationLine = inlineStyle->getPropertyCS SValue(CSSPropertyTextDecorationLine); |
| 738 conflictingProperties->append(CSSPropertyTextDecoration); | 758 if (textDecorationLine) { |
| 739 if (extractedStyle) | 759 if (!conflictingProperties) |
| 740 extractedStyle->setProperty(CSSPropertyTextDecoration, inlineSty le->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportan t(CSSPropertyTextDecoration)); | 760 return true; |
| 741 continue; | 761 conflictingProperties->append(CSSPropertyTextDecoration); |
| 762 conflictingProperties->append(CSSPropertyTextDecorationLine) ; | |
| 763 if (extractedStyle) | |
| 764 extractedStyle->setProperty(CSSPropertyTextDecorationLin e, inlineStyle->getPropertyValue(CSSPropertyTextDecorationLine), inlineStyle->pr opertyIsImportant(CSSPropertyTextDecorationLine)); | |
| 765 continue; | |
| 766 } | |
| 767 } else { | |
| 768 RefPtr<CSSValue> textDecoration = inlineStyle->getPropertyCSSVal ue(CSSPropertyTextDecoration); | |
| 769 if (textDecoration) { | |
| 770 if (!conflictingProperties) | |
| 771 return true; | |
| 772 conflictingProperties->append(CSSPropertyTextDecoration); | |
| 773 if (extractedStyle) | |
| 774 extractedStyle->setProperty(CSSPropertyTextDecoration, i nlineStyle->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIs Important(CSSPropertyTextDecoration)); | |
| 775 continue; | |
| 776 } | |
| 777 } | |
| 742 } | 778 } |
| 743 | 779 |
| 744 if (!inlineStyle->getPropertyCSSValue(propertyID)) | 780 if (!inlineStyle->getPropertyCSSValue(propertyID)) |
| 745 continue; | 781 continue; |
| 746 | 782 |
| 747 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV alue(CSSPropertyDirection)) { | 783 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV alue(CSSPropertyDirection)) { |
| 748 if (!conflictingProperties) | 784 if (!conflictingProperties) |
| 749 return true; | 785 return true; |
| 750 conflictingProperties->append(CSSPropertyDirection); | 786 conflictingProperties->append(CSSPropertyDirection); |
| 751 if (extractedStyle) | 787 if (extractedStyle) |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 m_mutableStyle = style->mutableCopy(); | 1107 m_mutableStyle = style->mutableCopy(); |
| 1072 return; | 1108 return; |
| 1073 } | 1109 } |
| 1074 | 1110 |
| 1075 unsigned propertyCount = style->propertyCount(); | 1111 unsigned propertyCount = style->propertyCount(); |
| 1076 for (unsigned i = 0; i < propertyCount; ++i) { | 1112 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1077 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1113 StylePropertySet::PropertyReference property = style->propertyAt(i); |
| 1078 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ()); | 1114 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ()); |
| 1079 | 1115 |
| 1080 // text decorations never override values | 1116 // text decorations never override values |
| 1081 if ((property.id() == CSSPropertyTextDecoration || property.id() == CSSP ropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && valu e) { | 1117 bool isPropertyTextDecorationEquivalent = property.id() == CSSPropertyWe bkitTextDecorationsInEffect; |
| 1118 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | |
| 1119 isPropertyTextDecorationEquivalent = isPropertyTextDecorationEquival ent || property.id() == CSSPropertyTextDecorationLine; | |
|
Julien - ping for review
2013/07/27 01:46:35
isPropertyTextDecorationEquivalent |= property.id(
abinader
2013/07/28 04:21:52
Ah yes, shame on me on skipping operator|= usage :
| |
| 1120 else | |
| 1121 isPropertyTextDecorationEquivalent = isPropertyTextDecorationEquival ent || property.id() == CSSPropertyTextDecoration; | |
| 1122 if (isPropertyTextDecorationEquivalent && property.value()->isValueList( ) && value) { | |
| 1082 if (value->isValueList()) { | 1123 if (value->isValueList()) { |
| 1083 mergeTextDecorationValues(static_cast<CSSValueList*>(value.get() ), static_cast<CSSValueList*>(property.value())); | 1124 mergeTextDecorationValues(static_cast<CSSValueList*>(value.get() ), static_cast<CSSValueList*>(property.value())); |
| 1084 continue; | 1125 continue; |
| 1085 } | 1126 } |
| 1086 value = 0; // text-decoration: none is equivalent to not having the property | 1127 value = 0; // text-decoration: none is equivalent to not having the property |
| 1087 } | 1128 } |
| 1088 | 1129 |
| 1089 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) | 1130 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) |
| 1090 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); | 1131 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); |
| 1091 } | 1132 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; | 1368 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; |
| 1328 } | 1369 } |
| 1329 hasNestedOrMultipleEmbeddings = false; | 1370 hasNestedOrMultipleEmbeddings = false; |
| 1330 return foundDirection; | 1371 return foundDirection; |
| 1331 } | 1372 } |
| 1332 | 1373 |
| 1333 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) | 1374 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
| 1334 { | 1375 { |
| 1335 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect); | 1376 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect); |
| 1336 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration); | 1377 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText Decoration); |
| 1378 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. | 1379 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. |
| 1338 ASSERT(!textDecorationsInEffect || !textDecoration); | 1380 ASSERT(!textDecorationsInEffect || (!textDecoration || !textDecorationLine)) ; |
| 1339 if (textDecorationsInEffect) { | 1381 if (textDecorationsInEffect) { |
| 1340 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->c ssText()); | 1382 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) { |
| 1383 style->setProperty(CSSPropertyTextDecorationLine, textDecorationsInE ffect->cssText()); | |
| 1384 textDecorationLine = textDecorationsInEffect; | |
| 1385 } else { | |
| 1386 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffec t->cssText()); | |
| 1387 textDecoration = textDecorationsInEffect; | |
| 1388 } | |
| 1341 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1389 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 1342 textDecoration = textDecorationsInEffect; | |
| 1343 } | 1390 } |
| 1344 | 1391 |
| 1345 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". | 1392 // 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()) | 1393 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) { |
| 1347 style->removeProperty(CSSPropertyTextDecoration); | 1394 if (textDecorationLine && !textDecorationLine->isValueList()) |
| 1395 style->removeProperty(CSSPropertyTextDecorationLine); | |
| 1396 } else { | |
| 1397 if (textDecoration && !textDecoration->isValueList()) | |
| 1398 style->removeProperty(CSSPropertyTextDecoration); | |
| 1399 } | |
| 1348 } | 1400 } |
| 1349 | 1401 |
| 1350 StyleChange::StyleChange(EditingStyle* style, const Position& position) | 1402 StyleChange::StyleChange(EditingStyle* style, const Position& position) |
| 1351 : m_applyBold(false) | 1403 : m_applyBold(false) |
| 1352 , m_applyItalic(false) | 1404 , m_applyItalic(false) |
| 1353 , m_applyUnderline(false) | 1405 , m_applyUnderline(false) |
| 1354 , m_applyLineThrough(false) | 1406 , m_applyLineThrough(false) |
| 1355 , m_applySubscript(false) | 1407 , m_applySubscript(false) |
| 1356 , m_applySuperscript(false) | 1408 , m_applySuperscript(false) |
| 1357 { | 1409 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1401 } | 1453 } |
| 1402 | 1454 |
| 1403 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1455 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
| 1404 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1456 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
| 1405 style->removeProperty(CSSPropertyFontStyle); | 1457 style->removeProperty(CSSPropertyFontStyle); |
| 1406 m_applyItalic = true; | 1458 m_applyItalic = true; |
| 1407 } | 1459 } |
| 1408 | 1460 |
| 1409 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect | 1461 // 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. | 1462 // 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); | 1463 CSSPropertyID textDecorationProperty = RuntimeEnabledFeatures::css3TextDecor ationsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; |
| 1464 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP roperty); | |
| 1412 if (textDecoration && textDecoration->isValueList()) { | 1465 if (textDecoration && textDecoration->isValueList()) { |
| 1413 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV alue::createIdentifier(CSSValueUnderline))); | 1466 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV alue::createIdentifier(CSSValueUnderline))); |
| 1414 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv eValue::createIdentifier(CSSValueLineThrough))); | 1467 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv eValue::createIdentifier(CSSValueLineThrough))); |
| 1415 | 1468 |
| 1416 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(text Decoration.get())->copy(); | 1469 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(text Decoration.get())->copy(); |
| 1417 if (newTextDecoration->removeAll(underline.get())) | 1470 if (newTextDecoration->removeAll(underline.get())) |
| 1418 m_applyUnderline = true; | 1471 m_applyUnderline = true; |
| 1419 if (newTextDecoration->removeAll(lineThrough.get())) | 1472 if (newTextDecoration->removeAll(lineThrough.get())) |
| 1420 m_applyLineThrough = true; | 1473 m_applyLineThrough = true; |
| 1421 | 1474 |
| 1422 // If trimTextDecorations, delete underline and line-through | 1475 // If trimTextDecorations, delete underline and line-through |
| 1423 setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTex tDecoration); | 1476 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration Property); |
| 1424 } | 1477 } |
| 1425 | 1478 |
| 1426 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); | 1479 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); |
| 1427 switch (verticalAlign) { | 1480 switch (verticalAlign) { |
| 1428 case CSSValueSub: | 1481 case CSSValueSub: |
| 1429 style->removeProperty(CSSPropertyVerticalAlign); | 1482 style->removeProperty(CSSPropertyVerticalAlign); |
| 1430 m_applySubscript = true; | 1483 m_applySubscript = true; |
| 1431 break; | 1484 break; |
| 1432 case CSSValueSuper: | 1485 case CSSValueSuper: |
| 1433 style->removeProperty(CSSPropertyVerticalAlign); | 1486 style->removeProperty(CSSPropertyVerticalAlign); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1518 | 1571 |
| 1519 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) | 1572 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) |
| 1520 { | 1573 { |
| 1521 ASSERT(styleWithRedundantProperties); | 1574 ASSERT(styleWithRedundantProperties); |
| 1522 ASSERT(baseStyle); | 1575 ASSERT(baseStyle); |
| 1523 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); | 1576 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); |
| 1524 | 1577 |
| 1525 result->removeEquivalentProperties(baseStyle); | 1578 result->removeEquivalentProperties(baseStyle); |
| 1526 | 1579 |
| 1527 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1580 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
| 1528 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat ionsInEffect.get()); | 1581 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
| 1582 diffTextDecorations(result.get(), CSSPropertyTextDecorationLine, baseTex tDecorationsInEffect.get()); | |
| 1583 else | |
| 1584 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDec orationsInEffect.get()); | |
| 1529 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); | 1585 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); |
| 1530 | 1586 |
| 1531 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) | 1587 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) |
| 1532 result->removeProperty(CSSPropertyFontWeight); | 1588 result->removeProperty(CSSPropertyFontWeight); |
| 1533 | 1589 |
| 1534 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) | 1590 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) |
| 1535 result->removeProperty(CSSPropertyColor); | 1591 result->removeProperty(CSSPropertyColor); |
| 1536 | 1592 |
| 1537 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1593 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
| 1538 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) | 1594 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 { | 1672 { |
| 1617 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1673 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1618 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); | 1674 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); |
| 1619 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1675 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1620 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); | 1676 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); |
| 1621 } | 1677 } |
| 1622 return 0; | 1678 return 0; |
| 1623 } | 1679 } |
| 1624 | 1680 |
| 1625 } | 1681 } |
| OLD | NEW |