Changeset 109570 in webkit


Ignore:
Timestamp:
Mar 2, 2012 6:07:59 AM (12 years ago)
Author:
caio.oliveira@openbossa.org
Message:

Make parser code not depend on NamedNodeMap
https://bugs.webkit.org/show_bug.cgi?id=79963

Reviewed by Adam Barth.

Source/WebCore:

Instead of creating Element-less NamedNodeMaps, the parsing code now creates
AttributeVectors, that are used to fill Element via the parserSetAttributes()
method. This allows us to remove even more methods from the NamedNodeMap.

The AttributeVector class contains convenience methods that take the attribute's
QualifiedName as parameter. This class is also used inside ElementAttributeData.

  • dom/Attr.h:

(Attr):

  • dom/Element.cpp:

(WebCore::Element::getAttribute):
(WebCore::Element::parserSetAttributes): Now we have to create the attribute
storage, and fill it (by Vector::swap()) with the passed attributes. Also use an
early return to reduce indentation.
(WebCore::Element::insertedIntoDocument):
(WebCore::Element::removedFromDocument):
(WebCore::Element::getURLAttribute):
(WebCore::Element::getNonEmptyURLAttribute):

  • dom/Element.h:

(Element):
(WebCore::Element::fastHasAttribute):
(WebCore::Element::fastGetAttribute):
(WebCore::Element::hasAttributesWithoutUpdate):
(WebCore::Element::attributeItem):
(WebCore::Element::getAttributeItem):

  • dom/ElementAttributeData.cpp:

(WebCore::AttributeVector::removeAttribute):
(WebCore):

  • dom/ElementAttributeData.h:

(AttributeVector):
(WebCore::AttributeVector::create):
(WebCore::AttributeVector::attributeItem):
(WebCore::AttributeVector::AttributeVector):
(WebCore):
(WebCore::AttributeVector::getAttributeItem):
(WebCore::AttributeVector::getAttributeItemIndex):
(WebCore::AttributeVector::insertAttribute): Boolean parameter isn't necessary
since all the callers used 'false', indicating that duplicates were not allowed.
(WebCore::ElementAttributeData::attributeItem):
(WebCore::ElementAttributeData::getAttributeItem):
(WebCore::ElementAttributeData::getAttributeItemIndex):
(ElementAttributeData):

  • dom/NamedNodeMap.cpp:

(WebCore::NamedNodeMap::getNamedItem):
(WebCore::NamedNodeMap::setNamedItem):
(WebCore::NamedNodeMap::removeNamedItem):
(WebCore::NamedNodeMap::mapsEquivalent):

  • dom/NamedNodeMap.h:
  • html/parser/HTMLConstructionSite.cpp:

(WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML):
(WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
(WebCore::HTMLConstructionSite::insertScriptElement):
(WebCore::HTMLConstructionSite::createElement):
(WebCore::HTMLConstructionSite::createHTMLElement):
(WebCore):

  • html/parser/HTMLToken.h:

(WebCore::AtomicHTMLToken::AtomicHTMLToken):

  • html/parser/HTMLTreeBuilder.cpp:

(WebCore::HTMLTreeBuilder::processFakeStartTag):
(WebCore::HTMLTreeBuilder::attributesForIsindexInput):
(WebCore):

  • html/parser/HTMLTreeBuilder.h:
  • html/parser/TextDocumentParser.cpp:

(WebCore::TextDocumentParser::insertFakePreElement):

  • xml/parser/MarkupTokenBase.h:

(WebCore::AtomicMarkupTokenBase::AtomicMarkupTokenBase):
(WebCore::AtomicMarkupTokenBase::attributes):
(WebCore::AtomicMarkupTokenBase::takeAttributes):
(AtomicMarkupTokenBase):
(WebCore::::initializeAttributes):

  • xml/parser/XMLToken.h:

(WebCore::AtomicXMLToken::AtomicXMLToken):

  • xml/parser/XMLTreeBuilder.cpp:

(WebCore::XMLTreeBuilder::processNamespaces):
(WebCore::XMLTreeBuilder::processAttributes):

Source/WebKit/chromium:

  • src/WebNamedNodeMap.cpp:

(WebKit::WebNamedNodeMap::attributeItem):

Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109568 r109570  
     12012-03-01  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        Make parser code not depend on NamedNodeMap
     4        https://bugs.webkit.org/show_bug.cgi?id=79963
     5
     6        Reviewed by Adam Barth.
     7
     8        Instead of creating Element-less NamedNodeMaps, the parsing code now creates
     9        AttributeVectors, that are used to fill Element via the parserSetAttributes()
     10        method. This allows us to remove even more methods from the NamedNodeMap.
     11
     12        The AttributeVector class contains convenience methods that take the attribute's
     13        QualifiedName as parameter. This class is also used inside ElementAttributeData.
     14
     15        * dom/Attr.h:
     16        (Attr):
     17        * dom/Element.cpp:
     18        (WebCore::Element::getAttribute):
     19        (WebCore::Element::parserSetAttributes): Now we have to create the attribute
     20        storage, and fill it (by Vector::swap()) with the passed attributes. Also use an
     21        early return to reduce indentation.
     22        (WebCore::Element::insertedIntoDocument):
     23        (WebCore::Element::removedFromDocument):
     24        (WebCore::Element::getURLAttribute):
     25        (WebCore::Element::getNonEmptyURLAttribute):
     26        * dom/Element.h:
     27        (Element):
     28        (WebCore::Element::fastHasAttribute):
     29        (WebCore::Element::fastGetAttribute):
     30        (WebCore::Element::hasAttributesWithoutUpdate):
     31        (WebCore::Element::attributeItem):
     32        (WebCore::Element::getAttributeItem):
     33        * dom/ElementAttributeData.cpp:
     34        (WebCore::AttributeVector::removeAttribute):
     35        (WebCore):
     36        * dom/ElementAttributeData.h:
     37        (AttributeVector):
     38        (WebCore::AttributeVector::create):
     39        (WebCore::AttributeVector::attributeItem):
     40        (WebCore::AttributeVector::AttributeVector):
     41        (WebCore):
     42        (WebCore::AttributeVector::getAttributeItem):
     43        (WebCore::AttributeVector::getAttributeItemIndex):
     44        (WebCore::AttributeVector::insertAttribute): Boolean parameter isn't necessary
     45        since all the callers used 'false', indicating that duplicates were not allowed.
     46        (WebCore::ElementAttributeData::attributeItem):
     47        (WebCore::ElementAttributeData::getAttributeItem):
     48        (WebCore::ElementAttributeData::getAttributeItemIndex):
     49        (ElementAttributeData):
     50        * dom/NamedNodeMap.cpp:
     51        (WebCore::NamedNodeMap::getNamedItem):
     52        (WebCore::NamedNodeMap::setNamedItem):
     53        (WebCore::NamedNodeMap::removeNamedItem):
     54        (WebCore::NamedNodeMap::mapsEquivalent):
     55        * dom/NamedNodeMap.h:
     56        * html/parser/HTMLConstructionSite.cpp:
     57        (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML):
     58        (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
     59        (WebCore::HTMLConstructionSite::insertScriptElement):
     60        (WebCore::HTMLConstructionSite::createElement):
     61        (WebCore::HTMLConstructionSite::createHTMLElement):
     62        (WebCore):
     63        * html/parser/HTMLToken.h:
     64        (WebCore::AtomicHTMLToken::AtomicHTMLToken):
     65        * html/parser/HTMLTreeBuilder.cpp:
     66        (WebCore::HTMLTreeBuilder::processFakeStartTag):
     67        (WebCore::HTMLTreeBuilder::attributesForIsindexInput):
     68        (WebCore):
     69        * html/parser/HTMLTreeBuilder.h:
     70        * html/parser/TextDocumentParser.cpp:
     71        (WebCore::TextDocumentParser::insertFakePreElement):
     72        * xml/parser/MarkupTokenBase.h:
     73        (WebCore::AtomicMarkupTokenBase::AtomicMarkupTokenBase):
     74        (WebCore::AtomicMarkupTokenBase::attributes):
     75        (WebCore::AtomicMarkupTokenBase::takeAttributes):
     76        (AtomicMarkupTokenBase):
     77        (WebCore::::initializeAttributes):
     78        * xml/parser/XMLToken.h:
     79        (WebCore::AtomicXMLToken::AtomicXMLToken):
     80        * xml/parser/XMLTreeBuilder.cpp:
     81        (WebCore::XMLTreeBuilder::processNamespaces):
     82        (WebCore::XMLTreeBuilder::processAttributes):
     83
    1842012-03-02  Yury Semikhatsky  <yurys@chromium.org>
    285
  • trunk/Source/WebCore/dom/Attr.h

    r107570 r109570  
    4040
    4141class Attr : public ContainerNode {
     42    friend class AttributeVector;
    4243    friend class ElementAttributeData;
    43     friend class NamedNodeMap;
    4444public:
    4545    static PassRefPtr<Attr> create(Element*, Document*, PassRefPtr<Attribute>);
  • trunk/Source/WebCore/dom/Element.cpp

    r109563 r109570  
    222222
    223223    if (m_attributeMap) {
    224         if (Attribute* attribute = m_attributeMap->getAttributeItem(name))
     224        if (Attribute* attribute = getAttributeItem(name))
    225225            return attribute->value();
    226226    }
     
    599599
    600600    if (m_attributeMap) {
    601         if (Attribute* attribute = m_attributeMap->getAttributeItem(name, ignoreCase))
     601        if (Attribute* attribute = m_attributeMap->attributeData()->getAttributeItem(name, ignoreCase))
    602602            return attribute->value();
    603603    }
     
    728728}
    729729
    730 void Element::parserSetAttributeMap(PassOwnPtr<NamedNodeMap> list, FragmentScriptingPermission scriptingPermission)
     730void Element::parserSetAttributes(PassOwnPtr<AttributeVector> attributeVector, FragmentScriptingPermission scriptingPermission)
    731731{
    732732    ASSERT(!inDocument());
     
    736736
    737737    ASSERT(!m_attributeMap);
    738     m_attributeMap = list;
    739 
    740     if (m_attributeMap) {
    741         ElementAttributeData* attributeData = &m_attributeMap->m_attributeData;
    742         m_attributeMap->m_element = this;
    743         // If the element is created as result of a paste or drag-n-drop operation
    744         // we want to remove all the script and event handlers.
    745         if (scriptingPermission == FragmentScriptingNotAllowed) {
    746             unsigned i = 0;
    747             while (i < m_attributeMap->length()) {
    748                 const QualifiedName& attributeName = attributeData->m_attributes[i]->name();
    749                 if (isEventHandlerAttribute(attributeName)) {
    750                     attributeData->m_attributes.remove(i);
    751                     continue;
    752                 }
    753 
    754                 if (isAttributeToRemove(attributeName, attributeData->m_attributes[i]->value()))
    755                     attributeData->m_attributes[i]->setValue(nullAtom);
    756                 i++;
     738
     739    if (!attributeVector)
     740        return;
     741
     742    m_attributeMap = NamedNodeMap::create(this);
     743    ElementAttributeData* attributeData = m_attributeMap->attributeData();
     744    attributeData->m_attributes.swap(*attributeVector);
     745
     746    m_attributeMap->m_element = this;
     747    // If the element is created as result of a paste or drag-n-drop operation
     748    // we want to remove all the script and event handlers.
     749    if (scriptingPermission == FragmentScriptingNotAllowed) {
     750        unsigned i = 0;
     751        while (i < m_attributeMap->length()) {
     752            const QualifiedName& attributeName = attributeData->m_attributes[i]->name();
     753            if (isEventHandlerAttribute(attributeName)) {
     754                attributeData->m_attributes.remove(i);
     755                continue;
    757756            }
    758         }
    759         // Store the set of attributes that changed on the stack in case
    760         // attributeChanged mutates m_attributeMap.
    761         Vector<RefPtr<Attribute> > attributes;
    762         attributeData->copyAttributesToVector(attributes);
    763         for (Vector<RefPtr<Attribute> >::iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
    764             attributeChanged(iter->get());
    765     }
     757
     758            if (isAttributeToRemove(attributeName, attributeData->m_attributes[i]->value()))
     759                attributeData->m_attributes[i]->setValue(nullAtom);
     760            i++;
     761        }
     762    }
     763
     764    // Store the set of attributes that changed on the stack in case
     765    // attributeChanged mutates m_attributeMap.
     766    Vector<RefPtr<Attribute> > attributes;
     767    attributeData->copyAttributesToVector(attributes);
     768    for (Vector<RefPtr<Attribute> >::iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
     769        attributeChanged(iter->get());
    766770}
    767771
     
    867871    if (m_attributeMap) {
    868872        if (hasID()) {
    869             Attribute* idItem = m_attributeMap->getAttributeItem(document()->idAttributeName());
     873            Attribute* idItem = getAttributeItem(document()->idAttributeName());
    870874            if (idItem && !idItem->isNull())
    871875                updateId(nullAtom, idItem->value());
    872876        }
    873877        if (hasName()) {
    874             Attribute* nameItem = m_attributeMap->getAttributeItem(HTMLNames::nameAttr);
     878            Attribute* nameItem = getAttributeItem(HTMLNames::nameAttr);
    875879            if (nameItem && !nameItem->isNull())
    876880                updateName(nullAtom, nameItem->value());
     
    883887    if (m_attributeMap) {
    884888        if (hasID()) {
    885             Attribute* idItem = m_attributeMap->getAttributeItem(document()->idAttributeName());
     889            Attribute* idItem = getAttributeItem(document()->idAttributeName());
    886890            if (idItem && !idItem->isNull())
    887891                updateId(idItem->value(), nullAtom);
    888892        }
    889893        if (hasName()) {
    890             Attribute* nameItem = m_attributeMap->getAttributeItem(HTMLNames::nameAttr);
     894            Attribute* nameItem = getAttributeItem(HTMLNames::nameAttr);
    891895            if (nameItem && !nameItem->isNull())
    892896                updateName(nameItem->value(), nullAtom);
     
    17541758#if !ASSERT_DISABLED
    17551759    if (m_attributeMap) {
    1756         if (Attribute* attribute = m_attributeMap->getAttributeItem(name))
     1760        if (Attribute* attribute = getAttributeItem(name))
    17571761            ASSERT(isURLAttribute(attribute));
    17581762    }
     
    17651769#if !ASSERT_DISABLED
    17661770    if (m_attributeMap) {
    1767         if (Attribute* attribute = m_attributeMap->getAttributeItem(name))
     1771        if (Attribute* attribute = getAttributeItem(name))
    17681772            ASSERT(isURLAttribute(attribute));
    17691773    }
  • trunk/Source/WebCore/dom/Element.h

    r109285 r109570  
    238238
    239239    // Only called by the parser immediately after element construction.
    240     void parserSetAttributeMap(PassOwnPtr<NamedNodeMap>, FragmentScriptingPermission);
     240    void parserSetAttributes(PassOwnPtr<AttributeVector>, FragmentScriptingPermission);
    241241
    242242    ElementAttributeData* attributeData() const { return m_attributeMap ? m_attributeMap->attributeData() : 0; }
     
    608608{
    609609    ASSERT(fastAttributeLookupAllowed(name));
    610     return m_attributeMap && m_attributeMap->getAttributeItem(name);
     610    return m_attributeMap && getAttributeItem(name);
    611611}
    612612
     
    615615    ASSERT(fastAttributeLookupAllowed(name));
    616616    if (m_attributeMap) {
    617         if (Attribute* attribute = m_attributeMap->getAttributeItem(name))
     617        if (Attribute* attribute = getAttributeItem(name))
    618618            return attribute->value();
    619619    }
     
    623623inline bool Element::hasAttributesWithoutUpdate() const
    624624{
    625     return m_attributeMap && !m_attributeMap->isEmpty();
     625    return m_attributeMap && !m_attributeMap->attributeData()->isEmpty();
    626626}
    627627
     
    665665{
    666666    ASSERT(m_attributeMap);
    667     return m_attributeMap->attributeItem(index);
     667    return m_attributeMap->attributeData()->attributeItem(index);
    668668}
    669669
     
    671671{
    672672    ASSERT(m_attributeMap);
    673     return m_attributeMap->getAttributeItem(name);
     673    return m_attributeMap->attributeData()->getAttributeItem(name);
    674674}
    675675
  • trunk/Source/WebCore/dom/ElementAttributeData.cpp

    r108345 r109570  
    3131
    3232namespace WebCore {
     33
     34void AttributeVector::removeAttribute(const QualifiedName& name)
     35{
     36    size_t index = getAttributeItemIndex(name);
     37    if (index == notFound)
     38        return;
     39
     40    RefPtr<Attribute> attribute = at(index);
     41    if (Attr* attr = attribute->attr())
     42        attr->m_element = 0;
     43    remove(index);
     44}
    3345
    3446ElementAttributeData::~ElementAttributeData()
  • trunk/Source/WebCore/dom/ElementAttributeData.h

    r108449 r109570  
    3636class Element;
    3737
     38class AttributeVector : public Vector<RefPtr<Attribute>, 4> {
     39    friend class ElementAttributeData;
     40
     41public:
     42    static PassOwnPtr<AttributeVector> create()
     43    {
     44        return adoptPtr(new AttributeVector());
     45    }
     46
     47    Attribute* attributeItem(unsigned index) const { return at(index).get(); }
     48    Attribute* getAttributeItem(const QualifiedName&) const;
     49    size_t getAttributeItemIndex(const QualifiedName&) const;
     50
     51    // Used during parsing: only inserts if not already there.
     52    void insertAttribute(PassRefPtr<Attribute> newAttribute);
     53    void removeAttribute(const QualifiedName&);
     54
     55private:
     56    AttributeVector() { }
     57};
     58
     59inline Attribute* AttributeVector::getAttributeItem(const QualifiedName& name) const
     60{
     61    size_t index = getAttributeItemIndex(name);
     62    if (index != notFound)
     63        return at(index).get();
     64    return 0;
     65}
     66
     67inline size_t AttributeVector::getAttributeItemIndex(const QualifiedName& name) const
     68{
     69    for (unsigned i = 0; i < size(); ++i) {
     70        if (at(i)->name().matches(name))
     71            return i;
     72    }
     73    return notFound;
     74}
     75
     76inline void AttributeVector::insertAttribute(PassRefPtr<Attribute> newAttribute)
     77{
     78    if (!getAttributeItem(newAttribute->name()))
     79        append(newAttribute);
     80}
     81
    3882class ElementAttributeData {
    3983public:
     
    58102
    59103    // Internal interface.
    60     Attribute* attributeItem(unsigned index) const { return m_attributes[index].get(); }
    61     Attribute* getAttributeItem(const QualifiedName&) const;
    62     size_t getAttributeItemIndex(const QualifiedName&) const;
     104    Attribute* attributeItem(unsigned index) const { return m_attributes.attributeItem(index); }
     105    Attribute* getAttributeItem(const QualifiedName& name) const { return m_attributes.getAttributeItem(name); }
     106    size_t getAttributeItemIndex(const QualifiedName& name) const { return m_attributes.getAttributeItemIndex(name); }
    63107
    64108    // These functions do no error checking.
     
    91135    SpaceSplitString m_classNames;
    92136    AtomicString m_idForStyleResolution;
    93     Vector<RefPtr<Attribute>, 4> m_attributes;
     137    AttributeVector m_attributes;
    94138};
    95139
     
    111155}
    112156
    113 inline Attribute* ElementAttributeData::getAttributeItem(const QualifiedName& name) const
    114 {
    115     size_t index = getAttributeItemIndex(name);
    116     if (index != notFound)
    117         return m_attributes[index].get();
    118     return 0;
    119 }
    120 
    121157// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller
    122158// can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not).
    123 inline size_t ElementAttributeData::getAttributeItemIndex(const QualifiedName& name) const
    124 {
    125     size_t len = length();
    126     for (unsigned i = 0; i < len; ++i) {
    127         if (m_attributes[i]->name().matches(name))
    128             return i;
    129     }
    130     return notFound;
    131 }
    132 
    133159inline size_t ElementAttributeData::getAttributeItemIndex(const String& name, bool shouldIgnoreAttributeCase) const
    134160{
  • trunk/Source/WebCore/dom/NamedNodeMap.cpp

    r107570 r109570  
    8585PassRefPtr<Node> NamedNodeMap::getNamedItem(const QualifiedName& name) const
    8686{
    87     Attribute* a = getAttributeItem(name);
     87    Attribute* a = m_attributeData.getAttributeItem(name);
    8888    if (!a)
    8989        return 0;
     
    107107
    108108    Attribute* attribute = attr->attr();
    109     size_t index = getAttributeItemIndex(attribute->name());
    110     Attribute* oldAttribute = index != notFound ? attributeItem(index) : 0;
     109    size_t index = m_attributeData.getAttributeItemIndex(attribute->name());
     110    Attribute* oldAttribute = index != notFound ? m_attributeData.attributeItem(index) : 0;
    111111    if (oldAttribute == attribute)
    112112        return node; // we know about it already
     
    138138    ASSERT(m_element);
    139139
    140     size_t index = getAttributeItemIndex(name);
     140    size_t index = m_attributeData.getAttributeItemIndex(name);
    141141    if (index == notFound) {
    142142        ec = NOT_FOUND_ERR;
     
    172172{
    173173    if (!otherMap)
    174         return isEmpty();
     174        return m_attributeData.isEmpty();
    175175   
    176176    unsigned len = length();
     
    178178        return false;
    179179   
     180    const ElementAttributeData& otherAttributeData = otherMap->m_attributeData;
    180181    for (unsigned i = 0; i < len; i++) {
    181         Attribute* attr = attributeItem(i);
    182         Attribute* otherAttr = otherMap->getAttributeItem(attr->name());
     182        Attribute* attr = m_attributeData.attributeItem(i);
     183        Attribute* otherAttr = otherAttributeData.getAttributeItem(attr->name());
    183184        if (!otherAttr || attr->value() != otherAttr->value())
    184185            return false;
  • trunk/Source/WebCore/dom/NamedNodeMap.h

    r107570 r109570  
    6161    PassRefPtr<Node> item(unsigned index) const;
    6262    size_t length() const { return m_attributeData.length(); }
    63     bool isEmpty() const { return m_attributeData.isEmpty(); }
    64 
    65     // Internal interface.
    66 
    67     Attribute* attributeItem(unsigned index) const { return m_attributeData.attributeItem(index); }
    68     Attribute* getAttributeItem(const QualifiedName& name) const { return m_attributeData.getAttributeItem(name); }
    69     size_t getAttributeItemIndex(const QualifiedName& name) const { return m_attributeData.getAttributeItemIndex(name); }
    70 
    71     void shrinkToLength() { m_attributeData.m_attributes.shrinkCapacity(length()); }
    72     void reserveInitialCapacity(unsigned capacity) { m_attributeData.m_attributes.reserveInitialCapacity(capacity); }
    73 
    74     // Used during parsing: only inserts if not already there. No error checking!
    75     void insertAttribute(PassRefPtr<Attribute> newAttribute, bool allowDuplicates)
    76     {
    77         ASSERT(!m_element);
    78         if (allowDuplicates || !getAttributeItem(newAttribute->name()))
    79             addAttribute(newAttribute);
    80     }
    8163
    8264    bool mapsEquivalent(const NamedNodeMap* otherMap) const;
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r106757 r109570  
    195195{
    196196    RefPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(m_document);
    197     element->parserSetAttributeMap(token.takeAttributes(), m_fragmentScriptingPermission);
     197    element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
    198198    attachLater(m_attachmentRoot, element);
    199199    m_openElements.pushHTMLHtmlElement(element);
     
    209209        return;
    210210
    211     NamedNodeMap* attributes = element->ensureUpdatedAttributes();
    212     for (unsigned i = 0; i < token.attributes()->length(); ++i) {
     211    ElementAttributeData* attributes = element->ensureAttributeData();
     212    for (unsigned i = 0; i < token.attributes()->size(); ++i) {
    213213        Attribute* attribute = token.attributes()->attributeItem(i);
    214214        if (!attributes->getAttributeItem(attribute->name()))
     
    337337    RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, currentNode()->document(), true);
    338338    if (m_fragmentScriptingPermission == FragmentScriptingAllowed)
    339         element->parserSetAttributeMap(token.takeAttributes(), m_fragmentScriptingPermission);
     339        element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
    340340    attachLater(currentNode(), element);
    341341    m_openElements.push(element.release());
     
    400400    QualifiedName tagName(nullAtom, token.name(), namespaceURI);
    401401    RefPtr<Element> element = currentNode()->document()->createElement(tagName, true);
    402     element->parserSetAttributeMap(token.takeAttributes(), m_fragmentScriptingPermission);
     402    element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
    403403    return element.release();
    404404}
     
    411411    // to occur after construction to allow better code sharing here.
    412412    RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, currentNode()->document(), form(), true);
    413     element->parserSetAttributeMap(token.takeAttributes(), m_fragmentScriptingPermission);
     413    element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
    414414    ASSERT(element->isHTMLElement());
    415415    return element.release();
     
    424424
    425425// FIXME: Move this function to the top of the file.
    426 inline PassOwnPtr<NamedNodeMap> cloneAttributes(Element* element)
    427 {
    428     NamedNodeMap* attributes = element->updatedAttributes();
     426inline PassOwnPtr<AttributeVector> cloneAttributes(Element* element)
     427{
     428    ElementAttributeData* attributes = element->updatedAttributeData();
    429429    if (!attributes)
    430430        return nullptr;
    431431
    432     OwnPtr<NamedNodeMap> newAttributes = NamedNodeMap::create();
     432    OwnPtr<AttributeVector> newAttributes = AttributeVector::create();
    433433    for (size_t i = 0; i < attributes->length(); ++i) {
    434434        Attribute* attribute = attributes->attributeItem(i);
    435435        RefPtr<Attribute> clone = Attribute::create(attribute->name(), attribute->value());
    436         newAttributes->addAttribute(clone);
     436        newAttributes->append(clone);
    437437    }
    438438    return newAttributes.release();
  • trunk/Source/WebCore/html/parser/HTMLToken.h

    r104130 r109570  
    8787    AtomicHTMLToken(HTMLToken& token) : AtomicMarkupTokenBase<HTMLToken>(&token) { }
    8888
    89     AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, PassOwnPtr<NamedNodeMap> attributes = nullptr)
     89    AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr)
    9090        : AtomicMarkupTokenBase<HTMLToken>(type, name, attributes)
    9191    {
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r108311 r109570  
    532532}
    533533
    534 void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, PassOwnPtr<NamedNodeMap> attributes)
     534void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, PassOwnPtr<AttributeVector> attributes)
    535535{
    536536    // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML tags.
     
    561561}
    562562
    563 PassOwnPtr<NamedNodeMap> HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)
    564 {
    565     OwnPtr<NamedNodeMap> attributes = token.takeAttributes();
     563PassOwnPtr<AttributeVector> HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)
     564{
     565    OwnPtr<AttributeVector> attributes = token.takeAttributes();
    566566    if (!attributes)
    567         attributes = NamedNodeMap::create();
     567        attributes = AttributeVector::create();
    568568    else {
    569569        attributes->removeAttribute(nameAttr);
     
    573573
    574574    RefPtr<Attribute> mappedAttribute = Attribute::create(nameAttr, isindexTag.localName());
    575     attributes->insertAttribute(mappedAttribute.release(), false);
     575    attributes->insertAttribute(mappedAttribute.release());
    576576    return attributes.release();
    577577}
     
    680680    }
    681681
    682     NamedNodeMap* attributes = token.attributes();
     682    AttributeVector* attributes = token.attributes();
    683683    if (!attributes)
    684684        return;
    685685
    686     for (unsigned x = 0; x < attributes->length(); ++x) {
     686    for (unsigned x = 0; x < attributes->size(); ++x) {
    687687        Attribute* attribute = attributes->attributeItem(x);
    688688        const QualifiedName& casedName = caseMap->get(attribute->localName());
     
    729729    }
    730730
    731     NamedNodeMap* attributes = token.attributes();
     731    AttributeVector* attributes = token.attributes();
    732732    if (!attributes)
    733733        return;
    734734
    735     for (unsigned x = 0; x < attributes->length(); ++x) {
     735    for (unsigned x = 0; x < attributes->size(); ++x) {
    736736        Attribute* attribute = attributes->attributeItem(x);
    737737        const QualifiedName& name = map->get(attribute->localName());
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h

    r104130 r109570  
    152152    inline void processCharacterBufferForInBody(ExternalCharacterTokenBuffer&);
    153153
    154     void processFakeStartTag(const QualifiedName&, PassOwnPtr<NamedNodeMap> attributes = nullptr);
     154    void processFakeStartTag(const QualifiedName&, PassOwnPtr<AttributeVector> attributes = nullptr);
    155155    void processFakeEndTag(const QualifiedName&);
    156156    void processFakeCharacters(const String&);
     
    173173    void processTokenInForeignContent(AtomicHTMLToken&);
    174174
    175     PassOwnPtr<NamedNodeMap> attributesForIsindexInput(AtomicHTMLToken&);
     175    PassOwnPtr<AttributeVector> attributesForIsindexInput(AtomicHTMLToken&);
    176176
    177177    HTMLElementStack::ElementRecord* furthestBlockForFormattingElement(Element*);
  • trunk/Source/WebCore/html/parser/TextDocumentParser.cpp

    r106757 r109570  
    6262
    6363    RefPtr<Attribute> styleAttribute = Attribute::create("style", "word-wrap: break-word; white-space: pre-wrap;");
    64     OwnPtr<NamedNodeMap> attributes = NamedNodeMap::create();
    65     attributes->insertAttribute(styleAttribute.release(), false);
     64    OwnPtr<AttributeVector> attributes = AttributeVector::create();
     65    attributes->insertAttribute(styleAttribute.release());
    6666    AtomicHTMLToken fakePre(HTMLTokenTypes::StartTag, preTag.localName(), attributes.release());
    6767
  • trunk/Source/WebCore/xml/parser/MarkupTokenBase.h

    r107468 r109570  
    2828#define MarkupTokenBase_h
    2929
    30 #include "NamedNodeMap.h"
     30#include "ElementAttributeData.h"
    3131#include <wtf/PassOwnPtr.h>
    3232#include <wtf/Vector.h>
     
    411411    }
    412412
    413     AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, PassOwnPtr<NamedNodeMap> attributes = nullptr)
     413    AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr)
    414414        : m_type(type)
    415415        , m_name(name)
     
    447447    }
    448448
    449     NamedNodeMap* attributes() const
     449    AttributeVector* attributes() const
    450450    {
    451451        ASSERT(usesAttributes());
     
    453453    }
    454454
    455     PassOwnPtr<NamedNodeMap> takeAttributes()
     455    PassOwnPtr<AttributeVector> takeAttributes()
    456456    {
    457457        ASSERT(usesAttributes());
     
    517517    bool m_selfClosing;
    518518
    519     OwnPtr<NamedNodeMap> m_attributes;
     519    OwnPtr<AttributeVector> m_attributes;
    520520};
    521521
     
    527527        return;
    528528
    529     m_attributes = NamedNodeMap::create();
     529    m_attributes = AttributeVector::create();
    530530    m_attributes->reserveInitialCapacity(size);
    531531    for (size_t i = 0; i < size; ++i) {
     
    542542
    543543        AtomicString value(attribute.m_value.data(), attribute.m_value.size());
    544         m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value), false);
     544        m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value));
    545545    }
    546546}
  • trunk/Source/WebCore/xml/parser/XMLToken.h

    r104130 r109570  
    432432    }
    433433
    434     AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr<NamedNodeMap> attributes = nullptr)
     434    AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr)
    435435        : AtomicMarkupTokenBase<XMLToken>(type, name, attributes)
    436436    {
  • trunk/Source/WebCore/xml/parser/XMLTreeBuilder.cpp

    r106833 r109570  
    302302        return;
    303303
    304     for (size_t i = 0; i < token.attributes()->length(); ++i) {
     304    for (size_t i = 0; i < token.attributes()->size(); ++i) {
    305305        Attribute* attribute = token.attributes()->attributeItem(i);
    306306        if (attribute->name().prefix() == xmlnsAtom)
     
    316316        return;
    317317
    318     for (size_t i = 0; i < token.attributes()->length(); ++i) {
     318    for (size_t i = 0; i < token.attributes()->size(); ++i) {
    319319        Attribute* attribute = token.attributes()->attributeItem(i);
    320320        ExceptionCode ec = 0;
  • trunk/Source/WebKit/chromium/ChangeLog

    r109514 r109570  
     12012-03-01  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        Make parser code not depend on NamedNodeMap
     4        https://bugs.webkit.org/show_bug.cgi?id=79963
     5
     6        Reviewed by Adam Barth.
     7
     8        * src/WebNamedNodeMap.cpp:
     9        (WebKit::WebNamedNodeMap::attributeItem):
     10
    1112012-03-01  Dana Jansens  <danakj@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/WebNamedNodeMap.cpp

    r95901 r109570  
    3232#include "WebNamedNodeMap.h"
    3333
     34#include "Element.h"
    3435#include "NamedNodeMap.h"
    3536#include "Node.h"
     
    6465WebAttribute WebNamedNodeMap::attributeItem(unsigned index) const
    6566{
    66     return WebAttribute(m_private->attributeItem(index));
     67    return WebAttribute(m_private->element()->attributeItem(index));
    6768}
    6869
Note: See TracChangeset for help on using the changeset viewer.