<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[165045] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/165045">165045</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2014-03-04 02:28:38 -0800 (Tue, 04 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove Document::idAttributeName().
&lt;https://webkit.org/b/129663&gt;

Reviewed by Ryosuke &quot;DYEB&quot; Niwa.

This abstraction is not actually used and causes unnecessary indirection
in some pretty hot code paths.

Replace it with hard-coded HTMLNames::idAttr instead which is a compile
time constant pointer. We can revisit this in the future if we wish to
implement support for custom id attributes.

* dom/Attr.cpp:
(WebCore::Attr::isId):
* dom/Document.cpp:
(WebCore::Document::Document):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::attributeChanged):
(WebCore::Element::willModifyAttribute):
* dom/Element.h:
(WebCore::Element::getIdAttribute):
(WebCore::Element::getNameAttribute):
(WebCore::Element::setIdAttribute):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::parseAttribute):
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::parseAttribute):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::parseAttribute):
* svg/SVGElement.cpp:
(WebCore::SVGElement::attributeChanged):
(WebCore::SVGElement::isKnownAttribute):
(WebCore::SVGElement::svgAttributeChanged):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomAttrcpp">trunk/Source/WebCore/dom/Attr.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFrameElementBasecpp">trunk/Source/WebCore/html/HTMLFrameElementBase.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMapElementcpp">trunk/Source/WebCore/html/HTMLMapElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGElementcpp">trunk/Source/WebCore/svg/SVGElement.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/ChangeLog        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2014-03-04  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Remove Document::idAttributeName().
+        &lt;https://webkit.org/b/129663&gt;
+
+        Reviewed by Ryosuke &quot;DYEB&quot; Niwa.
+
+        This abstraction is not actually used and causes unnecessary indirection
+        in some pretty hot code paths.
+
+        Replace it with hard-coded HTMLNames::idAttr instead which is a compile
+        time constant pointer. We can revisit this in the future if we wish to
+        implement support for custom id attributes.
+
+        * dom/Attr.cpp:
+        (WebCore::Attr::isId):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        * dom/Document.h:
+        * dom/Element.cpp:
+        (WebCore::Element::attributeChanged):
+        (WebCore::Element::willModifyAttribute):
+        * dom/Element.h:
+        (WebCore::Element::getIdAttribute):
+        (WebCore::Element::getNameAttribute):
+        (WebCore::Element::setIdAttribute):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::parseAttribute):
+        * html/HTMLFrameElementBase.cpp:
+        (WebCore::HTMLFrameElementBase::parseAttribute):
+        * html/HTMLMapElement.cpp:
+        (WebCore::HTMLMapElement::parseAttribute):
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::attributeChanged):
+        (WebCore::SVGElement::isKnownAttribute):
+        (WebCore::SVGElement::svgAttributeChanged):
+
</ins><span class="cx"> 2014-03-04  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r164856): Use after free in WebCore::QualifiedName::operator== / WebCore::StyledElement::attributeChanged
</span></span></pre></div>
<a id="trunkSourceWebCoredomAttrcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Attr.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Attr.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/dom/Attr.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -182,7 +182,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool Attr::isId() const
</span><span class="cx"> {
</span><del>-    return qualifiedName().matches(document().idAttributeName());
</del><ins>+    return qualifiedName().matches(HTMLNames::idAttr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CSSStyleDeclaration* Attr::style()
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/dom/Document.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -468,7 +468,6 @@
</span><span class="cx">     , m_isSrcdocDocument(false)
</span><span class="cx">     , m_eventQueue(*this)
</span><span class="cx">     , m_weakFactory(this)
</span><del>-    , m_idAttributeName(idAttr)
</del><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     , m_areKeysEnabledInFullScreen(0)
</span><span class="cx">     , m_fullScreenRenderer(nullptr)
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/dom/Document.h        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -1108,8 +1108,6 @@
</span><span class="cx">     void removeMediaCanStartListener(MediaCanStartListener*);
</span><span class="cx">     MediaCanStartListener* takeAnyMediaCanStartListener();
</span><span class="cx"> 
</span><del>-    const QualifiedName&amp; idAttributeName() const { return m_idAttributeName; }
-    
</del><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     bool webkitIsFullScreen() const { return m_fullScreenElement.get(); }
</span><span class="cx">     bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenElement.get() &amp;&amp; m_areKeysEnabledInFullScreen; }
</span><span class="lines">@@ -1559,8 +1557,6 @@
</span><span class="cx"> 
</span><span class="cx">     HashSet&lt;MediaCanStartListener*&gt; m_mediaCanStartListeners;
</span><span class="cx"> 
</span><del>-    QualifiedName m_idAttributeName;
-
</del><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     bool m_areKeysEnabledInFullScreen;
</span><span class="cx">     RefPtr&lt;Element&gt; m_fullScreenElement;
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/dom/Element.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -1078,7 +1078,7 @@
</span><span class="cx">     bool testShouldInvalidateStyle = inRenderedDocument() &amp;&amp; styleResolver &amp;&amp; styleChangeType() &lt; FullStyleChange;
</span><span class="cx">     bool shouldInvalidateStyle = false;
</span><span class="cx"> 
</span><del>-    if (isIdAttributeName(name)) {
</del><ins>+    if (name == HTMLNames::idAttr) {
</ins><span class="cx">         AtomicString oldId = elementData()-&gt;idForStyleResolution();
</span><span class="cx">         AtomicString newId = makeIdForStyleResolution(newValue, document().inQuirksMode());
</span><span class="cx">         if (newId != oldId) {
</span><span class="lines">@@ -2745,7 +2745,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Element::willModifyAttribute(const QualifiedName&amp; name, const AtomicString&amp; oldValue, const AtomicString&amp; newValue)
</span><span class="cx"> {
</span><del>-    if (isIdAttributeName(name))
</del><ins>+    if (name == HTMLNames::idAttr)
</ins><span class="cx">         updateId(oldValue, newValue);
</span><span class="cx">     else if (name == HTMLNames::nameAttr)
</span><span class="cx">         updateName(oldValue, newValue);
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/dom/Element.h        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -179,7 +179,6 @@
</span><span class="cx">     static bool parseAttributeName(QualifiedName&amp;, const AtomicString&amp; namespaceURI, const AtomicString&amp; qualifiedName, ExceptionCode&amp;);
</span><span class="cx">     void setAttributeNS(const AtomicString&amp; namespaceURI, const AtomicString&amp; qualifiedName, const AtomicString&amp; value, ExceptionCode&amp;);
</span><span class="cx"> 
</span><del>-    bool isIdAttributeName(const QualifiedName&amp;) const;
</del><span class="cx">     const AtomicString&amp; getIdAttribute() const;
</span><span class="cx">     void setIdAttribute(const AtomicString&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -742,28 +741,23 @@
</span><span class="cx">     return elementData()-&gt;idForStyleResolution();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool Element::isIdAttributeName(const QualifiedName&amp; attributeName) const
-{
-    // FIXME: This check is probably not correct for the case where the document has an id attribute
-    // with a non-null namespace, because it will return false, a false negative, if the prefixes
-    // don't match but the local name and namespace both do. However, since this has been like this
-    // for a while and the code paths may be hot, we'll have to measure performance if we fix it.
-    return attributeName == document().idAttributeName();
-}
-
</del><span class="cx"> inline const AtomicString&amp; Element::getIdAttribute() const
</span><span class="cx"> {
</span><del>-    return hasID() ? fastGetAttribute(document().idAttributeName()) : nullAtom;
</del><ins>+    if (hasID())
+        return elementData()-&gt;findAttributeByName(HTMLNames::idAttr)-&gt;value();
+    return nullAtom;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline const AtomicString&amp; Element::getNameAttribute() const
</span><span class="cx"> {
</span><del>-    return hasName() ? fastGetAttribute(HTMLNames::nameAttr) : nullAtom;
</del><ins>+    if (hasName())
+        return elementData()-&gt;findAttributeByName(HTMLNames::nameAttr)-&gt;value();
+    return nullAtom;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline void Element::setIdAttribute(const AtomicString&amp; value)
</span><span class="cx"> {
</span><del>-    setAttribute(document().idAttributeName(), value);
</del><ins>+    setAttribute(HTMLNames::idAttr, value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline const SpaceSplitString&amp; Element::classNames() const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/html/HTMLElement.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -338,7 +338,7 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLElement::parseAttribute(const QualifiedName&amp; name, const AtomicString&amp; value)
</span><span class="cx"> {
</span><del>-    if (isIdAttributeName(name) || name == classAttr || name == styleAttr)
</del><ins>+    if (name == HTMLNames::idAttr || name == HTMLNames::classAttr || name == HTMLNames::styleAttr)
</ins><span class="cx">         return StyledElement::parseAttribute(name, value);
</span><span class="cx"> 
</span><span class="cx">     if (name == dirAttr)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFrameElementBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFrameElementBase.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFrameElementBase.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/html/HTMLFrameElementBase.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -94,8 +94,7 @@
</span><span class="cx">         setLocation(&quot;about:srcdoc&quot;);
</span><span class="cx">     else if (name == srcAttr &amp;&amp; !fastHasAttribute(srcdocAttr))
</span><span class="cx">         setLocation(stripLeadingAndTrailingHTMLSpaces(value));
</span><del>-    else if (isIdAttributeName(name)) {
-        // Important to call through to base for the id attribute so the hasID bit gets set.
</del><ins>+    else if (name == HTMLNames::idAttr) {
</ins><span class="cx">         HTMLFrameOwnerElement::parseAttribute(name, value);
</span><span class="cx">         m_frameName = value;
</span><span class="cx">     } else if (name == nameAttr) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMapElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMapElement.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMapElement.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/html/HTMLMapElement.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -88,8 +88,8 @@
</span><span class="cx">     // FIXME: This logic seems wrong for XML documents.
</span><span class="cx">     // Either the id or name will be used depending on the order the attributes are parsed.
</span><span class="cx"> 
</span><del>-    if (isIdAttributeName(name) || name == nameAttr) {
-        if (isIdAttributeName(name)) {
</del><ins>+    if (name == HTMLNames::idAttr || name == HTMLNames::nameAttr) {
+        if (name == HTMLNames::idAttr) {
</ins><span class="cx">             // Call base class so that hasID bit gets set.
</span><span class="cx">             HTMLElement::parseAttribute(name, value);
</span><span class="cx">             if (document().isHTMLDocument())
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGElement.cpp (165044 => 165045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGElement.cpp        2014-03-04 09:45:55 UTC (rev 165044)
+++ trunk/Source/WebCore/svg/SVGElement.cpp        2014-03-04 10:28:38 UTC (rev 165045)
</span><span class="lines">@@ -720,7 +720,7 @@
</span><span class="cx"> {
</span><span class="cx">     StyledElement::attributeChanged(name, oldValue, newValue);
</span><span class="cx"> 
</span><del>-    if (isIdAttributeName(name))
</del><ins>+    if (name == HTMLNames::idAttr)
</ins><span class="cx">         document().accessSVGExtensions()-&gt;rebuildAllElementReferencesForTarget(this);
</span><span class="cx"> 
</span><span class="cx">     // Changes to the style attribute are processed lazily (see Element::getAttribute() and related methods),
</span><span class="lines">@@ -1014,7 +1014,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool SVGElement::isKnownAttribute(const QualifiedName&amp; attrName)
</span><span class="cx"> {
</span><del>-    return isIdAttributeName(attrName);
</del><ins>+    return attrName == HTMLNames::idAttr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SVGElement::svgAttributeChanged(const QualifiedName&amp; attrName)
</span><span class="lines">@@ -1031,7 +1031,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (isIdAttributeName(attrName)) {
</del><ins>+    if (attrName == HTMLNames::idAttr) {
</ins><span class="cx">         auto renderer = this-&gt;renderer();
</span><span class="cx">         // Notify resources about id changes, this is important as we cache resources by id in SVGDocumentExtensions
</span><span class="cx">         if (renderer &amp;&amp; renderer-&gt;isSVGResourceContainer())
</span></span></pre>
</div>
</div>

</body>
</html>