Changeset 148403 in webkit
- Timestamp:
- Apr 14, 2013 10:49:06 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r148402 r148403 1 2013-04-14 Andreas Kling <akling@apple.com> 2 3 Move property setting/removing functions to MutableStylePropertySet. 4 <http://webkit.org/b/114589> 5 6 Reviewed by Antti Koivisto. 7 8 Move all functions for setting/removing properties from StylePropertySet to MutableStylePropertySet. 9 Had to change SVGElement::animatedSMILStyleProperties() & friends to hand out MutableStylePropertySet* 10 which was always the internal type anyway. 11 12 * css/StylePropertySet.cpp: 13 (WebCore::MutableStylePropertySet::removeShorthandProperty): 14 (WebCore::MutableStylePropertySet::removeProperty): 15 (WebCore::MutableStylePropertySet::removePrefixedOrUnprefixedProperty): 16 (WebCore::MutableStylePropertySet::setProperty): 17 (WebCore::MutableStylePropertySet::appendPrefixingVariantProperty): 18 (WebCore::MutableStylePropertySet::setPrefixingVariantProperty): 19 (WebCore::MutableStylePropertySet::mergeAndOverrideOnConflict): 20 (WebCore::MutableStylePropertySet::removeBlockProperties): 21 (WebCore::MutableStylePropertySet::removePropertiesInSet): 22 (WebCore::MutableStylePropertySet::findCSSPropertyWithID): 23 (WebCore::MutableStylePropertySet::removeEquivalentProperties): 24 * css/StylePropertySet.h: 25 (StylePropertySet): 26 (MutableStylePropertySet): 27 * editing/ApplyStyleCommand.cpp: 28 (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): 29 (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock): 30 (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange): 31 * editing/EditingStyle.cpp: 32 (WebCore::EditingStyle::triStateOfStyle): 33 (WebCore::removePropertiesInStyle): 34 (WebCore::reconcileTextDecorationProperties): 35 * svg/SVGAnimateElement.cpp: 36 (WebCore::applyCSSPropertyToTarget): 37 * svg/SVGElement.cpp: 38 (WebCore::SVGElement::animatedSMILStyleProperties): 39 (WebCore::SVGElement::ensureAnimatedSMILStyleProperties): 40 * svg/SVGElement.h: 41 (SVGElement): 42 * svg/SVGElementRareData.h: 43 (WebCore::SVGElementRareData::animatedSMILStyleProperties): 44 (WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties): 45 (SVGElementRareData): 46 1 47 2013-04-14 Andreas Kling <akling@apple.com> 2 48 -
trunk/Source/WebCore/css/StylePropertySet.cpp
r148402 r148403 590 590 } 591 591 592 bool StylePropertySet::removeShorthandProperty(CSSPropertyID propertyID) 593 { 594 ASSERT(isMutable()); 592 bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID) 593 { 595 594 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); 596 595 if (!shorthand.length()) … … 607 606 } 608 607 609 bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText) 610 { 611 ASSERT(isMutable()); 608 bool MutableStylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText) 609 { 612 610 if (removeShorthandProperty(propertyID)) { 613 611 // FIXME: Return an equivalent shorthand when possible. … … 636 634 } 637 635 638 void StylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID)636 void MutableStylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID) 639 637 { 640 638 int foundPropertyIndex = findPropertyIndex(prefixingVariantForPropertyId(propertyID)); … … 677 675 } 678 676 679 bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet) 680 { 681 ASSERT(isMutable()); 677 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet) 678 { 682 679 // Setting the value to an empty string just removes the property in both IE and Gecko. 683 680 // Setting it to null seems to produce less consistent results, but we treat it just the same. 684 681 if (value.isEmpty()) { 685 removeProperty(propertyID);682 static_cast<MutableStylePropertySet*>(this)->removeProperty(propertyID); 686 683 return true; 687 684 } … … 692 689 } 693 690 694 void StylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important) 695 { 696 ASSERT(isMutable()); 691 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important) 692 { 697 693 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); 698 694 if (!shorthand.length()) { … … 708 704 } 709 705 710 void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot) 711 { 712 ASSERT(isMutable()); 706 void MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot) 707 { 713 708 if (!removeShorthandProperty(property.id())) { 714 CSSProperty* toReplace = slot ? slot : find MutableCSSPropertyWithID(property.id());709 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id()); 715 710 if (toReplace) { 716 711 *toReplace = property; … … 722 717 } 723 718 724 void StylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)719 void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property) 725 720 { 726 721 mutablePropertyVector().append(property); … … 731 726 } 732 727 733 void StylePropertySet::setPrefixingVariantProperty(const CSSProperty& property)728 void MutableStylePropertySet::setPrefixingVariantProperty(const CSSProperty& property) 734 729 { 735 730 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); 736 CSSProperty* toReplace = find MutableCSSPropertyWithID(prefixingVariant);731 CSSProperty* toReplace = findCSSPropertyWithID(prefixingVariant); 737 732 if (toReplace) 738 733 *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit); 739 734 } 740 735 741 bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important) 742 { 743 ASSERT(isMutable()); 736 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important) 737 { 744 738 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important)); 745 739 return true; … … 1037 1031 } 1038 1032 1039 void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) 1040 { 1041 ASSERT(isMutable()); 1033 void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) 1034 { 1042 1035 unsigned size = other->propertyCount(); 1043 1036 for (unsigned n = 0; n < size; ++n) { 1044 1037 PropertyReference toMerge = other->propertyAt(n); 1045 CSSProperty* old = find MutableCSSPropertyWithID(toMerge.id());1038 CSSProperty* old = findCSSPropertyWithID(toMerge.id()); 1046 1039 if (old) 1047 1040 setProperty(toMerge.toCSSProperty(), old); … … 1112 1105 } 1113 1106 1114 void StylePropertySet::removeBlockProperties()1107 void MutableStylePropertySet::removeBlockProperties() 1115 1108 { 1116 1109 removePropertiesInSet(blockProperties, numBlockProperties); 1117 1110 } 1118 1111 1119 bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length) 1120 { 1121 ASSERT(isMutable()); 1112 bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length) 1113 { 1122 1114 if (mutablePropertyVector().isEmpty()) 1123 1115 return false; … … 1156 1148 } 1157 1149 1158 CSSProperty* StylePropertySet::findMutableCSSPropertyWithID(CSSPropertyID propertyID) 1159 { 1160 ASSERT(isMutable()); 1150 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID) 1151 { 1161 1152 int foundPropertyIndex = findPropertyIndex(propertyID); 1162 1153 if (foundPropertyIndex == -1) … … 1173 1164 } 1174 1165 1175 void StylePropertySet::removeEquivalentProperties(const StylePropertySet* style) 1176 { 1177 ASSERT(isMutable()); 1166 void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet* style) 1167 { 1178 1168 Vector<CSSPropertyID> propertiesToRemove; 1179 1169 unsigned size = mutablePropertyVector().size(); … … 1188 1178 } 1189 1179 1190 void StylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style) 1191 { 1192 ASSERT(isMutable()); 1180 void MutableStylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style) 1181 { 1193 1182 Vector<CSSPropertyID> propertiesToRemove; 1194 1183 unsigned size = mutablePropertyVector().size(); -
trunk/Source/WebCore/css/StylePropertySet.h
r148402 r148403 105 105 bool isPropertyImplicit(CSSPropertyID) const; 106 106 107 // These expand shorthand properties into multiple properties.108 bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);109 void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);110 111 // These do not. FIXME: This is too messy, we can do better.112 bool setProperty(CSSPropertyID, int identifier, bool important = false);113 void appendPrefixingVariantProperty(const CSSProperty&);114 void setPrefixingVariantProperty(const CSSProperty&);115 void setProperty(const CSSProperty&, CSSProperty* slot = 0);116 117 bool removeProperty(CSSPropertyID, String* returnText = 0);118 void removePrefixedOrUnprefixedProperty(CSSPropertyID);119 120 107 PassRefPtr<MutableStylePropertySet> copyBlockProperties() const; 121 void removeBlockProperties();122 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);123 124 void mergeAndOverrideOnConflict(const StylePropertySet*);125 108 126 109 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); } … … 130 113 PassRefPtr<MutableStylePropertySet> mutableCopy() const; 131 114 PassRefPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() const; 132 133 void removeEquivalentProperties(const StylePropertySet*);134 void removeEquivalentProperties(const CSSStyleDeclaration*);135 115 136 116 PassRefPtr<MutableStylePropertySet> copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const; … … 154 134 const CSSValue** immutableValueArray() const; 155 135 const StylePropertyMetadata* immutableMetadataArray() const; 136 137 bool propertyMatches(CSSPropertyID, const CSSValue*) const; 156 138 157 139 protected: … … 169 151 , m_arraySize(immutableArraySize) 170 152 { } 153 154 int findPropertyIndex(CSSPropertyID) const; 171 155 172 156 Vector<CSSProperty, 4>& mutablePropertyVector(); … … 191 175 void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const; 192 176 193 bool removeShorthandProperty(CSSPropertyID);194 bool propertyMatches(CSSPropertyID, const CSSValue*) const;195 196 int findPropertyIndex(CSSPropertyID) const;197 CSSProperty* findMutableCSSPropertyWithID(CSSPropertyID);198 199 177 friend class PropertySetCSSStyleDeclaration; 200 178 }; … … 233 211 void addParsedProperty(const CSSProperty&); 234 212 213 // These expand shorthand properties into multiple properties. 214 bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0); 215 void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false); 216 217 // These do not. FIXME: This is too messy, we can do better. 218 bool setProperty(CSSPropertyID, int identifier, bool important = false); 219 void appendPrefixingVariantProperty(const CSSProperty&); 220 void setPrefixingVariantProperty(const CSSProperty&); 221 void setProperty(const CSSProperty&, CSSProperty* slot = 0); 222 223 bool removeProperty(CSSPropertyID, String* returnText = 0); 224 void removePrefixedOrUnprefixedProperty(CSSPropertyID); 225 void removeBlockProperties(); 226 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 227 void removeEquivalentProperties(const StylePropertySet*); 228 void removeEquivalentProperties(const CSSStyleDeclaration*); 229 230 void mergeAndOverrideOnConflict(const StylePropertySet*); 231 235 232 void clear(); 236 233 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet); … … 245 242 : StylePropertySet(cssParserMode) 246 243 { } 244 247 245 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 246 247 bool removeShorthandProperty(CSSPropertyID); 248 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 248 249 }; 249 250 -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r148395 r148403 395 395 lastStyledNode = node; 396 396 397 RefPtr< StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());397 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle()); 398 398 float currentFontSize = computedFontSize(node); 399 399 float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta()); … … 522 522 removeNodeAttribute(element, dirAttr); 523 523 } else { 524 RefPtr< StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());524 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle()); 525 525 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); 526 526 inlineStyle->removeProperty(CSSPropertyDirection); … … 766 766 // Add to this element's inline style and skip over its contents. 767 767 HTMLElement* element = toHTMLElement(node.get()); 768 RefPtr< StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());768 RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle()); 769 769 inlineStyle->mergeAndOverrideOnConflict(style->style()); 770 770 setNodeAttribute(element, styleAttr, inlineStyle->asText()); -
trunk/Source/WebCore/editing/EditingStyle.cpp
r148402 r148403 653 653 TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const 654 654 { 655 RefPtr< StylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(), styleToCompare);655 RefPtr<MutableStylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(), styleToCompare); 656 656 657 657 if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties) … … 1125 1125 } 1126 1126 1127 static void removePropertiesInStyle( StylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style)1127 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style) 1128 1128 { 1129 1129 unsigned propertyCount = style->propertyCount(); … … 1312 1312 } 1313 1313 1314 static void reconcileTextDecorationProperties( StylePropertySet* style)1314 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) 1315 1315 { 1316 1316 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); -
trunk/Source/WebCore/svg/SVGAnimateElement.cpp
r143926 r148403 240 240 ASSERT(!targetElement->m_deletionHasBegun); 241 241 242 StylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();242 MutableStylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties(); 243 243 if (!propertySet->setProperty(id, value, false, 0)) 244 244 return; -
trunk/Source/WebCore/svg/SVGElement.cpp
r147983 r148403 595 595 } 596 596 597 StylePropertySet* SVGElement::animatedSMILStyleProperties() const597 MutableStylePropertySet* SVGElement::animatedSMILStyleProperties() const 598 598 { 599 599 if (hasSVGRareData()) … … 602 602 } 603 603 604 StylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties()604 MutableStylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties() 605 605 { 606 606 return ensureSVGRareData()->ensureAnimatedSMILStyleProperties(); -
trunk/Source/WebCore/svg/SVGElement.h
r147983 r148403 112 112 #endif 113 113 114 StylePropertySet* animatedSMILStyleProperties() const;115 StylePropertySet* ensureAnimatedSMILStyleProperties();114 MutableStylePropertySet* animatedSMILStyleProperties() const; 115 MutableStylePropertySet* ensureAnimatedSMILStyleProperties(); 116 116 void setUseOverrideComputedStyle(bool); 117 117 -
trunk/Source/WebCore/svg/SVGElementRareData.h
r148395 r148403 76 76 void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; } 77 77 78 StylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); }79 StylePropertySet* ensureAnimatedSMILStyleProperties()78 MutableStylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); } 79 MutableStylePropertySet* ensureAnimatedSMILStyleProperties() 80 80 { 81 81 if (!m_animatedSMILStyleProperties) … … 115 115 bool m_useOverrideComputedStyle : 1; 116 116 bool m_needsOverrideComputedStyleUpdate : 1; 117 RefPtr< StylePropertySet> m_animatedSMILStyleProperties;117 RefPtr<MutableStylePropertySet> m_animatedSMILStyleProperties; 118 118 RefPtr<RenderStyle> m_overrideComputedStyle; 119 119 };
Note: See TracChangeset
for help on using the changeset viewer.