Changeset 121982 in webkit


Ignore:
Timestamp:
Jul 6, 2012 10:05:39 AM (12 years ago)
Author:
kling@webkit.org
Message:

Separate mutating CSSStyleDeclaration operations.
<http://webkit.org/b/89945>

Reviewed by Antti Koivisto.

Use separate paths for mutating the StylePropertySet wrapped by a CSSStyleDeclaration.
PropertySetCSSStyleDeclaration now has:

  • propertySet() const
  • ensureMutablePropertySet()

This is prep work for supporting immutable ElementAttributeData objects, the idea being
that calling ensureMutablePropertySet() may cause the element to convert its internal
attribute storage (which also holds the inline StylePropertySet.)

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::PropertySetCSSStyleDeclaration::length):
(WebCore::PropertySetCSSStyleDeclaration::item):
(WebCore::PropertySetCSSStyleDeclaration::cssText):
(WebCore::PropertySetCSSStyleDeclaration::setCssText):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyValue):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyPriority):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyShorthand):
(WebCore::PropertySetCSSStyleDeclaration::isPropertyImplicit):
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::removeProperty):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
(WebCore::PropertySetCSSStyleDeclaration::copy):
(WebCore::PropertySetCSSStyleDeclaration::makeMutable):
(WebCore::PropertySetCSSStyleDeclaration::cssPropertyMatches):
(WebCore::InlineCSSStyleDeclaration::didMutate):
(WebCore::InlineCSSStyleDeclaration::ensureMutablePropertySet):

  • css/PropertySetCSSStyleDeclaration.h:

