Changeset 148403 in webkit


Ignore:
Timestamp:
Apr 14, 2013 10:49:06 AM (11 years ago)
Author:
akling@apple.com
Message:

Move property setting/removing functions to MutableStylePropertySet.
<http://webkit.org/b/114589>

Reviewed by Antti Koivisto.

Move all functions for setting/removing properties from StylePropertySet to MutableStylePropertySet.
Had to change SVGElement::animatedSMILStyleProperties() & friends to hand out MutableStylePropertySet*
which was always the internal type anyway.

  • css/StylePropertySet.cpp:

(WebCore::MutableStylePropertySet::removeShorthandProperty):
(WebCore::MutableStylePropertySet::removeProperty):
(WebCore::MutableStylePropertySet::removePrefixedOrUnprefixedProperty):
(WebCore::MutableStylePropertySet::setProperty):
(WebCore::MutableStylePropertySet::appendPrefixingVariantProperty):
(WebCore::MutableStylePropertySet::setPrefixingVariantProperty):
(WebCore::MutableStylePropertySet::mergeAndOverrideOnConflict):
(WebCore::MutableStylePropertySet::removeBlockProperties):
(WebCore::MutableStylePropertySet::removePropertiesInSet):
(WebCore::MutableStylePropertySet::findCSSPropertyWithID):
(WebCore::MutableStylePropertySet::removeEquivalentProperties):

  • css/StylePropertySet.h:

(StylePropertySet):
(MutableStylePropertySet):

  • editing/ApplyStyleCommand.cpp:

(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):

  • editing/EditingStyle.cpp:

(WebCore::EditingStyle::triStateOfStyle):
(WebCore::removePropertiesInStyle):
(WebCore::reconcileTextDecorationProperties):

  • svg/SVGAnimateElement.cpp:

(WebCore::applyCSSPropertyToTarget):

  • svg/SVGElement.cpp:

(WebCore::SVGElement::animatedSMILStyleProperties):
(WebCore::SVGElement::ensureAnimatedSMILStyleProperties):

  • svg/SVGElement.h:

(SVGElement):

  • svg/SVGElementRareData.h:

