Changeset 118761 in webkit


Ignore:
Timestamp:
May 29, 2012 5:25:07 AM (12 years ago)
Author:
kling@webkit.org
Message:

Give StylePropertySet a proper mutability flag.
<http://webkit.org/b/87675>

Reviewed by Antti Koivisto.

Add a flag to StylePropertySet that determines whether it's mutable or not. Only objects
constructed from the CSS parser (by way of StylePropertySet::adopt()) are made immutable.
This is clean-up and prep work for implementing a more efficient storage scheme for immutable
StylePropertySets (fixed-size array instead of vector) as the vast majority of them are
unlikely to ever mutate during their lifetime.

Sprinkled ASSERT(isMutable()) all over StylePropertySet to catch any attempts to modify
an immutable object.

Also made properties() const on StyleRule and friends, which brought some additional code
churn along with it.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::copyPropertiesInSet):

  • css/CSSFontFaceRule.cpp:

(WebCore::CSSFontFaceRule::style):
(WebCore::CSSFontFaceRule::reattach):

  • css/CSSFontFaceSrcValue.cpp:

(WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs):

  • css/CSSFontFaceSrcValue.h:

(CSSFontFaceSrcValue):

  • css/CSSPageRule.cpp:

(WebCore::CSSPageRule::style):
(WebCore::CSSPageRule::reattach):

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::addSubresourceStyleURLs):

  • css/CSSPrimitiveValue.h:

(CSSPrimitiveValue):

  • css/CSSReflectValue.cpp:

(WebCore::CSSReflectValue::addSubresourceStyleURLs):

  • css/CSSReflectValue.h:

(CSSReflectValue):

  • css/CSSStyleRule.cpp:

(WebCore::CSSStyleRule::style):
(WebCore::CSSStyleRule::reattach):

  • css/CSSValue.cpp:

(WebCore::CSSValue::addSubresourceStyleURLs):

  • css/CSSValue.h:

(CSSValue):

  • css/CSSValueList.cpp:

(WebCore::CSSValueList::addSubresourceStyleURLs):

  • css/CSSValueList.h:

(CSSValueList):

  • css/StylePropertySet.cpp:

(WebCore::StylePropertySet::StylePropertySet):
(WebCore::StylePropertySet::setCSSParserMode):
(WebCore):
(WebCore::StylePropertySet::copyPropertiesFrom):
(WebCore::StylePropertySet::removeShorthandProperty):
(WebCore::StylePropertySet::removeProperty):
(WebCore::StylePropertySet::setProperty):
(WebCore::StylePropertySet::parseDeclaration):
(WebCore::StylePropertySet::addParsedProperties):
(WebCore::StylePropertySet::addParsedProperty):
(WebCore::StylePropertySet::merge):
(WebCore::StylePropertySet::addSubresourceStyleURLs):
(WebCore::StylePropertySet::removePropertiesInSet):
(WebCore::StylePropertySet::findPropertyWithId):
(WebCore::StylePropertySet::removeEquivalentProperties):
(WebCore::StylePropertySet::copyPropertiesInSet):

  • css/StylePropertySet.h:

(WebCore::StylePropertySet::adopt):
(WebCore::StylePropertySet::adoptMutable):
(StylePropertySet):
(WebCore::StylePropertySet::isMutable):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::addMatchedProperties):
(WebCore::StyleResolver::collectMatchingRulesForList):

  • css/StyleResolver.h:

(StyleResolver):

  • css/StyleRule.cpp:

(WebCore::StyleRule::mutableProperties):
(WebCore):
(WebCore::StyleRulePage::mutableProperties):
(WebCore::StyleRuleFontFace::mutableProperties):

  • css/StyleRule.h:

(WebCore::StyleRule::properties):
(StyleRule):
(WebCore::StyleRuleFontFace::properties):
(StyleRuleFontFace):
(WebCore::StyleRulePage::properties):
(StyleRulePage):

  • dom/ElementAttributeData.cpp:

(WebCore::ElementAttributeData::ensureInlineStyle):
(WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):

  • editing/EditingStyle.cpp:

