Changeset 142791 in webkit


Ignore:
Timestamp:
Feb 13, 2013 1:48:40 PM (11 years ago)
Author:
akling@apple.com
Message:

Better names for ElementAttributeData & subclasses.
<http://webkit.org/b/109529>

Reviewed by Antti Koivisto.

  • ElementAttributeData => ElementData

Because ElementAttributeData won't be a good name once we move some non-attribute related
things to this structure.

  • ImmutableElementAttributeData => ShareableElementData

These objects can be shared with other Elements that have the same attribute name/value pairs.

  • MutableElementAttributeData => UniqueElementData

These objects contain data that is unique to a specific Element, and cannot be shared with
other Elements. This is what's important about it, not that its underlying storage is mutable.

  • attributeData() -> elementData()
  • updatedAttributeData() -> elementDataWithSynchronizedAttributes()
  • ensureUpdatedAttributeData() -> ensureElementDataWithSynchronizedAttributes()
  • mutableAttributeData() -> ensureUniqueElementData()

Ride-along renames. Much less vague than previous names IMO.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::canShareStyleWithControl):
(WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):

  • dom/Attr.cpp:

(WebCore::Attr::elementAttribute):

  • dom/DocumentSharedObjectPool.cpp:

(WebCore::ShareableElementDataCacheKey::ShareableElementDataCacheKey):
(WebCore::ShareableElementDataCacheKey::operator!=):
(WebCore::ShareableElementDataCacheEntry::ShareableElementDataCacheEntry):
(ShareableElementDataCacheEntry):
(WebCore::DocumentSharedObjectPool::cachedShareableElementDataWithAttributes):

  • dom/DocumentSharedObjectPool.h:

(DocumentSharedObjectPool):

  • dom/Element.cpp:

(WebCore::Element::detachAttribute):
(WebCore::Element::removeAttribute):
(WebCore::Element::attributes):
(WebCore::Element::getAttribute):
(WebCore::Element::setAttribute):
(WebCore::Element::setSynchronizedLazyAttribute):
(WebCore::Element::setAttributeInternal):
(WebCore::Element::attributeChanged):
(WebCore::Element::classAttributeChanged):
(WebCore::Element::shouldInvalidateDistributionWhenAttributeChanged):
(WebCore::Element::parserSetAttributes):
(WebCore::Element::hasAttributes):
(WebCore::Element::hasEquivalentAttributes):
(WebCore::Element::setAttributeNode):
(WebCore::Element::removeAttributeNode):
(WebCore::Element::removeAttributeInternal):
(WebCore::Element::addAttributeInternal):
(WebCore::Element::getAttributeNode):
(WebCore::Element::getAttributeNodeNS):
(WebCore::Element::hasAttribute):
(WebCore::Element::hasAttributeNS):
(WebCore::Element::computeInheritedLanguage):
(WebCore::Element::getURLAttribute):
(WebCore::Element::getNonEmptyURLAttribute):
(WebCore::Element::cloneAttributesFromElement):
(WebCore::Element::createUniqueElementData):
(WebCore::Element::reportMemoryUsage):
(WebCore::ElementData::deref):
(WebCore::ElementData::ElementData):
(WebCore::sizeForShareableElementDataWithAttributeCount):
(WebCore::ElementData::createShareableWithAttributes):
(WebCore::ElementData::createUnique):
(WebCore::ShareableElementData::ShareableElementData):
(WebCore::ShareableElementData::~ShareableElementData):
(WebCore::UniqueElementData::UniqueElementData):
(WebCore::ElementData::makeMutableCopy):
(WebCore::ElementData::makeImmutableCopy):
(WebCore::ElementData::setPresentationAttributeStyle):
(WebCore::ElementData::addAttribute):
(WebCore::ElementData::removeAttribute):
(WebCore::ElementData::isEquivalent):
(WebCore::ElementData::reportMemoryUsage):
(WebCore::ElementData::getAttributeItemIndexSlowCase):

  • dom/Element.h:

(ElementData):
(WebCore::ElementData::isUnique):
(ShareableElementData):
(UniqueElementData):
(WebCore::Element::getAttributeItemIndex):
(WebCore::Element::elementData):
(Element):
(WebCore::Element::elementDataWithSynchronizedAttributes):
(WebCore::Element::ensureElementDataWithSynchronizedAttributes):
(WebCore::Element::fastHasAttribute):
(WebCore::Element::fastGetAttribute):
(WebCore::Element::hasAttributesWithoutUpdate):
(WebCore::Element::idForStyleResolution):
(WebCore::Element::classNames):
(WebCore::Element::attributeCount):
(WebCore::Element::attributeItem):
(WebCore::Element::getAttributeItem):
(WebCore::Element::updateInvalidAttributes):
(WebCore::Element::hasID):
(WebCore::Element::hasClass):
(WebCore::Element::ensureUniqueElementData):
(WebCore::ElementData::mutableAttributeVector):
(WebCore::ElementData::immutableAttributeArray):
(WebCore::ElementData::length):
(WebCore::ElementData::presentationAttributeStyle):
(WebCore::ElementData::getAttributeItem):
(WebCore::ElementData::getAttributeItemIndex):
(WebCore::ElementData::attributeItem):

  • dom/Node.cpp:

(WebCore::Node::dumpStatistics):
(WebCore::Node::compareDocumentPosition):

  • dom/StyledElement.cpp:

(WebCore::StyledElement::updateStyleAttribute):
(WebCore::StyledElement::ensureMutableInlineStyle):
(WebCore::StyledElement::attributeChanged):
(WebCore::StyledElement::inlineStyleCSSOMWrapper):
(WebCore::StyledElement::setInlineStyleFromString):
(WebCore::StyledElement::styleAttributeChanged):
(WebCore::StyledElement::inlineStyleChanged):
(WebCore::StyledElement::addSubresourceAttributeURLs):
(WebCore::StyledElement::rebuildPresentationAttributeStyle):

  • dom/StyledElement.h:

(WebCore::StyledElement::inlineStyle):
(WebCore::StyledElement::invalidateStyleAttribute):
(WebCore::StyledElement::presentationAttributeStyle):

  • html/ClassList.cpp:

(WebCore::ClassList::classNames):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::updateType):

  • html/parser/HTMLConstructionSite.cpp:

(WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):

  • svg/SVGElement.cpp:

(WebCore::SVGElement::updateAnimatedSVGAttribute):

  • svg/SVGElement.h:

(WebCore::SVGElement::invalidateSVGAttributes):

  • xml/parser/XMLDocumentParserQt.cpp:

(WebCore::XMLDocumentParser::XMLDocumentParser):

