Changeset 142827 in webkit


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

Remove Element::getAttributeItem() overload that returned a mutable Attribute*.
<http://webkit.org/b/109756>

Reviewed by Antti Koivisto.

Remove this to prevent callers from accidentally causing elements to convert to UniqueElementData.
There are two call sites (Attr and HTMLSelectElement) that legitimately need to mutate Attribute
objects in-place, they now use Element::ensureUniqueElementData()->getAttributeItem() directly instead.

Small progression on Membuster3, mostly for peace of mind.

  • dom/Attr.cpp:

(WebCore::Attr::elementAttribute):

  • dom/Element.h:

(Element):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::updateType):

  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::parseAttribute):

  • svg/SVGStyledElement.cpp:

(WebCore::SVGStyledElement::getPresentationAttribute):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142826 r142827  
     12013-02-13  Andreas Kling  <akling@apple.com>
     2
     3        Remove Element::getAttributeItem() overload that returned a mutable Attribute*.
     4        <http://webkit.org/b/109756>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Remove this to prevent callers from accidentally causing elements to convert to UniqueElementData.
     9        There are two call sites (Attr and HTMLSelectElement) that legitimately need to mutate Attribute
     10        objects in-place, they now use Element::ensureUniqueElementData()->getAttributeItem() directly instead.
     11
     12        Small progression on Membuster3, mostly for peace of mind.
     13
     14        * dom/Attr.cpp:
     15        (WebCore::Attr::elementAttribute):
     16        * dom/Element.h:
     17        (Element):
     18        * html/HTMLInputElement.cpp:
     19        (WebCore::HTMLInputElement::updateType):
     20        * html/HTMLSelectElement.cpp:
     21        (WebCore::HTMLSelectElement::parseAttribute):
     22        * svg/SVGStyledElement.cpp:
     23        (WebCore::SVGStyledElement::getPresentationAttribute):
     24
    1252013-02-13  Andreas Kling  <akling@apple.com>
    226
  • trunk/Source/WebCore/dom/Attr.cpp

    r142791 r142827  
    212212    ASSERT(m_element);
    213213    ASSERT(m_element->elementData());
    214     return *m_element->getAttributeItem(qualifiedName());
     214    return *m_element->ensureUniqueElementData()->getAttributeItem(qualifiedName());
    215215}
    216216
  • trunk/Source/WebCore/dom/Element.h

    r142826 r142827  
    286286    const Attribute* attributeItem(unsigned index) const;
    287287    const Attribute* getAttributeItem(const QualifiedName&) const;
    288     Attribute* getAttributeItem(const QualifiedName&);
    289288    size_t getAttributeItemIndex(const QualifiedName& name) const { return elementData()->getAttributeItemIndex(name); }
    290289    size_t getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const { return elementData()->getAttributeItemIndex(name, shouldIgnoreAttributeCase); }
     
    905904}
    906905
    907 inline Attribute* Element::getAttributeItem(const QualifiedName& name)
    908 {
    909     ASSERT(elementData());
    910     return ensureUniqueElementData()->getAttributeItem(name);
    911 }
    912 
    913906inline void Element::updateInvalidAttributes() const
    914907{
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r142791 r142827  
    517517    if (didRespectHeightAndWidth != m_inputType->shouldRespectHeightAndWidthAttributes()) {
    518518        ASSERT(elementData());
    519         if (Attribute* height = getAttributeItem(heightAttr))
     519        if (const Attribute* height = getAttributeItem(heightAttr))
    520520            attributeChanged(heightAttr, height->value());
    521         if (Attribute* width = getAttributeItem(widthAttr))
     521        if (const Attribute* width = getAttributeItem(widthAttr))
    522522            attributeChanged(widthAttr, width->value());
    523         if (Attribute* align = getAttributeItem(alignAttr))
     523        if (const Attribute* align = getAttributeItem(alignAttr))
    524524            attributeChanged(alignAttr, align->value());
    525525    }
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r142631 r142827  
    292292        if (attrSize != value) {
    293293            // FIXME: This is horribly factored.
    294             if (Attribute* sizeAttribute = getAttributeItem(sizeAttr))
     294            if (Attribute* sizeAttribute = ensureUniqueElementData()->getAttributeItem(sizeAttr))
    295295                sizeAttribute->setValue(attrSize);
    296296        }
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r141524 r142827  
    401401
    402402    QualifiedName attributeName(nullAtom, name, nullAtom);
    403     Attribute* attr = getAttributeItem(attributeName);
     403    const Attribute* attr = getAttributeItem(attributeName);
    404404    if (!attr)
    405405        return 0;
Note: See TracChangeset for help on using the changeset viewer.