<!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>[166369] 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/166369">166369</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2014-03-27 13:49:27 -0700 (Thu, 27 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove some unnecessary branches from LiveNodeList traversal
https://bugs.webkit.org/show_bug.cgi?id=130854

Reviewed by Andreas Kling.

Compile different traversal code paths for all NodeList subclasses.

* dom/ClassNodeList.cpp:
(WebCore::ClassNodeList::ClassNodeList):
(WebCore::ClassNodeList::~ClassNodeList):
(WebCore::ClassNodeList::nodeMatches): Deleted.
* dom/ClassNodeList.h:
(WebCore::ClassNodeList::nodeMatches):
(WebCore::ClassNodeList::nodeMatchesInlined): Deleted.
        
    Remove separate nodeMatchesInlined functions. 
    We now rely on exact types and marking classes final.

* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::LiveNodeList):
(WebCore::LiveNodeList::~LiveNodeList):
(WebCore::LiveNodeList::namedItem):
(WebCore::LiveNodeList::rootNode): Deleted.
(WebCore::isMatchingElement): Deleted.
(WebCore::firstMatchingElement): Deleted.
(WebCore::lastMatchingElement): Deleted.
(WebCore::nextMatchingElement): Deleted.
(WebCore::previousMatchingElement): Deleted.
(WebCore::traverseMatchingElementsForward): Deleted.
(WebCore::traverseMatchingElementsBackward): Deleted.
(WebCore::LiveNodeList::collectionFirst): Deleted.
(WebCore::LiveNodeList::collectionLast): Deleted.
(WebCore::LiveNodeList::collectionTraverseForward): Deleted.
(WebCore::LiveNodeList::collectionTraverseBackward): Deleted.
(WebCore::LiveNodeList::length): Deleted.
(WebCore::LiveNodeList::item): Deleted.
(WebCore::LiveNodeList::memoryCost): Deleted.
(WebCore::LiveNodeList::invalidateCache): Deleted.
* dom/LiveNodeList.h:
(WebCore::LiveNodeList::invalidateCacheForAttribute):
(WebCore::CachedLiveNodeList::collectionCanTraverseBackward):
(WebCore::LiveNodeList::rootNode):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::CachedLiveNodeList):
        
    Add CachedLiveNodeList&lt;NodeListType&gt; utility type that interfaces with CollectionIndexCache.
    It is the base class for all concrete LiveNodeLists.

(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::~CachedLiveNodeList):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionFirst):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionLast):
(WebCore::nextMatchingElement):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionTraverseForward):
(WebCore::previousMatchingElement):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionTraverseBackward):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::willValidateIndexCache):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::invalidateCache):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::length):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::item):
(WebCore::CachedLiveNodeList&lt;NodeListType&gt;::memoryCost):
        
    Templated code moves to header.