Location:
trunk/Source/WebCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142788 r142791  
     12013-02-13  Andreas Kling  <akling@apple.com>
     2
     3        Better names for ElementAttributeData & subclasses.
     4        <http://webkit.org/b/109529>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        - ElementAttributeData => ElementData
     9
     10            Because ElementAttributeData won't be a good name once we move some non-attribute related
     11            things to this structure.
     12
     13        - ImmutableElementAttributeData => ShareableElementData
     14
     15            These objects can be shared with other Elements that have the same attribute name/value pairs.
     16
     17        - MutableElementAttributeData => UniqueElementData
     18
     19            These objects contain data that is unique to a specific Element, and cannot be shared with
     20            other Elements. This is what's important about it, not that its underlying storage is mutable.
     21
     22        - attributeData() -> elementData()
     23        - updatedAttributeData() -> elementDataWithSynchronizedAttributes()
     24        - ensureUpdatedAttributeData() -> ensureElementDataWithSynchronizedAttributes()
     25        - mutableAttributeData() -> ensureUniqueElementData()
     26
     27            Ride-along renames. Much less vague than previous names IMO.
     28
     29        * css/StyleResolver.cpp:
     30        (WebCore::StyleResolver::canShareStyleWithControl):
     31        (WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
     32        * dom/Attr.cpp:
     33        (WebCore::Attr::elementAttribute):
     34        * dom/DocumentSharedObjectPool.cpp:
     35        (WebCore::ShareableElementDataCacheKey::ShareableElementDataCacheKey):
     36        (WebCore::ShareableElementDataCacheKey::operator!=):
     37        (WebCore::ShareableElementDataCacheEntry::ShareableElementDataCacheEntry):
     38        (ShareableElementDataCacheEntry):
     39        (WebCore::DocumentSharedObjectPool::cachedShareableElementDataWithAttributes):
     40        * dom/DocumentSharedObjectPool.h:
     41        (DocumentSharedObjectPool):
     42        * dom/Element.cpp:
     43        (WebCore::Element::detachAttribute):
     44        (WebCore::Element::removeAttribute):
     45        (WebCore::Element::attributes):
     46        (WebCore::Element::getAttribute):
     47        (WebCore::Element::setAttribute):
     48        (WebCore::Element::setSynchronizedLazyAttribute):
     49        (WebCore::Element::setAttributeInternal):
     50        (WebCore::Element::attributeChanged):
     51        (WebCore::Element::classAttributeChanged):
     52        (WebCore::Element::shouldInvalidateDistributionWhenAttributeChanged):
     53        (WebCore::Element::parserSetAttributes):
     54        (WebCore::Element::hasAttributes):
     55        (WebCore::Element::hasEquivalentAttributes):
     56        (WebCore::Element::setAttributeNode):
     57        (WebCore::Element::removeAttributeNode):
     58        (WebCore::Element::removeAttributeInternal):
     59        (WebCore::Element::addAttributeInternal):
     60        (WebCore::Element::getAttributeNode):
     61        (WebCore::Element::getAttributeNodeNS):
     62        (WebCore::Element::hasAttribute):
     63        (WebCore::Element::hasAttributeNS):
     64        (WebCore::Element::computeInheritedLanguage):
     65        (WebCore::Element::getURLAttribute):
     66        (WebCore::Element::getNonEmptyURLAttribute):
     67        (WebCore::Element::cloneAttributesFromElement):
     68        (WebCore::Element::createUniqueElementData):
     69        (WebCore::Element::reportMemoryUsage):
     70        (WebCore::ElementData::deref):
     71        (WebCore::ElementData::ElementData):
     72        (WebCore::sizeForShareableElementDataWithAttributeCount):
     73        (WebCore::ElementData::createShareableWithAttributes):
     74        (WebCore::ElementData::createUnique):
     75        (WebCore::ShareableElementData::ShareableElementData):
     76        (WebCore::ShareableElementData::~ShareableElementData):
     77        (WebCore::UniqueElementData::UniqueElementData):
     78        (WebCore::ElementData::makeMutableCopy):
     79        (WebCore::ElementData::makeImmutableCopy):
     80        (WebCore::ElementData::setPresentationAttributeStyle):
     81        (WebCore::ElementData::addAttribute):
     82        (WebCore::ElementData::removeAttribute):
     83        (WebCore::ElementData::isEquivalent):
     84        (WebCore::ElementData::reportMemoryUsage):
     85        (WebCore::ElementData::getAttributeItemIndexSlowCase):
     86        * dom/Element.h:
     87        (ElementData):
     88        (WebCore::ElementData::isUnique):
     89        (ShareableElementData):
     90        (UniqueElementData):
     91        (WebCore::Element::getAttributeItemIndex):
     92        (WebCore::Element::elementData):
     93        (Element):
     94        (WebCore::Element::elementDataWithSynchronizedAttributes):
     95        (WebCore::Element::ensureElementDataWithSynchronizedAttributes):
     96        (WebCore::Element::fastHasAttribute):
     97        (WebCore::Element::fastGetAttribute):
     98        (WebCore::Element::hasAttributesWithoutUpdate):
     99        (WebCore::Element::idForStyleResolution):
     100        (WebCore::Element::classNames):
     101        (WebCore::Element::attributeCount):
     102        (WebCore::Element::attributeItem):
     103        (WebCore::Element::getAttributeItem):
     104        (WebCore::Element::updateInvalidAttributes):
     105        (WebCore::Element::hasID):
     106        (WebCore::Element::hasClass):
     107        (WebCore::Element::ensureUniqueElementData):
     108        (WebCore::ElementData::mutableAttributeVector):
     109        (WebCore::ElementData::immutableAttributeArray):
     110        (WebCore::ElementData::length):
     111        (WebCore::ElementData::presentationAttributeStyle):
     112        (WebCore::ElementData::getAttributeItem):
     113        (WebCore::ElementData::getAttributeItemIndex):
     114        (WebCore::ElementData::attributeItem):
     115        * dom/Node.cpp:
     116        (WebCore::Node::dumpStatistics):
     117        (WebCore::Node::compareDocumentPosition):
     118        * dom/StyledElement.cpp:
     119        (WebCore::StyledElement::updateStyleAttribute):
     120        (WebCore::StyledElement::ensureMutableInlineStyle):
     121        (WebCore::StyledElement::attributeChanged):
     122        (WebCore::StyledElement::inlineStyleCSSOMWrapper):
     123        (WebCore::StyledElement::setInlineStyleFromString):
     124        (WebCore::StyledElement::styleAttributeChanged):
     125        (WebCore::StyledElement::inlineStyleChanged):
     126        (WebCore::StyledElement::addSubresourceAttributeURLs):
     127        (WebCore::StyledElement::rebuildPresentationAttributeStyle):
     128        * dom/StyledElement.h:
     129        (WebCore::StyledElement::inlineStyle):
     130        (WebCore::StyledElement::invalidateStyleAttribute):
     131        (WebCore::StyledElement::presentationAttributeStyle):
     132        * html/ClassList.cpp:
     133        (WebCore::ClassList::classNames):
     134        * html/HTMLInputElement.cpp:
     135        (WebCore::HTMLInputElement::updateType):
     136        * html/parser/HTMLConstructionSite.cpp:
     137        (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
     138        * svg/SVGElement.cpp:
     139        (WebCore::SVGElement::updateAnimatedSVGAttribute):
     140        * svg/SVGElement.h:
     141        (WebCore::SVGElement::invalidateSVGAttributes):
     142        * xml/parser/XMLDocumentParserQt.cpp:
     143        (WebCore::XMLDocumentParser::XMLDocumentParser):
     144
    11452013-02-13  Christian Biesinger  <cbiesinger@chromium.org>
    2146
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r142757 r142791  
    908908        return false;
    909909
    910     if (thisInputElement->attributeData() != otherInputElement->attributeData()) {
     910    if (thisInputElement->elementData() != otherInputElement->elementData()) {
    911911        if (thisInputElement->fastGetAttribute(typeAttr) != otherInputElement->fastGetAttribute(typeAttr))
    912912            return false;
     
    958958{
    959959    const State& state = m_state;
    960     if (state.element()->attributeData() == sharingCandidate->attributeData())
     960    if (state.element()->elementData() == sharingCandidate->elementData())
    961961        return true;
    962962    if (state.element()->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr))
  • trunk/Source/WebCore/dom/Attr.cpp

    r141935 r142791  
    211211{
    212212    ASSERT(m_element);
    213     ASSERT(m_element->attributeData());
     213    ASSERT(m_element->elementData());
    214214    return *m_element->getAttributeItem(qualifiedName());
    215215}
  • trunk/Source/WebCore/dom/DocumentSharedObjectPool.cpp

    r142698 r142791  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232namespace WebCore {
    3333
    34 class ImmutableElementAttributeDataCacheKey {
     34class ShareableElementDataCacheKey {
    3535public:
    36     ImmutableElementAttributeDataCacheKey(const Attribute* attributes, unsigned attributeCount)
     36    ShareableElementDataCacheKey(const Attribute* attributes, unsigned attributeCount)
    3737        : m_attributes(attributes)
    3838        , m_attributeCount(attributeCount)
    3939    { }
    4040
    41     bool operator!=(const ImmutableElementAttributeDataCacheKey& other) const
     41    bool operator!=(const ShareableElementDataCacheKey& other) const
    4242    {
    4343        if (m_attributeCount != other.m_attributeCount)
     
    5656};
    5757
    58 class ImmutableElementAttributeDataCacheEntry {
     58class ShareableElementDataCacheEntry {
    5959public:
    60     ImmutableElementAttributeDataCacheEntry(const ImmutableElementAttributeDataCacheKey& k, PassRefPtr<ElementAttributeData> v)
     60    ShareableElementDataCacheEntry(const ShareableElementDataCacheKey& k, PassRefPtr<ElementData> v)
    6161        : key(k)
    6262        , value(v)
    6363    { }
    6464
    65     ImmutableElementAttributeDataCacheKey key;
    66     RefPtr<ElementAttributeData> value;
     65    ShareableElementDataCacheKey key;
     66    RefPtr<ElementData> value;
    6767};
    6868
    69 PassRefPtr<ElementAttributeData> DocumentSharedObjectPool::cachedImmutableElementAttributeData(const Vector<Attribute>& attributes)
     69PassRefPtr<ElementData> DocumentSharedObjectPool::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
    7070{
    7171    ASSERT(!attributes.isEmpty());
    7272
    73     ImmutableElementAttributeDataCacheKey cacheKey(attributes.data(), attributes.size());
     73    ShareableElementDataCacheKey cacheKey(attributes.data(), attributes.size());
    7474    unsigned cacheHash = cacheKey.hash();
    7575
    76     ImmutableElementAttributeDataCache::iterator cacheIterator = m_immutableElementAttributeDataCache.add(cacheHash, nullptr).iterator;
     76    ShareableElementDataCache::iterator cacheIterator = m_shareableElementDataCache.add(cacheHash, nullptr).iterator;
    7777    if (cacheIterator->value && cacheIterator->value->key != cacheKey)
    7878        cacheHash = 0;
    7979
    80     RefPtr<ElementAttributeData> attributeData;
     80    RefPtr<ElementData> elementData;
    8181    if (cacheHash && cacheIterator->value)
    82         attributeData = cacheIterator->value->value;
     82        elementData = cacheIterator->value->value;
    8383    else
    84         attributeData = ElementAttributeData::createImmutable(attributes);
     84        elementData = ElementData::createShareableWithAttributes(attributes);
    8585
    8686    if (!cacheHash || cacheIterator->value)
    87         return attributeData.release();
     87        return elementData.release();
    8888
    89     cacheIterator->value = adoptPtr(new ImmutableElementAttributeDataCacheEntry(ImmutableElementAttributeDataCacheKey(attributeData->immutableAttributeArray(), attributeData->length()), attributeData));
     89    cacheIterator->value = adoptPtr(new ShareableElementDataCacheEntry(ShareableElementDataCacheKey(elementData->immutableAttributeArray(), elementData->length()), elementData));
    9090
    91     return attributeData.release();
     91    return elementData.release();
    9292}
    9393
  • trunk/Source/WebCore/dom/DocumentSharedObjectPool.h

    r136334 r142791  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535
    3636class Attribute;
    37 class ElementAttributeData;
    38 class ImmutableElementAttributeDataCacheEntry;
     37class ElementData;
     38class ShareableElementDataCacheEntry;
    3939
    4040class DocumentSharedObjectPool {
     
    4343    ~DocumentSharedObjectPool();
    4444
    45     PassRefPtr<ElementAttributeData> cachedImmutableElementAttributeData(const Vector<Attribute>&);
     45    PassRefPtr<ElementData> cachedShareableElementDataWithAttributes(const Vector<Attribute>&);
    4646
    4747private:
    4848    DocumentSharedObjectPool();
    4949
    50     typedef HashMap<unsigned, OwnPtr<ImmutableElementAttributeDataCacheEntry>, AlreadyHashed> ImmutableElementAttributeDataCache;
    51     ImmutableElementAttributeDataCache m_immutableElementAttributeDataCache;
     50    typedef HashMap<unsigned, OwnPtr<ShareableElementDataCacheEntry>, AlreadyHashed> ShareableElementDataCache;
     51    ShareableElementDataCache m_shareableElementDataCache;
    5252};
    5353
  • trunk/Source/WebCore/dom/Element.cpp

    r142714 r142791  
    277277PassRefPtr<Attr> Element::detachAttribute(size_t index)
    278278{
    279     ASSERT(attributeData());
    280 
    281     const Attribute* attribute = attributeData()->attributeItem(index);
     279    ASSERT(elementData());
     280
     281    const Attribute* attribute = elementData()->attributeItem(index);
    282282    ASSERT(attribute);
    283283
     
    294294void Element::removeAttribute(const QualifiedName& name)
    295295{
    296     if (!attributeData())
     296    if (!elementData())
    297297        return;
    298298
    299     size_t index = attributeData()->getAttributeItemIndex(name);
     299    size_t index = elementData()->getAttributeItemIndex(name);
    300300    if (index == notFound)
    301301        return;
     
    314314NamedNodeMap* Element::attributes() const
    315315{
    316     ensureUpdatedAttributeData();
     316    ensureElementDataWithSynchronizedAttributes();
    317317    ElementRareData* rareData = const_cast<Element*>(this)->ensureElementRareData();
    318318    if (NamedNodeMap* attributeMap = rareData->attributeMap())
     
    335335const AtomicString& Element::getAttribute(const QualifiedName& name) const
    336336{
    337     if (!attributeData())
     337    if (!elementData())
    338338        return nullAtom;
    339339
    340     if (UNLIKELY(name == styleAttr && attributeData()->m_styleAttributeIsDirty))
     340    if (UNLIKELY(name == styleAttr && elementData()->m_styleAttributeIsDirty))
    341341        updateStyleAttribute();
    342342
    343343#if ENABLE(SVG)
    344     if (UNLIKELY(attributeData()->m_animatedSVGAttributesAreDirty))
     344    if (UNLIKELY(elementData()->m_animatedSVGAttributesAreDirty))
    345345        updateAnimatedSVGAttribute(name);
    346346#endif
     
    707707const AtomicString& Element::getAttribute(const AtomicString& name) const
    708708{
    709     if (!attributeData())
     709    if (!elementData())
    710710        return nullAtom;
    711711
     
    713713
    714714    // Update the 'style' attribute if it's invalid and being requested:
    715     if (attributeData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))
     715    if (elementData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))
    716716        updateStyleAttribute();
    717717
    718718#if ENABLE(SVG)
    719     if (attributeData()->m_animatedSVGAttributesAreDirty) {
     719    if (elementData()->m_animatedSVGAttributesAreDirty) {
    720720        // We're not passing a namespace argument on purpose. SVGNames::*Attr are defined w/o namespaces as well.
    721721        updateAnimatedSVGAttribute(QualifiedName(nullAtom, name, nullAtom));
     
    723723#endif
    724724
    725     if (const Attribute* attribute = attributeData()->getAttributeItem(name, ignoreCase))
     725    if (const Attribute* attribute = elementData()->getAttributeItem(name, ignoreCase))
    726726        return attribute->value();
    727727    return nullAtom;
     
    742742    const AtomicString& localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
    743743
    744     size_t index = ensureUpdatedAttributeData()->getAttributeItemIndex(localName, false);
     744    size_t index = ensureElementDataWithSynchronizedAttributes()->getAttributeItemIndex(localName, false);
    745745    const QualifiedName& qName = index != notFound ? attributeItem(index)->name() : QualifiedName(nullAtom, localName, nullAtom);
    746746    setAttributeInternal(index, qName, value, NotInSynchronizationOfLazyAttribute);
     
    749749void Element::setAttribute(const QualifiedName& name, const AtomicString& value)
    750750{
    751     setAttributeInternal(ensureUpdatedAttributeData()->getAttributeItemIndex(name), name, value, NotInSynchronizationOfLazyAttribute);
     751    setAttributeInternal(ensureElementDataWithSynchronizedAttributes()->getAttributeItemIndex(name), name, value, NotInSynchronizationOfLazyAttribute);
    752752}
    753753
    754754void Element::setSynchronizedLazyAttribute(const QualifiedName& name, const AtomicString& value)
    755755{
    756     setAttributeInternal(mutableAttributeData()->getAttributeItemIndex(name), name, value, InSynchronizationOfLazyAttribute);
     756    setAttributeInternal(ensureUniqueElementData()->getAttributeItemIndex(name), name, value, InSynchronizationOfLazyAttribute);
    757757}
    758758
     
    775775    if (newValue != attributeItem(index)->value()) {
    776776        // If there is an Attr node hooked to this attribute, the Attr::setValue() call below
    777         // will write into the ElementAttributeData.
     777        // will write into the ElementData.
    778778        // FIXME: Refactor this so it makes some sense.
    779779        if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrIfExists(name))
    780780            attrNode->setValue(newValue);
    781781        else
    782             mutableAttributeData()->attributeItem(index)->setValue(newValue);
     782            ensureUniqueElementData()->attributeItem(index)->setValue(newValue);
    783783    }
    784784
     
    820820
    821821    if (isIdAttributeName(name)) {
    822         AtomicString oldId = attributeData()->idForStyleResolution();
     822        AtomicString oldId = elementData()->idForStyleResolution();
    823823        AtomicString newId = makeIdForStyleResolution(newValue, document()->inQuirksMode());
    824824        if (newId != oldId) {
    825             attributeData()->setIdForStyleResolution(newId);
     825            elementData()->setIdForStyleResolution(newId);
    826826            shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForIdChange(oldId, newId, styleResolver);
    827827        }
     
    923923    if (classStringHasClassName(newClassString)) {
    924924        const bool shouldFoldCase = document()->inQuirksMode();
    925         const SpaceSplitString oldClasses = attributeData()->classNames();
    926         attributeData()->setClass(newClassString, shouldFoldCase);
    927         const SpaceSplitString& newClasses = attributeData()->classNames();
     925        const SpaceSplitString oldClasses = elementData()->classNames();
     926        elementData()->setClass(newClassString, shouldFoldCase);
     927        const SpaceSplitString& newClasses = elementData()->classNames();
    928928        shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForClassChange(oldClasses, newClasses, *styleResolver);
    929929    } else {
    930         const SpaceSplitString& oldClasses = attributeData()->classNames();
     930        const SpaceSplitString& oldClasses = elementData()->classNames();
    931931        shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForClassChange(oldClasses, *styleResolver);
    932         attributeData()->clearClass();
     932        elementData()->clearClass();
    933933    }
    934934
     
    946946
    947947    if (isIdAttributeName(name)) {
    948         AtomicString oldId = attributeData()->idForStyleResolution();
     948        AtomicString oldId = elementData()->idForStyleResolution();
    949949        AtomicString newId = makeIdForStyleResolution(newValue, document()->inQuirksMode());
    950950        if (newId != oldId) {
     
    960960        if (classStringHasClassName(newClassString)) {
    961961            const bool shouldFoldCase = document()->inQuirksMode();
    962             const SpaceSplitString& oldClasses = attributeData()->classNames();
     962            const SpaceSplitString& oldClasses = elementData()->classNames();
    963963            const SpaceSplitString newClasses(newClassString, shouldFoldCase);
    964964            if (checkSelectorForClassChange(oldClasses, newClasses, featureSet))
    965965                return true;
    966966        } else {
    967             const SpaceSplitString& oldClasses = attributeData()->classNames();
     967            const SpaceSplitString& oldClasses = elementData()->classNames();
    968968            if (checkSelectorForClassChange(oldClasses, featureSet))
    969969                return true;
     
    996996    ASSERT(!parentNode());
    997997
    998     ASSERT(!m_attributeData);
     998    ASSERT(!m_elementData);
    999999
    10001000    if (attributeVector.isEmpty())
     
    10211021
    10221022    if (document() && document()->sharedObjectPool())
    1023         m_attributeData = document()->sharedObjectPool()->cachedImmutableElementAttributeData(filteredAttributes);
     1023        m_elementData = document()->sharedObjectPool()->cachedShareableElementDataWithAttributes(filteredAttributes);
    10241024    else
    1025         m_attributeData = ElementAttributeData::createImmutable(filteredAttributes);
     1025        m_elementData = ElementData::createShareableWithAttributes(filteredAttributes);
    10261026
    10271027    // Iterate over the set of attributes we already have on the stack in case
    1028     // attributeChanged mutates m_attributeData.
     1028    // attributeChanged mutates m_elementData.
    10291029    // FIXME: Find a way so we don't have to do this.
    10301030    for (unsigned i = 0; i < filteredAttributes.size(); ++i)
     
    10351035{
    10361036    updateInvalidAttributes();
    1037     return attributeData() && attributeData()->length();
     1037    return elementData() && elementData()->length();
    10381038}
    10391039
    10401040bool Element::hasEquivalentAttributes(const Element* other) const
    10411041{
    1042     const ElementAttributeData* attributeData = updatedAttributeData();
    1043     const ElementAttributeData* otherAttributeData = other->updatedAttributeData();
    1044     if (attributeData == otherAttributeData)
     1042    const ElementData* elementData = elementDataWithSynchronizedAttributes();
     1043    const ElementData* otherElementData = other->elementDataWithSynchronizedAttributes();
     1044    if (elementData == otherElementData)
    10451045        return true;
    1046     if (attributeData)
    1047         return attributeData->isEquivalent(otherAttributeData);
    1048     if (otherAttributeData)
    1049         return otherAttributeData->isEquivalent(attributeData);
     1046    if (elementData)
     1047        return elementData->isEquivalent(otherElementData);
     1048    if (otherElementData)
     1049        return otherElementData->isEquivalent(elementData);
    10501050    return true;
    10511051}
     
    16881688
    16891689    updateInvalidAttributes();
    1690     ElementAttributeData* attributeData = mutableAttributeData();
    1691 
    1692     size_t index = attributeData->getAttributeItemIndex(attrNode->qualifiedName());
     1690    ElementData* elementData = ensureUniqueElementData();
     1691
     1692    size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName());
    16931693    if (index != notFound) {
    16941694        if (oldAttrNode)
    1695             detachAttrNodeFromElementWithValue(oldAttrNode.get(), attributeData->attributeItem(index)->value());
     1695            detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->attributeItem(index)->value());
    16961696        else
    1697             oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), attributeData->attributeItem(index)->value());
     1697            oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), elementData->attributeItem(index)->value());
    16981698    }
    16991699
     
    17241724    ASSERT(document() == attr->document());
    17251725
    1726     const ElementAttributeData* attributeData = updatedAttributeData();
    1727     ASSERT(attributeData);
    1728 
    1729     size_t index = attributeData->getAttributeItemIndex(attr->qualifiedName());
     1726    const ElementData* elementData = elementDataWithSynchronizedAttributes();
     1727    ASSERT(elementData);
     1728
     1729    size_t index = elementData->getAttributeItemIndex(attr->qualifiedName());
    17301730    if (index == notFound) {
    17311731        ec = NOT_FOUND_ERR;
     
    17661766    ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount());
    17671767
    1768     ElementAttributeData* attributeData = mutableAttributeData();
    1769 
    1770     QualifiedName name = attributeData->attributeItem(index)->name();
    1771     AtomicString valueBeingRemoved = attributeData->attributeItem(index)->value();
     1768    ElementData* elementData = ensureUniqueElementData();
     1769
     1770    QualifiedName name = elementData->attributeItem(index)->name();
     1771    AtomicString valueBeingRemoved = elementData->attributeItem(index)->value();
    17721772
    17731773    if (!inSynchronizationOfLazyAttribute) {
     
    17771777
    17781778    if (RefPtr<Attr> attrNode = attrIfExists(name))
    1779         detachAttrNodeFromElementWithValue(attrNode.get(), attributeData->attributeItem(index)->value());
    1780 
    1781     attributeData->removeAttribute(index);
     1779        detachAttrNodeFromElementWithValue(attrNode.get(), elementData->attributeItem(index)->value());
     1780
     1781    elementData->removeAttribute(index);
    17821782
    17831783    if (!inSynchronizationOfLazyAttribute)
     
    17891789    if (!inSynchronizationOfLazyAttribute)
    17901790        willModifyAttribute(name, nullAtom, value);
    1791     mutableAttributeData()->addAttribute(Attribute(name, value));
     1791    ensureUniqueElementData()->addAttribute(Attribute(name, value));
    17921792    if (!inSynchronizationOfLazyAttribute)
    17931793        didAddAttribute(name, value);
     
    17961796void Element::removeAttribute(const AtomicString& name)
    17971797{
    1798     if (!attributeData())
     1798    if (!elementData())
    17991799        return;
    18001800
    18011801    AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
    1802     size_t index = attributeData()->getAttributeItemIndex(localName, false);
     1802    size_t index = elementData()->getAttributeItemIndex(localName, false);
    18031803    if (index == notFound) {
    1804         if (UNLIKELY(localName == styleAttr) && attributeData()->m_styleAttributeIsDirty && isStyledElement())
     1804        if (UNLIKELY(localName == styleAttr) && elementData()->m_styleAttributeIsDirty && isStyledElement())
    18051805            static_cast<StyledElement*>(this)->removeAllInlineStyleProperties();
    18061806        return;
     
    18171817PassRefPtr<Attr> Element::getAttributeNode(const AtomicString& name)
    18181818{
    1819     const ElementAttributeData* attributeData = updatedAttributeData();
    1820     if (!attributeData)
     1819    const ElementData* elementData = elementDataWithSynchronizedAttributes();
     1820    if (!elementData)
    18211821        return 0;
    1822     const Attribute* attribute = attributeData->getAttributeItem(name, shouldIgnoreAttributeCase(this));
     1822    const Attribute* attribute = elementData->getAttributeItem(name, shouldIgnoreAttributeCase(this));
    18231823    if (!attribute)
    18241824        return 0;
     
    18281828PassRefPtr<Attr> Element::getAttributeNodeNS(const AtomicString& namespaceURI, const AtomicString& localName)
    18291829{
    1830     const ElementAttributeData* attributeData = updatedAttributeData();
    1831     if (!attributeData)
     1830    const ElementData* elementData = elementDataWithSynchronizedAttributes();
     1831    if (!elementData)
    18321832        return 0;
    1833     const Attribute* attribute = attributeData->getAttributeItem(QualifiedName(nullAtom, localName, namespaceURI));
     1833    const Attribute* attribute = elementData->getAttributeItem(QualifiedName(nullAtom, localName, namespaceURI));
    18341834    if (!attribute)
    18351835        return 0;
     
    18391839bool Element::hasAttribute(const AtomicString& name) const
    18401840{
    1841     if (!attributeData())
     1841    if (!elementData())
    18421842        return false;
    18431843
     
    18451845    // there may be a way to remove it.
    18461846    AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
    1847     return updatedAttributeData()->getAttributeItem(localName, false);
     1847    return elementDataWithSynchronizedAttributes()->getAttributeItem(localName, false);
    18481848}
    18491849
    18501850bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const
    18511851{
    1852     const ElementAttributeData* attributeData = updatedAttributeData();
    1853     if (!attributeData)
     1852    const ElementData* elementData = elementDataWithSynchronizedAttributes();
     1853    if (!elementData)
    18541854        return false;
    1855     return attributeData->getAttributeItem(QualifiedName(nullAtom, localName, namespaceURI));
     1855    return elementData->getAttributeItem(QualifiedName(nullAtom, localName, namespaceURI));
    18561856}
    18571857
     
    21602160    do {
    21612161        if (n->isElementNode()) {
    2162             if (const ElementAttributeData* attributeData = static_cast<const Element*>(n)->attributeData()) {
     2162            if (const ElementData* elementData = static_cast<const Element*>(n)->elementData()) {
    21632163                // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml1/#C_7
    2164                 if (const Attribute* attribute = attributeData->getAttributeItem(XMLNames::langAttr))
     2164                if (const Attribute* attribute = elementData->getAttributeItem(XMLNames::langAttr))
    21652165                    value = attribute->value();
    2166                 else if (const Attribute* attribute = attributeData->getAttributeItem(HTMLNames::langAttr))
     2166                else if (const Attribute* attribute = elementData->getAttributeItem(HTMLNames::langAttr))
    21672167                    value = attribute->value();
    21682168            }
     
    23282328{
    23292329#if !ASSERT_DISABLED
    2330     if (attributeData()) {
     2330    if (elementData()) {
    23312331        if (const Attribute* attribute = getAttributeItem(name))
    23322332            ASSERT(isURLAttribute(*attribute));
     
    23392339{
    23402340#if !ASSERT_DISABLED
    2341     if (attributeData()) {
     2341    if (elementData()) {
    23422342        if (const Attribute* attribute = getAttributeItem(name))
    23432343            ASSERT(isURLAttribute(*attribute));
     
    27462746
    27472747    other.updateInvalidAttributes();
    2748     if (!other.m_attributeData) {
    2749         m_attributeData.clear();
     2748    if (!other.m_elementData) {
     2749        m_elementData.clear();
    27502750        return;
    27512751    }
     
    27632763        updateName(oldName, newName);
    27642764
    2765     // If 'other' has a mutable ElementAttributeData, convert it to an immutable one so we can share it between both elements.
     2765    // If 'other' has a mutable ElementData, convert it to an immutable one so we can share it between both elements.
    27662766    // We can only do this if there is no CSSOM wrapper for other's inline style, and there are no presentation attributes.
    2767     if (other.m_attributeData->isMutable()
    2768         && !other.m_attributeData->presentationAttributeStyle()
    2769         && (!other.m_attributeData->inlineStyle() || !other.m_attributeData->inlineStyle()->hasCSSOMWrapper()))
    2770         const_cast<Element&>(other).m_attributeData = other.m_attributeData->makeImmutableCopy();
    2771 
    2772     if (!other.m_attributeData->isMutable())
    2773         m_attributeData = other.m_attributeData;
     2767    if (other.m_elementData->isUnique()
     2768        && !other.m_elementData->presentationAttributeStyle()
     2769        && (!other.m_elementData->inlineStyle() || !other.m_elementData->inlineStyle()->hasCSSOMWrapper()))
     2770        const_cast<Element&>(other).m_elementData = other.m_elementData->makeShareableCopy();
     2771
     2772    if (!other.m_elementData->isUnique())
     2773        m_elementData = other.m_elementData;
    27742774    else
    2775         m_attributeData = other.m_attributeData->makeMutableCopy();
    2776 
    2777     for (unsigned i = 0; i < m_attributeData->length(); ++i) {
    2778         const Attribute* attribute = const_cast<const ElementAttributeData*>(m_attributeData.get())->attributeItem(i);
     2775        m_elementData = other.m_elementData->makeUniqueCopy();
     2776
     2777    for (unsigned i = 0; i < m_elementData->length(); ++i) {
     2778        const Attribute* attribute = const_cast<const ElementData*>(m_elementData.get())->attributeItem(i);
    27792779        attributeChanged(attribute->name(), attribute->value());
    27802780    }
     
    27872787}
    27882788
    2789 void Element::createMutableAttributeData()
    2790 {
    2791     if (!m_attributeData)
    2792         m_attributeData = ElementAttributeData::create();
     2789void Element::createUniqueElementData()
     2790{
     2791    if (!m_elementData)
     2792        m_elementData = ElementData::createUnique();
    27932793    else
    2794         m_attributeData = m_attributeData->makeMutableCopy();
     2794        m_elementData = m_elementData->makeUniqueCopy();
    27952795}
    27962796
     
    28002800    ContainerNode::reportMemoryUsage(memoryObjectInfo);
    28012801    info.addMember(m_tagName, "tagName");
    2802     info.addMember(m_attributeData, "attributeData");
     2802    info.addMember(m_elementData, "elementData");
    28032803}
    28042804
     
    28202820#endif
    28212821
    2822 void ElementAttributeData::deref()
     2822void ElementData::deref()
    28232823{
    28242824    if (!derefBase())
    28252825        return;
    28262826
    2827     if (m_isMutable)
    2828         delete static_cast<MutableElementAttributeData*>(this);
     2827    if (m_isUnique)
     2828        delete static_cast<UniqueElementData*>(this);
    28292829    else
    2830         delete static_cast<ImmutableElementAttributeData*>(this);
    2831 }
    2832 
    2833 ElementAttributeData::ElementAttributeData()
    2834     : m_isMutable(true)
     2830        delete static_cast<ShareableElementData*>(this);
     2831}
     2832
     2833ElementData::ElementData()
     2834    : m_isUnique(true)
    28352835    , m_arraySize(0)
    28362836    , m_presentationAttributeStyleIsDirty(false)
     
    28422842}
    28432843
    2844 ElementAttributeData::ElementAttributeData(unsigned arraySize)
    2845     : m_isMutable(false)
     2844ElementData::ElementData(unsigned arraySize)
     2845    : m_isUnique(false)
    28462846    , m_arraySize(arraySize)
    28472847    , m_presentationAttributeStyleIsDirty(false)
     
    28532853}
    28542854
    2855 struct SameSizeAsElementAttributeData : public RefCounted<SameSizeAsElementAttributeData> {
     2855struct SameSizeAsElementData : public RefCounted<SameSizeAsElementData> {
    28562856    unsigned bitfield;
    28572857    void* refPtrs[3];
    28582858};
    28592859
    2860 COMPILE_ASSERT(sizeof(ElementAttributeData) == sizeof(SameSizeAsElementAttributeData), element_attribute_data_should_stay_small);
    2861 
    2862 static size_t sizeForImmutableElementAttributeDataWithAttributeCount(unsigned count)
    2863 {
    2864     return sizeof(ImmutableElementAttributeData) - sizeof(void*) + sizeof(Attribute) * count;
    2865 }
    2866 
    2867 PassRefPtr<ElementAttributeData> ElementAttributeData::createImmutable(const Vector<Attribute>& attributes)
    2868 {
    2869     void* slot = WTF::fastMalloc(sizeForImmutableElementAttributeDataWithAttributeCount(attributes.size()));
    2870     return adoptRef(new (slot) ImmutableElementAttributeData(attributes));
    2871 }
    2872 
    2873 PassRefPtr<ElementAttributeData> ElementAttributeData::create()
    2874 {
    2875     return adoptRef(new MutableElementAttributeData);
    2876 }
    2877 
    2878 ImmutableElementAttributeData::ImmutableElementAttributeData(const Vector<Attribute>& attributes)
    2879     : ElementAttributeData(attributes.size())
     2860COMPILE_ASSERT(sizeof(ElementData) == sizeof(SameSizeAsElementData), element_attribute_data_should_stay_small);
     2861
     2862static size_t sizeForShareableElementDataWithAttributeCount(unsigned count)
     2863{
     2864    return sizeof(ShareableElementData) - sizeof(void*) + sizeof(Attribute) * count;
     2865}
     2866
     2867PassRefPtr<ElementData> ElementData::createShareableWithAttributes(const Vector<Attribute>& attributes)
     2868{
     2869    void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(attributes.size()));
     2870    return adoptRef(new (slot) ShareableElementData(attributes));
     2871}
     2872
     2873PassRefPtr<ElementData> ElementData::createUnique()
     2874{
     2875    return adoptRef(new UniqueElementData);
     2876}
     2877
     2878ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes)
     2879    : ElementData(attributes.size())
    28802880{
    28812881    for (unsigned i = 0; i < m_arraySize; ++i)
     
    28832883}
    28842884
    2885 ImmutableElementAttributeData::~ImmutableElementAttributeData()
     2885ShareableElementData::~ShareableElementData()
    28862886{
    28872887    for (unsigned i = 0; i < m_arraySize; ++i)
     
    28892889}
    28902890
    2891 ImmutableElementAttributeData::ImmutableElementAttributeData(const MutableElementAttributeData& other)
    2892     : ElementAttributeData(other, false)
     2891ShareableElementData::ShareableElementData(const UniqueElementData& other)
     2892    : ElementData(other, false)
    28932893{
    28942894    ASSERT(!other.m_presentationAttributeStyle);
     
    29032903}
    29042904
    2905 ElementAttributeData::ElementAttributeData(const ElementAttributeData& other, bool isMutable)
    2906     : m_isMutable(isMutable)
    2907     , m_arraySize(isMutable ? 0 : other.length())
     2905ElementData::ElementData(const ElementData& other, bool isUnique)
     2906    : m_isUnique(isUnique)
     2907    , m_arraySize(isUnique ? 0 : other.length())
    29082908    , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty)
    29092909    , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty)
     
    29172917}
    29182918
    2919 MutableElementAttributeData::MutableElementAttributeData()
    2920 {
    2921 }
    2922 
    2923 MutableElementAttributeData::MutableElementAttributeData(const MutableElementAttributeData& other)
    2924     : ElementAttributeData(other, true)
     2919UniqueElementData::UniqueElementData()
     2920{
     2921}
     2922
     2923UniqueElementData::UniqueElementData(const UniqueElementData& other)
     2924    : ElementData(other, true)
    29252925    , m_presentationAttributeStyle(other.m_presentationAttributeStyle)
    29262926    , m_attributeVector(other.m_attributeVector)
     
    29292929}
    29302930
    2931 MutableElementAttributeData::MutableElementAttributeData(const ImmutableElementAttributeData& other)
    2932     : ElementAttributeData(other, true)
    2933 {
    2934     // An ImmutableElementAttributeData should never have a mutable inline StylePropertySet attached.
     2931UniqueElementData::UniqueElementData(const ShareableElementData& other)
     2932    : ElementData(other, true)
     2933{
     2934    // An ShareableElementData should never have a mutable inline StylePropertySet attached.
    29352935    ASSERT(!other.m_inlineStyle || !other.m_inlineStyle->isMutable());
    29362936    m_inlineStyle = other.m_inlineStyle;
     
    29412941}
    29422942
    2943 PassRefPtr<ElementAttributeData> ElementAttributeData::makeMutableCopy() const
    2944 {
    2945     if (isMutable())
    2946         return adoptRef(new MutableElementAttributeData(static_cast<const MutableElementAttributeData&>(*this)));
    2947     return adoptRef(new MutableElementAttributeData(static_cast<const ImmutableElementAttributeData&>(*this)));
    2948 }
    2949 
    2950 PassRefPtr<ElementAttributeData> ElementAttributeData::makeImmutableCopy() const
    2951 {
    2952     ASSERT(isMutable());
    2953     void* slot = WTF::fastMalloc(sizeForImmutableElementAttributeDataWithAttributeCount(mutableAttributeVector().size()));
    2954     return adoptRef(new (slot) ImmutableElementAttributeData(static_cast<const MutableElementAttributeData&>(*this)));
    2955 }
    2956 
    2957 void ElementAttributeData::setPresentationAttributeStyle(PassRefPtr<StylePropertySet> style) const
    2958 {
    2959     ASSERT(m_isMutable);
    2960     static_cast<const MutableElementAttributeData*>(this)->m_presentationAttributeStyle = style;
    2961 }
    2962 
    2963 void ElementAttributeData::addAttribute(const Attribute& attribute)
    2964 {
    2965     ASSERT(isMutable());
     2943PassRefPtr<ElementData> ElementData::makeUniqueCopy() const
     2944{
     2945    if (isUnique())
     2946        return adoptRef(new UniqueElementData(static_cast<const UniqueElementData&>(*this)));
     2947    return adoptRef(new UniqueElementData(static_cast<const ShareableElementData&>(*this)));
     2948}
     2949
     2950PassRefPtr<ElementData> ElementData::makeShareableCopy() const
     2951{
     2952    ASSERT(isUnique());
     2953    void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(mutableAttributeVector().size()));
     2954    return adoptRef(new (slot) ShareableElementData(static_cast<const UniqueElementData&>(*this)));
     2955}
     2956
     2957void ElementData::setPresentationAttributeStyle(PassRefPtr<StylePropertySet> style) const
     2958{
     2959    ASSERT(m_isUnique);
     2960    static_cast<const UniqueElementData*>(this)->m_presentationAttributeStyle = style;
     2961}
     2962
     2963void ElementData::addAttribute(const Attribute& attribute)
     2964{
     2965    ASSERT(isUnique());
    29662966    mutableAttributeVector().append(attribute);
    29672967}
    29682968
    2969 void ElementAttributeData::removeAttribute(size_t index)
    2970 {
    2971     ASSERT(isMutable());
     2969void ElementData::removeAttribute(size_t index)
     2970{
     2971    ASSERT(isUnique());
    29722972    ASSERT_WITH_SECURITY_IMPLICATION(index < length());
    29732973    mutableAttributeVector().remove(index);
    29742974}
    29752975
    2976 bool ElementAttributeData::isEquivalent(const ElementAttributeData* other) const
     2976bool ElementData::isEquivalent(const ElementData* other) const
    29772977{
    29782978    if (!other)
     
    29932993}
    29942994
    2995 void ElementAttributeData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    2996 {
    2997     size_t actualSize = m_isMutable ? sizeof(ElementAttributeData) : sizeForImmutableElementAttributeDataWithAttributeCount(m_arraySize);
     2995void ElementData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     2996{
     2997    size_t actualSize = m_isUnique ? sizeof(ElementData) : sizeForShareableElementDataWithAttributeCount(m_arraySize);
    29982998    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM, actualSize);
    29992999    info.addMember(m_inlineStyle, "inlineStyle");
    30003000    info.addMember(m_classNames, "classNames");
    30013001    info.addMember(m_idForStyleResolution, "idForStyleResolution");
    3002     if (m_isMutable) {
     3002    if (m_isUnique) {
    30033003        info.addMember(presentationAttributeStyle(), "presentationAttributeStyle()");
    30043004        info.addMember(mutableAttributeVector(), "mutableAttributeVector");
     
    30083008}
    30093009
    3010 size_t ElementAttributeData::getAttributeItemIndexSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
     3010size_t ElementData::getAttributeItemIndexSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
    30113011{
    30123012    // Continue to checking case-insensitively and/or full namespaced names if necessary:
  • trunk/Source/WebCore/dom/Element.h

    r142714 r142791  
    4444class ElementRareData;
    4545class ElementShadow;
    46 class ImmutableElementAttributeData;
     46class ShareableElementData;
    4747class IntSize;
    4848class Locale;
    49 class MutableElementAttributeData;
     49class UniqueElementData;
    5050class PseudoElement;
    5151class RenderRegion;
     
    5353class StylePropertySet;
    5454
    55 class ElementAttributeData : public RefCounted<ElementAttributeData> {
     55class ElementData : public RefCounted<ElementData> {
    5656    WTF_MAKE_FAST_ALLOCATED;
    5757public:
    58     static PassRefPtr<ElementAttributeData> create();
    59     static PassRefPtr<ElementAttributeData> createImmutable(const Vector<Attribute>&);
     58    static PassRefPtr<ElementData> createUnique();
     59    static PassRefPtr<ElementData> createShareableWithAttributes(const Vector<Attribute>&);
    6060
    6161    // Override RefCounted's deref() to ensure operator delete is called on
     
    9292    bool hasClass() const { return !m_classNames.isNull(); }
    9393
    94     bool isEquivalent(const ElementAttributeData* other) const;
     94    bool isEquivalent(const ElementData* other) const;
    9595
    9696    void reportMemoryUsage(MemoryObjectInfo*) const;
    9797
    98     bool isMutable() const { return m_isMutable; }
     98    bool isUnique() const { return m_isUnique; }
    9999    const Attribute* immutableAttributeArray() const;
    100100
    101101protected:
    102     ElementAttributeData();
    103     ElementAttributeData(unsigned arraySize);
    104     ElementAttributeData(const ElementAttributeData&, bool isMutable);
    105 
    106     unsigned m_isMutable : 1;
     102    ElementData();
     103    ElementData(unsigned arraySize);
     104    ElementData(const ElementData&, bool isUnique);
     105
     106    unsigned m_isUnique : 1;
    107107    unsigned m_arraySize : 28;
    108108    mutable unsigned m_presentationAttributeStyleIsDirty : 1;
     
    119119    friend class Element;
    120120    friend class StyledElement;
    121     friend class ImmutableElementAttributeData;
    122     friend class MutableElementAttributeData;
     121    friend class ShareableElementData;
     122    friend class UniqueElementData;
    123123#if ENABLE(SVG)
    124124    friend class SVGElement;
     
    129129    size_t getAttributeItemIndexSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
    130130
    131     PassRefPtr<ElementAttributeData> makeMutableCopy() const;
    132     PassRefPtr<ElementAttributeData> makeImmutableCopy() const;
     131    PassRefPtr<ElementData> makeUniqueCopy() const;
     132    PassRefPtr<ElementData> makeShareableCopy() const;
    133133
    134134    Vector<Attribute, 4>& mutableAttributeVector();
     
    136136};
    137137
    138 class ImmutableElementAttributeData : public ElementAttributeData {
     138class ShareableElementData : public ElementData {
    139139public:
    140     ImmutableElementAttributeData(const Vector<Attribute>&);
    141     ImmutableElementAttributeData(const MutableElementAttributeData&);
    142     ~ImmutableElementAttributeData();
     140    ShareableElementData(const Vector<Attribute>&);
     141    ShareableElementData(const UniqueElementData&);
     142    ~ShareableElementData();
    143143
    144144    void* m_attributeArray;
    145145};
    146146
    147 class MutableElementAttributeData : public ElementAttributeData {
     147class UniqueElementData : public ElementData {
    148148public:
    149     MutableElementAttributeData();
    150     MutableElementAttributeData(const ImmutableElementAttributeData&);
    151     MutableElementAttributeData(const MutableElementAttributeData&);
     149    UniqueElementData();
     150    UniqueElementData(const ShareableElementData&);
     151    UniqueElementData(const UniqueElementData&);
    152152
    153153    mutable RefPtr<StylePropertySet> m_presentationAttributeStyle;
     
    287287    const Attribute* getAttributeItem(const QualifiedName&) const;
    288288    Attribute* getAttributeItem(const QualifiedName&);
    289     size_t getAttributeItemIndex(const QualifiedName& name) const { return attributeData()->getAttributeItemIndex(name); }
    290     size_t getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const { return attributeData()->getAttributeItemIndex(name, shouldIgnoreAttributeCase); }
     289    size_t getAttributeItemIndex(const QualifiedName& name) const { return elementData()->getAttributeItemIndex(name); }
     290    size_t getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const { return elementData()->getAttributeItemIndex(name, shouldIgnoreAttributeCase); }
    291291
    292292    void scrollIntoView(bool alignToTop = true);
     
    372372    void parserSetAttributes(const Vector<Attribute>&, FragmentScriptingPermission);
    373373
    374     const ElementAttributeData* attributeData() const { return m_attributeData.get(); }
    375     ElementAttributeData* mutableAttributeData();
    376     const ElementAttributeData* updatedAttributeData() const;
    377     const ElementAttributeData* ensureUpdatedAttributeData() const;
     374    const ElementData* elementData() const { return m_elementData.get(); }
     375    ElementData* ensureUniqueElementData();
     376    const ElementData* elementDataWithSynchronizedAttributes() const;
     377    const ElementData* ensureElementDataWithSynchronizedAttributes() const;
    378378
    379379    // Clones attributes only.
     
    706706    void unregisterNamedFlowContentNode();
    707707
    708     void createMutableAttributeData();
     708    void createUniqueElementData();
    709709
    710710    bool shouldInvalidateDistributionWhenAttributeChanged(ElementShadow*, const QualifiedName&, const AtomicString&);
     
    718718    void createRendererIfNeeded();
    719719
    720     RefPtr<ElementAttributeData> m_attributeData;
     720    RefPtr<ElementData> m_elementData;
    721721};
    722722   
     
    778778}
    779779
    780 inline const ElementAttributeData* Element::updatedAttributeData() const
     780inline const ElementData* Element::elementDataWithSynchronizedAttributes() const
    781781{
    782782    updateInvalidAttributes();
    783     return attributeData();
    784 }
    785 
    786 inline const ElementAttributeData* Element::ensureUpdatedAttributeData() const
     783    return elementData();
     784}
     785
     786inline const ElementData* Element::ensureElementDataWithSynchronizedAttributes() const
    787787{
    788788    updateInvalidAttributes();
    789     if (attributeData())
    790         return attributeData();
    791     return const_cast<Element*>(this)->mutableAttributeData();
     789    if (elementData())
     790        return elementData();
     791    return const_cast<Element*>(this)->ensureUniqueElementData();
    792792}
    793793
     
    832832{
    833833    ASSERT(fastAttributeLookupAllowed(name));
    834     return attributeData() && getAttributeItem(name);
     834    return elementData() && getAttributeItem(name);
    835835}
    836836
     
    838838{
    839839    ASSERT(fastAttributeLookupAllowed(name));
    840     if (attributeData()) {
     840    if (elementData()) {
    841841        if (const Attribute* attribute = getAttributeItem(name))
    842842            return attribute->value();
     
    847847inline bool Element::hasAttributesWithoutUpdate() const
    848848{
    849     return attributeData() && !attributeData()->isEmpty();
     849    return elementData() && !elementData()->isEmpty();
    850850}
    851851
     
    853853{
    854854    ASSERT(hasID());
    855     return attributeData()->idForStyleResolution();
     855    return elementData()->idForStyleResolution();
    856856}
    857857
     
    883883{
    884884    ASSERT(hasClass());
    885     ASSERT(attributeData());
    886     return attributeData()->classNames();
     885    ASSERT(elementData());
     886    return elementData()->classNames();
    887887}
    888888
    889889inline size_t Element::attributeCount() const
    890890{
    891     ASSERT(attributeData());
    892     return attributeData()->length();
     891    ASSERT(elementData());
     892    return elementData()->length();
    893893}
    894894
    895895inline const Attribute* Element::attributeItem(unsigned index) const
    896896{
    897     ASSERT(attributeData());
    898     return attributeData()->attributeItem(index);
     897    ASSERT(elementData());
     898    return elementData()->attributeItem(index);
    899899}
    900900
    901901inline const Attribute* Element::getAttributeItem(const QualifiedName& name) const
    902902{
    903     ASSERT(attributeData());
    904     return attributeData()->getAttributeItem(name);
     903    ASSERT(elementData());
     904    return elementData()->getAttributeItem(name);
    905905}
    906906
    907907inline Attribute* Element::getAttributeItem(const QualifiedName& name)
    908908{
    909     ASSERT(attributeData());
    910     return mutableAttributeData()->getAttributeItem(name);
     909    ASSERT(elementData());
     910    return ensureUniqueElementData()->getAttributeItem(name);
    911911}
    912912
    913913inline void Element::updateInvalidAttributes() const
    914914{
    915     if (!attributeData())
     915    if (!elementData())
    916916        return;
    917917
    918     if (attributeData()->m_styleAttributeIsDirty)
     918    if (elementData()->m_styleAttributeIsDirty)
    919919        updateStyleAttribute();
    920920
    921921#if ENABLE(SVG)
    922     if (attributeData()->m_animatedSVGAttributesAreDirty)
     922    if (elementData()->m_animatedSVGAttributesAreDirty)
    923923        updateAnimatedSVGAttribute(anyQName());
    924924#endif
     
    927927inline bool Element::hasID() const
    928928{
    929     return attributeData() && attributeData()->hasID();
     929    return elementData() && elementData()->hasID();
    930930}
    931931
    932932inline bool Element::hasClass() const
    933933{
    934     return attributeData() && attributeData()->hasClass();
    935 }
    936 
    937 inline ElementAttributeData* Element::mutableAttributeData()
    938 {
    939     if (!attributeData() || !attributeData()->isMutable())
    940         createMutableAttributeData();
    941     return m_attributeData.get();
     934    return elementData() && elementData()->hasClass();
     935}
     936
     937inline ElementData* Element::ensureUniqueElementData()
     938{
     939    if (!elementData() || !elementData()->isUnique())
     940        createUniqueElementData();
     941    return m_elementData.get();
    942942}
    943943
     
    976976    return node && node->isElementNode() && toElement(node)->shadow();
    977977}
    978 inline Vector<Attribute, 4>& ElementAttributeData::mutableAttributeVector()
    979 {
    980     ASSERT(m_isMutable);
    981     return static_cast<MutableElementAttributeData*>(this)->m_attributeVector;
    982 }
    983 
    984 inline const Vector<Attribute, 4>& ElementAttributeData::mutableAttributeVector() const
    985 {
    986     ASSERT(m_isMutable);
    987     return static_cast<const MutableElementAttributeData*>(this)->m_attributeVector;
    988 }
    989 
    990 inline const Attribute* ElementAttributeData::immutableAttributeArray() const
    991 {
    992     ASSERT(!m_isMutable);
    993     return reinterpret_cast<const Attribute*>(&static_cast<const ImmutableElementAttributeData*>(this)->m_attributeArray);
    994 }
    995 
    996 inline size_t ElementAttributeData::length() const
    997 {
    998     if (isMutable())
     978inline Vector<Attribute, 4>& ElementData::mutableAttributeVector()
     979{
     980    ASSERT(m_isUnique);
     981    return static_cast<UniqueElementData*>(this)->m_attributeVector;
     982}
     983
     984inline const Vector<Attribute, 4>& ElementData::mutableAttributeVector() const
     985{
     986    ASSERT(m_isUnique);
     987    return static_cast<const UniqueElementData*>(this)->m_attributeVector;
     988}
     989
     990inline const Attribute* ElementData::immutableAttributeArray() const
     991{
     992    ASSERT(!m_isUnique);
     993    return reinterpret_cast<const Attribute*>(&static_cast<const ShareableElementData*>(this)->m_attributeArray);
     994}
     995
     996inline size_t ElementData::length() const
     997{
     998    if (isUnique())
    999999        return mutableAttributeVector().size();
    10001000    return m_arraySize;
    10011001}
    10021002
    1003 inline const StylePropertySet* ElementAttributeData::presentationAttributeStyle() const
    1004 {
    1005     if (!m_isMutable)
     1003inline const StylePropertySet* ElementData::presentationAttributeStyle() const
     1004{
     1005    if (!m_isUnique)
    10061006        return 0;
    1007     return static_cast<const MutableElementAttributeData*>(this)->m_presentationAttributeStyle.get();
    1008 }
    1009 
    1010 inline Attribute* ElementAttributeData::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase)
     1007    return static_cast<const UniqueElementData*>(this)->m_presentationAttributeStyle.get();
     1008}
     1009
     1010inline Attribute* ElementData::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase)
    10111011{
    10121012    size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase);
     
    10161016}
    10171017
    1018 inline const Attribute* ElementAttributeData::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const
     1018inline const Attribute* ElementData::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const
    10191019{
    10201020    size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase);
     
    10241024}
    10251025
    1026 inline size_t ElementAttributeData::getAttributeItemIndex(const QualifiedName& name) const
     1026inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name) const
    10271027{
    10281028    for (unsigned i = 0; i < length(); ++i) {
     
    10351035// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller
    10361036// can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not).
    1037 inline size_t ElementAttributeData::getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const
     1037inline size_t ElementData::getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const
    10381038{
    10391039    unsigned len = length();
     
    10551055}
    10561056
    1057 inline const Attribute* ElementAttributeData::getAttributeItem(const QualifiedName& name) const
     1057inline const Attribute* ElementData::getAttributeItem(const QualifiedName& name) const
    10581058{
    10591059    for (unsigned i = 0; i < length(); ++i) {
     
    10641064}
    10651065
    1066 inline Attribute* ElementAttributeData::getAttributeItem(const QualifiedName& name)
     1066inline Attribute* ElementData::getAttributeItem(const QualifiedName& name)
    10671067{
    10681068    for (unsigned i = 0; i < length(); ++i) {
     
    10731073}
    10741074
    1075 inline const Attribute* ElementAttributeData::attributeItem(unsigned index) const
     1075inline const Attribute* ElementData::attributeItem(unsigned index) const
    10761076{
    10771077    ASSERT_WITH_SECURITY_IMPLICATION(index < length());
    1078     if (m_isMutable)
     1078    if (m_isUnique)
    10791079        return &mutableAttributeVector().at(index);
    10801080    return &immutableAttributeArray()[index];
    10811081}
    10821082
    1083 inline Attribute* ElementAttributeData::attributeItem(unsigned index)
     1083inline Attribute* ElementData::attributeItem(unsigned index)
    10841084{
    10851085    ASSERT_WITH_SECURITY_IMPLICATION(index < length());
  • trunk/Source/WebCore/dom/Node.cpp

    r142719 r142791  
    206206                    result.iterator->value++;
    207207
    208                 if (ElementAttributeData* attributeData = element->attributeData()) {
    209                     attributes += attributeData->length();
     208                if (ElementData* elementData = element->elementData()) {
     209                    attributes += elementData->length();
    210210                    ++elementsWithAttributeStorage;
    211                     for (unsigned i = 0; i < attributeData->length(); ++i) {
    212                         Attribute* attr = attributeData->attributeItem(i);
     211                    for (unsigned i = 0; i < elementData->length(); ++i) {
     212                        Attribute* attr = elementData->attributeItem(i);
    213213                        if (attr->attr())
    214214                            ++attributesWithAttr;
     
    297297    printf("  Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes, sizeof(Attribute));
    298298    printf("  Number of Attributes with an Attr: %zu\n", attributesWithAttr);
    299     printf("  Number of Elements with attribute storage: %zu [%zu]\n", elementsWithAttributeStorage, sizeof(ElementAttributeData));
     299    printf("  Number of Elements with attribute storage: %zu [%zu]\n", elementsWithAttributeStorage, sizeof(ElementData));
    300300    printf("  Number of Elements with RareData: %zu\n", elementsWithRareData);
    301301    printf("  Number of Elements with NamedNodeMap: %zu [%zu]\n", elementsWithNamedNodeMap, sizeof(NamedNodeMap));
     
    17541754        // We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first.
    17551755        Element* owner1 = attr1->ownerElement();
    1756         owner1->updatedAttributeData(); // Force update invalid attributes.
     1756        owner1->elementDataWithSynchronizedAttributes(); // Force update invalid attributes.
    17571757        unsigned length = owner1->attributeCount();
    17581758        for (unsigned i = 0; i < length; ++i) {
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r135421 r142791  
    129129void StyledElement::updateStyleAttribute() const
    130130{
    131     ASSERT(attributeData());
    132     ASSERT(attributeData()->m_styleAttributeIsDirty);
    133     attributeData()->m_styleAttributeIsDirty = false;
     131    ASSERT(elementData());
     132    ASSERT(elementData()->m_styleAttributeIsDirty);
     133    elementData()->m_styleAttributeIsDirty = false;
    134134    if (const StylePropertySet* inlineStyle = this->inlineStyle())
    135135        const_cast<StyledElement*>(this)->setSynchronizedLazyAttribute(styleAttr, inlineStyle->asText());
     
    149149StylePropertySet* StyledElement::ensureMutableInlineStyle()
    150150{
    151     RefPtr<StylePropertySet>& inlineStyle = mutableAttributeData()->m_inlineStyle;
     151    RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineStyle;
    152152    if (!inlineStyle)
    153153        inlineStyle = StylePropertySet::create(strictToCSSParserMode(isHTMLElement() && !document()->inQuirksMode()));
     
    162162        styleAttributeChanged(newValue);
    163163    else if (isPresentationAttribute(name)) {
    164         attributeData()->m_presentationAttributeStyleIsDirty = true;
     164        elementData()->m_presentationAttributeStyleIsDirty = true;
    165165        setNeedsStyleRecalc(InlineStyleChange);
    166166    }
     
    173173    if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper())
    174174        return 0;
    175     PropertySetCSSStyleDeclaration* cssomWrapper = mutableAttributeData()->m_inlineStyle->cssStyleDeclaration();
     175    PropertySetCSSStyleDeclaration* cssomWrapper = ensureUniqueElementData()->m_inlineStyle->cssStyleDeclaration();
    176176    ASSERT(cssomWrapper && cssomWrapper->parentElement() == this);
    177177    return cssomWrapper;
     
    180180inline void StyledElement::setInlineStyleFromString(const AtomicString& newStyleString)
    181181{
    182     RefPtr<StylePropertySet>& inlineStyle = attributeData()->m_inlineStyle;
     182    RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle;
    183183
    184184    // Avoid redundant work if we're using shared attribute data with already parsed inline style.
    185     if (inlineStyle && !attributeData()->isMutable())
     185    if (inlineStyle && !elementData()->isUnique())
    186186        return;
    187187
     
    206206        if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper())
    207207            cssomWrapper->clearParentElement();
    208         mutableAttributeData()->m_inlineStyle.clear();
     208        ensureUniqueElementData()->m_inlineStyle.clear();
    209209    } else if (document()->contentSecurityPolicy()->allowInlineStyle(document()->url(), startLineNumber))
    210210        setInlineStyleFromString(newStyleString);
    211211
    212     attributeData()->m_styleAttributeIsDirty = false;
     212    elementData()->m_styleAttributeIsDirty = false;
    213213
    214214    setNeedsStyleRecalc(InlineStyleChange);
     
    219219{
    220220    setNeedsStyleRecalc(InlineStyleChange);
    221     ASSERT(attributeData());
    222     attributeData()->m_styleAttributeIsDirty = true;
     221    ASSERT(elementData());
     222    elementData()->m_styleAttributeIsDirty = true;
    223223    InspectorInstrumentation::didInvalidateStyleAttr(document(), this);
    224224}
     
    266266void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
    267267{
    268     if (const StylePropertySet* inlineStyle = attributeData() ? attributeData()->inlineStyle() : 0)
     268    if (const StylePropertySet* inlineStyle = elementData() ? elementData()->inlineStyle() : 0)
    269269        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet()->contents());
    270270}
     
    341341    }
    342342
    343     // ImmutableElementAttributeData doesn't store presentation attribute style, so make sure we have a MutableElementAttributeData.
    344     ElementAttributeData* attributeData = mutableAttributeData();
    345 
    346     attributeData->m_presentationAttributeStyleIsDirty = false;
    347     attributeData->setPresentationAttributeStyle(style->isEmpty() ? 0 : style);
     343    // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
     344    ElementData* elementData = ensureUniqueElementData();
     345
     346    elementData->m_presentationAttributeStyleIsDirty = false;
     347    elementData->setPresentationAttributeStyle(style->isEmpty() ? 0 : style);
    348348
    349349    if (!cacheHash || cacheIterator->value)
  • trunk/Source/WebCore/dom/StyledElement.h

    r135101 r142791  
    4141    void invalidateStyleAttribute();
    4242
    43     const StylePropertySet* inlineStyle() const { return attributeData() ? attributeData()->m_inlineStyle.get() : 0; }
     43    const StylePropertySet* inlineStyle() const { return elementData() ? elementData()->m_inlineStyle.get() : 0; }
    4444    StylePropertySet* ensureMutableInlineStyle();
    4545   
     
    8787inline void StyledElement::invalidateStyleAttribute()
    8888{
    89     ASSERT(attributeData());
    90     attributeData()->m_styleAttributeIsDirty = true;
     89    ASSERT(elementData());
     90    elementData()->m_styleAttributeIsDirty = true;
    9191}
    9292
    9393inline const StylePropertySet* StyledElement::presentationAttributeStyle()
    9494{
    95     if (!attributeData())
     95    if (!elementData())
    9696        return 0;
    97     if (attributeData()->m_presentationAttributeStyleIsDirty)
     97    if (elementData()->m_presentationAttributeStyleIsDirty)
    9898        rebuildPresentationAttributeStyle();
    99     return attributeData()->presentationAttributeStyle();
     99    return elementData()->presentationAttributeStyle();
    100100}
    101101
  • trunk/Source/WebCore/html/ClassList.cpp

    r138691 r142791  
    6969        return *m_classNamesForQuirksMode.get();
    7070    }
    71     return m_element->attributeData()->classNames();
     71    return m_element->elementData()->classNames();
    7272}
    7373
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r142592 r142791  
    516516
    517517    if (didRespectHeightAndWidth != m_inputType->shouldRespectHeightAndWidthAttributes()) {
    518         ASSERT(attributeData());
     518        ASSERT(elementData());
    519519        if (Attribute* height = getAttributeItem(heightAttr))
    520520            attributeChanged(heightAttr, height->value());
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r142641 r142791  
    212212    for (unsigned i = 0; i < token->attributes().size(); ++i) {
    213213        const Attribute& tokenAttribute = token->attributes().at(i);
    214         if (!element->attributeData() || !element->getAttributeItem(tokenAttribute.name()))
     214        if (!element->elementData() || !element->getAttributeItem(tokenAttribute.name()))
    215215            element->setAttribute(tokenAttribute.name(), tokenAttribute.value());
    216216    }
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r141524 r142791  
    545545void SVGElement::updateAnimatedSVGAttribute(const QualifiedName& name) const
    546546{
    547     if (!attributeData() || !attributeData()->m_animatedSVGAttributesAreDirty)
     547    if (!elementData() || !elementData()->m_animatedSVGAttributesAreDirty)
    548548        return;
    549549
     
    551551    if (name == anyQName()) {
    552552        nonConstThis->localAttributeToPropertyMap().synchronizeProperties(nonConstThis);
    553         attributeData()->m_animatedSVGAttributesAreDirty = false;
     553        elementData()->m_animatedSVGAttributesAreDirty = false;
    554554    } else
    555555        nonConstThis->localAttributeToPropertyMap().synchronizeProperty(nonConstThis, name);
  • trunk/Source/WebCore/svg/SVGElement.h

    r142714 r142791  
    8080    virtual AffineTransform* supplementalTransform() { return 0; }
    8181
    82     void invalidateSVGAttributes() { mutableAttributeData()->m_animatedSVGAttributesAreDirty = true; }
     82    void invalidateSVGAttributes() { ensureUniqueElementData()->m_animatedSVGAttributesAreDirty = true; }
    8383
    8484    const HashSet<SVGElementInstance*>& instancesForElement() const;
  • trunk/Source/WebCore/xml/parser/XMLDocumentParserQt.cpp

    r142375 r142791  
    147147    QXmlStreamNamespaceDeclarations namespaces;
    148148    for (Element* element = elemStack.last(); !elemStack.isEmpty(); elemStack.removeLast()) {
    149         if (const ElementAttributeData* attrs = element->updatedAttributeData()) {
     149        if (const ElementData* attrs = element->elementDataWithSynchronizedAttributes()) {
    150150            for (unsigned i = 0; i < attrs->length(); i++) {
    151151                const Attribute* attr = attrs->attributeItem(i);
Note: See TracChangeset for help on using the changeset viewer.