diff options
author | Steve Block <steveblock@google.com> | 2010-02-02 14:57:50 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-04 15:06:55 +0000 |
commit | d0825bca7fe65beaee391d30da42e937db621564 (patch) | |
tree | 7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /WebCore/dom/NamedAttrMap.h | |
parent | 3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff) | |
download | external_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2 |
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'WebCore/dom/NamedAttrMap.h')
-rw-r--r-- | WebCore/dom/NamedAttrMap.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/WebCore/dom/NamedAttrMap.h b/WebCore/dom/NamedAttrMap.h index 759900b..d5136b5 100644 --- a/WebCore/dom/NamedAttrMap.h +++ b/WebCore/dom/NamedAttrMap.h @@ -103,12 +103,45 @@ private: void detachAttributesFromElement(); void detachFromElement(); Attribute* getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const; + Attribute* getAttributeItemSlowCase(const String& name, bool shouldIgnoreAttributeCase) const; Element* m_element; Vector<RefPtr<Attribute> > m_attributes; AtomicString m_id; }; +inline Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) const +{ + unsigned len = length(); + for (unsigned i = 0; i < len; ++i) { + if (m_attributes[i]->name().matches(name)) + return m_attributes[i].get(); + } + return 0; +} + +// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller +// can tune the behaviour (hasAttribute is case sensitive whereas getAttribute is not). +inline Attribute* NamedNodeMap::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const +{ + unsigned len = length(); + bool doSlowCheck = shouldIgnoreAttributeCase; + + // 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()) + return m_attributes[i].get(); + } else + doSlowCheck = true; + } + + if (doSlowCheck) + return getAttributeItemSlowCase(name, shouldIgnoreAttributeCase); + return 0; +} + } //namespace #undef id |