Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
- index 6d84249..25a47a4 100644
- --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
- +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
- @@ -4151,7 +4151,6 @@
- A8C4A80709D563270003AC8D /* Element.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C4A7F509D563270003AC8D /* Element.h */; settings = {ATTRIBUTES = (Private, ); }; };
- A8C4A80809D563270003AC8D /* Element.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C4A7F609D563270003AC8D /* Element.cpp */; };
- A8C4A80B09D563270003AC8D /* Attribute.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C4A7F909D563270003AC8D /* Attribute.h */; settings = {ATTRIBUTES = (Private, ); }; };
- - A8C4A80C09D563270003AC8D /* Attribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C4A7FA09D563270003AC8D /* Attribute.cpp */; };
- A8C4A80D09D563270003AC8D /* Attr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C4A7FB09D563270003AC8D /* Attr.h */; settings = {ATTRIBUTES = (Private, ); }; };
- A8C4A80E09D563270003AC8D /* Attr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C4A7FC09D563270003AC8D /* Attr.cpp */; };
- A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A8CB41020E85B8A50032C4F0 /* DashArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
- @@ -11048,7 +11047,6 @@
- A8C4A7F509D563270003AC8D /* Element.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Element.h; sourceTree = "<group>"; };
- A8C4A7F609D563270003AC8D /* Element.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Element.cpp; sourceTree = "<group>"; };
- A8C4A7F909D563270003AC8D /* Attribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Attribute.h; sourceTree = "<group>"; };
- - A8C4A7FA09D563270003AC8D /* Attribute.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Attribute.cpp; sourceTree = "<group>"; };
- A8C4A7FB09D563270003AC8D /* Attr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Attr.h; sourceTree = "<group>"; };
- A8C4A7FC09D563270003AC8D /* Attr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Attr.cpp; sourceTree = "<group>"; };
- A8CB41020E85B8A50032C4F0 /* DashArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DashArray.h; sourceTree = "<group>"; };
- @@ -20887,7 +20885,6 @@
- A8C4A7FC09D563270003AC8D /* Attr.cpp */,
- A8C4A7FB09D563270003AC8D /* Attr.h */,
- 93EEC1E509C2877700C515D1 /* Attr.idl */,
- - A8C4A7FA09D563270003AC8D /* Attribute.cpp */,
- A8C4A7F909D563270003AC8D /* Attribute.h */,
- BC9462D7107A7B4C00857193 /* BeforeLoadEvent.h */,
- BC9462CB107A7A3900857193 /* BeforeLoadEvent.idl */,
- @@ -25126,7 +25123,6 @@
- E1CDE92015018ED000862CC5 /* AsyncFileStream.cpp in Sources */,
- 89D08D9F12228451001241DF /* AsyncFileSystem.cpp in Sources */,
- A8C4A80E09D563270003AC8D /* Attr.cpp in Sources */,
- - A8C4A80C09D563270003AC8D /* Attribute.cpp in Sources */,
- FD315FF612B0267600C1A359 /* AudioBasicProcessorNode.cpp in Sources */,
- FD315FF812B0267600C1A359 /* AudioBuffer.cpp in Sources */,
- FD315FFB12B0267600C1A359 /* AudioBufferSourceNode.cpp in Sources */,
- diff --git a/Source/WebCore/dom/Attr.cpp b/Source/WebCore/dom/Attr.cpp
- index 088fc2f..227862f 100644
- --- a/Source/WebCore/dom/Attr.cpp
- +++ b/Source/WebCore/dom/Attr.cpp
- @@ -3,7 +3,7 @@
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2001 Peter Kelly (pmk@post.com)
- * (C) 2001 Dirk Mueller (mueller@kde.org)
- - * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.
- + * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- @@ -36,35 +36,48 @@ namespace WebCore {
- using namespace HTMLNames;
- -inline Attr::Attr(Element* element, Document* document, PassRefPtr<Attribute> attribute)
- - : ContainerNode(document)
- +Attr::Attr(Element* element, const QualifiedName& name)
- + : ContainerNode(element->document())
- , m_element(element)
- - , m_attribute(attribute)
- + , m_name(name)
- + , m_ignoreChildrenChanged(0)
- + , m_specified(true)
- +{
- +}
- +
- +Attr::Attr(Document* document, const QualifiedName& name, const AtomicString& value)
- + : ContainerNode(document)
- + , m_element(0)
- + , m_name(name)
- + , m_value(value)
- , m_ignoreChildrenChanged(0)
- , m_specified(true)
- {
- - ASSERT(!m_attribute->attr());
- - m_attribute->bindAttr(this);
- }
- -PassRefPtr<Attr> Attr::create(Element* element, Document* document, PassRefPtr<Attribute> attribute)
- +PassRefPtr<Attr> Attr::create(Element* element, const QualifiedName& name)
- +{
- + RefPtr<Attr> attr = adoptRef(new Attr(element, name));
- + attr->createTextChild();
- + return attr.release();
- +}
- +
- +PassRefPtr<Attr> Attr::create(Document* document, const QualifiedName& name, const AtomicString& value)
- {
- - RefPtr<Attr> attr = adoptRef(new Attr(element, document, attribute));
- + RefPtr<Attr> attr = adoptRef(new Attr(document, name, value));
- attr->createTextChild();
- return attr.release();
- }
- Attr::~Attr()
- {
- - ASSERT(m_attribute->attr() == this);
- - m_attribute->unbindAttr(this);
- }
- void Attr::createTextChild()
- {
- ASSERT(refCount());
- - if (!m_attribute->value().isEmpty()) {
- - RefPtr<Text> textNode = document()->createTextNode(m_attribute->value().string());
- + if (!value().isEmpty()) {
- + RefPtr<Text> textNode = document()->createTextNode(value().string());
- // This does everything appendChild() would do in this situation (assuming m_ignoreChildrenChanged was set),
- // but much more efficiently.
- @@ -74,31 +87,6 @@ void Attr::createTextChild()
- }
- }
- -String Attr::nodeName() const
- -{
- - return name();
- -}
- -
- -Node::NodeType Attr::nodeType() const
- -{
- - return ATTRIBUTE_NODE;
- -}
- -
- -const AtomicString& Attr::localName() const
- -{
- - return m_attribute->localName();
- -}
- -
- -const AtomicString& Attr::namespaceURI() const
- -{
- - return m_attribute->namespaceURI();
- -}
- -
- -const AtomicString& Attr::prefix() const
- -{
- - return m_attribute->prefix();
- -}
- -
- void Attr::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
- {
- ec = 0;
- @@ -112,12 +100,11 @@ void Attr::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
- return;
- }
- - m_attribute->setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
- -}
- + const AtomicString& newPrefix = prefix.isEmpty() ? nullAtom : prefix;
- -String Attr::nodeValue() const
- -{
- - return value();
- + if (Attribute* attribute = elementAttribute())
- + attribute->setPrefix(newPrefix);
- + m_name.setPrefix(newPrefix);
- }
- void Attr::setValue(const AtomicString& value)
- @@ -125,22 +112,25 @@ void Attr::setValue(const AtomicString& value)
- EventQueueScope scope;
- m_ignoreChildrenChanged++;
- removeChildren();
- - m_attribute->setValue(value);
- + if (m_element)
- + elementAttribute()->setValue(value);
- + else
- + m_value = value;
- createTextChild();
- m_ignoreChildrenChanged--;
- - invalidateNodeListsCacheAfterAttributeChanged(m_attribute->name());
- + invalidateNodeListsCacheAfterAttributeChanged(m_name);
- }
- void Attr::setValue(const AtomicString& value, ExceptionCode&)
- {
- if (m_element)
- - m_element->willModifyAttribute(m_attribute->name(), m_attribute->value(), value);
- + m_element->willModifyAttribute(qualifiedName(), this->value(), value);
- setValue(value);
- if (m_element)
- - m_element->didModifyAttribute(m_attribute.get());
- + m_element->didModifyAttribute(elementAttribute());
- }
- void Attr::setNodeValue(const String& v, ExceptionCode& ec)
- @@ -150,7 +140,7 @@ void Attr::setNodeValue(const String& v, ExceptionCode& ec)
- PassRefPtr<Node> Attr::cloneNode(bool /*deep*/)
- {
- - RefPtr<Attr> clone = adoptRef(new Attr(0, document(), m_attribute->clone()));
- + RefPtr<Attr> clone = adoptRef(new Attr(document(), qualifiedName(), value()));
- cloneChildNodes(clone.get());
- return clone.release();
- }
- @@ -172,7 +162,7 @@ void Attr::childrenChanged(bool, Node*, Node*, int)
- if (m_ignoreChildrenChanged > 0)
- return;
- - invalidateNodeListsCacheAfterAttributeChanged(m_attribute->name());
- + invalidateNodeListsCacheAfterAttributeChanged(qualifiedName());
- // FIXME: We should include entity references in the value
- @@ -184,11 +174,15 @@ void Attr::childrenChanged(bool, Node*, Node*, int)
- AtomicString newValue = valueBuilder.toString();
- if (m_element)
- - m_element->willModifyAttribute(m_attribute->name(), m_attribute->value(), newValue);
- + m_element->willModifyAttribute(qualifiedName(), value(), newValue);
- +
- + if (m_element)
- + elementAttribute()->setValue(newValue);
- + else
- + m_value = newValue;
- - m_attribute->setValue(newValue);
- if (m_element)
- - m_element->attributeChanged(m_attribute.get());
- + m_element->attributeChanged(elementAttribute());
- }
- bool Attr::isId() const
- @@ -202,8 +196,37 @@ CSSStyleDeclaration* Attr::style()
- if (!m_element->isStyledElement())
- return 0;
- m_style = StylePropertySet::create();
- - static_cast<StyledElement*>(m_element)->collectStyleForAttribute(m_attribute.get(), m_style.get());
- + static_cast<StyledElement*>(m_element)->collectStyleForAttribute(elementAttribute(), m_style.get());
- return m_style->ensureCSSStyleDeclaration();
- }
- +const AtomicString& Attr::value() const
- +{
- + if (m_element)
- + return m_element->getAttributeItem(qualifiedName())->value();
- + return m_value;
- +}
- +
- +Attribute* Attr::elementAttribute()
- +{
- + if (!m_element || !m_element->attributeData())
- + return 0;
- + return m_element->getAttributeItem(qualifiedName());
- +}
- +
- +void Attr::disconnectWithValue(const AtomicString& value)
- +{
- + ASSERT(m_element);
- + ASSERT(m_value.isNull());
- + m_value = value;
- + m_element = 0;
- +}
- +
- +void Attr::attachToElement(Element* element)
- +{
- + ASSERT(!m_element);
- + m_element = element;
- + m_value = nullAtom;
- +}
- +
- }
- diff --git a/Source/WebCore/dom/Attr.h b/Source/WebCore/dom/Attr.h
- index 7e1d293..c2d54b7 100644
- --- a/Source/WebCore/dom/Attr.h
- +++ b/Source/WebCore/dom/Attr.h
- @@ -26,7 +26,7 @@
- #define Attr_h
- #include "ContainerNode.h"
- -#include "Attribute.h"
- +#include "QualifiedName.h"
- namespace WebCore {
- @@ -36,26 +36,24 @@ class StylePropertySet;
- // Attr can have Text and EntityReference children
- // therefore it has to be a fullblown Node. The plan
- // is to dynamically allocate a textchild and store the
- -// resulting nodevalue in the Attribute upon
- +// resulting nodevalue in the attribute upon
- // destruction. however, this is not yet implemented.
- class Attr : public ContainerNode {
- - friend class AttributeVector;
- - friend class ElementAttributeData;
- public:
- - static PassRefPtr<Attr> create(Element*, Document*, PassRefPtr<Attribute>);
- + static PassRefPtr<Attr> create(Element*, const QualifiedName&);
- + static PassRefPtr<Attr> create(Document*, const QualifiedName&, const AtomicString& value);
- virtual ~Attr();
- String name() const { return qualifiedName().toString(); }
- bool specified() const { return m_specified; }
- Element* ownerElement() const { return m_element; }
- - const AtomicString& value() const { return m_attribute->value(); }
- + const AtomicString& value() const;
- void setValue(const AtomicString&, ExceptionCode&);
- void setValue(const AtomicString&);
- - Attribute* attr() const { return m_attribute.get(); }
- - const QualifiedName& qualifiedName() const { return m_attribute->name(); }
- + const QualifiedName& qualifiedName() const { return m_name; }
- bool isId() const;
- @@ -63,21 +61,25 @@ public:
- void setSpecified(bool specified) { m_specified = specified; }
- + void attachToElement(Element*);
- + void disconnectWithValue(const AtomicString&);
- +
- private:
- - Attr(Element*, Document*, PassRefPtr<Attribute>);
- + Attr(Element*, const QualifiedName&);
- + Attr(Document*, const QualifiedName&, const AtomicString& value);
- void createTextChild();
- - virtual String nodeName() const;
- - virtual NodeType nodeType() const;
- + virtual String nodeName() const OVERRIDE { return name(); }
- + virtual NodeType nodeType() const OVERRIDE { return ATTRIBUTE_NODE; }
- - const AtomicString& localName() const;
- - const AtomicString& namespaceURI() const;
- - const AtomicString& prefix() const;
- + const AtomicString& localName() const { return m_name.localName(); }
- + const AtomicString& namespaceURI() const { return m_name.namespaceURI(); }
- + const AtomicString& prefix() const { return m_name.prefix(); }
- virtual void setPrefix(const AtomicString&, ExceptionCode&);
- - virtual String nodeValue() const;
- + virtual String nodeValue() const OVERRIDE { return value(); }
- virtual void setNodeValue(const String&, ExceptionCode&);
- virtual PassRefPtr<Node> cloneNode(bool deep);
- @@ -90,8 +92,14 @@ private:
- virtual const AtomicString& virtualLocalName() const { return localName(); }
- virtual const AtomicString& virtualNamespaceURI() const { return namespaceURI(); }
- + Attribute* elementAttribute();
- +
- + // Attr wraps either an element/name, or a name/value pair (when it's a standalone Node.)
- + // Note that m_name is always set, but m_element/m_value may be null.
- Element* m_element;
- - RefPtr<Attribute> m_attribute;
- + QualifiedName m_name;
- + AtomicString m_value;
- +
- RefPtr<StylePropertySet> m_style;
- unsigned m_ignoreChildrenChanged : 31;
- bool m_specified : 1;
- diff --git a/Source/WebCore/dom/Attribute.h b/Source/WebCore/dom/Attribute.h
- index 8c59d1c..9310c72 100644
- --- a/Source/WebCore/dom/Attribute.h
- +++ b/Source/WebCore/dom/Attribute.h
- @@ -3,7 +3,7 @@
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2001 Peter Kelly (pmk@post.com)
- * (C) 2001 Dirk Mueller (mueller@kde.org)
- - * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- + * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- @@ -29,38 +29,37 @@
- namespace WebCore {
- -class Attr;
- -class Element;
- -
- // This has no counterpart in DOM.
- // It is an internal representation of the node value of an Attr.
- // The actual Attr with its value as a Text child is allocated only if needed.
- -class Attribute : public RefCounted<Attribute> {
- - friend class Attr;
- +class Attribute {
- public:
- - static PassRefPtr<Attribute> create(const QualifiedName& name, const AtomicString& value)
- + Attribute()
- + : m_name(nullAtom, nullAtom, nullAtom)
- {
- - return adoptRef(new Attribute(name, value));
- }
- - static PassRefPtr<Attribute> create(const AtomicString& name, const AtomicString& value)
- +
- + Attribute(const QualifiedName& name, const AtomicString& value)
- + : m_name(name)
- + , m_value(value)
- + {
- + }
- +
- + Attribute(const AtomicString& name, const AtomicString& value)
- + : m_name(nullAtom, name, nullAtom)
- + , m_value(value)
- {
- - return adoptRef(new Attribute(name, value));
- }
- const AtomicString& value() const { return m_value; }
- const AtomicString& prefix() const { return m_name.prefix(); }
- const AtomicString& localName() const { return m_name.localName(); }
- const AtomicString& namespaceURI() const { return m_name.namespaceURI(); }
- -
- +
- const QualifiedName& name() const { return m_name; }
- -
- - Attr* attr() const;
- - PassRefPtr<Attr> createAttrIfNeeded(Element*);
- bool isNull() const { return m_value.isNull(); }
- bool isEmpty() const { return m_value.isEmpty(); }
- -
- - PassRefPtr<Attribute> clone() const;
- void setValue(const AtomicString& value) { m_value = value; }
- void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); }
- @@ -71,26 +70,6 @@ public:
- void parserSetName(const QualifiedName& name) { m_name = name; }
- private:
- - Attribute(const QualifiedName& name, const AtomicString& value)
- - : m_hasAttr(false)
- - , m_name(name)
- - , m_value(value)
- - {
- - }
- -
- - Attribute(const AtomicString& name, const AtomicString& value)
- - : m_hasAttr(false)
- - , m_name(nullAtom, name, nullAtom)
- - , m_value(value)
- - {
- - }
- -
- - void bindAttr(Attr*);
- - void unbindAttr(Attr*);
- -
- - // This boolean will go into the spare 32-bits of padding from RefCounted in 64-bit.
- - bool m_hasAttr;
- -
- QualifiedName m_name;
- AtomicString m_value;
- };
- diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
- index 8aad1a3..0e13cbb 100644
- --- a/Source/WebCore/dom/Document.cpp
- +++ b/Source/WebCore/dom/Document.cpp
- @@ -912,7 +912,7 @@ PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCo
- return newElement.release();
- }
- case ATTRIBUTE_NODE:
- - return Attr::create(0, this, static_cast<Attr*>(importedNode)->attr()->clone());
- + return Attr::create(this, QualifiedName(nullAtom, static_cast<Attr*>(importedNode)->name(), nullAtom), static_cast<Attr*>(importedNode)->value());
- case DOCUMENT_FRAGMENT_NODE: {
- if (importedNode->isShadowRoot()) {
- // ShadowRoot nodes should not be explicitly importable.
- @@ -4459,7 +4459,7 @@ PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const S
- return 0;
- }
- - return Attr::create(0, this, Attribute::create(qName, StringImpl::empty()));
- + return Attr::create(this, qName, emptyString());
- }
- #if ENABLE(SVG)
- diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
- index 9d66c01..e9b4b30 100644
- --- a/Source/WebCore/dom/Element.cpp
- +++ b/Source/WebCore/dom/Element.cpp
- @@ -127,7 +127,7 @@ Element::~Element()
- if (shadowTree())
- rareData()->m_shadowTree.clear();
- if (m_attributeData)
- - m_attributeData->clearAttributes();
- + m_attributeData->clearAttributes(this);
- }
- inline ElementRareData* Element::rareData() const
- @@ -650,14 +650,14 @@ inline void Element::setAttributeInternal(size_t index, const QualifiedName& nam
- }
- if (!old) {
- - m_attributeData->addAttribute(Attribute::create(name, value), this, inUpdateStyleAttribute);
- + m_attributeData->addAttribute(Attribute(name, value), this, inUpdateStyleAttribute);
- return;
- }
- if (inUpdateStyleAttribute == NotInUpdateStyleAttribute)
- - willModifyAttribute(name, old ? old->value() : nullAtom, value);
- + willModifyAttribute(name, old->value(), value);
- - if (Attr* attrNode = old->attr())
- + if (Attr* attrNode = getAttr(name))
- attrNode->setValue(value);
- else
- old->setValue(value);
- @@ -739,42 +739,41 @@ static bool isAttributeToRemove(const QualifiedName& name, const AtomicString& v
- return (name.localName().endsWith(hrefAttr.localName()) || name == srcAttr || name == actionAttr) && protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value));
- }
- -void Element::parserSetAttributes(PassOwnPtr<AttributeVector> attributeVector, FragmentScriptingPermission scriptingPermission)
- +void Element::parserSetAttributes(const AttributeVector& attributeVector, FragmentScriptingPermission scriptingPermission)
- {
- ASSERT(!inDocument());
- ASSERT(!parentNode());
- ASSERT(!m_attributeData);
- - if (!attributeVector)
- + if (attributeVector.isEmpty())
- return;
- createAttributeData();
- - m_attributeData->m_attributes.swap(*attributeVector);
- + m_attributeData->m_attributes = attributeVector;
- // If the element is created as result of a paste or drag-n-drop operation
- // we want to remove all the script and event handlers.
- if (scriptingPermission == FragmentScriptingNotAllowed) {
- unsigned i = 0;
- while (i < m_attributeData->length()) {
- - const QualifiedName& attributeName = m_attributeData->m_attributes[i]->name();
- + const QualifiedName& attributeName = m_attributeData->m_attributes[i].name();
- if (isEventHandlerAttribute(attributeName)) {
- m_attributeData->m_attributes.remove(i);
- continue;
- }
- - if (isAttributeToRemove(attributeName, m_attributeData->m_attributes[i]->value()))
- - m_attributeData->m_attributes[i]->setValue(nullAtom);
- + if (isAttributeToRemove(attributeName, m_attributeData->m_attributes[i].value()))
- + m_attributeData->m_attributes[i].setValue(nullAtom);
- i++;
- }
- }
- // Store the set of attributes that changed on the stack in case
- // attributeChanged mutates m_attributeData.
- - Vector<RefPtr<Attribute> > attributes;
- - m_attributeData->copyAttributesToVector(attributes);
- - for (Vector<RefPtr<Attribute> >::iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
- - attributeChanged(iter->get());
- + AttributeVector attributes = m_attributeData->attributeVector();
- + for (unsigned i = 0; i < attributes.size(); ++i)
- + attributeChanged(&attributes[i]);
- }
- bool Element::hasAttributes() const
- @@ -1390,11 +1389,10 @@ PassRefPtr<Attr> Element::setAttributeNode(Attr* attr, ExceptionCode& ec)
- }
- ElementAttributeData* attributeData = ensureUpdatedAttributeData();
- - Attribute* attribute = attr->attr();
- - size_t index = attributeData->getAttributeItemIndex(attribute->name());
- - Attribute* oldAttribute = index != notFound ? attributeData->attributeItem(index) : 0;
- - if (oldAttribute == attribute)
- - return attr; // we know about it already
- +
- + RefPtr<Attr> oldAttr = getAttr(attr->qualifiedName());
- + if (oldAttr.get() == attr)
- + return attr; // This Attr is already attached to the element.
- // INUSE_ATTRIBUTE_ERR: Raised if node is an Attr that is already an attribute of another Element object.
- // The DOM user must explicitly clone Attr nodes to re-use them in other elements.
- @@ -1403,13 +1401,22 @@ PassRefPtr<Attr> Element::setAttributeNode(Attr* attr, ExceptionCode& ec)
- return 0;
- }
- - RefPtr<Attr> oldAttr;
- - if (oldAttribute) {
- - oldAttr = oldAttribute->createAttrIfNeeded(this);
- - attributeData->replaceAttribute(index, attribute, this);
- - } else
- - attributeData->addAttribute(attribute, this);
- + size_t index = attributeData->getAttributeItemIndex(attr->qualifiedName());
- + Attribute* oldAttribute = index != notFound ? attributeData->attributeItem(index) : 0;
- +
- + if (!oldAttribute) {
- + attributeData->addAttribute(Attribute(attr->qualifiedName(), attr->value()), this);
- + attributeData->setAttr(this, attr->qualifiedName(), attr);
- + return 0;
- + }
- +
- + if (oldAttr)
- + oldAttr->disconnectWithValue(oldAttribute->value());
- + else
- + oldAttr = Attr::create(document(), oldAttribute->name(), oldAttribute->value());
- + attributeData->replaceAttribute(index, Attribute(attr->name(), attr->value()), this);
- + attributeData->setAttr(this, attr->qualifiedName(), attr);
- return oldAttr.release();
- }
- @@ -1441,7 +1448,9 @@ PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionCode& ec)
- return 0;
- }
- - return attributeData->takeAttribute(index, this);
- + RefPtr<Attr> oldAttr = getOrCreateAttr(attr->qualifiedName());
- + attributeData->removeAttribute(index, this);
- + return oldAttr.release();
- }
- void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode& ec, FragmentScriptingPermission scriptingPermission)
- @@ -1709,11 +1718,9 @@ void Element::normalizeAttributes()
- if (!attributeData || attributeData->isEmpty())
- return;
- - Vector<RefPtr<Attribute> > attributeVector;
- - attributeData->copyAttributesToVector(attributeVector);
- - size_t numAttrs = attributeVector.size();
- - for (size_t i = 0; i < numAttrs; ++i) {
- - if (Attr* attr = attributeVector[i]->attr())
- + AttributeVector attributes = attributeData->attributeVector();
- + for (size_t i = 0; i < attributes.size(); ++i) {
- + if (Attr* attr = getAttr(attributes[i].name()))
- attr->normalize();
- }
- }
- @@ -2024,17 +2031,12 @@ void Element::didModifyAttribute(Attribute* attr)
- // Do not dispatch a DOMSubtreeModified event here; see bug 81141.
- }
- -void Element::didRemoveAttribute(Attribute* attr)
- +void Element::didRemoveAttribute(const QualifiedName& name)
- {
- - if (attr->isNull())
- - return;
- -
- - AtomicString savedValue = attr->value();
- - attr->setValue(nullAtom);
- - attributeChanged(attr);
- - attr->setValue(savedValue);
- + Attribute dummyAttribute(name, nullAtom);
- + attributeChanged(&dummyAttribute);
- - InspectorInstrumentation::didRemoveDOMAttr(document(), this, attr->name().localName());
- + InspectorInstrumentation::didRemoveDOMAttr(document(), this, name.localName());
- dispatchSubtreeModifiedEvent();
- }
- @@ -2080,4 +2082,17 @@ void Element::setSavedLayerScrollOffset(const IntSize& size)
- ensureRareData()->m_savedLayerScrollOffset = size;
- }
- +Attr* Element::getAttr(const QualifiedName& name)
- +{
- + if (!attributeData())
- + return 0;
- + return attributeData()->getAttr(this, name);
- +}
- +
- +Attr* Element::getOrCreateAttr(const QualifiedName& name)
- +{
- + ASSERT(attributeData());
- + return attributeData()->getOrCreateAttr(this, name);
- +}
- +
- } // namespace WebCore
- diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h
- index be26547..86b1235 100644
- --- a/Source/WebCore/dom/Element.h
- +++ b/Source/WebCore/dom/Element.h
- @@ -202,6 +202,9 @@ public:
- PassRefPtr<Attr> setAttributeNode(Attr*, ExceptionCode&);
- PassRefPtr<Attr> setAttributeNodeNS(Attr*, ExceptionCode&);
- PassRefPtr<Attr> removeAttributeNode(Attr*, ExceptionCode&);
- +
- + Attr* getAttr(const QualifiedName&);
- + Attr* getOrCreateAttr(const QualifiedName&);
- virtual CSSStyleDeclaration* style();
- @@ -236,7 +239,7 @@ public:
- virtual void attributeChanged(Attribute*);
- // Only called by the parser immediately after element construction.
- - void parserSetAttributes(PassOwnPtr<AttributeVector>, FragmentScriptingPermission);
- + void parserSetAttributes(const AttributeVector&, FragmentScriptingPermission);
- ElementAttributeData* attributeData() const { return m_attributeData.get(); }
- ElementAttributeData* ensureAttributeData() const;
- @@ -297,7 +300,7 @@ public:
- void willRemoveAttribute(const QualifiedName&, const AtomicString& value);
- void didAddAttribute(Attribute*);
- void didModifyAttribute(Attribute*);
- - void didRemoveAttribute(Attribute*);
- + void didRemoveAttribute(const QualifiedName&);
- LayoutSize minimumSizeForResizing() const;
- void setMinimumSizeForResizing(const LayoutSize&);
- diff --git a/Source/WebCore/dom/ElementAttributeData.cpp b/Source/WebCore/dom/ElementAttributeData.cpp
- index d732b6e..320f137 100644
- --- a/Source/WebCore/dom/ElementAttributeData.cpp
- +++ b/Source/WebCore/dom/ElementAttributeData.cpp
- @@ -26,25 +26,63 @@
- #include "config.h"
- #include "ElementAttributeData.h"
- +#include "Attr.h"
- #include "StyledElement.h"
- namespace WebCore {
- +typedef HashMap<pair<Element*, QualifiedName>, RefPtr<Attr> > AttrMap;
- +static AttrMap& attrMap()
- +{
- + DEFINE_STATIC_LOCAL(AttrMap, map, ());
- + return map;
- +}
- +
- +// FIXME: We are leaking these into the map.
- +
- +Attr* ElementAttributeData::getAttr(Element* element, const QualifiedName& name)
- +{
- + if (!m_attrCount)
- + return 0;
- + return attrMap().get(std::make_pair(element, name)).get();
- +}
- +
- +Attr* ElementAttributeData::getOrCreateAttr(Element* element, const QualifiedName& name)
- +{
- + AttrMap::AddResult result = attrMap().add(std::make_pair(element, name), 0);
- + if (result.isNewEntry) {
- + result.iterator->second = Attr::create(element, name);
- + setAttr(element, name, result.iterator->second.get());
- + }
- + return result.iterator->second.get();
- +}
- +
- +void ElementAttributeData::setAttr(Element* element, const QualifiedName& name, Attr* attr)
- +{
- + ASSERT(!attrMap().contains(std::make_pair(element, name)));
- + attrMap().add(std::make_pair(element, name), attr);
- + attr->attachToElement(element);
- + didAddAttr();
- +}
- +
- +void ElementAttributeData::removeAttr(Element* element, const QualifiedName& name)
- +{
- + ASSERT(attrMap().contains(std::make_pair(element, name)));
- + attrMap().remove(std::make_pair(element, name));
- + didRemoveAttr();
- +}
- +
- void AttributeVector::removeAttribute(const QualifiedName& name)
- {
- size_t index = getAttributeItemIndex(name);
- if (index == notFound)
- return;
- - RefPtr<Attribute> attribute = at(index);
- - if (Attr* attr = attribute->attr())
- - attr->m_element = 0;
- remove(index);
- }
- ElementAttributeData::~ElementAttributeData()
- {
- - detachAttributesFromElement();
- }
- void ElementAttributeData::setClass(const String& className, bool shouldFoldCase)
- @@ -93,46 +131,36 @@ void ElementAttributeData::destroyInlineStyle(StyledElement* element)
- m_inlineStyleDecl = 0;
- }
- -void ElementAttributeData::addAttribute(PassRefPtr<Attribute> prpAttribute, Element* element, EInUpdateStyleAttribute inUpdateStyleAttribute)
- +void ElementAttributeData::addAttribute(const Attribute& attribute, Element* element, EInUpdateStyleAttribute inUpdateStyleAttribute)
- {
- - RefPtr<Attribute> attribute = prpAttribute;
- -
- if (element && inUpdateStyleAttribute == NotInUpdateStyleAttribute)
- - element->willModifyAttribute(attribute->name(), nullAtom, attribute->value());
- + element->willModifyAttribute(attribute.name(), nullAtom, attribute.value());
- m_attributes.append(attribute);
- - if (Attr* attr = attribute->attr())
- - attr->m_element = element;
- if (element && inUpdateStyleAttribute == NotInUpdateStyleAttribute)
- - element->didAddAttribute(attribute.get());
- + element->didAddAttribute(const_cast<Attribute*>(&attribute));
- }
- void ElementAttributeData::removeAttribute(size_t index, Element* element, EInUpdateStyleAttribute inUpdateStyleAttribute)
- {
- ASSERT(index < length());
- - RefPtr<Attribute> attribute = m_attributes[index];
- + Attribute& attribute = m_attributes[index];
- + QualifiedName name = attribute.name();
- if (element && inUpdateStyleAttribute == NotInUpdateStyleAttribute)
- - element->willRemoveAttribute(attribute->name(), attribute->value());
- + element->willRemoveAttribute(name, attribute.value());
- +
- + if (Attr* attr = getAttr(element, name)) {
- + attr->disconnectWithValue(attribute.value());
- + removeAttr(element, name);
- + }
- - if (Attr* attr = attribute->attr())
- - attr->m_element = 0;
- m_attributes.remove(index);
- if (element && inUpdateStyleAttribute == NotInUpdateStyleAttribute)
- - element->didRemoveAttribute(attribute.get());
- -}
- -
- -PassRefPtr<Attr> ElementAttributeData::takeAttribute(size_t index, Element* element)
- -{
- - ASSERT(index < length());
- - ASSERT(element);
- -
- - RefPtr<Attr> attr = m_attributes[index]->createAttrIfNeeded(element);
- - removeAttribute(index, element);
- - return attr.release();
- + element->didRemoveAttribute(name);
- }
- bool ElementAttributeData::isEquivalent(const ElementAttributeData* other) const
- @@ -145,44 +173,39 @@ bool ElementAttributeData::isEquivalent(const ElementAttributeData* other) const
- return false;
- for (unsigned i = 0; i < len; i++) {
- - Attribute* attr = attributeItem(i);
- - Attribute* otherAttr = other->getAttributeItem(attr->name());
- - if (!otherAttr || attr->value() != otherAttr->value())
- + Attribute* otherAttr = other->getAttributeItem(m_attributes[i].name());
- + if (!otherAttr || m_attributes[i].value() != otherAttr->value())
- return false;
- }
- return true;
- }
- -void ElementAttributeData::detachAttributesFromElement()
- +void ElementAttributeData::detachAttributesFromElement(Element* element)
- {
- - size_t size = m_attributes.size();
- - for (size_t i = 0; i < size; i++) {
- - if (Attr* attr = m_attributes[i]->attr())
- - attr->m_element = 0;
- - }
- -}
- + if (!m_attrCount)
- + return;
- -void ElementAttributeData::copyAttributesToVector(Vector<RefPtr<Attribute> >& copy)
- -{
- - copy = m_attributes;
- + for (unsigned i = 0; i < m_attributes.size(); ++i) {
- + if (Attr* attr = getAttr(element, m_attributes[i].name()))
- + attr->disconnectWithValue(m_attributes[i].value()); {
- + removeAttr(element, m_attributes[i].name());
- + }
- + }
- }
- size_t ElementAttributeData::getAttributeItemIndexSlowCase(const String& name, bool shouldIgnoreAttributeCase) const
- {
- - unsigned len = length();
- -
- // Continue to checking case-insensitively and/or full namespaced names if necessary:
- - for (unsigned i = 0; i < len; ++i) {
- - const QualifiedName& attrName = m_attributes[i]->name();
- - if (!attrName.hasPrefix()) {
- - if (shouldIgnoreAttributeCase && equalIgnoringCase(name, attrName.localName()))
- + for (unsigned i = 0; i < m_attributes.size(); ++i) {
- + if (!m_attributes[i].name().hasPrefix()) {
- + if (shouldIgnoreAttributeCase && equalIgnoringCase(name, m_attributes[i].localName()))
- return i;
- } else {
- // FIXME: Would be faster to do this comparison without calling toString, which
- // generates a temporary string by concatenation. But this branch is only reached
- // if the attribute name has a prefix, which is rare in HTML.
- - if (equalPossiblyIgnoringCase(name, attrName.toString(), shouldIgnoreAttributeCase))
- + if (equalPossiblyIgnoringCase(name, m_attributes[i].name().toString(), shouldIgnoreAttributeCase))
- return i;
- }
- }
- @@ -207,41 +230,51 @@ void ElementAttributeData::setAttributes(const ElementAttributeData& other, Elem
- if (oldName || newName)
- element->updateName(oldName ? oldName->value() : nullAtom, newName ? newName->value() : nullAtom);
- - clearAttributes();
- + clearAttributes(element);
- unsigned newLength = other.length();
- m_attributes.resize(newLength);
- // FIXME: These loops can probably be combined.
- for (unsigned i = 0; i < newLength; i++)
- - m_attributes[i] = other.m_attributes[i]->clone();
- + m_attributes[i] = other.m_attributes[i];
- for (unsigned i = 0; i < newLength; i++)
- - element->attributeChanged(m_attributes[i].get());
- + element->attributeChanged(&m_attributes[i]);
- }
- -void ElementAttributeData::clearAttributes()
- +void ElementAttributeData::clearAttributes(Element* element)
- {
- clearClass();
- - detachAttributesFromElement();
- + detachAttributesFromElement(element);
- m_attributes.clear();
- }
- -void ElementAttributeData::replaceAttribute(size_t index, PassRefPtr<Attribute> prpAttribute, Element* element)
- +void ElementAttributeData::replaceAttribute(size_t index, const Attribute& attribute, Element* element)
- {
- ASSERT(element);
- ASSERT(index < length());
- - RefPtr<Attribute> attribute = prpAttribute;
- - Attribute* old = m_attributes[index].get();
- -
- - element->willModifyAttribute(attribute->name(), old->value(), attribute->value());
- -
- - if (Attr* attr = old->attr())
- - attr->m_element = 0;
- + element->willModifyAttribute(attribute.name(), m_attributes[index].value(), attribute.value());
- m_attributes[index] = attribute;
- - if (Attr* attr = attribute->attr())
- - attr->m_element = element;
- + element->didModifyAttribute(const_cast<Attribute*>(&attribute));
- +}
- - element->didModifyAttribute(attribute.get());
- +PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const
- +{
- + ASSERT(element);
- + Attribute* attribute = getAttributeItem(name, shouldIgnoreAttributeCase);
- + if (!attribute)
- + return 0;
- + return const_cast<ElementAttributeData*>(this)->getOrCreateAttr(element, attribute->name());
- }
- +PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const QualifiedName& name, Element* element) const
- +{
- + ASSERT(element);
- + Attribute* attribute = getAttributeItem(name);
- + if (!attribute)
- + return 0;
- + return const_cast<ElementAttributeData*>(this)->getOrCreateAttr(element, attribute->name());
- +}
- +
- +
- }
- diff --git a/Source/WebCore/dom/ElementAttributeData.h b/Source/WebCore/dom/ElementAttributeData.h
- index f854328..1882534 100644
- --- a/Source/WebCore/dom/ElementAttributeData.h
- +++ b/Source/WebCore/dom/ElementAttributeData.h
- @@ -26,7 +26,6 @@
- #ifndef ElementAttributeData_h
- #define ElementAttributeData_h
- -#include "Attr.h"
- #include "Attribute.h"
- #include "SpaceSplitString.h"
- #include "StylePropertySet.h"
- @@ -34,49 +33,42 @@
- namespace WebCore {
- +class Attr;
- class Element;
- -class AttributeVector : public Vector<RefPtr<Attribute>, 4> {
- - friend class ElementAttributeData;
- -
- +class AttributeVector : public Vector<Attribute, 4> {
- public:
- - static PassOwnPtr<AttributeVector> create()
- - {
- - return adoptPtr(new AttributeVector());
- - }
- + AttributeVector() { }
- - Attribute* attributeItem(unsigned index) const { return at(index).get(); }
- + Attribute* attributeItem(unsigned index) const { return &const_cast<AttributeVector*>(this)->at(index); }
- Attribute* getAttributeItem(const QualifiedName&) const;
- size_t getAttributeItemIndex(const QualifiedName&) const;
- // Used during parsing: only inserts if not already there.
- - void insertAttribute(PassRefPtr<Attribute> newAttribute);
- + void insertAttribute(const Attribute&);
- void removeAttribute(const QualifiedName&);
- -
- -private:
- - AttributeVector() { }
- };
- inline Attribute* AttributeVector::getAttributeItem(const QualifiedName& name) const
- {
- size_t index = getAttributeItemIndex(name);
- if (index != notFound)
- - return at(index).get();
- + return &const_cast<AttributeVector*>(this)->at(index);
- return 0;
- }
- inline size_t AttributeVector::getAttributeItemIndex(const QualifiedName& name) const
- {
- for (unsigned i = 0; i < size(); ++i) {
- - if (at(i)->name().matches(name))
- + if (at(i).name().matches(name))
- return i;
- }
- return notFound;
- }
- -inline void AttributeVector::insertAttribute(PassRefPtr<Attribute> newAttribute)
- +inline void AttributeVector::insertAttribute(const Attribute& newAttribute)
- {
- - if (!getAttributeItem(newAttribute->name()))
- + if (!getAttributeItem(newAttribute.name()))
- append(newAttribute);
- }
- @@ -120,7 +112,7 @@ public:
- size_t getAttributeItemIndex(const String& name, bool shouldIgnoreAttributeCase) const;
- // These functions do no error checking.
- - void addAttribute(PassRefPtr<Attribute>, Element*, EInUpdateStyleAttribute = NotInUpdateStyleAttribute);
- + void addAttribute(const Attribute&, Element*, EInUpdateStyleAttribute = NotInUpdateStyleAttribute);
- void removeAttribute(const QualifiedName&, Element*);
- void removeAttribute(size_t index, Element*, EInUpdateStyleAttribute = NotInUpdateStyleAttribute);
- PassRefPtr<Attr> takeAttribute(size_t index, Element*);
- @@ -130,26 +122,40 @@ public:
- bool isEquivalent(const ElementAttributeData* other) const;
- + bool hasAttrs() const { return m_attrCount; }
- + void didAddAttr() { m_attrCount++; }
- + void didRemoveAttr() { m_attrCount--; }
- +
- + void setAttr(Element*, const QualifiedName&, Attr*);
- + void removeAttr(Element*, const QualifiedName&);
- + Attr* getAttr(Element*, const QualifiedName&);
- + Attr* getOrCreateAttr(Element*, const QualifiedName&);
- +
- private:
- friend class Element;
- + friend class HTMLConstructionSite;
- ElementAttributeData()
- + : m_attrCount(0)
- {
- }
- - void detachAttributesFromElement();
- - void copyAttributesToVector(Vector<RefPtr<Attribute> >&);
- + AttributeVector attributeVector() const { return m_attributes; }
- +
- + void detachAttributesFromElement(Element*);
- Attribute* getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const;
- size_t getAttributeItemIndexSlowCase(const String& name, bool shouldIgnoreAttributeCase) const;
- void setAttributes(const ElementAttributeData& other, Element*);
- - void clearAttributes();
- - void replaceAttribute(size_t index, PassRefPtr<Attribute>, Element*);
- + void clearAttributes(Element*);
- + void replaceAttribute(size_t index, const Attribute&, Element*);
- RefPtr<StylePropertySet> m_inlineStyleDecl;
- RefPtr<StylePropertySet> m_attributeStyle;
- SpaceSplitString m_classNames;
- AtomicString m_idForStyleResolution;
- AttributeVector m_attributes;
- +
- + unsigned m_attrCount;
- };
- inline void ElementAttributeData::removeAttribute(const QualifiedName& name, Element* element)
- @@ -161,29 +167,11 @@ inline void ElementAttributeData::removeAttribute(const QualifiedName& name, Ele
- removeAttribute(index, element);
- }
- -inline PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const
- -{
- - ASSERT(element);
- - Attribute* attribute = getAttributeItem(name, shouldIgnoreAttributeCase);
- - if (!attribute)
- - return 0;
- - return attribute->createAttrIfNeeded(element);
- -}
- -
- -inline PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const QualifiedName& name, Element* element) const
- -{
- - ASSERT(element);
- - Attribute* attribute = getAttributeItem(name);
- - if (!attribute)
- - return 0;
- - return attribute->createAttrIfNeeded(element);
- -}
- -
- inline Attribute* ElementAttributeData::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const
- {
- size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase);
- if (index != notFound)
- - return m_attributes[index].get();
- + return &const_cast<ElementAttributeData*>(this)->m_attributes[index];
- return 0;
- }
- @@ -196,9 +184,8 @@ inline size_t ElementAttributeData::getAttributeItemIndex(const String& name, bo
- // Optimize for the case where the attribute exists and its name exactly matches.
- for (unsigned i = 0; i < len; ++i) {
- - const QualifiedName& attrName = m_attributes[i]->name();
- - if (!attrName.hasPrefix()) {
- - if (name == attrName.localName())
- + if (!m_attributes[i].name().hasPrefix()) {
- + if (name == m_attributes[i].localName())
- return i;
- } else
- doSlowCheck = true;
- diff --git a/Source/WebCore/dom/NamedNodeMap.cpp b/Source/WebCore/dom/NamedNodeMap.cpp
- index 942c40c..25b5a19 100644
- --- a/Source/WebCore/dom/NamedNodeMap.cpp
- +++ b/Source/WebCore/dom/NamedNodeMap.cpp
- @@ -69,8 +69,10 @@ PassRefPtr<Node> NamedNodeMap::removeNamedItem(const String& name, ExceptionCode
- ec = NOT_FOUND_ERR;
- return 0;
- }
- -
- - return attributeData->takeAttribute(index, m_element);
- +
- + RefPtr<Attr> oldAttr = m_element->getOrCreateAttr(m_element->attributeItem(index)->name());
- + attributeData->removeAttribute(index, m_element);
- + return oldAttr.release();
- }
- PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)
- @@ -83,7 +85,9 @@ PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const String& namespaceURI, con
- return 0;
- }
- - return attributeData->takeAttribute(index, m_element);
- + RefPtr<Attr> oldAttr = m_element->getOrCreateAttr(m_element->attributeItem(index)->name());
- + attributeData->removeAttribute(index, m_element);
- + return oldAttr.release();
- }
- PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionCode& ec)
- @@ -111,7 +115,7 @@ PassRefPtr<Node> NamedNodeMap::item(unsigned index) const
- {
- if (index >= length())
- return 0;
- - return m_element->attributeItem(index)->createAttrIfNeeded(m_element);
- + return m_element->getOrCreateAttr(m_element->attributeItem(index)->name());
- }
- size_t NamedNodeMap::length() const
- diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
- index 0407527..1f45ef3 100644
- --- a/Source/WebCore/dom/Node.cpp
- +++ b/Source/WebCore/dom/Node.cpp
- @@ -2094,10 +2094,10 @@ unsigned short Node::compareDocumentPosition(Node* otherNode)
- // the same nodeType are inserted into or removed from the direct container. This would be the case, for example,
- // when comparing two attributes of the same element, and inserting or removing additional attributes might change
- // the order between existing attributes.
- - Attribute* attr = owner1->attributeItem(i);
- - if (attr1->attr() == attr)
- + Attribute* attribute = owner1->attributeItem(i);
- + if (attr1->qualifiedName() == attribute->name())
- return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_FOLLOWING;
- - if (attr2->attr() == attr)
- + if (attr2->qualifiedName() == attribute->name())
- return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_PRECEDING;
- }
- diff --git a/Source/WebCore/html/parser/HTMLConstructionSite.cpp b/Source/WebCore/html/parser/HTMLConstructionSite.cpp
- index 9fa5d37..02b1f36 100644
- --- a/Source/WebCore/html/parser/HTMLConstructionSite.cpp
- +++ b/Source/WebCore/html/parser/HTMLConstructionSite.cpp
- @@ -194,7 +194,7 @@ void HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded()
- void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken& token)
- {
- RefPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(m_document);
- - element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
- + element->parserSetAttributes(token.attributes(), m_fragmentScriptingPermission);
- attachLater(m_attachmentRoot, element);
- m_openElements.pushHTMLHtmlElement(element);
- @@ -205,12 +205,12 @@ void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken& tok
- void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken& token, Element* element)
- {
- - if (!token.attributes())
- + if (token.attributes().isEmpty())
- return;
- ElementAttributeData* attributes = element->ensureAttributeData();
- - for (unsigned i = 0; i < token.attributes()->size(); ++i) {
- - Attribute* attribute = token.attributes()->attributeItem(i);
- + for (unsigned i = 0; i < token.attributes().size(); ++i) {
- + Attribute* attribute = token.attributes().attributeItem(i);
- if (!attributes->getAttributeItem(attribute->name()))
- element->setAttribute(attribute->name(), attribute->value());
- }
- @@ -336,7 +336,7 @@ void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken& token)
- {
- RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, currentNode()->document(), true);
- if (m_fragmentScriptingPermission == FragmentScriptingAllowed)
- - element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
- + element->parserSetAttributes(token.attributes(), m_fragmentScriptingPermission);
- attachLater(currentNode(), element);
- m_openElements.push(element.release());
- }
- @@ -399,7 +399,7 @@ PassRefPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLToken& token,
- {
- QualifiedName tagName(nullAtom, token.name(), namespaceURI);
- RefPtr<Element> element = currentNode()->document()->createElement(tagName, true);
- - element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
- + element->parserSetAttributes(token.attributes(), m_fragmentScriptingPermission);
- return element.release();
- }
- @@ -410,7 +410,7 @@ PassRefPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken& tok
- // have to pass the current form element. We should rework form association
- // to occur after construction to allow better code sharing here.
- RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, currentNode()->document(), form(), true);
- - element->parserSetAttributes(token.takeAttributes(), m_fragmentScriptingPermission);
- + element->parserSetAttributes(token.attributes(), m_fragmentScriptingPermission);
- ASSERT(element->isHTMLElement());
- return element.release();
- }
- @@ -420,26 +420,6 @@ PassRefPtr<Element> HTMLConstructionSite::createHTMLElementFromElementRecord(HTM
- return createHTMLElementFromSavedElement(record->element());
- }
- -namespace {
- -
- -// FIXME: Move this function to the top of the file.
- -inline PassOwnPtr<AttributeVector> cloneAttributes(Element* element)
- -{
- - ElementAttributeData* attributes = element->updatedAttributeData();
- - if (!attributes)
- - return nullptr;
- -
- - OwnPtr<AttributeVector> newAttributes = AttributeVector::create();
- - for (size_t i = 0; i < attributes->length(); ++i) {
- - Attribute* attribute = attributes->attributeItem(i);
- - RefPtr<Attribute> clone = Attribute::create(attribute->name(), attribute->value());
- - newAttributes->append(clone);
- - }
- - return newAttributes.release();
- -}
- -
- -} // namespace
- -
- PassRefPtr<Element> HTMLConstructionSite::createHTMLElementFromSavedElement(Element* element)
- {
- // FIXME: This method is wrong. We should be using the original token.
- @@ -450,7 +430,12 @@ PassRefPtr<Element> HTMLConstructionSite::createHTMLElementFromSavedElement(Elem
- // spec implies it should be "1". Minefield matches the HTML5 spec here.
- ASSERT(element->isHTMLElement()); // otherwise localName() might be wrong.
- - AtomicHTMLToken fakeToken(HTMLTokenTypes::StartTag, element->localName(), cloneAttributes(element));
- +
- + AttributeVector attributes;
- + if (ElementAttributeData* attributeData = element->updatedAttributeData())
- + attributes = attributeData->attributeVector();
- +
- + AtomicHTMLToken fakeToken(HTMLTokenTypes::StartTag, element->localName(), attributes);
- return createHTMLElement(fakeToken);
- }
- diff --git a/Source/WebCore/html/parser/HTMLToken.h b/Source/WebCore/html/parser/HTMLToken.h
- index a391d34..686dd3a 100644
- --- a/Source/WebCore/html/parser/HTMLToken.h
- +++ b/Source/WebCore/html/parser/HTMLToken.h
- @@ -86,7 +86,7 @@ class AtomicHTMLToken : public AtomicMarkupTokenBase<HTMLToken> {
- public:
- AtomicHTMLToken(HTMLToken& token) : AtomicMarkupTokenBase<HTMLToken>(&token) { }
- - AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr)
- + AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, const AttributeVector& attributes = AttributeVector())
- : AtomicMarkupTokenBase<HTMLToken>(type, name, attributes)
- {
- }
- diff --git a/Source/WebCore/html/parser/HTMLTreeBuilder.cpp b/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
- index 8062ebd..2412cd8 100644
- --- a/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
- +++ b/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
- @@ -531,7 +531,7 @@ void HTMLTreeBuilder::processDoctypeToken(AtomicHTMLToken& token)
- parseError(token);
- }
- -void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, PassOwnPtr<AttributeVector> attributes)
- +void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, const AttributeVector& attributes)
- {
- // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML tags.
- AtomicHTMLToken fakeToken(HTMLTokenTypes::StartTag, tagName.localName(), attributes);
- @@ -560,20 +560,17 @@ void HTMLTreeBuilder::processFakePEndTagIfPInButtonScope()
- processEndTag(endP);
- }
- -PassOwnPtr<AttributeVector> HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)
- +AttributeVector HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)
- {
- - OwnPtr<AttributeVector> attributes = token.takeAttributes();
- - if (!attributes)
- - attributes = AttributeVector::create();
- - else {
- - attributes->removeAttribute(nameAttr);
- - attributes->removeAttribute(actionAttr);
- - attributes->removeAttribute(promptAttr);
- + AttributeVector& attributes = token.attributes();
- + if (!attributes.isEmpty()) {
- + attributes.removeAttribute(nameAttr);
- + attributes.removeAttribute(actionAttr);
- + attributes.removeAttribute(promptAttr);
- }
- - RefPtr<Attribute> mappedAttribute = Attribute::create(nameAttr, isindexTag.localName());
- - attributes->insertAttribute(mappedAttribute.release());
- - return attributes.release();
- + attributes.insertAttribute(Attribute(nameAttr, isindexTag.localName()));
- + return attributes;
- }
- void HTMLTreeBuilder::processIsindexStartTagForInBody(AtomicHTMLToken& token)
- @@ -585,12 +582,12 @@ void HTMLTreeBuilder::processIsindexStartTagForInBody(AtomicHTMLToken& token)
- return;
- notImplemented(); // Acknowledge self-closing flag
- processFakeStartTag(formTag);
- - RefPtr<Attribute> actionAttribute = token.getAttributeItem(actionAttr);
- + Attribute* actionAttribute = token.getAttributeItem(actionAttr);
- if (actionAttribute)
- m_tree.form()->setAttribute(actionAttr, actionAttribute->value());
- processFakeStartTag(hrTag);
- processFakeStartTag(labelTag);
- - RefPtr<Attribute> promptAttribute = token.getAttributeItem(promptAttr);
- + Attribute* promptAttribute = token.getAttributeItem(promptAttr);
- if (promptAttribute)
- processFakeCharacters(promptAttribute->value());
- else
- @@ -679,12 +676,8 @@ void adjustAttributes(AtomicHTMLToken& token)
- mapLoweredLocalNameToName(caseMap, attrs, length);
- }
- - AttributeVector* attributes = token.attributes();
- - if (!attributes)
- - return;
- -
- - for (unsigned x = 0; x < attributes->size(); ++x) {
- - Attribute* attribute = attributes->attributeItem(x);
- + for (unsigned i = 0; i < token.attributes().size(); ++i) {
- + Attribute* attribute = token.attributes().attributeItem(i);
- const QualifiedName& casedName = caseMap->get(attribute->localName());
- if (!casedName.localName().isNull())
- attribute->parserSetName(casedName);
- @@ -728,12 +721,8 @@ void adjustForeignAttributes(AtomicHTMLToken& token)
- map->add("xmlns:xlink", QualifiedName("xmlns", "xlink", XMLNSNames::xmlnsNamespaceURI));
- }
- - AttributeVector* attributes = token.attributes();
- - if (!attributes)
- - return;
- -
- - for (unsigned x = 0; x < attributes->size(); ++x) {
- - Attribute* attribute = attributes->attributeItem(x);
- + for (unsigned i = 0; i < token.attributes().size(); ++i) {
- + Attribute* attribute = token.attributes().attributeItem(i);
- const QualifiedName& name = map->get(attribute->localName());
- if (!name.localName().isNull())
- attribute->parserSetName(name);
- @@ -930,7 +919,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
- return;
- }
- if (token.name() == inputTag) {
- - RefPtr<Attribute> typeAttribute = token.getAttributeItem(typeAttr);
- + Attribute* typeAttribute = token.getAttributeItem(typeAttr);
- m_tree.reconstructTheActiveFormattingElements();
- m_tree.insertSelfClosingHTMLElement(token);
- if (!typeAttribute || !equalIgnoringCase(typeAttribute->value(), "hidden"))
- diff --git a/Source/WebCore/html/parser/HTMLTreeBuilder.h b/Source/WebCore/html/parser/HTMLTreeBuilder.h
- index 35024f8..bc36a79 100644
- --- a/Source/WebCore/html/parser/HTMLTreeBuilder.h
- +++ b/Source/WebCore/html/parser/HTMLTreeBuilder.h
- @@ -151,7 +151,7 @@ private:
- void processCharacterBuffer(ExternalCharacterTokenBuffer&);
- inline void processCharacterBufferForInBody(ExternalCharacterTokenBuffer&);
- - void processFakeStartTag(const QualifiedName&, PassOwnPtr<AttributeVector> attributes = nullptr);
- + void processFakeStartTag(const QualifiedName&, const AttributeVector& attributes = AttributeVector());
- void processFakeEndTag(const QualifiedName&);
- void processFakeCharacters(const String&);
- void processFakePEndTagIfPInButtonScope();
- @@ -172,7 +172,7 @@ private:
- inline bool shouldProcessTokenInForeignContent(AtomicHTMLToken&);
- void processTokenInForeignContent(AtomicHTMLToken&);
- - PassOwnPtr<AttributeVector> attributesForIsindexInput(AtomicHTMLToken&);
- + AttributeVector attributesForIsindexInput(AtomicHTMLToken&);
- HTMLElementStack::ElementRecord* furthestBlockForFormattingElement(Element*);
- void callTheAdoptionAgency(AtomicHTMLToken&);
- diff --git a/Source/WebCore/html/parser/TextDocumentParser.cpp b/Source/WebCore/html/parser/TextDocumentParser.cpp
- index 3589c3f..742fbf7 100644
- --- a/Source/WebCore/html/parser/TextDocumentParser.cpp
- +++ b/Source/WebCore/html/parser/TextDocumentParser.cpp
- @@ -60,10 +60,9 @@ void TextDocumentParser::insertFakePreElement()
- // sending fake bytes through the front-end of the parser to avoid
- // distrubing the line/column number calculations.
- - RefPtr<Attribute> styleAttribute = Attribute::create("style", "word-wrap: break-word; white-space: pre-wrap;");
- - OwnPtr<AttributeVector> attributes = AttributeVector::create();
- - attributes->insertAttribute(styleAttribute.release());
- - AtomicHTMLToken fakePre(HTMLTokenTypes::StartTag, preTag.localName(), attributes.release());
- + AttributeVector attributes;
- + attributes.insertAttribute(Attribute("style", "word-wrap: break-word; white-space: pre-wrap;"));
- + AtomicHTMLToken fakePre(HTMLTokenTypes::StartTag, preTag.localName(), attributes);
- treeBuilder()->constructTreeFromAtomicToken(fakePre);
- // Normally we would skip the first \n after a <pre> element, but we don't
- diff --git a/Source/WebCore/page/PageSerializer.cpp b/Source/WebCore/page/PageSerializer.cpp
- index 9d50211..b7f38e0 100644
- --- a/Source/WebCore/page/PageSerializer.cpp
- +++ b/Source/WebCore/page/PageSerializer.cpp
- @@ -159,8 +159,7 @@ void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& out, Ele
- // We need to give a fake location to blank frames so they can be referenced by the serialized frame.
- url = m_serializer->urlForBlankFrame(frame);
- - RefPtr<Attribute> attribute = Attribute::create(frameOwnerURLAttributeName(*frameOwner), url.string());
- - appendAttribute(out, element, *attribute, namespaces);
- + appendAttribute(out, element, Attribute(frameOwnerURLAttributeName(*frameOwner), url.string()), namespaces);
- }
- void SerializerMarkupAccumulator::appendEndTag(Node* node)
- diff --git a/Source/WebCore/svg/SVGFitToViewBox.cpp b/Source/WebCore/svg/SVGFitToViewBox.cpp
- index 929167c..2c7b106 100644
- --- a/Source/WebCore/svg/SVGFitToViewBox.cpp
- +++ b/Source/WebCore/svg/SVGFitToViewBox.cpp
- @@ -24,7 +24,7 @@
- #include "SVGFitToViewBox.h"
- #include "AffineTransform.h"
- -#include "Attr.h"
- +#include "Attribute.h"
- #include "Document.h"
- #include "FloatRect.h"
- #include "SVGDocumentExtensions.h"
- diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h b/Source/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h
- index 6e4c487..887bc18 100644
- --- a/Source/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h
- +++ b/Source/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h
- @@ -42,7 +42,7 @@ struct SVGAnimatedPropertySynchronizer<true> {
- if (old && value.isNull())
- attributeData->removeAttribute(old->name(), ownerElement);
- else if (!old && !value.isNull())
- - attributeData->addAttribute(Attribute::create(attrName, value), ownerElement);
- + attributeData->addAttribute(Attribute(attrName, value), ownerElement);
- else if (old && !value.isNull())
- old->setValue(value);
- }
- diff --git a/Source/WebCore/xml/XMLErrors.cpp b/Source/WebCore/xml/XMLErrors.cpp
- index 515772e..3851135 100644
- --- a/Source/WebCore/xml/XMLErrors.cpp
- +++ b/Source/WebCore/xml/XMLErrors.cpp
- @@ -91,18 +91,18 @@ static inline PassRefPtr<Element> createXHTMLParserErrorHeader(Document* doc, co
- {
- RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), true);
- - OwnPtr<AttributeVector> reportAttributes = AttributeVector::create();
- - reportAttributes->append(Attribute::create(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
- - reportElement->parserSetAttributes(reportAttributes.release(), FragmentScriptingNotAllowed);
- + AttributeVector reportAttributes;
- + reportAttributes.append(Attribute(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
- + reportElement->parserSetAttributes(reportAttributes, FragmentScriptingNotAllowed);
- RefPtr<Element> h3 = doc->createElement(h3Tag, true);
- reportElement->parserAddChild(h3.get());
- h3->parserAddChild(doc->createTextNode("This page contains the following errors:"));
- RefPtr<Element> fixed = doc->createElement(divTag, true);
- - OwnPtr<AttributeVector> fixedAttributes = AttributeVector::create();
- - fixedAttributes->append(Attribute::create(styleAttr, "font-family:monospace;font-size:12px"));
- - fixed->parserSetAttributes(fixedAttributes.release(), FragmentScriptingNotAllowed);
- + AttributeVector fixedAttributes;
- + fixedAttributes.append(Attribute(styleAttr, "font-family:monospace;font-size:12px"));
- + fixed->parserSetAttributes(fixedAttributes, FragmentScriptingNotAllowed);
- reportElement->parserAddChild(fixed.get());
- fixed->parserAddChild(doc->createTextNode(errorMessages));
- @@ -158,10 +158,10 @@ void XMLErrors::insertErrorMessageBlock()
- #if ENABLE(XSLT)
- if (m_document->transformSourceDocument()) {
- - OwnPtr<AttributeVector> attributes = AttributeVector::create();
- - attributes->append(Attribute::create(styleAttr, "white-space: normal"));
- + AttributeVector attributes;
- + attributes.append(Attribute(styleAttr, "white-space: normal"));
- RefPtr<Element> paragraph = m_document->createElement(pTag, true);
- - paragraph->parserSetAttributes(attributes.release(), FragmentScriptingNotAllowed);
- + paragraph->parserSetAttributes(attributes, FragmentScriptingNotAllowed);
- paragraph->parserAddChild(m_document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."));
- reportElement->parserAddChild(paragraph.release());
- }
- diff --git a/Source/WebCore/xml/XPathNodeSet.cpp b/Source/WebCore/xml/XPathNodeSet.cpp
- index f4e4d9a..a18b5df 100644
- --- a/Source/WebCore/xml/XPathNodeSet.cpp
- +++ b/Source/WebCore/xml/XPathNodeSet.cpp
- @@ -219,9 +219,9 @@ void NodeSet::traversalSort() const
- unsigned attributeCount = element->attributeCount();
- for (unsigned i = 0; i < attributeCount; ++i) {
- - Attr* attribute = element->attributeItem(i)->attr();
- - if (attribute && nodes.contains(attribute))
- - sortedNodes.append(attribute);
- + Attr* attr = element->attributeData()->getAttr(element, element->attributeItem(i)->name());
- + if (attr && nodes.contains(attr))
- + sortedNodes.append(attr);
- }
- }
- diff --git a/Source/WebCore/xml/XPathStep.cpp b/Source/WebCore/xml/XPathStep.cpp
- index ff7e685..c7f736d 100644
- --- a/Source/WebCore/xml/XPathStep.cpp
- +++ b/Source/WebCore/xml/XPathStep.cpp
- @@ -346,7 +346,7 @@ void Step::nodesInAxis(Node* context, NodeSet& nodes) const
- return;
- for (unsigned i = 0; i < contextElement->attributeCount(); ++i) {
- - RefPtr<Attr> attr = contextElement->attributeItem(i)->createAttrIfNeeded(static_cast<Element*>(context));
- + RefPtr<Attr> attr = contextElement->attributeData()->getOrCreateAttr(contextElement, contextElement->attributeItem(i)->name());
- if (nodeMatches(attr.get(), AttributeAxis, m_nodeTest))
- nodes.append(attr.release());
- }
- diff --git a/Source/WebCore/xml/parser/MarkupTokenBase.h b/Source/WebCore/xml/parser/MarkupTokenBase.h
- index 9644f40..1c96a4e 100644
- --- a/Source/WebCore/xml/parser/MarkupTokenBase.h
- +++ b/Source/WebCore/xml/parser/MarkupTokenBase.h
- @@ -28,7 +28,6 @@
- #define MarkupTokenBase_h
- #include "ElementAttributeData.h"
- -#include <wtf/PassOwnPtr.h>
- #include <wtf/Vector.h>
- #ifndef NDEBUG
- @@ -410,7 +409,7 @@ public:
- }
- }
- - AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr)
- + AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, const AttributeVector& attributes = AttributeVector())
- : m_type(type)
- , m_name(name)
- , m_externalCharacters(0)
- @@ -442,21 +441,19 @@ public:
- Attribute* getAttributeItem(const QualifiedName& attributeName)
- {
- ASSERT(usesAttributes());
- - if (!m_attributes)
- - return 0;
- - return m_attributes->getAttributeItem(attributeName);
- + return m_attributes.getAttributeItem(attributeName);
- }
- - AttributeVector* attributes() const
- + AttributeVector& attributes()
- {
- ASSERT(usesAttributes());
- - return m_attributes.get();
- + return m_attributes;
- }
- - PassOwnPtr<AttributeVector> takeAttributes()
- + const AttributeVector& attributes() const
- {
- ASSERT(usesAttributes());
- - return m_attributes.release();
- + return m_attributes;
- }
- const typename Token::DataVector& characters() const
- @@ -517,7 +514,7 @@ protected:
- // For StartTag and EndTag
- bool m_selfClosing;
- - OwnPtr<AttributeVector> m_attributes;
- + AttributeVector m_attributes;
- };
- template<typename Token>
- @@ -527,8 +524,8 @@ inline void AtomicMarkupTokenBase<Token>::initializeAttributes(const typename To
- if (!size)
- return;
- - m_attributes = AttributeVector::create();
- - m_attributes->reserveInitialCapacity(size);
- + m_attributes.clear();
- + m_attributes.reserveInitialCapacity(size);
- for (size_t i = 0; i < size; ++i) {
- const typename Token::Attribute& attribute = attributes[i];
- if (attribute.m_name.isEmpty())
- @@ -542,7 +539,7 @@ inline void AtomicMarkupTokenBase<Token>::initializeAttributes(const typename To
- ASSERT(attribute.m_valueRange.m_end);
- AtomicString value(attribute.m_value.data(), attribute.m_value.size());
- - m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value));
- + m_attributes.insertAttribute(Attribute(nameForAttribute(attribute), value));
- }
- }
- diff --git a/Source/WebCore/xml/parser/XMLToken.h b/Source/WebCore/xml/parser/XMLToken.h
- index 1ed16ca..6e14a11 100644
- --- a/Source/WebCore/xml/parser/XMLToken.h
- +++ b/Source/WebCore/xml/parser/XMLToken.h
- @@ -431,7 +431,7 @@ public:
- }
- }
- - AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr)
- + AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, const AttributeVector& attributes = AttributeVector())
- : AtomicMarkupTokenBase<XMLToken>(type, name, attributes)
- {
- }
- diff --git a/Source/WebCore/xml/parser/XMLTreeBuilder.cpp b/Source/WebCore/xml/parser/XMLTreeBuilder.cpp
- index 81793ed..e783bd2 100644
- --- a/Source/WebCore/xml/parser/XMLTreeBuilder.cpp
- +++ b/Source/WebCore/xml/parser/XMLTreeBuilder.cpp
- @@ -298,11 +298,8 @@ void XMLTreeBuilder::processEntity(const AtomicXMLToken& token)
- void XMLTreeBuilder::processNamespaces(const AtomicXMLToken& token, NodeStackItem& stackItem)
- {
- - if (!token.attributes())
- - return;
- -
- - for (size_t i = 0; i < token.attributes()->size(); ++i) {
- - Attribute* attribute = token.attributes()->attributeItem(i);
- + for (unsigned i = 0; i < token.attributes().size(); ++i) {
- + Attribute* attribute = token.attributes().attributeItem(i);
- if (attribute->name().prefix() == xmlnsAtom)
- stackItem.setNamespaceURI(attribute->name().localName(), attribute->value());
- else if (attribute->name() == xmlnsAtom)
- @@ -312,11 +309,8 @@ void XMLTreeBuilder::processNamespaces(const AtomicXMLToken& token, NodeStackIte
- void XMLTreeBuilder::processAttributes(const AtomicXMLToken& token, NodeStackItem& stackItem, PassRefPtr<Element> newElement)
- {
- - if (!token.attributes())
- - return;
- -
- - for (size_t i = 0; i < token.attributes()->size(); ++i) {
- - Attribute* attribute = token.attributes()->attributeItem(i);
- + for (unsigned i = 0; i < token.attributes().size(); ++i) {
- + Attribute* attribute = token.attributes().attributeItem(i);
- ExceptionCode ec = 0;
- if (attribute->name().prefix() == xmlnsAtom)
- newElement->setAttributeNS(XMLNSNames::xmlnsNamespaceURI, "xmlns:" + attribute->name().localName(), attribute->value(), ec);
Add Comment
Please, Sign In to add comment