(WebCore::LiveNodeList::LiveNodeList): Deleted.
(WebCore::LiveNodeList::~LiveNodeList): Deleted.
(WebCore::LiveNodeList::invalidateCache): Deleted.
(WebCore::LiveNodeList::collectionCanTraverseBackward): Deleted.
(WebCore::LiveNodeList::willValidateIndexCache): Deleted.
* dom/NameNodeList.cpp:
(WebCore::NameNodeList::NameNodeList):
* dom/NameNodeList.h:
* dom/Node.cpp:
(WebCore::Document::invalidateNodeListAndCollectionCaches):
(WebCore::NodeListsNodeData::invalidateCaches):
* dom/TagNodeList.cpp:
(WebCore::TagNodeList::TagNodeList):
(WebCore::HTMLTagNodeList::HTMLTagNodeList):
(WebCore::HTMLTagNodeList::~HTMLTagNodeList):
(WebCore::TagNodeList::nodeMatches): Deleted.
(WebCore::HTMLTagNodeList::nodeMatches): Deleted.
* dom/TagNodeList.h:
(WebCore::TagNodeList::nodeMatches):
(WebCore::HTMLTagNodeList::nodeMatches):
(WebCore::TagNodeList::create): Deleted.
(WebCore::HTMLTagNodeList::nodeMatchesInlined): Deleted.
* html/LabelsNodeList.cpp:
(WebCore::LabelsNodeList::LabelsNodeList):
* html/LabelsNodeList.h:
* html/RadioNodeList.cpp:
(WebCore::RadioNodeList::RadioNodeList):
* html/RadioNodeList.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomClassNodeListcpp">trunk/Source/WebCore/dom/ClassNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCoredomClassNodeListh">trunk/Source/WebCore/dom/ClassNodeList.h</a></li>
<li><a href="#trunkSourceWebCoredomLiveNodeListcpp">trunk/Source/WebCore/dom/LiveNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCoredomLiveNodeListh">trunk/Source/WebCore/dom/LiveNodeList.h</a></li>
<li><a href="#trunkSourceWebCoredomNameNodeListcpp">trunk/Source/WebCore/dom/NameNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCoredomNameNodeListh">trunk/Source/WebCore/dom/NameNodeList.h</a></li>
<li><a href="#trunkSourceWebCoredomNodecpp">trunk/Source/WebCore/dom/Node.cpp</a></li>
<li><a href="#trunkSourceWebCoredomTagNodeListcpp">trunk/Source/WebCore/dom/TagNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCoredomTagNodeListh">trunk/Source/WebCore/dom/TagNodeList.h</a></li>
<li><a href="#trunkSourceWebCorehtmlLabelsNodeListcpp">trunk/Source/WebCore/html/LabelsNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlLabelsNodeListh">trunk/Source/WebCore/html/LabelsNodeList.h</a></li>
<li><a href="#trunkSourceWebCorehtmlRadioNodeListcpp">trunk/Source/WebCore/html/RadioNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlRadioNodeListh">trunk/Source/WebCore/html/RadioNodeList.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/ChangeLog        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -1,3 +1,96 @@
</span><ins>+2014-03-27  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Remove some unnecessary branches from LiveNodeList traversal
+        https://bugs.webkit.org/show_bug.cgi?id=130854
+
+        Reviewed by Andreas Kling.
+
+        Compile different traversal code paths for all NodeList subclasses.
+
+        * dom/ClassNodeList.cpp:
+        (WebCore::ClassNodeList::ClassNodeList):
+        (WebCore::ClassNodeList::~ClassNodeList):
+        (WebCore::ClassNodeList::nodeMatches): Deleted.
+        * dom/ClassNodeList.h:
+        (WebCore::ClassNodeList::nodeMatches):
+        (WebCore::ClassNodeList::nodeMatchesInlined): Deleted.
+        
+            Remove separate nodeMatchesInlined functions. 
+            We now rely on exact types and marking classes final.
+
+        * dom/LiveNodeList.cpp:
+        (WebCore::LiveNodeList::LiveNodeList):
+        (WebCore::LiveNodeList::~LiveNodeList):
+        (WebCore::LiveNodeList::namedItem):
+        (WebCore::LiveNodeList::rootNode): Deleted.
+        (WebCore::isMatchingElement): Deleted.
+        (WebCore::firstMatchingElement): Deleted.
+        (WebCore::lastMatchingElement): Deleted.
+        (WebCore::nextMatchingElement): Deleted.
+        (WebCore::previousMatchingElement): Deleted.
+        (WebCore::traverseMatchingElementsForward): Deleted.
+        (WebCore::traverseMatchingElementsBackward): Deleted.
+        (WebCore::LiveNodeList::collectionFirst): Deleted.
+        (WebCore::LiveNodeList::collectionLast): Deleted.
+        (WebCore::LiveNodeList::collectionTraverseForward): Deleted.
+        (WebCore::LiveNodeList::collectionTraverseBackward): Deleted.
+        (WebCore::LiveNodeList::length): Deleted.
+        (WebCore::LiveNodeList::item): Deleted.
+        (WebCore::LiveNodeList::memoryCost): Deleted.
+        (WebCore::LiveNodeList::invalidateCache): Deleted.
+        * dom/LiveNodeList.h:
+        (WebCore::LiveNodeList::invalidateCacheForAttribute):
+        (WebCore::CachedLiveNodeList::collectionCanTraverseBackward):
+        (WebCore::LiveNodeList::rootNode):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::CachedLiveNodeList):
+        
+            Add CachedLiveNodeList&lt;NodeListType&gt; utility type that interfaces with CollectionIndexCache.
+            It is the base class for all concrete LiveNodeLists.
+
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::~CachedLiveNodeList):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionFirst):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionLast):
+        (WebCore::nextMatchingElement):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionTraverseForward):
+        (WebCore::previousMatchingElement):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::collectionTraverseBackward):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::willValidateIndexCache):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::invalidateCache):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::length):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::item):
+        (WebCore::CachedLiveNodeList&lt;NodeListType&gt;::memoryCost):
+        
+            Templated code moves to header.
+
+        (WebCore::LiveNodeList::LiveNodeList): Deleted.
+        (WebCore::LiveNodeList::~LiveNodeList): Deleted.
+        (WebCore::LiveNodeList::invalidateCache): Deleted.
+        (WebCore::LiveNodeList::collectionCanTraverseBackward): Deleted.
+        (WebCore::LiveNodeList::willValidateIndexCache): Deleted.
+        * dom/NameNodeList.cpp:
+        (WebCore::NameNodeList::NameNodeList):
+        * dom/NameNodeList.h:
+        * dom/Node.cpp:
+        (WebCore::Document::invalidateNodeListAndCollectionCaches):
+        (WebCore::NodeListsNodeData::invalidateCaches):
+        * dom/TagNodeList.cpp:
+        (WebCore::TagNodeList::TagNodeList):
+        (WebCore::HTMLTagNodeList::HTMLTagNodeList):
+        (WebCore::HTMLTagNodeList::~HTMLTagNodeList):
+        (WebCore::TagNodeList::nodeMatches): Deleted.
+        (WebCore::HTMLTagNodeList::nodeMatches): Deleted.
+        * dom/TagNodeList.h:
+        (WebCore::TagNodeList::nodeMatches):
+        (WebCore::HTMLTagNodeList::nodeMatches):
+        (WebCore::TagNodeList::create): Deleted.
+        (WebCore::HTMLTagNodeList::nodeMatchesInlined): Deleted.
+        * html/LabelsNodeList.cpp:
+        (WebCore::LabelsNodeList::LabelsNodeList):
+        * html/LabelsNodeList.h:
+        * html/RadioNodeList.cpp:
+        (WebCore::RadioNodeList::RadioNodeList):
+        * html/RadioNodeList.h:
+
</ins><span class="cx"> 2014-03-27  Adenilson Cavalcanti  &lt;cavalcantii@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove comment from Filter.h
</span></span></pre></div>
<a id="trunkSourceWebCoredomClassNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ClassNodeList.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ClassNodeList.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/ClassNodeList.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> ClassNodeList::ClassNodeList(ContainerNode&amp; rootNode, const String&amp; classNames)
</span><del>-    : LiveNodeList(rootNode, Type::ClassNodeListType, InvalidateOnClassAttrChange)
</del><ins>+    : CachedLiveNodeList(rootNode, Type::ClassNodeListType, InvalidateOnClassAttrChange)
</ins><span class="cx">     , m_classNames(classNames, document().inQuirksMode())
</span><span class="cx">     , m_originalClassNames(classNames)
</span><span class="cx"> {
</span><span class="lines">@@ -45,11 +45,6 @@
</span><span class="cx"> ClassNodeList::~ClassNodeList()
</span><span class="cx"> {
</span><span class="cx">     ownerNode().nodeLists()-&gt;removeCacheWithName(this, m_originalClassNames);
</span><del>-} 
-
-bool ClassNodeList::nodeMatches(Element* testNode) const
-{
-    return nodeMatchesInlined(testNode);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomClassNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ClassNodeList.h (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ClassNodeList.h        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/ClassNodeList.h        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class ClassNodeList : public LiveNodeList {
</del><ins>+class ClassNodeList final : public CachedLiveNodeList&lt;ClassNodeList&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;ClassNodeList&gt; create(ContainerNode&amp; rootNode, const String&amp; classNames)
</span><span class="cx">     {
</span><span class="lines">@@ -46,28 +46,26 @@
</span><span class="cx"> 
</span><span class="cx">     virtual ~ClassNodeList();
</span><span class="cx"> 
</span><del>-    bool nodeMatchesInlined(Element*) const;
</del><ins>+    virtual bool nodeMatches(Element*) const override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     ClassNodeList(ContainerNode&amp; rootNode, const String&amp; classNames);
</span><span class="cx"> 
</span><del>-    virtual bool nodeMatches(Element*) const override;
-
</del><span class="cx">     SpaceSplitString m_classNames;
</span><span class="cx">     String m_originalClassNames;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool ClassNodeList::nodeMatchesInlined(Element* testNode) const
</del><ins>+inline bool ClassNodeList::nodeMatches(Element* element) const
</ins><span class="cx"> {
</span><del>-    if (!testNode-&gt;hasClass())
</del><ins>+    if (!element-&gt;hasClass())
</ins><span class="cx">         return false;
</span><span class="cx">     if (!m_classNames.size())
</span><span class="cx">         return false;
</span><span class="cx">     // FIXME: DOM4 allows getElementsByClassName to return non StyledElement.
</span><span class="cx">     // https://bugs.webkit.org/show_bug.cgi?id=94718
</span><del>-    if (!testNode-&gt;isStyledElement())
</del><ins>+    if (!element-&gt;isStyledElement())
</ins><span class="cx">         return false;
</span><del>-    return testNode-&gt;classNames().containsAll(m_classNames);
</del><ins>+    return element-&gt;classNames().containsAll(m_classNames);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomLiveNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LiveNodeList.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -31,155 +31,22 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-ContainerNode&amp; LiveNodeList::rootNode() const
</del><ins>+LiveNodeList::LiveNodeList(ContainerNode&amp; ownerNode, Type type, NodeListInvalidationType invalidationType, NodeListRootType rootType)
+    : m_ownerNode(ownerNode)
+    , m_rootType(rootType)
+    , m_invalidationType(invalidationType)
+    , m_type(static_cast&lt;unsigned&gt;(type))
</ins><span class="cx"> {
</span><del>-    if (isRootedAtDocument() &amp;&amp; ownerNode().inDocument())
-        return ownerNode().document();
-
-    return ownerNode();
</del><ins>+    ASSERT(m_rootType == static_cast&lt;unsigned&gt;(rootType));
+    ASSERT(m_invalidationType == static_cast&lt;unsigned&gt;(invalidationType));
+    ASSERT(m_type == static_cast&lt;unsigned&gt;(type));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;class NodeListType&gt;
-inline bool isMatchingElement(const NodeListType*, Element*);
-
-template &lt;&gt; inline bool isMatchingElement(const LiveNodeList* nodeList, Element* element)
</del><ins>+LiveNodeList::~LiveNodeList()
</ins><span class="cx"> {
</span><del>-    return nodeList-&gt;nodeMatches(element);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;&gt; inline bool isMatchingElement(const HTMLTagNodeList* nodeList, Element* element)
-{
-    return nodeList-&gt;nodeMatchesInlined(element);
-}
</del><span class="cx"> 
</span><del>-template &lt;&gt; inline bool isMatchingElement(const ClassNodeList* nodeList, Element* element)
-{
-    return nodeList-&gt;nodeMatchesInlined(element);
-}
-
-template &lt;class NodeListType&gt;
-inline Element* firstMatchingElement(const NodeListType* nodeList, ContainerNode&amp; root)
-{
-    Element* element = ElementTraversal::firstWithin(&amp;root);
-    while (element &amp;&amp; !isMatchingElement(nodeList, element))
-        element = ElementTraversal::next(element, &amp;root);
-    return element;
-}
-
-template &lt;class NodeListType&gt;
-inline Element* lastMatchingElement(const NodeListType* nodeList, ContainerNode&amp; root)
-{
-    Element* element = ElementTraversal::lastWithin(&amp;root);
-    while (element &amp;&amp; !isMatchingElement(nodeList, element))
-        element = ElementTraversal::previous(element, &amp;root);
-    return element;
-}
-
-template &lt;class NodeListType&gt;
-inline Element* nextMatchingElement(const NodeListType* nodeList, Element* current, ContainerNode&amp; root)
-{
-    do {
-        current = ElementTraversal::next(current, &amp;root);
-    } while (current &amp;&amp; !isMatchingElement(nodeList, current));
-    return current;
-}
-
-template &lt;class NodeListType&gt;
-inline Element* previousMatchingElement(const NodeListType* nodeList, Element* current, ContainerNode&amp; root)
-{
-    do {
-        current = ElementTraversal::previous(current, &amp;root);
-    } while (current &amp;&amp; !isMatchingElement(nodeList, current));
-    return current;
-}
-
-template &lt;class NodeListType&gt;
-inline Element* traverseMatchingElementsForward(const NodeListType* nodeList, Element&amp; current, unsigned count, unsigned&amp; traversedCount, ContainerNode&amp; root)
-{
-    Element* element = &amp;current;
-    for (traversedCount = 0; traversedCount &lt; count; ++traversedCount) {
-        element = nextMatchingElement(nodeList, element, root);
-        if (!element)
-            return nullptr;
-    }
-    return element;
-}
-
-template &lt;class NodeListType&gt;
-inline Element* traverseMatchingElementsBackward(const NodeListType* nodeList, Element&amp; current, unsigned count, ContainerNode&amp; root)
-{
-    Element* element = &amp;current;
-    for (; count; --count) {
-        element = previousMatchingElement(nodeList, element, root);
-        if (!element)
-            return nullptr;
-    }
-    return element;
-}
-
-Element* LiveNodeList::collectionFirst() const
-{
-    auto&amp; root = rootNode();
-    if (type() == Type::HTMLTagNodeListType)
-        return firstMatchingElement(static_cast&lt;const HTMLTagNodeList*&gt;(this), root);
-    if (type() == Type::ClassNodeListType)
-        return firstMatchingElement(static_cast&lt;const ClassNodeList*&gt;(this), root);
-    return firstMatchingElement(static_cast&lt;const LiveNodeList*&gt;(this), root);
-}
-
-Element* LiveNodeList::collectionLast() const
-{
-    auto&amp; root = rootNode();
-    if (type() == Type::HTMLTagNodeListType)
-        return lastMatchingElement(static_cast&lt;const HTMLTagNodeList*&gt;(this), root);
-    if (type() == Type::ClassNodeListType)
-        return lastMatchingElement(static_cast&lt;const ClassNodeList*&gt;(this), root);
-    return lastMatchingElement(static_cast&lt;const LiveNodeList*&gt;(this), root);
-}
-
-Element* LiveNodeList::collectionTraverseForward(Element&amp; current, unsigned count, unsigned&amp; traversedCount) const
-{
-    auto&amp; root = rootNode();
-    if (type() == Type::HTMLTagNodeListType)
-        return traverseMatchingElementsForward(static_cast&lt;const HTMLTagNodeList*&gt;(this), current, count, traversedCount, root);
-    if (type() == Type::ClassNodeListType)
-        return traverseMatchingElementsForward(static_cast&lt;const ClassNodeList*&gt;(this), current, count, traversedCount, root);
-    return traverseMatchingElementsForward(static_cast&lt;const LiveNodeList*&gt;(this), current, count, traversedCount, root);
-}
-
-Element* LiveNodeList::collectionTraverseBackward(Element&amp; current, unsigned count) const
-{
-    auto&amp; root = rootNode();
-    if (type() == Type::HTMLTagNodeListType)
-        return traverseMatchingElementsBackward(static_cast&lt;const HTMLTagNodeList*&gt;(this), current, count, root);
-    if (type() == Type::ClassNodeListType)
-        return traverseMatchingElementsBackward(static_cast&lt;const ClassNodeList*&gt;(this), current, count, root);
-    return traverseMatchingElementsBackward(static_cast&lt;const LiveNodeList*&gt;(this), current, count, root);
-}
-
-unsigned LiveNodeList::length() const
-{
-    return m_indexCache.nodeCount(*this);
-}
-
-Node* LiveNodeList::item(unsigned offset) const
-{
-    return m_indexCache.nodeAt(*this, offset);
-}
-
-size_t LiveNodeList::memoryCost() const
-{
-    return m_indexCache.memoryCost();
-}
-
-void LiveNodeList::invalidateCache(Document&amp; document) const
-{
-    if (!m_indexCache.hasValidCache())
-        return;
-    document.unregisterNodeList(const_cast&lt;LiveNodeList&amp;&gt;(*this));
-    m_indexCache.invalidate();
-}
-
</del><span class="cx"> Node* LiveNodeList::namedItem(const AtomicString&amp; elementId) const
</span><span class="cx"> {
</span><span class="cx">     // FIXME: Why doesn't this look into the name attribute like HTMLCollection::namedItem does?
</span><span class="lines">@@ -190,7 +57,7 @@
</span><span class="cx">         if (element &amp;&amp; nodeMatches(element) &amp;&amp; element-&gt;isDescendantOf(&amp;rootNode))
</span><span class="cx">             return element;
</span><span class="cx">         if (!element)
</span><del>-            return 0;
</del><ins>+            return nullptr;
</ins><span class="cx">         // In the case of multiple nodes with the same name, just fall through.
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -205,7 +72,7 @@
</span><span class="cx">             return node;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomLiveNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LiveNodeList.h (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LiveNodeList.h        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/LiveNodeList.h        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;CollectionIndexCache.h&quot;
</span><span class="cx"> #include &quot;CollectionType.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><ins>+#include &quot;ElementTraversal.h&quot;
</ins><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;NodeList.h&quot;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="lines">@@ -54,49 +55,23 @@
</span><span class="cx">         LabelsNodeListType,
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    LiveNodeList(ContainerNode&amp; ownerNode, Type type, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
-        : m_ownerNode(ownerNode)
-        , m_rootType(rootType)
-        , m_invalidationType(invalidationType)
-        , m_type(static_cast&lt;unsigned&gt;(type))
-    {
-        ASSERT(m_rootType == static_cast&lt;unsigned&gt;(rootType));
-        ASSERT(m_invalidationType == static_cast&lt;unsigned&gt;(invalidationType));
-        ASSERT(m_type == static_cast&lt;unsigned&gt;(type));
-    }
</del><ins>+    LiveNodeList(ContainerNode&amp; ownerNode, Type, NodeListInvalidationType, NodeListRootType);
</ins><span class="cx">     virtual Node* namedItem(const AtomicString&amp;) const override final;
</span><span class="cx">     virtual bool nodeMatches(Element*) const = 0;
</span><span class="cx"> 
</span><del>-    virtual ~LiveNodeList()
-    {
-        if (m_indexCache.hasValidCache())
-            document().unregisterNodeList(*this);
-    }
</del><ins>+    virtual ~LiveNodeList();
</ins><span class="cx"> 
</span><del>-    // DOM API
-    virtual unsigned length() const override final;
-    virtual Node* item(unsigned offset) const override final;
-    virtual size_t memoryCost() const override;
-
</del><span class="cx">     ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; }
</span><span class="cx">     ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast&lt;NodeListInvalidationType&gt;(m_invalidationType); }
</span><span class="cx">     ALWAYS_INLINE Type type() const { return static_cast&lt;Type&gt;(m_type); }
</span><span class="cx">     ContainerNode&amp; ownerNode() const { return const_cast&lt;ContainerNode&amp;&gt;(m_ownerNode.get()); }
</span><del>-    ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const
</del><ins>+    ALWAYS_INLINE void invalidateCacheForAttribute(const QualifiedName* attrName) const
</ins><span class="cx">     {
</span><span class="cx">         if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *attrName))
</span><span class="cx">             invalidateCache(document());
</span><span class="cx">     }
</span><del>-    void invalidateCache(Document&amp;) const;
</del><ins>+    virtual void invalidateCache(Document&amp;) const = 0;
</ins><span class="cx"> 
</span><del>-    // For CollectionIndexCache
-    Element* collectionFirst() const;
-    Element* collectionLast() const;
-    Element* collectionTraverseForward(Element&amp;, unsigned count, unsigned&amp; traversedCount) const;
-    Element* collectionTraverseBackward(Element&amp;, unsigned count) const;
-    bool collectionCanTraverseBackward() const { return true; }
-    void willValidateIndexCache() const { document().registerNodeList(const_cast&lt;LiveNodeList&amp;&gt;(*this)); }
-
</del><span class="cx"> protected:
</span><span class="cx">     Document&amp; document() const { return m_ownerNode-&gt;document(); }
</span><span class="cx">     ContainerNode&amp; rootNode() const;
</span><span class="lines">@@ -110,13 +85,37 @@
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;ContainerNode&gt; m_ownerNode;
</span><span class="cx"> 
</span><del>-    mutable CollectionIndexCache&lt;LiveNodeList, Element&gt; m_indexCache;
-
</del><span class="cx">     const unsigned m_rootType : 1;
</span><span class="cx">     const unsigned m_invalidationType : 4;
</span><span class="cx">     const unsigned m_type : 3;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template &lt;class NodeListType&gt;
+class CachedLiveNodeList : public LiveNodeList {
+public:
+    virtual ~CachedLiveNodeList();
+
+    virtual unsigned length() const override final;
+    virtual Node* item(unsigned offset) const override final;
+
+    // For CollectionIndexCache
+    Element* collectionFirst() const;
+    Element* collectionLast() const;
+    Element* collectionTraverseForward(Element&amp;, unsigned count, unsigned&amp; traversedCount) const;
+    Element* collectionTraverseBackward(Element&amp;, unsigned count) const;
+    bool collectionCanTraverseBackward() const { return true; }
+    void willValidateIndexCache() const;
+
+    virtual void invalidateCache(Document&amp;) const;
+    virtual size_t memoryCost() const override;
+
+protected:
+    CachedLiveNodeList(ContainerNode&amp; rootNode, Type, NodeListInvalidationType, NodeListRootType = NodeListIsRootedAtNode);
+
+private:
+    mutable CollectionIndexCache&lt;NodeListType, Element&gt; m_indexCache;
+};
+
</ins><span class="cx"> ALWAYS_INLINE bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType type, const QualifiedName&amp; attrName)
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span><span class="lines">@@ -141,6 +140,123 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline ContainerNode&amp; LiveNodeList::rootNode() const
+{
+    if (isRootedAtDocument() &amp;&amp; ownerNode().inDocument())
+        return ownerNode().document();
+
+    return ownerNode();
+}
+
+template &lt;class NodeListType&gt;
+CachedLiveNodeList&lt;NodeListType&gt;::CachedLiveNodeList(ContainerNode&amp; ownerNode, Type type, NodeListInvalidationType invalidationType, NodeListRootType rootType)
+    : LiveNodeList(ownerNode, type, invalidationType, rootType)
+{
+}
+
+template &lt;class NodeListType&gt;
+CachedLiveNodeList&lt;NodeListType&gt;::~CachedLiveNodeList()
+{
+    if (m_indexCache.hasValidCache())
+        document().unregisterNodeList(*this);
+}
+
+template &lt;class NodeListType&gt;
+Element* CachedLiveNodeList&lt;NodeListType&gt;::collectionFirst() const
+{
+    auto&amp; root = rootNode();
+    Element* element = ElementTraversal::firstWithin(&amp;root);
+    while (element &amp;&amp; !static_cast&lt;const NodeListType*&gt;(this)-&gt;nodeMatches(element))
+        element = ElementTraversal::next(element, &amp;root);
+    return element;
+}
+
+template &lt;class NodeListType&gt;
+Element* CachedLiveNodeList&lt;NodeListType&gt;::collectionLast() const
+{
+    auto&amp; root = rootNode();
+    Element* element = ElementTraversal::lastWithin(&amp;root);
+    while (element &amp;&amp; !static_cast&lt;const NodeListType*&gt;(this)-&gt;nodeMatches(element))
+        element = ElementTraversal::previous(element, &amp;root);
+    return element;
+}
+
+template &lt;class NodeListType&gt;
+inline Element* nextMatchingElement(const NodeListType* nodeList, Element* current, ContainerNode&amp; root)
+{
+    do {
+        current = ElementTraversal::next(current, &amp;root);
+    } while (current &amp;&amp; !static_cast&lt;const NodeListType*&gt;(nodeList)-&gt;nodeMatches(current));
+    return current;
+}
+
+template &lt;class NodeListType&gt;
+Element* CachedLiveNodeList&lt;NodeListType&gt;::collectionTraverseForward(Element&amp; current, unsigned count, unsigned&amp; traversedCount) const
+{
+    auto&amp; root = rootNode();
+    Element* element = &amp;current;
+    for (traversedCount = 0; traversedCount &lt; count; ++traversedCount) {
+        element = nextMatchingElement(static_cast&lt;const NodeListType*&gt;(this), element, root);
+        if (!element)
+            return nullptr;
+    }
+    return element;
+}
+
+template &lt;class NodeListType&gt;
+inline Element* previousMatchingElement(const NodeListType* nodeList, Element* current, ContainerNode&amp; root)
+{
+    do {
+        current = ElementTraversal::previous(current, &amp;root);
+    } while (current &amp;&amp; !nodeList-&gt;nodeMatches(current));
+    return current;
+}
+
+template &lt;class NodeListType&gt;
+Element* CachedLiveNodeList&lt;NodeListType&gt;::collectionTraverseBackward(Element&amp; current, unsigned count) const
+{
+    auto&amp; root = rootNode();
+    Element* element = &amp;current;
+    for (; count; --count) {
+        element = previousMatchingElement(static_cast&lt;const NodeListType*&gt;(this), element, root);
+        if (!element)
+            return nullptr;
+    }
+    return element;
+}
+template &lt;class NodeListType&gt;
+void CachedLiveNodeList&lt;NodeListType&gt;::willValidateIndexCache() const
+{
+    document().registerNodeList(const_cast&lt;NodeListType&amp;&gt;(static_cast&lt;const NodeListType&amp;&gt;(*this)));
+}
+
+template &lt;class NodeListType&gt;
+void CachedLiveNodeList&lt;NodeListType&gt;::invalidateCache(Document&amp; document) const
+{
+    if (!m_indexCache.hasValidCache())
+        return;
+    document.unregisterNodeList(const_cast&lt;NodeListType&amp;&gt;(static_cast&lt;const NodeListType&amp;&gt;(*this)));
+    m_indexCache.invalidate();
+}
+
+template &lt;class NodeListType&gt;
+unsigned CachedLiveNodeList&lt;NodeListType&gt;::length() const
+{
+    return m_indexCache.nodeCount(static_cast&lt;const NodeListType&amp;&gt;(*this));
+}
+
+template &lt;class NodeListType&gt;
+Node* CachedLiveNodeList&lt;NodeListType&gt;::item(unsigned offset) const
+{
+    return m_indexCache.nodeAt(static_cast&lt;const NodeListType&amp;&gt;(*this), offset);
+}
+
+template &lt;class NodeListType&gt;
+size_t CachedLiveNodeList&lt;NodeListType&gt;::memoryCost() const
+{
+    return m_indexCache.memoryCost();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // LiveNodeList_h
</span></span></pre></div>
<a id="trunkSourceWebCoredomNameNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/NameNodeList.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/NameNodeList.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/NameNodeList.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><span class="cx"> NameNodeList::NameNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; name)
</span><del>-    : LiveNodeList(rootNode, Type::NameNodeListType, InvalidateOnNameAttrChange)
</del><ins>+    : CachedLiveNodeList(rootNode, Type::NameNodeListType, InvalidateOnNameAttrChange)
</ins><span class="cx">     , m_name(name)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomNameNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/NameNodeList.h (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/NameNodeList.h        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/NameNodeList.h        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> // NodeList which lists all Nodes in a Element with a given &quot;name&quot; attribute
</span><del>-class NameNodeList : public LiveNodeList {
</del><ins>+class NameNodeList final : public CachedLiveNodeList&lt;NameNodeList&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;NameNodeList&gt; create(ContainerNode&amp; rootNode, Type type, const AtomicString&amp; name)
</span><span class="cx">     {
</span><span class="lines">@@ -41,11 +41,11 @@
</span><span class="cx"> 
</span><span class="cx">     virtual ~NameNodeList();
</span><span class="cx"> 
</span><ins>+    virtual bool nodeMatches(Element*) const override;
+
</ins><span class="cx"> private:
</span><span class="cx">     NameNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; name);
</span><span class="cx"> 
</span><del>-    virtual bool nodeMatches(Element*) const override;
-
</del><span class="cx">     AtomicString m_name;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/Node.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -726,7 +726,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     HashSet&lt;LiveNodeList*&gt; lists = std::move(m_listsInvalidatedAtDocument);
</span><span class="cx">     for (auto* list : lists)
</span><del>-        list-&gt;invalidateCache(attrName);
</del><ins>+        list-&gt;invalidateCacheForAttribute(attrName);
</ins><span class="cx">     HashSet&lt;HTMLCollection*&gt; collections = std::move(m_collectionsInvalidatedAtDocument);
</span><span class="cx">     for (auto* collection : collections)
</span><span class="cx">         collection-&gt;invalidateCache(attrName);
</span><span class="lines">@@ -1685,10 +1685,10 @@
</span><span class="cx"> void NodeListsNodeData::invalidateCaches(const QualifiedName* attrName)
</span><span class="cx"> {
</span><span class="cx">     for (auto&amp; atomicName : m_atomicNameCaches)
</span><del>-        atomicName.value-&gt;invalidateCache(attrName);
</del><ins>+        atomicName.value-&gt;invalidateCacheForAttribute(attrName);
</ins><span class="cx"> 
</span><span class="cx">     for (auto&amp; name : m_nameCaches)
</span><del>-        name.value-&gt;invalidateCache(attrName);
</del><ins>+        name.value-&gt;invalidateCacheForAttribute(attrName);
</ins><span class="cx"> 
</span><span class="cx">     for (auto&amp; collection : m_cachedCollections)
</span><span class="cx">         collection.value-&gt;invalidateCache(attrName);
</span><span class="lines">@@ -1697,7 +1697,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; tagNodeList : m_tagNodeListCacheNS)
</span><del>-        tagNodeList.value-&gt;invalidateCache(nullptr);
</del><ins>+        tagNodeList.value-&gt;invalidateCacheForAttribute(nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Node::getSubresourceURLs(ListHashSet&lt;URL&gt;&amp; urls) const
</span></span></pre></div>
<a id="trunkSourceWebCoredomTagNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/TagNodeList.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/TagNodeList.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/TagNodeList.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -28,8 +28,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-TagNodeList::TagNodeList(ContainerNode&amp; rootNode, Type type, const AtomicString&amp; namespaceURI, const AtomicString&amp; localName)
-    : LiveNodeList(rootNode, type, DoNotInvalidateOnAttributeChanges)
</del><ins>+TagNodeList::TagNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; namespaceURI, const AtomicString&amp; localName)
+    : CachedLiveNodeList(rootNode, Type::TagNodeListType, DoNotInvalidateOnAttributeChanges)
</ins><span class="cx">     , m_namespaceURI(namespaceURI)
</span><span class="cx">     , m_localName(localName)
</span><span class="cx"> {
</span><span class="lines">@@ -44,24 +44,16 @@
</span><span class="cx">         ownerNode().nodeLists()-&gt;removeCacheWithQualifiedName(this, m_namespaceURI, m_localName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TagNodeList::nodeMatches(Element* testNode) const
-{
-    // Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagnamens
-    if (m_localName != starAtom &amp;&amp; m_localName != testNode-&gt;localName())
-        return false;
-
-    return m_namespaceURI == starAtom || m_namespaceURI == testNode-&gt;namespaceURI();
-}
-
</del><span class="cx"> HTMLTagNodeList::HTMLTagNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; localName)
</span><del>-    : TagNodeList(rootNode, Type::HTMLTagNodeListType, starAtom, localName)
</del><ins>+    : CachedLiveNodeList(rootNode, Type::HTMLTagNodeListType, DoNotInvalidateOnAttributeChanges)
+    , m_localName(localName)
</ins><span class="cx">     , m_loweredLocalName(localName.lower())
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLTagNodeList::nodeMatches(Element* testNode) const
</del><ins>+HTMLTagNodeList::~HTMLTagNodeList()
</ins><span class="cx"> {
</span><del>-    return nodeMatchesInlined(testNode);
</del><ins>+    ownerNode().nodeLists()-&gt;removeCacheWithAtomicName(this, m_localName);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomTagNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/TagNodeList.h (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/TagNodeList.h        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/dom/TagNodeList.h        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -31,32 +31,41 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> // NodeList that limits to a particular tag.
</span><del>-class TagNodeList : public LiveNodeList {
</del><ins>+class TagNodeList final : public CachedLiveNodeList&lt;TagNodeList&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;TagNodeList&gt; create(ContainerNode&amp; rootNode, const AtomicString&amp; namespaceURI, const AtomicString&amp; localName)
</span><span class="cx">     {
</span><span class="cx">         ASSERT(namespaceURI != starAtom);
</span><del>-        return adoptRef(new TagNodeList(rootNode, Type::TagNodeListType, namespaceURI, localName));
</del><ins>+        return adoptRef(new TagNodeList(rootNode, namespaceURI, localName));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static PassRefPtr&lt;TagNodeList&gt; create(ContainerNode&amp; rootNode, Type type, const AtomicString&amp; localName)
</span><span class="cx">     {
</span><span class="cx">         ASSERT_UNUSED(type, type == Type::TagNodeListType);
</span><del>-        return adoptRef(new TagNodeList(rootNode, Type::TagNodeListType, starAtom, localName));
</del><ins>+        return adoptRef(new TagNodeList(rootNode, starAtom, localName));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     virtual ~TagNodeList();
</span><span class="cx"> 
</span><ins>+    virtual bool nodeMatches(Element*) const override;
+
</ins><span class="cx"> protected:
</span><del>-    TagNodeList(ContainerNode&amp; rootNode, Type, const AtomicString&amp; namespaceURI, const AtomicString&amp; localName);
</del><ins>+    TagNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; namespaceURI, const AtomicString&amp; localName);
</ins><span class="cx"> 
</span><del>-    virtual bool nodeMatches(Element*) const override;
-
</del><span class="cx">     AtomicString m_namespaceURI;
</span><span class="cx">     AtomicString m_localName;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class HTMLTagNodeList : public TagNodeList {
</del><ins>+inline bool TagNodeList::nodeMatches(Element* element) const
+{
+    // Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagnamens
+    if (m_localName != starAtom &amp;&amp; m_localName != element-&gt;localName())
+        return false;
+
+    return m_namespaceURI == starAtom || m_namespaceURI == element-&gt;namespaceURI();
+}
+
+class HTMLTagNodeList final : public CachedLiveNodeList&lt;HTMLTagNodeList&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;HTMLTagNodeList&gt; create(ContainerNode&amp; rootNode, Type type, const AtomicString&amp; localName)
</span><span class="cx">     {
</span><span class="lines">@@ -64,26 +73,24 @@
</span><span class="cx">         return adoptRef(new HTMLTagNodeList(rootNode, localName));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool nodeMatchesInlined(Element*) const;
</del><ins>+    virtual ~HTMLTagNodeList();
</ins><span class="cx"> 
</span><ins>+    virtual bool nodeMatches(Element*) const override;
+
</ins><span class="cx"> private:
</span><span class="cx">     HTMLTagNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; localName);
</span><span class="cx"> 
</span><del>-    virtual bool nodeMatches(Element*) const override;
-
</del><ins>+    AtomicString m_localName;
</ins><span class="cx">     AtomicString m_loweredLocalName;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool HTMLTagNodeList::nodeMatchesInlined(Element* testNode) const
</del><ins>+inline bool HTMLTagNodeList::nodeMatches(Element* element) const
</ins><span class="cx"> {
</span><span class="cx">     // Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagname
</span><del>-    if (m_localName != starAtom) {
-        const AtomicString&amp; localName = testNode-&gt;isHTMLElement() ? m_loweredLocalName : m_localName;
-        if (localName != testNode-&gt;localName())
-            return false;
-    }
-    ASSERT(m_namespaceURI == starAtom);
-    return true;
</del><ins>+    if (m_localName == starAtom)
+        return true;
+    const AtomicString&amp; localName = element-&gt;isHTMLElement() ? m_loweredLocalName : m_localName;
+    return localName == element-&gt;localName();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlLabelsNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/LabelsNodeList.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/LabelsNodeList.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/html/LabelsNodeList.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><span class="cx"> LabelsNodeList::LabelsNodeList(LabelableElement&amp; forNode)
</span><del>-    : LiveNodeList(forNode, Type::LabelsNodeListType, InvalidateOnForAttrChange, NodeListIsRootedAtDocument)
</del><ins>+    : CachedLiveNodeList(forNode, Type::LabelsNodeListType, InvalidateOnForAttrChange, NodeListIsRootedAtDocument)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlLabelsNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/LabelsNodeList.h (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/LabelsNodeList.h        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/html/LabelsNodeList.h        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class LabelsNodeList final : public LiveNodeList {
</del><ins>+class LabelsNodeList final : public CachedLiveNodeList&lt;LabelsNodeList&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRef&lt;LabelsNodeList&gt; create(LabelableElement&amp; forNode, Type type, const AtomicString&amp;)
</span><span class="cx">     {
</span><span class="lines">@@ -39,10 +39,10 @@
</span><span class="cx">     }
</span><span class="cx">     ~LabelsNodeList();
</span><span class="cx"> 
</span><del>-protected:
</del><ins>+    virtual bool nodeMatches(Element*) const override;
+
+private:
</ins><span class="cx">     explicit LabelsNodeList(LabelableElement&amp; forNode);
</span><del>-
-    virtual bool nodeMatches(Element*) const override;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlRadioNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/RadioNodeList.cpp        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><span class="cx"> RadioNodeList::RadioNodeList(ContainerNode&amp; rootNode, const AtomicString&amp; name)
</span><del>-    : LiveNodeList(rootNode, Type::RadioNodeListType, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
</del><ins>+    : CachedLiveNodeList(rootNode, Type::RadioNodeListType, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
</ins><span class="cx">     , m_name(name)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlRadioNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/RadioNodeList.h (166368 => 166369)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/RadioNodeList.h        2014-03-27 20:07:36 UTC (rev 166368)
+++ trunk/Source/WebCore/html/RadioNodeList.h        2014-03-27 20:49:27 UTC (rev 166369)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class RadioNodeList : public LiveNodeList {
</del><ins>+class RadioNodeList final : public CachedLiveNodeList&lt;RadioNodeList&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;RadioNodeList&gt; create(ContainerNode&amp; rootNode, Type type, const AtomicString&amp; name)
</span><span class="cx">     {
</span><span class="lines">@@ -45,7 +45,6 @@
</span><span class="cx">     String value() const;
</span><span class="cx">     void setValue(const String&amp;);
</span><span class="cx"> 
</span><del>-protected:
</del><span class="cx">     virtual bool nodeMatches(Element*) const override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre>
</div>
</div>

</body>
</html>