(WebCore::styleFromMatchedRulesForElement):

  • svg/SVGFontFaceElement.cpp:

(WebCore::SVGFontFaceElement::parseAttribute):
(WebCore::SVGFontFaceElement::rebuildFontFace):
(WebCore::SVGFontFaceElement::removedFrom):

Location:
trunk/Source/WebCore
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118760 r118761  
     12012-05-29  Andreas Kling  <kling@webkit.org>
     2
     3        Give StylePropertySet a proper mutability flag.
     4        <http://webkit.org/b/87675>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Add a flag to StylePropertySet that determines whether it's mutable or not. Only objects
     9        constructed from the CSS parser (by way of StylePropertySet::adopt()) are made immutable.
     10        This is clean-up and prep work for implementing a more efficient storage scheme for immutable
     11        StylePropertySets (fixed-size array instead of vector) as the vast majority of them are
     12        unlikely to ever mutate during their lifetime.
     13
     14        Sprinkled ASSERT(isMutable()) all over StylePropertySet to catch any attempts to modify
     15        an immutable object.
     16
     17        Also made properties() const on StyleRule and friends, which brought some additional code
     18        churn along with it.
     19
     20        * css/CSSComputedStyleDeclaration.cpp:
     21        (WebCore::CSSComputedStyleDeclaration::copyPropertiesInSet):
     22        * css/CSSFontFaceRule.cpp:
     23        (WebCore::CSSFontFaceRule::style):
     24        (WebCore::CSSFontFaceRule::reattach):
     25        * css/CSSFontFaceSrcValue.cpp:
     26        (WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs):
     27        * css/CSSFontFaceSrcValue.h:
     28        (CSSFontFaceSrcValue):
     29        * css/CSSPageRule.cpp:
     30        (WebCore::CSSPageRule::style):
     31        (WebCore::CSSPageRule::reattach):
     32        * css/CSSPrimitiveValue.cpp:
     33        (WebCore::CSSPrimitiveValue::addSubresourceStyleURLs):
     34        * css/CSSPrimitiveValue.h:
     35        (CSSPrimitiveValue):
     36        * css/CSSReflectValue.cpp:
     37        (WebCore::CSSReflectValue::addSubresourceStyleURLs):
     38        * css/CSSReflectValue.h:
     39        (CSSReflectValue):
     40        * css/CSSStyleRule.cpp:
     41        (WebCore::CSSStyleRule::style):
     42        (WebCore::CSSStyleRule::reattach):
     43        * css/CSSValue.cpp:
     44        (WebCore::CSSValue::addSubresourceStyleURLs):
     45        * css/CSSValue.h:
     46        (CSSValue):
     47        * css/CSSValueList.cpp:
     48        (WebCore::CSSValueList::addSubresourceStyleURLs):
     49        * css/CSSValueList.h:
     50        (CSSValueList):
     51        * css/StylePropertySet.cpp:
     52        (WebCore::StylePropertySet::StylePropertySet):
     53        (WebCore::StylePropertySet::setCSSParserMode):
     54        (WebCore):
     55        (WebCore::StylePropertySet::copyPropertiesFrom):
     56        (WebCore::StylePropertySet::removeShorthandProperty):
     57        (WebCore::StylePropertySet::removeProperty):
     58        (WebCore::StylePropertySet::setProperty):
     59        (WebCore::StylePropertySet::parseDeclaration):
     60        (WebCore::StylePropertySet::addParsedProperties):
     61        (WebCore::StylePropertySet::addParsedProperty):
     62        (WebCore::StylePropertySet::merge):
     63        (WebCore::StylePropertySet::addSubresourceStyleURLs):
     64        (WebCore::StylePropertySet::removePropertiesInSet):
     65        (WebCore::StylePropertySet::findPropertyWithId):
     66        (WebCore::StylePropertySet::removeEquivalentProperties):
     67        (WebCore::StylePropertySet::copyPropertiesInSet):
     68        * css/StylePropertySet.h:
     69        (WebCore::StylePropertySet::adopt):
     70        (WebCore::StylePropertySet::adoptMutable):
     71        (StylePropertySet):
     72        (WebCore::StylePropertySet::isMutable):
     73        * css/StyleResolver.cpp:
     74        (WebCore::StyleResolver::addMatchedProperties):
     75        (WebCore::StyleResolver::collectMatchingRulesForList):
     76        * css/StyleResolver.h:
     77        (StyleResolver):
     78        * css/StyleRule.cpp:
     79        (WebCore::StyleRule::mutableProperties):
     80        (WebCore):
     81        (WebCore::StyleRulePage::mutableProperties):
     82        (WebCore::StyleRuleFontFace::mutableProperties):
     83        * css/StyleRule.h:
     84        (WebCore::StyleRule::properties):
     85        (StyleRule):
     86        (WebCore::StyleRuleFontFace::properties):
     87        (StyleRuleFontFace):
     88        (WebCore::StyleRulePage::properties):
     89        (StyleRulePage):
     90        * dom/ElementAttributeData.cpp:
     91        (WebCore::ElementAttributeData::ensureInlineStyle):
     92        (WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):
     93        * editing/EditingStyle.cpp:
     94        (WebCore::styleFromMatchedRulesForElement):
     95        * svg/SVGFontFaceElement.cpp:
     96        (WebCore::SVGFontFaceElement::parseAttribute):
     97        (WebCore::SVGFontFaceElement::rebuildFontFace):
     98        (WebCore::SVGFontFaceElement::removedFrom):
     99
    11002012-05-29  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    2101
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r118583 r118761  
    26422642            list.append(CSSProperty(set[i], value.release(), false));
    26432643    }
    2644     return StylePropertySet::adopt(list);
     2644    return StylePropertySet::adoptMutable(list);
    26452645}
    26462646
  • trunk/Source/WebCore/css/CSSFontFaceRule.cpp

    r116291 r118761  
    4343{
    4444    if (!m_propertiesCSSOMWrapper)
    45         m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_fontFaceRule->properties(), const_cast<CSSFontFaceRule*>(this));
     45        m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_fontFaceRule->mutableProperties(), const_cast<CSSFontFaceRule*>(this));
    4646    return m_propertiesCSSOMWrapper.get();
    4747}
     
    6161    m_fontFaceRule = rule;
    6262    if (m_propertiesCSSOMWrapper)
    63         m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->properties());
     63        m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties());
    6464}
    6565
  • trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp

    r118336 r118761  
    7474}
    7575
    76 void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
     76void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
    7777{
    7878    if (!isLocal())
  • trunk/Source/WebCore/css/CSSFontFaceSrcValue.h

    r118194 r118761  
    6666    String customCssText() const;
    6767
    68     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
     68    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    6969
    7070    CachedFont* cachedFont(Document*);
  • trunk/Source/WebCore/css/CSSPageRule.cpp

    r116291 r118761  
    4949{
    5050    if (!m_propertiesCSSOMWrapper)
    51         m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_pageRule->properties(), const_cast<CSSPageRule*>(this));
     51        m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_pageRule->mutableProperties(), const_cast<CSSPageRule*>(this));
    5252    return m_propertiesCSSOMWrapper.get();
    5353}
     
    9393    m_pageRule = rule;
    9494    if (m_propertiesCSSOMWrapper)
    95         m_propertiesCSSOMWrapper->reattach(m_pageRule->properties());
     95        m_propertiesCSSOMWrapper->reattach(m_pageRule->mutableProperties());
    9696}
    9797
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r118336 r118761  
    10651065}
    10661066
    1067 void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
     1067void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
    10681068{
    10691069    if (m_primitiveUnitType == CSS_URI)
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r118194 r118761  
    284284    bool isQuirkValue() { return m_isQuirkValue; }
    285285
    286     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
     286    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    287287
    288288    Length viewportPercentageLength();
  • trunk/Source/WebCore/css/CSSReflectValue.cpp

    r118194 r118761  
    6060}
    6161
    62 void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
     62void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
    6363{
    6464    if (m_mask)
  • trunk/Source/WebCore/css/CSSReflectValue.h

    r118194 r118761  
    5050    String customCssText() const;
    5151
    52     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
     52    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    5353
    5454private:
  • trunk/Source/WebCore/css/CSSStyleRule.cpp

    r116291 r118761  
    6060CSSStyleDeclaration* CSSStyleRule::style() const
    6161{
    62     if (!m_propertiesCSSOMWrapper)
    63         m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_styleRule->properties(), const_cast<CSSStyleRule*>(this));
     62    if (!m_propertiesCSSOMWrapper) {
     63        m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_styleRule->mutableProperties(), const_cast<CSSStyleRule*>(this));
     64    }
    6465    return m_propertiesCSSOMWrapper.get();
    6566}
     
    124125    m_styleRule = rule;
    125126    if (m_propertiesCSSOMWrapper)
    126         m_propertiesCSSOMWrapper->reattach(m_styleRule->properties());
     127        m_propertiesCSSOMWrapper->reattach(m_styleRule->mutableProperties());
    127128}
    128129
  • trunk/Source/WebCore/css/CSSValue.cpp

    r118194 r118761  
    100100}
    101101
    102 void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
     102void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
    103103{
    104104    // This should get called for internal instances only.
     
    106106
    107107    if (isPrimitiveValue())
    108         static_cast<CSSPrimitiveValue*>(this)->addSubresourceStyleURLs(urls, styleSheet);
     108        static_cast<const CSSPrimitiveValue*>(this)->addSubresourceStyleURLs(urls, styleSheet);
    109109    else if (isValueList())
    110         static_cast<CSSValueList*>(this)->addSubresourceStyleURLs(urls, styleSheet);
     110        static_cast<const CSSValueList*>(this)->addSubresourceStyleURLs(urls, styleSheet);
    111111    else if (classType() == FontFaceSrcClass)
    112         static_cast<CSSFontFaceSrcValue*>(this)->addSubresourceStyleURLs(urls, styleSheet);
     112        static_cast<const CSSFontFaceSrcValue*>(this)->addSubresourceStyleURLs(urls, styleSheet);
    113113    else if (classType() == ReflectClass)
    114         static_cast<CSSReflectValue*>(this)->addSubresourceStyleURLs(urls, styleSheet);
     114        static_cast<const CSSReflectValue*>(this)->addSubresourceStyleURLs(urls, styleSheet);
    115115}
    116116
  • trunk/Source/WebCore/css/CSSValue.h

    r118194 r118761  
    108108    PassRefPtr<CSSValue> cloneForCSSOM() const;
    109109
    110     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
     110    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    111111
    112112protected:
  • trunk/Source/WebCore/css/CSSValueList.cpp

    r118194 r118761  
    137137}
    138138
    139 void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
     139void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
    140140{
    141141    size_t size = m_values.size();
  • trunk/Source/WebCore/css/CSSValueList.h

    r118194 r118761  
    6161    String customCssText() const;
    6262
    63     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
     63    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    6464   
    6565    PassRefPtr<CSSValueList> cloneForCSSOM() const;
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r118583 r118761  
    5454    : m_cssParserMode(cssParserMode)
    5555    , m_ownsCSSOMWrapper(false)
     56    , m_isMutable(true)
    5657{
    5758}
     
    6061    : m_cssParserMode(cssParserMode)
    6162    , m_ownsCSSOMWrapper(false)
     63    , m_isMutable(false)
    6264{
    6365    m_properties.swap(properties);
     
    7274    , m_cssParserMode(o.m_cssParserMode)
    7375    , m_ownsCSSOMWrapper(false)
     76    , m_isMutable(true)
    7477{
    7578}
     
    8285}
    8386
     87void StylePropertySet::setCSSParserMode(CSSParserMode cssParserMode)
     88{
     89    ASSERT(isMutable());
     90    m_cssParserMode = cssParserMode;
     91}
     92
    8493void StylePropertySet::copyPropertiesFrom(const StylePropertySet& other)
    8594{
     95    ASSERT(isMutable());
    8696    m_properties = other.m_properties;
    8797}
     
    454464bool StylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
    455465{
     466    ASSERT(isMutable());
    456467    StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
    457468    if (!shorthand.length())
     
    462473bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText)
    463474{
     475    ASSERT(isMutable());
    464476    if (removeShorthandProperty(propertyID)) {
    465477        // FIXME: Return an equivalent shorthand when possible.
     
    517529bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
    518530{
     531    ASSERT(isMutable());
    519532    // Setting the value to an empty string just removes the property in both IE and Gecko.
    520533    // Setting it to null seems to produce less consistent results, but we treat it just the same.
     
    531544void StylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important)
    532545{
     546    ASSERT(isMutable());
    533547    StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
    534548    if (!shorthand.length()) {
     
    546560void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
    547561{
     562    ASSERT(isMutable());
    548563    if (!removeShorthandProperty(property.id())) {
    549564        CSSProperty* toReplace = slot ? slot : findPropertyWithId(property.id());
     
    558573bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, bool important)
    559574{
     575    ASSERT(isMutable());
    560576    setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(identifier), important));
    561577    return true;
     
    564580void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet)
    565581{
     582    ASSERT(isMutable());
     583
    566584    m_properties.clear();
    567585
     
    577595void StylePropertySet::addParsedProperties(const Vector<CSSProperty>& properties)
    578596{
     597    ASSERT(isMutable());
    579598    m_properties.reserveCapacity(m_properties.size() + properties.size());
    580599    for (unsigned i = 0; i < properties.size(); ++i)
     
    584603void StylePropertySet::addParsedProperty(const CSSProperty& property)
    585604{
     605    ASSERT(isMutable());
    586606    // Only add properties that have no !important counterpart present
    587607    if (!propertyIsImportant(property.id()) || property.isImportant())
     
    813833void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnConflict)
    814834{
     835    ASSERT(isMutable());
    815836    unsigned size = other->m_properties.size();
    816837    for (unsigned n = 0; n < size; ++n) {
     
    826847}
    827848
    828 void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleSheetContents* contextStyleSheet)
     849void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleSheetContents* contextStyleSheet) const
    829850{
    830851    size_t size = m_properties.size();
     
    875896bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
    876897{
     898    ASSERT(isMutable());
    877899    if (m_properties.isEmpty())
    878900        return false;
     
    913935CSSProperty* StylePropertySet::findPropertyWithId(CSSPropertyID propertyID)
    914936{
     937    ASSERT(isMutable());
    915938    for (int n = m_properties.size() - 1 ; n >= 0; --n) {
    916939        if (propertyID == m_properties[n].id())
     
    928951void StylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
    929952{
     953    ASSERT(isMutable());
    930954    Vector<CSSPropertyID> propertiesToRemove;
    931955    size_t size = m_properties.size();
     
    942966void StylePropertySet::removeEquivalentProperties(const CSSStyleDeclaration* style)
    943967{
     968    ASSERT(isMutable());
    944969    Vector<CSSPropertyID> propertiesToRemove;
    945970    size_t size = m_properties.size();
     
    968993            list.append(CSSProperty(set[i], value.release(), false));
    969994    }
    970     return StylePropertySet::adopt(list);
     995    return StylePropertySet::adoptMutable(list);
    971996}
    972997
  • trunk/Source/WebCore/css/StylePropertySet.h

    r118194 r118761  
    5050        return adoptRef(new StylePropertySet(cssParserMode));
    5151    }
    52     static PassRefPtr<StylePropertySet> adopt(StylePropertyVector& properties, CSSParserMode cssParserMode = CSSStrictMode)
     52    static PassRefPtr<StylePropertySet> adopt(StylePropertyVector& properties, CSSParserMode cssParserMode)
    5353    {
    5454        return adoptRef(new StylePropertySet(properties, cssParserMode));
     55    }
     56    static PassRefPtr<StylePropertySet> adoptMutable(StylePropertyVector& properties)
     57    {
     58        RefPtr<StylePropertySet> result = adoptRef(new StylePropertySet(properties, CSSStrictMode));
     59        result->m_isMutable = true;
     60        return result.release();
    5561    }
    5662
     
    8894    void merge(const StylePropertySet*, bool argOverridesOnConflict = true);
    8995
    90     void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
     96    void setCSSParserMode(CSSParserMode);
    9197    CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
    9298
    93     void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* contextStyleSheet);
     99    void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* contextStyleSheet) const;
    94100
    95101    PassRefPtr<StylePropertySet> copy() const;
     102
    96103    // Used by StyledElement::copyNonAttributeProperties().
    97104    void copyPropertiesFrom(const StylePropertySet&);
     
    108115    CSSStyleDeclaration* ensureCSSStyleDeclaration() const;
    109116    CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) const;
    110    
    111     // FIXME: Expand the concept of mutable/immutable StylePropertySet.
    112     bool isMutable() const { return m_ownsCSSOMWrapper; }
     117
     118    bool isMutable() const { return m_isMutable; }
    113119
    114120    static unsigned averageSizeInBytes();
     
    145151    unsigned m_cssParserMode : 2;
    146152    mutable unsigned m_ownsCSSOMWrapper : 1;
     153    mutable unsigned m_isMutable : 1;
    147154   
    148155    friend class PropertySetCSSStyleDeclaration;
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r118659 r118761  
    817817}
    818818
    819 void StyleResolver::addMatchedProperties(MatchResult& matchResult, StylePropertySet* properties, StyleRule* rule, unsigned linkMatchType, bool inRegionRule)
     819void StyleResolver::addMatchedProperties(MatchResult& matchResult, const StylePropertySet* properties, StyleRule* rule, unsigned linkMatchType, bool inRegionRule)
    820820{
    821821    matchResult.matchedProperties.grow(matchResult.matchedProperties.size() + 1);
    822822    MatchedProperties& newProperties = matchResult.matchedProperties.last();
    823     newProperties.properties = properties;
     823    newProperties.properties = const_cast<StylePropertySet*>(properties);
    824824    newProperties.linkMatchType = linkMatchType;
    825825    newProperties.isInRegionRule = inRegionRule;
     
    10521052            }
    10531053            // If the rule has no properties to apply, then ignore it in the non-debug mode.
    1054             StylePropertySet* properties = rule->properties();
     1054            const StylePropertySet* properties = rule->properties();
    10551055            if (!properties || (properties->isEmpty() && !options.includeEmptyRules)) {
    10561056                InspectorInstrumentation::didMatchRule(cookie, false);
     
    29122912
    29132913        // If the rule has no properties to apply, then ignore it.
    2914         StylePropertySet* properties = rule->properties();
     2914        const StylePropertySet* properties = rule->properties();
    29152915        if (!properties || properties->isEmpty())
    29162916            continue;
  • trunk/Source/WebCore/css/StyleResolver.h

    r118659 r118761  
    335335    };
    336336
    337     static void addMatchedProperties(MatchResult&, StylePropertySet* properties, StyleRule* = 0, unsigned linkMatchType = SelectorChecker::MatchAll, bool inRegionRule = false);
     337    static void addMatchedProperties(MatchResult&, const StylePropertySet* properties, StyleRule* = 0, unsigned linkMatchType = SelectorChecker::MatchAll, bool inRegionRule = false);
    338338    void addElementStyleProperties(MatchResult&, StylePropertySet*, bool isCacheable = true);
    339339
  • trunk/Source/WebCore/css/StyleRule.cpp

    r118484 r118761  
    181181}
    182182
     183StylePropertySet* StyleRule::mutableProperties()
     184{
     185    if (!m_properties->isMutable())
     186        m_properties = m_properties->copy();
     187    return m_properties.get();
     188}
     189
    183190void StyleRule::setProperties(PassRefPtr<StylePropertySet> properties)
    184191{
     
    202209}
    203210
     211StylePropertySet* StyleRulePage::mutableProperties()
     212{
     213    if (!m_properties->isMutable())
     214        m_properties = m_properties->copy();
     215    return m_properties.get();
     216}
     217
    204218void StyleRulePage::setProperties(PassRefPtr<StylePropertySet> properties)
    205219{
     
    220234StyleRuleFontFace::~StyleRuleFontFace()
    221235{
     236}
     237
     238StylePropertySet* StyleRuleFontFace::mutableProperties()
     239{
     240    if (!m_properties->isMutable())
     241        m_properties = m_properties->copy();
     242    return m_properties.get();
    222243}
    223244
  • trunk/Source/WebCore/css/StyleRule.h

    r115379 r118761  
    9595
    9696    const CSSSelectorList& selectorList() const { return m_selectorList; }
    97     StylePropertySet* properties() const { return m_properties.get(); }
     97    const StylePropertySet* properties() const { return m_properties.get(); }
     98    StylePropertySet* mutableProperties();
    9899   
    99100    void parserAdoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); }
     
    119120    ~StyleRuleFontFace();
    120121
    121     StylePropertySet* properties() const { return m_properties.get(); }
     122    const StylePropertySet* properties() const { return m_properties.get(); }
     123    StylePropertySet* mutableProperties();
    122124
    123125    void setProperties(PassRefPtr<StylePropertySet>);
     
    139141
    140142    const CSSSelector* selector() const { return m_selectorList.first(); }   
    141     StylePropertySet* properties() const { return m_properties.get(); }
     143    const StylePropertySet* properties() const { return m_properties.get(); }
     144    StylePropertySet* mutableProperties();
    142145
    143146    void parserAdoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); }
  • trunk/Source/WebCore/dom/ElementAttributeData.cpp

    r118194 r118761  
    137137    if (!m_inlineStyleDecl) {
    138138        ASSERT(element->isStyledElement());
    139         m_inlineStyleDecl = StylePropertySet::create();
    140         m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
     139        m_inlineStyleDecl = StylePropertySet::create(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
    141140    }
    142141    return m_inlineStyleDecl.get();
     
    158157    if (m_inlineStyleDecl && !m_inlineStyleDecl->isMutable())
    159158        m_inlineStyleDecl.clear();
    160     if (!m_inlineStyleDecl) {
    161         m_inlineStyleDecl = StylePropertySet::create();
    162         m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
    163     }
     159    if (!m_inlineStyleDecl)
     160        m_inlineStyleDecl = StylePropertySet::create(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
    164161    m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet()->contents());
    165162}
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r117361 r118761  
    10341034    if (matchedRules) {
    10351035        for (unsigned i = 0; i < matchedRules->length(); i++) {
    1036             if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE) {
    1037                 RefPtr<StylePropertySet> s = static_cast<CSSStyleRule*>(matchedRules->item(i))->styleRule()->properties();
    1038                 style->merge(s.get(), true);
    1039             }
     1036            if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE)
     1037                style->merge(static_cast<CSSStyleRule*>(matchedRules->item(i))->styleRule()->properties(), true);
    10401038        }
    10411039    }
  • trunk/Source/WebCore/svg/SVGFontFaceElement.cpp

    r118192 r118761  
    114114    CSSPropertyID propId = cssPropertyIdForSVGAttributeName(attribute.name());
    115115    if (propId > 0) {
    116         m_fontFaceRule->properties()->setProperty(propId, attribute.value(), false);
     116        m_fontFaceRule->mutableProperties()->setProperty(propId, attribute.value(), false);
    117117        rebuildFontFace();
    118118        return;
     
    298298
    299299    // Parse in-memory CSS rules
    300     m_fontFaceRule->properties()->addParsedProperty(CSSProperty(CSSPropertySrc, list));
     300    m_fontFaceRule->mutableProperties()->addParsedProperty(CSSProperty(CSSPropertySrc, list));
    301301
    302302    if (describesParentFont) {   
     
    332332    if (rootParent->inDocument()) {
    333333        document()->accessSVGExtensions()->unregisterSVGFontFaceElement(this);
    334         m_fontFaceRule->properties()->parseDeclaration(emptyString(), 0);
     334        m_fontFaceRule->mutableProperties()->parseDeclaration(emptyString(), 0);
    335335
    336336        document()->styleResolverChanged(DeferRecalcStyle);
Note: See TracChangeset for help on using the changeset viewer.