Use Element's hasName/hasID flags to avoid unnecessary work when looking up name/id attributes.
<http://webkit.org/b/77845>
Reviewed by Anders Carlsson.
Have Element::getIdAttribute() check the hasID() flag before looking up the attribute.
Add an Element::getNameAttribute() to do the same thing with hasName().
Update call sites to make use of these helpers whenever possible.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::accessibilityDescription):
* dom/DocumentOrderedMap.cpp:
(WebCore::keyMatchesId):
* dom/Element.h:
(Element):
(WebCore::Element::getIdAttribute):
(WebCore):
(WebCore::Element::getNameAttribute):
* dom/NameNodeList.cpp:
(WebCore::NameNodeList::nodeMatches):
* dom/StaticHashSetNodeList.cpp:
(WebCore::StaticHashSetNodeList::itemWithName):
* dom/StaticNodeList.cpp:
(WebCore::StaticNodeList::itemWithName):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::name):
* html/HTMLAppletElement.cpp:
(WebCore::HTMLAppletElement::createRenderer):
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::checkForNameMatch):
(WebCore::HTMLCollection::updateNameCache):
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::updateWidget):
* html/HTMLFormCollection.cpp:
(WebCore::HTMLFormCollection::updateNameCache):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::formControlName):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::name):
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::setNameAndOpenURL):
* html/HTMLMetaElement.cpp:
(WebCore::HTMLMetaElement::name):
* html/HTMLNameCollection.cpp:
(WebCore::HTMLNameCollection::itemAfter):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::updateWidget):
(WebCore::HTMLObjectElement::updateDocNamedItem):
(WebCore::HTMLObjectElement::containsJavaApplet):
(WebCore::HTMLObjectElement::formControlName):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::buildObjectForFrame):
* page/Frame.cpp:
(WebCore::Frame::matchLabelsAgainstElement):
* rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::RenderSVGResourceContainer):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107477 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/html/HTMLCollection.cpp b/Source/WebCore/html/HTMLCollection.cpp
index e6f2eac0..7d06308f 100644
--- a/Source/WebCore/html/HTMLCollection.cpp
+++ b/Source/WebCore/html/HTMLCollection.cpp
@@ -254,7 +254,7 @@
if (m_type == DocAll && !nameShouldBeVisibleInDocumentAll(e))
return false;
- return e->getAttribute(nameAttr) == name && e->getIdAttribute() != name;
+ return e->getNameAttribute() == name && e->getIdAttribute() != name;
}
Node* HTMLCollection::namedItem(const AtomicString& name) const
@@ -294,7 +294,7 @@
continue;
HTMLElement* e = toHTMLElement(element);
const AtomicString& idAttrVal = e->getIdAttribute();
- const AtomicString& nameAttrVal = e->getAttribute(nameAttr);
+ const AtomicString& nameAttrVal = e->getNameAttribute();
if (!idAttrVal.isEmpty())
append(m_cache.idCache, idAttrVal, e);
if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && (m_type != DocAll || nameShouldBeVisibleInDocumentAll(e)))