(WebCore::SVGElementRareData::animatedSMILStyleProperties):
(WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
(SVGElementRareData):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148402 r148403  
     12013-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
    1472013-04-14  Andreas Kling  <akling@apple.com>
    248
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r148402 r148403  
    590590}
    591591
    592 bool StylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
    593 {
    594     ASSERT(isMutable());
     592bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
     593{
    595594    StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
    596595    if (!shorthand.length())
     
    607606}
    608607
    609 bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText)
    610 {
    611     ASSERT(isMutable());
     608bool MutableStylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText)
     609{
    612610    if (removeShorthandProperty(propertyID)) {
    613611        // FIXME: Return an equivalent shorthand when possible.
     
    636634}
    637635
    638 void StylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID)
     636void MutableStylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID)
    639637{
    640638    int foundPropertyIndex = findPropertyIndex(prefixingVariantForPropertyId(propertyID));
     
    677675}
    678676
    679 bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
    680 {
    681     ASSERT(isMutable());
     677bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
     678{
    682679    // Setting the value to an empty string just removes the property in both IE and Gecko.
    683680    // Setting it to null seems to produce less consistent results, but we treat it just the same.
    684681    if (value.isEmpty()) {
    685         removeProperty(propertyID);
     682        static_cast<MutableStylePropertySet*>(this)->removeProperty(propertyID);
    686683        return true;
    687684    }
     
    692689}
    693690
    694 void StylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important)
    695 {
    696     ASSERT(isMutable());
     691void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important)
     692{
    697693    StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
    698694    if (!shorthand.length()) {
     
    708704}
    709705
    710 void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
    711 {
    712     ASSERT(isMutable());
     706void MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
     707{
    713708    if (!removeShorthandProperty(property.id())) {
    714         CSSProperty* toReplace = slot ? slot : findMutableCSSPropertyWithID(property.id());
     709        CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id());
    715710        if (toReplace) {
    716711            *toReplace = property;
     
    722717}
    723718
    724 void StylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)
     719void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)
    725720{
    726721    mutablePropertyVector().append(property);
     
    731726}
    732727
    733 void StylePropertySet::setPrefixingVariantProperty(const CSSProperty& property)
     728void MutableStylePropertySet::setPrefixingVariantProperty(const CSSProperty& property)
    734729{
    735730    CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id());
    736     CSSProperty* toReplace = findMutableCSSPropertyWithID(prefixingVariant);
     731    CSSProperty* toReplace = findCSSPropertyWithID(prefixingVariant);
    737732    if (toReplace)
    738733        *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit);
    739734}
    740735
    741 bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important)
    742 {
    743     ASSERT(isMutable());
     736bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important)
     737{
    744738    setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
    745739    return true;
     
    10371031}
    10381032
    1039 void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other)
    1040 {
    1041     ASSERT(isMutable());
     1033void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other)
     1034{
    10421035    unsigned size = other->propertyCount();
    10431036    for (unsigned n = 0; n < size; ++n) {
    10441037        PropertyReference toMerge = other->propertyAt(n);
    1045         CSSProperty* old = findMutableCSSPropertyWithID(toMerge.id());
     1038        CSSProperty* old = findCSSPropertyWithID(toMerge.id());
    10461039        if (old)
    10471040            setProperty(toMerge.toCSSProperty(), old);
     
    11121105}
    11131106
    1114 void StylePropertySet::removeBlockProperties()
     1107void MutableStylePropertySet::removeBlockProperties()
    11151108{
    11161109    removePropertiesInSet(blockProperties, numBlockProperties);
    11171110}
    11181111
    1119 bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
    1120 {
    1121     ASSERT(isMutable());
     1112bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
     1113{
    11221114    if (mutablePropertyVector().isEmpty())
    11231115        return false;
     
    11561148}
    11571149
    1158 CSSProperty* StylePropertySet::findMutableCSSPropertyWithID(CSSPropertyID propertyID)
    1159 {
    1160     ASSERT(isMutable());
     1150CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID)
     1151{
    11611152    int foundPropertyIndex = findPropertyIndex(propertyID);
    11621153    if (foundPropertyIndex == -1)
     
    11731164}
    11741165   
    1175 void StylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
    1176 {
    1177     ASSERT(isMutable());
     1166void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
     1167{
    11781168    Vector<CSSPropertyID> propertiesToRemove;
    11791169    unsigned size = mutablePropertyVector().size();
     
    11881178}
    11891179
    1190 void StylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style)
    1191 {
    1192     ASSERT(isMutable());
     1180void MutableStylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style)
     1181{
    11931182    Vector<CSSPropertyID> propertiesToRemove;
    11941183    unsigned size = mutablePropertyVector().size();
  • trunk/Source/WebCore/css/StylePropertySet.h

    r148402 r148403  
    105105    bool isPropertyImplicit(CSSPropertyID) const;
    106106
    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 
    120107    PassRefPtr<MutableStylePropertySet> copyBlockProperties() const;
    121     void removeBlockProperties();
    122     bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
    123 
    124     void mergeAndOverrideOnConflict(const StylePropertySet*);
    125108
    126109    CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
     
    130113    PassRefPtr<MutableStylePropertySet> mutableCopy() const;
    131114    PassRefPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() const;
    132 
    133     void removeEquivalentProperties(const StylePropertySet*);
    134     void removeEquivalentProperties(const CSSStyleDeclaration*);
    135115
    136116    PassRefPtr<MutableStylePropertySet> copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const;
     
    154134    const CSSValue** immutableValueArray() const;
    155135    const StylePropertyMetadata* immutableMetadataArray() const;
     136
     137    bool propertyMatches(CSSPropertyID, const CSSValue*) const;
    156138
    157139protected:
     
    169151        , m_arraySize(immutableArraySize)
    170152    { }
     153
     154    int findPropertyIndex(CSSPropertyID) const;
    171155
    172156    Vector<CSSProperty, 4>& mutablePropertyVector();
     
    191175    void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const;
    192176
    193     bool removeShorthandProperty(CSSPropertyID);
    194     bool propertyMatches(CSSPropertyID, const CSSValue*) const;
    195 
    196     int findPropertyIndex(CSSPropertyID) const;
    197     CSSProperty* findMutableCSSPropertyWithID(CSSPropertyID);
    198 
    199177    friend class PropertySetCSSStyleDeclaration;
    200178};
     
    233211    void addParsedProperty(const CSSProperty&);
    234212
     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
    235232    void clear();
    236233    void parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
     
    245242        : StylePropertySet(cssParserMode)
    246243    { }
     244
    247245    MutableStylePropertySet(const CSSProperty* properties, unsigned count);
     246
     247    bool removeShorthandProperty(CSSPropertyID);
     248    CSSProperty* findCSSPropertyWithID(CSSPropertyID);
    248249};
    249250
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r148395 r148403  
    395395        lastStyledNode = node;
    396396
    397         RefPtr<StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
     397        RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
    398398        float currentFontSize = computedFontSize(node);
    399399        float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + style->fontSizeDelta());
     
    522522            removeNodeAttribute(element, dirAttr);
    523523        } else {
    524             RefPtr<StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
     524            RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
    525525            inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
    526526            inlineStyle->removeProperty(CSSPropertyDirection);
     
    766766            // Add to this element's inline style and skip over its contents.
    767767            HTMLElement* element = toHTMLElement(node.get());
    768             RefPtr<StylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
     768            RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
    769769            inlineStyle->mergeAndOverrideOnConflict(style->style());
    770770            setNodeAttribute(element, styleAttr, inlineStyle->asText());
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r148402 r148403  
    653653TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const
    654654{
    655     RefPtr<StylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(), styleToCompare);
     655    RefPtr<MutableStylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(), styleToCompare);
    656656
    657657    if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties)
     
    11251125}
    11261126
    1127 static void removePropertiesInStyle(StylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style)
     1127static void removePropertiesInStyle(MutableStylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style)
    11281128{
    11291129    unsigned propertyCount = style->propertyCount();
     
    13121312}
    13131313
    1314 static void reconcileTextDecorationProperties(StylePropertySet* style)
     1314static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
    13151315{   
    13161316    RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
  • trunk/Source/WebCore/svg/SVGAnimateElement.cpp

    r143926 r148403  
    240240    ASSERT(!targetElement->m_deletionHasBegun);
    241241
    242     StylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();
     242    MutableStylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();
    243243    if (!propertySet->setProperty(id, value, false, 0))
    244244        return;
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r147983 r148403  
    595595}
    596596
    597 StylePropertySet* SVGElement::animatedSMILStyleProperties() const
     597MutableStylePropertySet* SVGElement::animatedSMILStyleProperties() const
    598598{
    599599    if (hasSVGRareData())
     
    602602}
    603603
    604 StylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties()
     604MutableStylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties()
    605605{
    606606    return ensureSVGRareData()->ensureAnimatedSMILStyleProperties();
  • trunk/Source/WebCore/svg/SVGElement.h

    r147983 r148403  
    112112#endif
    113113
    114     StylePropertySet* animatedSMILStyleProperties() const;
    115     StylePropertySet* ensureAnimatedSMILStyleProperties();
     114    MutableStylePropertySet* animatedSMILStyleProperties() const;
     115    MutableStylePropertySet* ensureAnimatedSMILStyleProperties();
    116116    void setUseOverrideComputedStyle(bool);
    117117
  • trunk/Source/WebCore/svg/SVGElementRareData.h

    r148395 r148403  
    7676    void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; }
    7777
    78     StylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); }
    79     StylePropertySet* ensureAnimatedSMILStyleProperties()
     78    MutableStylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); }
     79    MutableStylePropertySet* ensureAnimatedSMILStyleProperties()
    8080    {
    8181        if (!m_animatedSMILStyleProperties)
     
    115115    bool m_useOverrideComputedStyle : 1;
    116116    bool m_needsOverrideComputedStyleUpdate : 1;
    117     RefPtr<StylePropertySet> m_animatedSMILStyleProperties;
     117    RefPtr<MutableStylePropertySet> m_animatedSMILStyleProperties;
    118118    RefPtr<RenderStyle> m_overrideComputedStyle;
    119119};
Note: See TracChangeset for help on using the changeset viewer.