(PropertySetCSSStyleDeclaration):
(WebCore::PropertySetCSSStyleDeclaration::propertySet):
(WebCore::PropertySetCSSStyleDeclaration::ensureMutablePropertySet):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121981 r121982  
     12012-07-06  Andreas Kling  <kling@webkit.org>
     2
     3        Separate mutating CSSStyleDeclaration operations.
     4        <http://webkit.org/b/89945>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Use separate paths for mutating the StylePropertySet wrapped by a CSSStyleDeclaration.
     9        PropertySetCSSStyleDeclaration now has:
     10
     11            - propertySet() const
     12            - ensureMutablePropertySet()
     13
     14        This is prep work for supporting immutable ElementAttributeData objects, the idea being
     15        that calling ensureMutablePropertySet() may cause the element to convert its internal
     16        attribute storage (which also holds the inline StylePropertySet.)
     17
     18        * css/PropertySetCSSStyleDeclaration.cpp:
     19        (WebCore::PropertySetCSSStyleDeclaration::length):
     20        (WebCore::PropertySetCSSStyleDeclaration::item):
     21        (WebCore::PropertySetCSSStyleDeclaration::cssText):
     22        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
     23        (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue):
     24        (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue):
     25        (WebCore::PropertySetCSSStyleDeclaration::getPropertyPriority):
     26        (WebCore::PropertySetCSSStyleDeclaration::getPropertyShorthand):
     27        (WebCore::PropertySetCSSStyleDeclaration::isPropertyImplicit):
     28        (WebCore::PropertySetCSSStyleDeclaration::setProperty):
     29        (WebCore::PropertySetCSSStyleDeclaration::removeProperty):
     30        (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal):
     31        (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal):
     32        (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
     33        (WebCore::PropertySetCSSStyleDeclaration::copy):
     34        (WebCore::PropertySetCSSStyleDeclaration::makeMutable):
     35        (WebCore::PropertySetCSSStyleDeclaration::cssPropertyMatches):
     36        (WebCore::InlineCSSStyleDeclaration::didMutate):
     37        (WebCore::InlineCSSStyleDeclaration::ensureMutablePropertySet):
     38        * css/PropertySetCSSStyleDeclaration.h:
     39        (PropertySetCSSStyleDeclaration):
     40        (WebCore::PropertySetCSSStyleDeclaration::propertySet):
     41        (WebCore::PropertySetCSSStyleDeclaration::ensureMutablePropertySet):
     42
    1432012-07-06  Pavel Feldman  <pfeldman@chromium.org>
    244
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r121874 r121982  
    133133unsigned PropertySetCSSStyleDeclaration::length() const
    134134{
    135     return m_propertySet->propertyCount();
     135    return propertySet()->propertyCount();
    136136}
    137137
    138138String PropertySetCSSStyleDeclaration::item(unsigned i) const
    139139{
    140     if (i >= m_propertySet->propertyCount())
     140    if (i >= propertySet()->propertyCount())
    141141        return "";
    142     return m_propertySet->propertyAt(i).cssName();
     142    return getPropertyName(propertySet()->propertyAt(i).id());
    143143}
    144144
    145145String PropertySetCSSStyleDeclaration::cssText() const
    146146{
    147     return m_propertySet->asText();
     147    return propertySet()->asText();
    148148}
    149149   
     
    157157    ec = 0;
    158158    // FIXME: Detect syntax errors and set ec.
    159     m_propertySet->parseDeclaration(text, contextStyleSheet());
     159    ensureMutablePropertySet()->parseDeclaration(text, contextStyleSheet());
    160160
    161161    didMutate(PropertyChanged);
     
    171171    if (!propertyID)
    172172        return 0;
    173     return cloneAndCacheForCSSOM(m_propertySet->getPropertyCSSValue(propertyID).get());
     173    return cloneAndCacheForCSSOM(propertySet()->getPropertyCSSValue(propertyID).get());
    174174}
    175175
     
    179179    if (!propertyID)
    180180        return String();
    181     return m_propertySet->getPropertyValue(propertyID);
     181    return propertySet()->getPropertyValue(propertyID);
    182182}
    183183
     
    187187    if (!propertyID)
    188188        return String();
    189     return m_propertySet->propertyIsImportant(propertyID) ? "important" : "";
     189    return propertySet()->propertyIsImportant(propertyID) ? "important" : "";
    190190}
    191191
     
    195195    if (!propertyID)
    196196        return String();
    197     CSSPropertyID shorthandID = m_propertySet->getPropertyShorthand(propertyID);
     197    CSSPropertyID shorthandID = propertySet()->getPropertyShorthand(propertyID);
    198198    if (!shorthandID)
    199199        return String();
     
    206206    if (!propertyID)
    207207        return false;
    208     return m_propertySet->isPropertyImplicit(propertyID);
     208    return propertySet()->isPropertyImplicit(propertyID);
    209209}
    210210
     
    223223
    224224    ec = 0;
    225     bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
     225    bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet());
    226226
    227227    didMutate(changed ? PropertyChanged : NoChanges);
     
    249249    ec = 0;
    250250    String result;
    251     bool changed = m_propertySet->removeProperty(propertyID, &result);
     251    bool changed = ensureMutablePropertySet()->removeProperty(propertyID, &result);
    252252
    253253    didMutate(changed ? PropertyChanged : NoChanges);
     
    263263PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
    264264{
    265     return m_propertySet->getPropertyCSSValue(propertyID);
     265    return propertySet()->getPropertyCSSValue(propertyID);
    266266}
    267267
    268268String PropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
    269269{
    270     return m_propertySet->getPropertyValue(propertyID);
     270    return propertySet()->getPropertyValue(propertyID);
    271271}
    272272
     
    279279
    280280    ec = 0;
    281     bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
     281    bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet());
    282282
    283283    didMutate(changed ? PropertyChanged : NoChanges);
     
    314314PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const
    315315{
    316     return m_propertySet->copy();
     316    return propertySet()->copy();
    317317}
    318318
    319319PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::makeMutable()
    320320{
    321     return m_propertySet;
     321    return ensureMutablePropertySet();
    322322}
    323323
    324324bool PropertySetCSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const
    325325{
    326     return m_propertySet->propertyMatches(property);
     326    return propertySet()->propertyMatches(property);
    327327}
    328328   
     
    390390    if (!m_parentElement)
    391391        return;
     392
    392393    m_parentElement->setNeedsStyleRecalc(InlineStyleChange);
    393394    m_parentElement->invalidateStyleAttribute();
     
    400401}
    401402
     403StylePropertySet* InlineCSSStyleDeclaration::ensureMutablePropertySet()
     404{
     405    ASSERT(m_propertySet);
     406    return m_propertySet;
     407}
     408
    402409} // namespace WebCore
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h

    r121570 r121982  
    4848    virtual void ref() OVERRIDE;
    4949    virtual void deref() OVERRIDE;
     50
     51protected:
     52    const StylePropertySet* propertySet() const { return m_propertySet; }
     53    virtual StylePropertySet* ensureMutablePropertySet() { return m_propertySet; }
    5054
    5155private:
     
    107111    virtual void didMutate(MutationType) OVERRIDE;
    108112
     113    virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE { return m_propertySet; }
     114
    109115    unsigned m_refCount;
    110116    CSSRule* m_parentRule;
     
    126132
    127133    virtual void didMutate(MutationType) OVERRIDE;
     134
     135    virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE;
    128136   
    129137    StyledElement* m_parentElement;
Note: See TracChangeset for help on using the changeset viewer.