Changeset 109570 in webkit
- Timestamp:
- Mar 2, 2012 6:07:59 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109568 r109570 1 2012-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 1 84 2012-03-02 Yury Semikhatsky <yurys@chromium.org> 2 85 -
trunk/Source/WebCore/dom/Attr.h
r107570 r109570 40 40 41 41 class Attr : public ContainerNode { 42 friend class AttributeVector; 42 43 friend class ElementAttributeData; 43 friend class NamedNodeMap;44 44 public: 45 45 static PassRefPtr<Attr> create(Element*, Document*, PassRefPtr<Attribute>); -
trunk/Source/WebCore/dom/Element.cpp
r109563 r109570 222 222 223 223 if (m_attributeMap) { 224 if (Attribute* attribute = m_attributeMap->getAttributeItem(name))224 if (Attribute* attribute = getAttributeItem(name)) 225 225 return attribute->value(); 226 226 } … … 599 599 600 600 if (m_attributeMap) { 601 if (Attribute* attribute = m_attributeMap-> getAttributeItem(name, ignoreCase))601 if (Attribute* attribute = m_attributeMap->attributeData()->getAttributeItem(name, ignoreCase)) 602 602 return attribute->value(); 603 603 } … … 728 728 } 729 729 730 void Element::parserSetAttribute Map(PassOwnPtr<NamedNodeMap> list, FragmentScriptingPermission scriptingPermission)730 void Element::parserSetAttributes(PassOwnPtr<AttributeVector> attributeVector, FragmentScriptingPermission scriptingPermission) 731 731 { 732 732 ASSERT(!inDocument()); … … 736 736 737 737 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; 757 756 } 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()); 766 770 } 767 771 … … 867 871 if (m_attributeMap) { 868 872 if (hasID()) { 869 Attribute* idItem = m_attributeMap->getAttributeItem(document()->idAttributeName());873 Attribute* idItem = getAttributeItem(document()->idAttributeName()); 870 874 if (idItem && !idItem->isNull()) 871 875 updateId(nullAtom, idItem->value()); 872 876 } 873 877 if (hasName()) { 874 Attribute* nameItem = m_attributeMap->getAttributeItem(HTMLNames::nameAttr);878 Attribute* nameItem = getAttributeItem(HTMLNames::nameAttr); 875 879 if (nameItem && !nameItem->isNull()) 876 880 updateName(nullAtom, nameItem->value()); … … 883 887 if (m_attributeMap) { 884 888 if (hasID()) { 885 Attribute* idItem = m_attributeMap->getAttributeItem(document()->idAttributeName());889 Attribute* idItem = getAttributeItem(document()->idAttributeName()); 886 890 if (idItem && !idItem->isNull()) 887 891 updateId(idItem->value(), nullAtom); 888 892 } 889 893 if (hasName()) { 890 Attribute* nameItem = m_attributeMap->getAttributeItem(HTMLNames::nameAttr);894 Attribute* nameItem = getAttributeItem(HTMLNames::nameAttr); 891 895 if (nameItem && !nameItem->isNull()) 892 896 updateName(nameItem->value(), nullAtom); … … 1754 1758 #if !ASSERT_DISABLED 1755 1759 if (m_attributeMap) { 1756 if (Attribute* attribute = m_attributeMap->getAttributeItem(name))1760 if (Attribute* attribute = getAttributeItem(name)) 1757 1761 ASSERT(isURLAttribute(attribute)); 1758 1762 } … … 1765 1769 #if !ASSERT_DISABLED 1766 1770 if (m_attributeMap) { 1767 if (Attribute* attribute = m_attributeMap->getAttributeItem(name))1771 if (Attribute* attribute = getAttributeItem(name)) 1768 1772 ASSERT(isURLAttribute(attribute)); 1769 1773 } -
trunk/Source/WebCore/dom/Element.h
r109285 r109570 238 238 239 239 // Only called by the parser immediately after element construction. 240 void parserSetAttribute Map(PassOwnPtr<NamedNodeMap>, FragmentScriptingPermission);240 void parserSetAttributes(PassOwnPtr<AttributeVector>, FragmentScriptingPermission); 241 241 242 242 ElementAttributeData* attributeData() const { return m_attributeMap ? m_attributeMap->attributeData() : 0; } … … 608 608 { 609 609 ASSERT(fastAttributeLookupAllowed(name)); 610 return m_attributeMap && m_attributeMap->getAttributeItem(name);610 return m_attributeMap && getAttributeItem(name); 611 611 } 612 612 … … 615 615 ASSERT(fastAttributeLookupAllowed(name)); 616 616 if (m_attributeMap) { 617 if (Attribute* attribute = m_attributeMap->getAttributeItem(name))617 if (Attribute* attribute = getAttributeItem(name)) 618 618 return attribute->value(); 619 619 } … … 623 623 inline bool Element::hasAttributesWithoutUpdate() const 624 624 { 625 return m_attributeMap && !m_attributeMap-> isEmpty();625 return m_attributeMap && !m_attributeMap->attributeData()->isEmpty(); 626 626 } 627 627 … … 665 665 { 666 666 ASSERT(m_attributeMap); 667 return m_attributeMap->attribute Item(index);667 return m_attributeMap->attributeData()->attributeItem(index); 668 668 } 669 669 … … 671 671 { 672 672 ASSERT(m_attributeMap); 673 return m_attributeMap-> getAttributeItem(name);673 return m_attributeMap->attributeData()->getAttributeItem(name); 674 674 } 675 675 -
trunk/Source/WebCore/dom/ElementAttributeData.cpp
r108345 r109570 31 31 32 32 namespace WebCore { 33 34 void 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 } 33 45 34 46 ElementAttributeData::~ElementAttributeData() -
trunk/Source/WebCore/dom/ElementAttributeData.h
r108449 r109570 36 36 class Element; 37 37 38 class AttributeVector : public Vector<RefPtr<Attribute>, 4> { 39 friend class ElementAttributeData; 40 41 public: 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 55 private: 56 AttributeVector() { } 57 }; 58 59 inline 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 67 inline 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 76 inline void AttributeVector::insertAttribute(PassRefPtr<Attribute> newAttribute) 77 { 78 if (!getAttributeItem(newAttribute->name())) 79 append(newAttribute); 80 } 81 38 82 class ElementAttributeData { 39 83 public: … … 58 102 59 103 // 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); } 63 107 64 108 // These functions do no error checking. … … 91 135 SpaceSplitString m_classNames; 92 136 AtomicString m_idForStyleResolution; 93 Vector<RefPtr<Attribute>, 4>m_attributes;137 AttributeVector m_attributes; 94 138 }; 95 139 … … 111 155 } 112 156 113 inline Attribute* ElementAttributeData::getAttributeItem(const QualifiedName& name) const114 {115 size_t index = getAttributeItemIndex(name);116 if (index != notFound)117 return m_attributes[index].get();118 return 0;119 }120 121 157 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller 122 158 // can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not). 123 inline size_t ElementAttributeData::getAttributeItemIndex(const QualifiedName& name) const124 {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 133 159 inline size_t ElementAttributeData::getAttributeItemIndex(const String& name, bool shouldIgnoreAttributeCase) const 134 160 { -
trunk/Source/WebCore/dom/NamedNodeMap.cpp
r107570 r109570 85 85 PassRefPtr<Node> NamedNodeMap::getNamedItem(const QualifiedName& name) const 86 86 { 87 Attribute* a = getAttributeItem(name);87 Attribute* a = m_attributeData.getAttributeItem(name); 88 88 if (!a) 89 89 return 0; … … 107 107 108 108 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; 111 111 if (oldAttribute == attribute) 112 112 return node; // we know about it already … … 138 138 ASSERT(m_element); 139 139 140 size_t index = getAttributeItemIndex(name);140 size_t index = m_attributeData.getAttributeItemIndex(name); 141 141 if (index == notFound) { 142 142 ec = NOT_FOUND_ERR; … … 172 172 { 173 173 if (!otherMap) 174 return isEmpty();174 return m_attributeData.isEmpty(); 175 175 176 176 unsigned len = length(); … … 178 178 return false; 179 179 180 const ElementAttributeData& otherAttributeData = otherMap->m_attributeData; 180 181 for (unsigned i = 0; i < len; i++) { 181 Attribute* attr = attributeItem(i);182 Attribute* otherAttr = other Map->getAttributeItem(attr->name());182 Attribute* attr = m_attributeData.attributeItem(i); 183 Attribute* otherAttr = otherAttributeData.getAttributeItem(attr->name()); 183 184 if (!otherAttr || attr->value() != otherAttr->value()) 184 185 return false; -
trunk/Source/WebCore/dom/NamedNodeMap.h
r107570 r109570 61 61 PassRefPtr<Node> item(unsigned index) const; 62 62 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 }81 63 82 64 bool mapsEquivalent(const NamedNodeMap* otherMap) const; -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r106757 r109570 195 195 { 196 196 RefPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(m_document); 197 element->parserSetAttribute Map(token.takeAttributes(), m_fragmentScriptingPermission);197 element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission); 198 198 attachLater(m_attachmentRoot, element); 199 199 m_openElements.pushHTMLHtmlElement(element); … … 209 209 return; 210 210 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) { 213 213 Attribute* attribute = token.attributes()->attributeItem(i); 214 214 if (!attributes->getAttributeItem(attribute->name())) … … 337 337 RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, currentNode()->document(), true); 338 338 if (m_fragmentScriptingPermission == FragmentScriptingAllowed) 339 element->parserSetAttribute Map(token.takeAttributes(), m_fragmentScriptingPermission);339 element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission); 340 340 attachLater(currentNode(), element); 341 341 m_openElements.push(element.release()); … … 400 400 QualifiedName tagName(nullAtom, token.name(), namespaceURI); 401 401 RefPtr<Element> element = currentNode()->document()->createElement(tagName, true); 402 element->parserSetAttribute Map(token.takeAttributes(), m_fragmentScriptingPermission);402 element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission); 403 403 return element.release(); 404 404 } … … 411 411 // to occur after construction to allow better code sharing here. 412 412 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, currentNode()->document(), form(), true); 413 element->parserSetAttribute Map(token.takeAttributes(), m_fragmentScriptingPermission);413 element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission); 414 414 ASSERT(element->isHTMLElement()); 415 415 return element.release(); … … 424 424 425 425 // FIXME: Move this function to the top of the file. 426 inline PassOwnPtr< NamedNodeMap> cloneAttributes(Element* element)427 { 428 NamedNodeMap* attributes = element->updatedAttributes();426 inline PassOwnPtr<AttributeVector> cloneAttributes(Element* element) 427 { 428 ElementAttributeData* attributes = element->updatedAttributeData(); 429 429 if (!attributes) 430 430 return nullptr; 431 431 432 OwnPtr< NamedNodeMap> newAttributes = NamedNodeMap::create();432 OwnPtr<AttributeVector> newAttributes = AttributeVector::create(); 433 433 for (size_t i = 0; i < attributes->length(); ++i) { 434 434 Attribute* attribute = attributes->attributeItem(i); 435 435 RefPtr<Attribute> clone = Attribute::create(attribute->name(), attribute->value()); 436 newAttributes->a ddAttribute(clone);436 newAttributes->append(clone); 437 437 } 438 438 return newAttributes.release(); -
trunk/Source/WebCore/html/parser/HTMLToken.h
r104130 r109570 87 87 AtomicHTMLToken(HTMLToken& token) : AtomicMarkupTokenBase<HTMLToken>(&token) { } 88 88 89 AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, PassOwnPtr< NamedNodeMap> attributes = nullptr)89 AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr) 90 90 : AtomicMarkupTokenBase<HTMLToken>(type, name, attributes) 91 91 { -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r108311 r109570 532 532 } 533 533 534 void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, PassOwnPtr< NamedNodeMap> attributes)534 void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, PassOwnPtr<AttributeVector> attributes) 535 535 { 536 536 // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML tags. … … 561 561 } 562 562 563 PassOwnPtr< NamedNodeMap> HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)564 { 565 OwnPtr< NamedNodeMap> attributes = token.takeAttributes();563 PassOwnPtr<AttributeVector> HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token) 564 { 565 OwnPtr<AttributeVector> attributes = token.takeAttributes(); 566 566 if (!attributes) 567 attributes = NamedNodeMap::create();567 attributes = AttributeVector::create(); 568 568 else { 569 569 attributes->removeAttribute(nameAttr); … … 573 573 574 574 RefPtr<Attribute> mappedAttribute = Attribute::create(nameAttr, isindexTag.localName()); 575 attributes->insertAttribute(mappedAttribute.release() , false);575 attributes->insertAttribute(mappedAttribute.release()); 576 576 return attributes.release(); 577 577 } … … 680 680 } 681 681 682 NamedNodeMap* attributes = token.attributes();682 AttributeVector* attributes = token.attributes(); 683 683 if (!attributes) 684 684 return; 685 685 686 for (unsigned x = 0; x < attributes-> length(); ++x) {686 for (unsigned x = 0; x < attributes->size(); ++x) { 687 687 Attribute* attribute = attributes->attributeItem(x); 688 688 const QualifiedName& casedName = caseMap->get(attribute->localName()); … … 729 729 } 730 730 731 NamedNodeMap* attributes = token.attributes();731 AttributeVector* attributes = token.attributes(); 732 732 if (!attributes) 733 733 return; 734 734 735 for (unsigned x = 0; x < attributes-> length(); ++x) {735 for (unsigned x = 0; x < attributes->size(); ++x) { 736 736 Attribute* attribute = attributes->attributeItem(x); 737 737 const QualifiedName& name = map->get(attribute->localName()); -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h
r104130 r109570 152 152 inline void processCharacterBufferForInBody(ExternalCharacterTokenBuffer&); 153 153 154 void processFakeStartTag(const QualifiedName&, PassOwnPtr< NamedNodeMap> attributes = nullptr);154 void processFakeStartTag(const QualifiedName&, PassOwnPtr<AttributeVector> attributes = nullptr); 155 155 void processFakeEndTag(const QualifiedName&); 156 156 void processFakeCharacters(const String&); … … 173 173 void processTokenInForeignContent(AtomicHTMLToken&); 174 174 175 PassOwnPtr< NamedNodeMap> attributesForIsindexInput(AtomicHTMLToken&);175 PassOwnPtr<AttributeVector> attributesForIsindexInput(AtomicHTMLToken&); 176 176 177 177 HTMLElementStack::ElementRecord* furthestBlockForFormattingElement(Element*); -
trunk/Source/WebCore/html/parser/TextDocumentParser.cpp
r106757 r109570 62 62 63 63 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()); 66 66 AtomicHTMLToken fakePre(HTMLTokenTypes::StartTag, preTag.localName(), attributes.release()); 67 67 -
trunk/Source/WebCore/xml/parser/MarkupTokenBase.h
r107468 r109570 28 28 #define MarkupTokenBase_h 29 29 30 #include " NamedNodeMap.h"30 #include "ElementAttributeData.h" 31 31 #include <wtf/PassOwnPtr.h> 32 32 #include <wtf/Vector.h> … … 411 411 } 412 412 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) 414 414 : m_type(type) 415 415 , m_name(name) … … 447 447 } 448 448 449 NamedNodeMap* attributes() const449 AttributeVector* attributes() const 450 450 { 451 451 ASSERT(usesAttributes()); … … 453 453 } 454 454 455 PassOwnPtr< NamedNodeMap> takeAttributes()455 PassOwnPtr<AttributeVector> takeAttributes() 456 456 { 457 457 ASSERT(usesAttributes()); … … 517 517 bool m_selfClosing; 518 518 519 OwnPtr< NamedNodeMap> m_attributes;519 OwnPtr<AttributeVector> m_attributes; 520 520 }; 521 521 … … 527 527 return; 528 528 529 m_attributes = NamedNodeMap::create();529 m_attributes = AttributeVector::create(); 530 530 m_attributes->reserveInitialCapacity(size); 531 531 for (size_t i = 0; i < size; ++i) { … … 542 542 543 543 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)); 545 545 } 546 546 } -
trunk/Source/WebCore/xml/parser/XMLToken.h
r104130 r109570 432 432 } 433 433 434 AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr< NamedNodeMap> attributes = nullptr)434 AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr) 435 435 : AtomicMarkupTokenBase<XMLToken>(type, name, attributes) 436 436 { -
trunk/Source/WebCore/xml/parser/XMLTreeBuilder.cpp
r106833 r109570 302 302 return; 303 303 304 for (size_t i = 0; i < token.attributes()-> length(); ++i) {304 for (size_t i = 0; i < token.attributes()->size(); ++i) { 305 305 Attribute* attribute = token.attributes()->attributeItem(i); 306 306 if (attribute->name().prefix() == xmlnsAtom) … … 316 316 return; 317 317 318 for (size_t i = 0; i < token.attributes()-> length(); ++i) {318 for (size_t i = 0; i < token.attributes()->size(); ++i) { 319 319 Attribute* attribute = token.attributes()->attributeItem(i); 320 320 ExceptionCode ec = 0; -
trunk/Source/WebKit/chromium/ChangeLog
r109514 r109570 1 2012-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 1 11 2012-03-01 Dana Jansens <danakj@chromium.org> 2 12 -
trunk/Source/WebKit/chromium/src/WebNamedNodeMap.cpp
r95901 r109570 32 32 #include "WebNamedNodeMap.h" 33 33 34 #include "Element.h" 34 35 #include "NamedNodeMap.h" 35 36 #include "Node.h" … … 64 65 WebAttribute WebNamedNodeMap::attributeItem(unsigned index) const 65 66 { 66 return WebAttribute(m_private-> attributeItem(index));67 return WebAttribute(m_private->element()->attributeItem(index)); 67 68 } 68 69
Note: See TracChangeset
for help on using the changeset viewer.