<!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>[175947] 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/175947">175947</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-11-11 09:35:29 -0800 (Tue, 11 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Minor tweaks to HTMLCollection
https://bugs.webkit.org/show_bug.cgi?id=138556

Reviewed by Chris Dumez.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addRadioButtonGroupMembers):
Update for namedElements function that now returns a Vector; also use
a new style for loop to iterate it.

* bindings/js/JSHTMLAllCollectionCustom.cpp: Removed some unneeded includes.
(WebCore::namedItems): Updated name to match WebKit coding style, and also
updated to use the return value from namedItems, which now returns a Vector.
(WebCore::callHTMLAllCollection): Updated for namedItems name change.
Also removed explicit Node* type from result of namedItemWithIndex, since that
function now returns a more specific type.
(WebCore::JSHTMLAllCollection::nameGetter): Update for namedItems name change.
(WebCore::JSHTMLAllCollection::item): Ditto.
(WebCore::JSHTMLAllCollection::namedItem): Ditto.

* bindings/js/JSHTMLFormControlsCollectionCustom.cpp: Removed some unneeded includes.
(WebCore::namedItems): Updated name to match WebKit coding style, and also
updated to use the return value from namedItems, which now returns a Vector.
(WebCore::JSHTMLFormControlsCollection::nameGetter): Update for namedItems name change.
(WebCore::JSHTMLFormControlsCollection::namedItem): Ditto.

* bindings/js/JSHTMLFormElementCustom.cpp:
(WebCore::JSHTMLFormElement::nameGetter): Updated to use the return value from
namedItems, which now returns a Vector.

* html/HTMLAllCollection.cpp:
(WebCore::HTMLAllCollection::HTMLAllCollection): Marked the constructor inline,
since it's only used in one place, the create function.
(WebCore::HTMLAllCollection::~HTMLAllCollection): Deleted. No need to have an
explicit destructor since there's nothing special to implement, and includers of
the header file have everything they ened to compile the compiler-generated one.
(WebCore::HTMLAllCollection::namedItemWithIndex): Changed return type to Element.

* html/HTMLAllCollection.h: Removed unneeded explicit declaration of destructor.
Chagned return type of namedItemWithIndex to Element.

* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::rootTypeFromCollectionType): Marked this inline. Also
changed this to be a static member function so it can use the RootType enum, which
is now private to the class.
(WebCore::isMatchingHTMLElement): Marked this function static so it will get
internal linkage.
(WebCore::isMatchingElement): Ditto.
(WebCore::previousElement): Marked this function inline since it's called in only
one place. Changed argument type to a reference since it can never be null.
(WebCore::HTMLCollection::iterateForPreviousElement): Changed argument name and
also updated for above changes.
(WebCore::firstMatchingElement): Marked this function static so it will get
internal linkage.
(WebCore::nextMatchingElement): Ditto. Changed argument type to a reference
since it can never be null.
(WebCore::HTMLCollection::item): Changed return type to Element.
(WebCore::nameShouldBeVisibleInDocumentAll): Added an overload that takes an
Element. This streamlines the code below that calls it so it fits on one line.
(WebCore::firstMatchingChildElement): Marked this function static so it will get
internal linkage.
(WebCore::nextMatchingSiblingElement): Ditto. Changed argument type to a reference
since it can never be null.
(WebCore::HTMLCollection::usesCustomForwardOnlyTraversal): Moved here from the
header since, although it's marked inline, it's only used inside this file.
(WebCore::HTMLCollection::traverseForward): Restructured the code a little bit
to make the function smaller and possibly easier to read. This does add one
redundant null check, but it seems OK to do that.
(WebCore::HTMLCollection::collectionTraverseBackward): Tweaked foramtting a bit.
(WebCore::HTMLCollection::namedItem): Changed return type to Element. Tightened
the code that calls nameShouldBeVisibleInDocumentAll so it fits better on one line.
Changed code that handles m_shouldOnlyIncludeDirectChildren to use a nested if
instead of an &amp;&amp; since it makes the code a little easier to read.
(WebCore::HTMLCollection::updateNamedElementCache): Tweaked code a little bit,
using shorter variable names, and using references instead of pointers. Also removed
the call to didPopulate, since setNamedItemCache now takes care of that.
(WebCore::HTMLCollection::namedItems): Changed to return a Vector instead of
appending to an existing one. Also use reserveInitialCapacity and uncheckedAppend
for better performance. Added a FIXME, because there seems to be something wrong
here about this being non-virtual. Made other small tweaks to streamline the code.
(WebCore::HTMLCollection::customElementAfter): Moved this here from the header.
There is no reason to need to inline this.

* html/HTMLCollection.h: Removed unneeded includes. Moved function bodies out
of the class definitions so the class definitions are easier to read. Made some
functions that were formerly public or protected be private instead. Added a call
to didPopulate to setNamedItemCache so the callers don't have to do it.

* html/HTMLFormControlsCollection.cpp:
(WebCore::HTMLFormControlsCollection::namedItem): Changed return value to Element.
Tweaked coding style a little bit.
(WebCore::HTMLFormControlsCollection::updateNamedElementCache): Rearranged to
simplify a bit. Don't build the foundInputElements set when the owner is not a
form element, since we don't use the set in that case. Use shorter variable names,
and modern for loops. Also removed the call to didPopulate, since setNamedItemCache
now takes care of that.

* html/HTMLFormControlsCollection.h: Removed some uneeded forward declarations.
Updated return type for namedItem, and also made the override private.

* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::namedElements): Changed to return a Vector and updated
function name accordingly.
* html/HTMLFormElement.h: Ditto.

* html/HTMLNameCollection.h: Removed a stray blank line.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::namedItem): Changed return value to Element.
(WebCore::HTMLSelectElement::item): Ditto.
* html/HTMLSelectElement.h: Ditto.

* page/scrolling/AxisScrollSnapOffsets.cpp:
(WebCore::appendChildSnapOffsets): Rewrote loop as a for loop rather than a while
loop. Removed unwanted use of children()-&gt;collectionBegin() to get the first element
child of an HTMLElement. This function uses a mix of DOM and rendering functions that
is probably incorrect, but I did not tackle fixing that at this time.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSHTMLAllCollectionCustomcpp">trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSHTMLFormControlsCollectionCustomcpp">trunk/Source/WebCore/bindings/js/JSHTMLFormControlsCollectionCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSHTMLFormElementCustomcpp">trunk/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAllCollectioncpp">trunk/Source/WebCore/html/HTMLAllCollection.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAllCollectionh">trunk/Source/WebCore/html/HTMLAllCollection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCollectioncpp">trunk/Source/WebCore/html/HTMLCollection.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCollectionh">trunk/Source/WebCore/html/HTMLCollection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlsCollectioncpp">trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlsCollectionh">trunk/Source/WebCore/html/HTMLFormControlsCollection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormElementcpp">trunk/Source/WebCore/html/HTMLFormElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormElementh">trunk/Source/WebCore/html/HTMLFormElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLNameCollectionh">trunk/Source/WebCore/html/HTMLNameCollection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSelectElementcpp">trunk/Source/WebCore/html/HTMLSelectElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSelectElementh">trunk/Source/WebCore/html/HTMLSelectElement.h</a></li>
<li><a href="#trunkSourceWebCorepagescrollingAxisScrollSnapOffsetscpp">trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/ChangeLog        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -1,3 +1,123 @@
</span><ins>+2014-11-09  Darin Adler  &lt;darin@apple.com&gt;
+
+        Minor tweaks to HTMLCollection
+        https://bugs.webkit.org/show_bug.cgi?id=138556
+
+        Reviewed by Chris Dumez.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::addRadioButtonGroupMembers):
+        Update for namedElements function that now returns a Vector; also use
+        a new style for loop to iterate it.
+
+        * bindings/js/JSHTMLAllCollectionCustom.cpp: Removed some unneeded includes.
+        (WebCore::namedItems): Updated name to match WebKit coding style, and also
+        updated to use the return value from namedItems, which now returns a Vector.
+        (WebCore::callHTMLAllCollection): Updated for namedItems name change.
+        Also removed explicit Node* type from result of namedItemWithIndex, since that
+        function now returns a more specific type.
+        (WebCore::JSHTMLAllCollection::nameGetter): Update for namedItems name change.
+        (WebCore::JSHTMLAllCollection::item): Ditto.
+        (WebCore::JSHTMLAllCollection::namedItem): Ditto.
+
+        * bindings/js/JSHTMLFormControlsCollectionCustom.cpp: Removed some unneeded includes.
+        (WebCore::namedItems): Updated name to match WebKit coding style, and also
+        updated to use the return value from namedItems, which now returns a Vector.
+        (WebCore::JSHTMLFormControlsCollection::nameGetter): Update for namedItems name change.
+        (WebCore::JSHTMLFormControlsCollection::namedItem): Ditto.
+
+        * bindings/js/JSHTMLFormElementCustom.cpp:
+        (WebCore::JSHTMLFormElement::nameGetter): Updated to use the return value from
+        namedItems, which now returns a Vector.
+
+        * html/HTMLAllCollection.cpp:
+        (WebCore::HTMLAllCollection::HTMLAllCollection): Marked the constructor inline,
+        since it's only used in one place, the create function.
+        (WebCore::HTMLAllCollection::~HTMLAllCollection): Deleted. No need to have an
+        explicit destructor since there's nothing special to implement, and includers of
+        the header file have everything they ened to compile the compiler-generated one.
+        (WebCore::HTMLAllCollection::namedItemWithIndex): Changed return type to Element.
+
+        * html/HTMLAllCollection.h: Removed unneeded explicit declaration of destructor.
+        Chagned return type of namedItemWithIndex to Element.
+
+        * html/HTMLCollection.cpp:
+        (WebCore::HTMLCollection::rootTypeFromCollectionType): Marked this inline. Also
+        changed this to be a static member function so it can use the RootType enum, which
+        is now private to the class.
+        (WebCore::isMatchingHTMLElement): Marked this function static so it will get
+        internal linkage.
+        (WebCore::isMatchingElement): Ditto.
+        (WebCore::previousElement): Marked this function inline since it's called in only
+        one place. Changed argument type to a reference since it can never be null.
+        (WebCore::HTMLCollection::iterateForPreviousElement): Changed argument name and
+        also updated for above changes.
+        (WebCore::firstMatchingElement): Marked this function static so it will get
+        internal linkage.
+        (WebCore::nextMatchingElement): Ditto. Changed argument type to a reference
+        since it can never be null.
+        (WebCore::HTMLCollection::item): Changed return type to Element.
+        (WebCore::nameShouldBeVisibleInDocumentAll): Added an overload that takes an
+        Element. This streamlines the code below that calls it so it fits on one line.
+        (WebCore::firstMatchingChildElement): Marked this function static so it will get
+        internal linkage.
+        (WebCore::nextMatchingSiblingElement): Ditto. Changed argument type to a reference
+        since it can never be null.
+        (WebCore::HTMLCollection::usesCustomForwardOnlyTraversal): Moved here from the
+        header since, although it's marked inline, it's only used inside this file.
+        (WebCore::HTMLCollection::traverseForward): Restructured the code a little bit
+        to make the function smaller and possibly easier to read. This does add one
+        redundant null check, but it seems OK to do that.
+        (WebCore::HTMLCollection::collectionTraverseBackward): Tweaked foramtting a bit.
+        (WebCore::HTMLCollection::namedItem): Changed return type to Element. Tightened
+        the code that calls nameShouldBeVisibleInDocumentAll so it fits better on one line.
+        Changed code that handles m_shouldOnlyIncludeDirectChildren to use a nested if
+        instead of an &amp;&amp; since it makes the code a little easier to read.
+        (WebCore::HTMLCollection::updateNamedElementCache): Tweaked code a little bit,
+        using shorter variable names, and using references instead of pointers. Also removed
+        the call to didPopulate, since setNamedItemCache now takes care of that.
+        (WebCore::HTMLCollection::namedItems): Changed to return a Vector instead of
+        appending to an existing one. Also use reserveInitialCapacity and uncheckedAppend
+        for better performance. Added a FIXME, because there seems to be something wrong
+        here about this being non-virtual. Made other small tweaks to streamline the code.
+        (WebCore::HTMLCollection::customElementAfter): Moved this here from the header.
+        There is no reason to need to inline this.
+
+        * html/HTMLCollection.h: Removed unneeded includes. Moved function bodies out
+        of the class definitions so the class definitions are easier to read. Made some
+        functions that were formerly public or protected be private instead. Added a call
+        to didPopulate to setNamedItemCache so the callers don't have to do it.
+
+        * html/HTMLFormControlsCollection.cpp:
+        (WebCore::HTMLFormControlsCollection::namedItem): Changed return value to Element.
+        Tweaked coding style a little bit.
+        (WebCore::HTMLFormControlsCollection::updateNamedElementCache): Rearranged to
+        simplify a bit. Don't build the foundInputElements set when the owner is not a
+        form element, since we don't use the set in that case. Use shorter variable names,
+        and modern for loops. Also removed the call to didPopulate, since setNamedItemCache
+        now takes care of that.
+
+        * html/HTMLFormControlsCollection.h: Removed some uneeded forward declarations.
+        Updated return type for namedItem, and also made the override private.
+
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::namedElements): Changed to return a Vector and updated
+        function name accordingly.
+        * html/HTMLFormElement.h: Ditto.
+
+        * html/HTMLNameCollection.h: Removed a stray blank line.
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::namedItem): Changed return value to Element.
+        (WebCore::HTMLSelectElement::item): Ditto.
+        * html/HTMLSelectElement.h: Ditto.
+
+        * page/scrolling/AxisScrollSnapOffsets.cpp:
+        (WebCore::appendChildSnapOffsets): Rewrote loop as a for loop rather than a while
+        loop. Removed unwanted use of children()-&gt;collectionBegin() to get the first element
+        child of an HTMLElement. This function uses a mix of DOM and rendering functions that
+        is probably incorrect, but I did not tackle fixing that at this time.
+
</ins><span class="cx"> 2014-11-11  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Mac] WebCore includes unused cursor image resources
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -949,10 +949,7 @@
</span><span class="cx">     HTMLInputElement&amp; input = downcast&lt;HTMLInputElement&gt;(*node);
</span><span class="cx">     // if there's a form, then this is easy
</span><span class="cx">     if (input.form()) {
</span><del>-        Vector&lt;Ref&lt;Element&gt;&gt; formElements;
-        input.form()-&gt;getNamedElements(input.name(), formElements);
-        
-        for (auto&amp; associateElement : formElements) {
</del><ins>+        for (auto&amp; associateElement : input.form()-&gt;namedElements(input.name())) {
</ins><span class="cx">             if (AccessibilityObject* object = axObjectCache()-&gt;getOrCreate(&amp;associateElement.get()))
</span><span class="cx">                 linkedUIElements.append(object);        
</span><span class="cx">         } 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSHTMLAllCollectionCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -27,24 +27,18 @@
</span><span class="cx"> #include &quot;JSHTMLAllCollection.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;HTMLAllCollection.h&quot;
</span><del>-#include &quot;JSDOMBinding.h&quot;
</del><span class="cx"> #include &quot;JSNode.h&quot;
</span><span class="cx"> #include &quot;JSNodeList.h&quot;
</span><del>-#include &quot;Node.h&quot;
</del><span class="cx"> #include &quot;StaticNodeList.h&quot;
</span><span class="cx"> #include &lt;runtime/IdentifierInlines.h&gt;
</span><del>-#include &lt;runtime/JSCJSValue.h&gt;
-#include &lt;wtf/Vector.h&gt;
-#include &lt;wtf/text/AtomicString.h&gt;
</del><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static JSValue getNamedItems(ExecState* exec, JSHTMLAllCollection* collection, PropertyName propertyName)
</del><ins>+static JSValue namedItems(ExecState* exec, JSHTMLAllCollection* collection, PropertyName propertyName)
</ins><span class="cx"> {
</span><del>-    Vector&lt;Ref&lt;Element&gt;&gt; namedItems;
-    collection-&gt;impl().namedItems(propertyNameToAtomicString(propertyName), namedItems);
</del><ins>+    Vector&lt;Ref&lt;Element&gt;&gt; namedItems = collection-&gt;impl().namedItems(propertyNameToAtomicString(propertyName));
</ins><span class="cx"> 
</span><span class="cx">     if (namedItems.isEmpty())
</span><span class="cx">         return jsUndefined();
</span><span class="lines">@@ -76,15 +70,15 @@
</span><span class="cx">             return JSValue::encode(toJS(exec, jsCollection-&gt;globalObject(), collection.item(index)));
</span><span class="cx"> 
</span><span class="cx">         // Support for document.images('&lt;name&gt;') etc.
</span><del>-        return JSValue::encode(getNamedItems(exec, jsCollection, Identifier(exec, string)));
</del><ins>+        return JSValue::encode(namedItems(exec, jsCollection, Identifier(exec, string)));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The second arg, if set, is the index of the item we want
</span><span class="cx">     String string = exec-&gt;argument(0).toString(exec)-&gt;value(exec);
</span><span class="cx">     unsigned index = toUInt32FromStringImpl(exec-&gt;argument(1).toWTFString(exec).impl());
</span><span class="cx">     if (index != PropertyName::NotAnIndex) {
</span><del>-        if (Node* node = collection.namedItemWithIndex(string, index))
-            return JSValue::encode(toJS(exec, jsCollection-&gt;globalObject(), node));
</del><ins>+        if (auto* item = collection.namedItemWithIndex(string, index))
+            return JSValue::encode(toJS(exec, jsCollection-&gt;globalObject(), item));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="lines">@@ -104,7 +98,7 @@
</span><span class="cx"> EncodedJSValue JSHTMLAllCollection::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName)
</span><span class="cx"> {
</span><span class="cx">     JSHTMLAllCollection* thisObj = jsCast&lt;JSHTMLAllCollection*&gt;(slotBase);
</span><del>-    return JSValue::encode(getNamedItems(exec, thisObj, propertyName));
</del><ins>+    return JSValue::encode(namedItems(exec, thisObj, propertyName));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSValue JSHTMLAllCollection::item(ExecState* exec)
</span><span class="lines">@@ -112,12 +106,12 @@
</span><span class="cx">     uint32_t index = toUInt32FromStringImpl(exec-&gt;argument(0).toString(exec)-&gt;value(exec).impl());
</span><span class="cx">     if (index != PropertyName::NotAnIndex)
</span><span class="cx">         return toJS(exec, globalObject(), impl().item(index));
</span><del>-    return getNamedItems(exec, this, Identifier(exec, exec-&gt;argument(0).toString(exec)-&gt;value(exec)));
</del><ins>+    return namedItems(exec, this, Identifier(exec, exec-&gt;argument(0).toString(exec)-&gt;value(exec)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSValue JSHTMLAllCollection::namedItem(ExecState* exec)
</span><span class="cx"> {
</span><del>-    JSValue value = getNamedItems(exec, this, Identifier(exec, exec-&gt;argument(0).toString(exec)-&gt;value(exec)));
</del><ins>+    JSValue value = namedItems(exec, this, Identifier(exec, exec-&gt;argument(0).toString(exec)-&gt;value(exec)));
</ins><span class="cx">     return value.isUndefined() ? jsNull() : value;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSHTMLFormControlsCollectionCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSHTMLFormControlsCollectionCustom.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSHTMLFormControlsCollectionCustom.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/bindings/js/JSHTMLFormControlsCollectionCustom.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -18,31 +18,22 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><del>-#include &quot;HTMLFormControlsCollection.h&quot;
-
-
-#include &quot;HTMLAllCollection.h&quot;
-#include &quot;JSDOMBinding.h&quot;
-#include &quot;JSHTMLCollection.h&quot;
</del><span class="cx"> #include &quot;JSHTMLFormControlsCollection.h&quot;
</span><ins>+
+#include &quot;HTMLFormControlsCollection.h&quot;
</ins><span class="cx"> #include &quot;JSNode.h&quot;
</span><del>-#include &quot;JSNodeList.h&quot;
</del><span class="cx"> #include &quot;JSRadioNodeList.h&quot;
</span><del>-#include &quot;Node.h&quot;
</del><span class="cx"> #include &quot;RadioNodeList.h&quot;
</span><span class="cx"> #include &lt;runtime/IdentifierInlines.h&gt;
</span><del>-#include &lt;wtf/Vector.h&gt;
-#include &lt;wtf/text/AtomicString.h&gt;
</del><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static JSValue getNamedItems(ExecState* exec, JSHTMLFormControlsCollection* collection, PropertyName propertyName)
</del><ins>+static JSValue namedItems(ExecState* exec, JSHTMLFormControlsCollection* collection, PropertyName propertyName)
</ins><span class="cx"> {
</span><del>-    Vector&lt;Ref&lt;Element&gt;&gt; namedItems;
</del><span class="cx">     const AtomicString&amp; name = propertyNameToAtomicString(propertyName);
</span><del>-    collection-&gt;impl().namedItems(name, namedItems);
</del><ins>+    Vector&lt;Ref&lt;Element&gt;&gt; namedItems = collection-&gt;impl().namedItems(name);
</ins><span class="cx"> 
</span><span class="cx">     if (namedItems.isEmpty())
</span><span class="cx">         return jsUndefined();
</span><span class="lines">@@ -61,12 +52,12 @@
</span><span class="cx"> EncodedJSValue JSHTMLFormControlsCollection::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName)
</span><span class="cx"> {
</span><span class="cx">     JSHTMLFormControlsCollection* thisObj = jsCast&lt;JSHTMLFormControlsCollection*&gt;(slotBase);
</span><del>-    return JSValue::encode(getNamedItems(exec, thisObj, propertyName));
</del><ins>+    return JSValue::encode(namedItems(exec, thisObj, propertyName));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSValue JSHTMLFormControlsCollection::namedItem(ExecState* exec)
</span><span class="cx"> {
</span><del>-    JSValue value = getNamedItems(exec, this, Identifier(exec, exec-&gt;argument(0).toString(exec)-&gt;value(exec)));
</del><ins>+    JSValue value = namedItems(exec, this, Identifier(exec, exec-&gt;argument(0).toString(exec)-&gt;value(exec)));
</ins><span class="cx">     return value.isUndefined() ? jsNull() : value;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSHTMLFormElementCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -47,8 +47,7 @@
</span><span class="cx">     JSHTMLFormElement* jsForm = jsCast&lt;JSHTMLFormElement*&gt;(slotBase);
</span><span class="cx">     HTMLFormElement&amp; form = jsForm-&gt;impl();
</span><span class="cx"> 
</span><del>-    Vector&lt;Ref&lt;Element&gt;&gt; namedItems;
-    form.getNamedElements(propertyNameToAtomicString(propertyName), namedItems);
</del><ins>+    Vector&lt;Ref&lt;Element&gt;&gt; namedItems = form.namedElements(propertyNameToAtomicString(propertyName));
</ins><span class="cx">     
</span><span class="cx">     if (namedItems.isEmpty())
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAllCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAllCollection.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAllCollection.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLAllCollection.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -35,17 +35,13 @@
</span><span class="cx">     return adoptRef(*new HTMLAllCollection(document, type));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLAllCollection::HTMLAllCollection(Document&amp; document, CollectionType type)
</del><ins>+inline HTMLAllCollection::HTMLAllCollection(Document&amp; document, CollectionType type)
</ins><span class="cx">     : HTMLCollection(document, type)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLAllCollection::~HTMLAllCollection()
</del><ins>+Element* HTMLAllCollection::namedItemWithIndex(const AtomicString&amp; name, unsigned index) const
</ins><span class="cx"> {
</span><del>-}
-
-Node* HTMLAllCollection::namedItemWithIndex(const AtomicString&amp; name, unsigned index) const
-{
</del><span class="cx">     updateNamedElementCache();
</span><span class="cx">     const CollectionNamedElementCache&amp; cache = namedItemCaches();
</span><span class="cx"> 
</span><span class="lines">@@ -60,7 +56,7 @@
</span><span class="cx">             return elements-&gt;at(index);
</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="trunkSourceWebCorehtmlHTMLAllCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAllCollection.h (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAllCollection.h        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLAllCollection.h        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -33,9 +33,8 @@
</span><span class="cx"> class HTMLAllCollection final : public HTMLCollection {
</span><span class="cx"> public:
</span><span class="cx">     static PassRef&lt;HTMLAllCollection&gt; create(Document&amp;, CollectionType);
</span><del>-    virtual ~HTMLAllCollection();
</del><span class="cx"> 
</span><del>-    Node* namedItemWithIndex(const AtomicString&amp; name, unsigned index) const;
</del><ins>+    Element* namedItemWithIndex(const AtomicString&amp; name, unsigned index) const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     HTMLAllCollection(Document&amp;, CollectionType);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCollection.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static HTMLCollection::RootType rootTypeFromCollectionType(CollectionType type)
</del><ins>+inline auto HTMLCollection::rootTypeFromCollectionType(CollectionType type) -&gt; RootType
</ins><span class="cx"> {
</span><span class="cx">     switch (type) {
</span><span class="cx">     case DocImages:
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx">     return ownerNode();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool isMatchingHTMLElement(const HTMLCollection&amp; collection, HTMLElement&amp; element)
</del><ins>+static inline bool isMatchingHTMLElement(const HTMLCollection&amp; collection, HTMLElement&amp; element)
</ins><span class="cx"> {
</span><span class="cx">     switch (collection.type()) {
</span><span class="cx">     case DocImages:
</span><span class="lines">@@ -218,7 +218,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool isMatchingElement(const HTMLCollection&amp; collection, Element&amp; element)
</del><ins>+static inline bool isMatchingElement(const HTMLCollection&amp; collection, Element&amp; element)
</ins><span class="cx"> {
</span><span class="cx">     // Collection types that deal with any type of Elements, not just HTMLElements.
</span><span class="cx">     switch (collection.type()) {
</span><span class="lines">@@ -233,23 +233,23 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Element* previousElement(ContainerNode&amp; base, Element* previous, bool onlyIncludeDirectChildren)
</del><ins>+static inline Element* previousElement(ContainerNode&amp; base, Element&amp; element, bool onlyIncludeDirectChildren)
</ins><span class="cx"> {
</span><del>-    return onlyIncludeDirectChildren ? ElementTraversal::previousSibling(previous) : ElementTraversal::previous(previous, &amp;base);
</del><ins>+    return onlyIncludeDirectChildren ? ElementTraversal::previousSibling(&amp;element) : ElementTraversal::previous(&amp;element, &amp;base);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ALWAYS_INLINE Element* HTMLCollection::iterateForPreviousElement(Element* current) const
</del><ins>+ALWAYS_INLINE Element* HTMLCollection::iterateForPreviousElement(Element* element) const
</ins><span class="cx"> {
</span><span class="cx">     bool onlyIncludeDirectChildren = m_shouldOnlyIncludeDirectChildren;
</span><span class="cx">     ContainerNode&amp; rootNode = this-&gt;rootNode();
</span><del>-    for (; current; current = previousElement(rootNode, current, onlyIncludeDirectChildren)) {
-        if (isMatchingElement(*this, *current))
-            return current;
</del><ins>+    for (; element; element = previousElement(rootNode, *element, onlyIncludeDirectChildren)) {
+        if (isMatchingElement(*this, *element))
+            return element;
</ins><span class="cx">     }
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline Element* firstMatchingElement(const HTMLCollection&amp; collection, ContainerNode&amp; root)
</del><ins>+static inline Element* firstMatchingElement(const HTMLCollection&amp; collection, ContainerNode&amp; root)
</ins><span class="cx"> {
</span><span class="cx">     Element* element = ElementTraversal::firstWithin(&amp;root);
</span><span class="cx">     while (element &amp;&amp; !isMatchingElement(collection, *element))
</span><span class="lines">@@ -257,12 +257,13 @@
</span><span class="cx">     return element;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline Element* nextMatchingElement(const HTMLCollection&amp; collection, Element* current, ContainerNode&amp; root)
</del><ins>+static inline Element* nextMatchingElement(const HTMLCollection&amp; collection, Element&amp; element, ContainerNode&amp; root)
</ins><span class="cx"> {
</span><ins>+    Element* next = &amp;element;
</ins><span class="cx">     do {
</span><del>-        current = ElementTraversal::next(current, &amp;root);
-    } while (current &amp;&amp; !isMatchingElement(collection, *current));
-    return current;
</del><ins>+        next = ElementTraversal::next(next, &amp;root);
+    } while (next &amp;&amp; !isMatchingElement(collection, *next));
+    return next;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned HTMLCollection::length() const
</span><span class="lines">@@ -270,7 +271,7 @@
</span><span class="cx">     return m_indexCache.nodeCount(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* HTMLCollection::item(unsigned offset) const
</del><ins>+Element* HTMLCollection::item(unsigned offset) const
</ins><span class="cx"> {
</span><span class="cx">     return m_indexCache.nodeAt(*this, offset);
</span><span class="cx"> }
</span><span class="lines">@@ -288,22 +289,33 @@
</span><span class="cx">         || element.hasTagName(selectTag);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline Element* firstMatchingChildElement(const HTMLCollection&amp; nodeList, ContainerNode&amp; root)
</del><ins>+static inline bool nameShouldBeVisibleInDocumentAll(Element&amp; element)
</ins><span class="cx"> {
</span><ins>+    return is&lt;HTMLElement&gt;(element) &amp;&amp; nameShouldBeVisibleInDocumentAll(downcast&lt;HTMLElement&gt;(element));
+}
+
+static inline Element* firstMatchingChildElement(const HTMLCollection&amp; nodeList, ContainerNode&amp; root)
+{
</ins><span class="cx">     Element* element = ElementTraversal::firstWithin(&amp;root);
</span><span class="cx">     while (element &amp;&amp; !isMatchingElement(nodeList, *element))
</span><span class="cx">         element = ElementTraversal::nextSibling(element);
</span><span class="cx">     return element;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline Element* nextMatchingSiblingElement(const HTMLCollection&amp; nodeList, Element* current)
</del><ins>+static inline Element* nextMatchingSiblingElement(const HTMLCollection&amp; nodeList, Element&amp; element)
</ins><span class="cx"> {
</span><ins>+    Element* next = &amp;element;
</ins><span class="cx">     do {
</span><del>-        current = ElementTraversal::nextSibling(current);
-    } while (current &amp;&amp; !isMatchingElement(nodeList, *current));
-    return current;
</del><ins>+        next = ElementTraversal::nextSibling(next);
+    } while (next &amp;&amp; !isMatchingElement(nodeList, *next));
+    return next;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool HTMLCollection::usesCustomForwardOnlyTraversal() const
+{
+    return m_usesCustomForwardOnlyTraversal;
+}
+
</ins><span class="cx"> inline Element* HTMLCollection::firstElement(ContainerNode&amp; root) const
</span><span class="cx"> {
</span><span class="cx">     if (usesCustomForwardOnlyTraversal())
</span><span class="lines">@@ -317,26 +329,15 @@
</span><span class="cx"> {
</span><span class="cx">     Element* element = &amp;current;
</span><span class="cx">     if (usesCustomForwardOnlyTraversal()) {
</span><del>-        for (traversedCount = 0; traversedCount &lt; count; ++traversedCount) {
</del><ins>+        for (traversedCount = 0; element &amp;&amp; traversedCount &lt; count; ++traversedCount)
</ins><span class="cx">             element = customElementAfter(element);
</span><del>-            if (!element)
-                return nullptr;
-        }
-        return element;
</del><ins>+    } else if (m_shouldOnlyIncludeDirectChildren) {
+        for (traversedCount = 0; element &amp;&amp; traversedCount &lt; count; ++traversedCount)
+            element = nextMatchingSiblingElement(*this, *element);
+    } else {
+        for (traversedCount = 0; element &amp;&amp; traversedCount &lt; count; ++traversedCount)
+            element = nextMatchingElement(*this, *element, root);
</ins><span class="cx">     }
</span><del>-    if (m_shouldOnlyIncludeDirectChildren) {
-        for (traversedCount = 0; traversedCount &lt; count; ++traversedCount) {
-            element = nextMatchingSiblingElement(*this, element);
-            if (!element)
-                return nullptr;
-        }
-        return element;
-    }
-    for (traversedCount = 0; traversedCount &lt; count; ++traversedCount) {
-        element = nextMatchingElement(*this, element, root);
-        if (!element)
-            return nullptr;
-    }
</del><span class="cx">     return element;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -361,13 +362,13 @@
</span><span class="cx"> void HTMLCollection::collectionTraverseBackward(Element*&amp; current, unsigned count) const
</span><span class="cx"> {
</span><span class="cx">     // FIXME: This should be optimized similarly to the forward case.
</span><del>-    auto&amp; root = rootNode();
</del><span class="cx">     if (m_shouldOnlyIncludeDirectChildren) {
</span><del>-        for (; count &amp;&amp; current ; --count)
</del><ins>+        for (; count &amp;&amp; current; --count)
</ins><span class="cx">             current = iterateForPreviousElement(ElementTraversal::previousSibling(current));
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    for (; count &amp;&amp; current ; --count)
</del><ins>+    auto&amp; root = rootNode();
+    for (; count &amp;&amp; current; --count)
</ins><span class="cx">         current = iterateForPreviousElement(ElementTraversal::previous(current, &amp;root));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -388,7 +389,7 @@
</span><span class="cx">     m_namedElementCache = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* HTMLCollection::namedItem(const AtomicString&amp; name) const
</del><ins>+Element* HTMLCollection::namedItem(const AtomicString&amp; name) const
</ins><span class="cx"> {
</span><span class="cx">     // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp
</span><span class="cx">     // This method first searches for an object with a matching id
</span><span class="lines">@@ -401,23 +402,25 @@
</span><span class="cx"> 
</span><span class="cx">     ContainerNode&amp; root = rootNode();
</span><span class="cx">     if (!usesCustomForwardOnlyTraversal() &amp;&amp; root.isInTreeScope()) {
</span><ins>+        Element* candidate = nullptr;
+
</ins><span class="cx">         TreeScope&amp; treeScope = root.treeScope();
</span><del>-        Element* candidate = nullptr;
</del><span class="cx">         if (treeScope.hasElementWithId(*name.impl())) {
</span><span class="cx">             if (!treeScope.containsMultipleElementsWithId(name))
</span><span class="cx">                 candidate = treeScope.getElementById(name);
</span><span class="cx">         } else if (treeScope.hasElementWithName(*name.impl())) {
</span><span class="cx">             if (!treeScope.containsMultipleElementsWithName(name)) {
</span><span class="cx">                 candidate = treeScope.getElementByName(name);
</span><del>-                if (candidate &amp;&amp; type() == DocAll &amp;&amp; (!is&lt;HTMLElement&gt;(*candidate) || !nameShouldBeVisibleInDocumentAll(downcast&lt;HTMLElement&gt;(*candidate))))
</del><ins>+                if (candidate &amp;&amp; type() == DocAll &amp;&amp; !nameShouldBeVisibleInDocumentAll(*candidate))
</ins><span class="cx">                     candidate = nullptr;
</span><span class="cx">             }
</span><span class="cx">         } else
</span><span class="cx">             return nullptr;
</span><span class="cx"> 
</span><del>-        if (candidate &amp;&amp; isMatchingElement(*this, *candidate)
-            &amp;&amp; (m_shouldOnlyIncludeDirectChildren ? candidate-&gt;parentNode() == &amp;root : candidate-&gt;isDescendantOf(&amp;root)))
-            return candidate;
</del><ins>+        if (candidate &amp;&amp; isMatchingElement(*this, *candidate)) {
+            if (m_shouldOnlyIncludeDirectChildren ? candidate-&gt;parentNode() == &amp;root : candidate-&gt;isDescendantOf(&amp;root))
+                return candidate;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The pathological case. We need to walk the entire subtree.
</span><span class="lines">@@ -442,25 +445,22 @@
</span><span class="cx">     if (hasNamedElementCache())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-
</del><span class="cx">     auto cache = std::make_unique&lt;CollectionNamedElementCache&gt;();
</span><span class="cx"> 
</span><span class="cx">     unsigned size = m_indexCache.nodeCount(*this);
</span><del>-    for (unsigned i = 0; i &lt; size; i++) {
-        Element* element = m_indexCache.nodeAt(*this, i);
-        ASSERT(element);
-        const AtomicString&amp; idAttrVal = element-&gt;getIdAttribute();
-        if (!idAttrVal.isEmpty())
-            cache-&gt;appendIdCache(idAttrVal, element);
-        if (!is&lt;HTMLElement&gt;(*element))
</del><ins>+    for (unsigned i = 0; i &lt; size; ++i) {
+        Element&amp; element = *m_indexCache.nodeAt(*this, i);
+        const AtomicString&amp; id = element.getIdAttribute();
+        if (!id.isEmpty())
+            cache-&gt;appendToIdCache(id, element);
+        if (!is&lt;HTMLElement&gt;(element))
</ins><span class="cx">             continue;
</span><del>-        const AtomicString&amp; nameAttrVal = element-&gt;getNameAttribute();
-        if (!nameAttrVal.isEmpty() &amp;&amp; idAttrVal != nameAttrVal &amp;&amp; (type() != DocAll || nameShouldBeVisibleInDocumentAll(downcast&lt;HTMLElement&gt;(*element))))
-            cache-&gt;appendNameCache(nameAttrVal, element);
</del><ins>+        const AtomicString&amp; name = element.getNameAttribute();
+        if (!name.isEmpty() &amp;&amp; id != name &amp;&amp; (type() != DocAll || nameShouldBeVisibleInDocumentAll(downcast&lt;HTMLElement&gt;(element))))
+            cache-&gt;appendToNameCache(name, element);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    cache-&gt;didPopulate();
-    setNameItemCache(WTF::move(cache));
</del><ins>+    setNamedItemCache(WTF::move(cache));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLCollection::hasNamedItem(const AtomicString&amp; name) const
</span><span class="lines">@@ -469,23 +469,34 @@
</span><span class="cx">     return namedItem(name);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLCollection::namedItems(const AtomicString&amp; name, Vector&lt;Ref&lt;Element&gt;&gt;&amp; result) const
</del><ins>+Vector&lt;Ref&lt;Element&gt;&gt; HTMLCollection::namedItems(const AtomicString&amp; name) const
</ins><span class="cx"> {
</span><del>-    ASSERT(result.isEmpty());
</del><ins>+    // FIXME: This non-virtual function can't possibly be doing the correct thing for
+    // any derived class that overrides the virtual namedItem function.
+
+    Vector&lt;Ref&lt;Element&gt;&gt; elements;
+
</ins><span class="cx">     if (name.isEmpty())
</span><del>-        return;
</del><ins>+        return elements;
</ins><span class="cx"> 
</span><span class="cx">     updateNamedElementCache();
</span><span class="cx">     ASSERT(m_namedElementCache);
</span><span class="cx"> 
</span><del>-    const Vector&lt;Element*&gt;* idResults = m_namedElementCache-&gt;findElementsWithId(name);
-    const Vector&lt;Element*&gt;* nameResults = m_namedElementCache-&gt;findElementsWithName(name);
</del><ins>+    auto* elementsWithId = m_namedElementCache-&gt;findElementsWithId(name);
+    auto* elementsWithName = m_namedElementCache-&gt;findElementsWithName(name);
</ins><span class="cx"> 
</span><del>-    for (unsigned i = 0; idResults &amp;&amp; i &lt; idResults-&gt;size(); ++i)
-        result.append(*idResults-&gt;at(i));
</del><ins>+    elements.reserveInitialCapacity((elementsWithId ? elementsWithId-&gt;size() : 0) + (elementsWithName ? elementsWithName-&gt;size() : 0));
</ins><span class="cx"> 
</span><del>-    for (unsigned i = 0; nameResults &amp;&amp; i &lt; nameResults-&gt;size(); ++i)
-        result.append(*nameResults-&gt;at(i));
</del><ins>+    if (elementsWithId) {
+        for (auto&amp; element : *elementsWithId)
+            elements.uncheckedAppend(*element);
+    }
+    if (elementsWithName) {
+        for (auto&amp; element : *elementsWithName)
+            elements.uncheckedAppend(*element);
+    }
+
+    return elements;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;NodeList&gt; HTMLCollection::tags(const String&amp; name)
</span><span class="lines">@@ -493,4 +504,10 @@
</span><span class="cx">     return ownerNode().getElementsByTagName(name);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Element* HTMLCollection::customElementAfter(Element*) const
+{
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCollection.h (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCollection.h        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLCollection.h        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -24,17 +24,10 @@
</span><span class="cx"> #define HTMLCollection_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CollectionIndexCache.h&quot;
</span><del>-#include &quot;CollectionType.h&quot;
-#include &quot;ContainerNode.h&quot;
-#include &quot;Document.h&quot;
</del><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;LiveNodeList.h&quot;
</span><span class="cx"> #include &quot;ScriptWrappable.h&quot;
</span><del>-#include &lt;memory&gt;
-#include &lt;wtf/Forward.h&gt;
</del><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><del>-#include &lt;wtf/TypeCasts.h&gt;
-#include &lt;wtf/Vector.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -42,47 +35,26 @@
</span><span class="cx"> 
</span><span class="cx"> class CollectionNamedElementCache {
</span><span class="cx"> public:
</span><del>-#ifndef ASSERT_DISABLED
-    CollectionNamedElementCache : m_didPopulateCalled(false) { }
-#endif
</del><ins>+    const Vector&lt;Element*&gt;* findElementsWithId(const AtomicString&amp; id) const;
+    const Vector&lt;Element*&gt;* findElementsWithName(const AtomicString&amp; name) const;
</ins><span class="cx"> 
</span><del>-    const Vector&lt;Element*&gt;* findElementsWithId(const AtomicString&amp; id) const { return find(m_idToElementsMap, id); }
-    const Vector&lt;Element*&gt;* findElementsWithName(const AtomicString&amp; name) const { return find(m_nameToElementsMap, name); }
</del><ins>+    void appendToIdCache(const AtomicString&amp; id, Element&amp;);
+    void appendToNameCache(const AtomicString&amp; name, Element&amp;);
+    void didPopulate();
</ins><span class="cx"> 
</span><del>-    void appendIdCache(const AtomicString&amp; id, Element* element) { return append(m_idToElementsMap, id, element); }
-    void appendNameCache(const AtomicString&amp; name, Element* element)  { return append(m_nameToElementsMap, name, element); }
</del><ins>+    size_t memoryCost() const;
</ins><span class="cx"> 
</span><del>-    void didPopulate()
-    {
-#ifndef ASSERT_DISABLED
-        m_didPopulateCalled = true;
-#endif
-        if (size_t cost = memoryCost())
-            reportExtraMemoryCostForCollectionIndexCache(cost);
-    }
-    size_t memoryCost() const { return (m_idToElementsMap.size() + m_nameToElementsMap.size()) * sizeof(Element*); }
-
</del><span class="cx"> private:
</span><span class="cx">     typedef HashMap&lt;AtomicStringImpl*, Vector&lt;Element*&gt;&gt; StringToElementsMap;
</span><span class="cx"> 
</span><del>-    const Vector&lt;Element*&gt;* find(const StringToElementsMap&amp; map, const AtomicString&amp; key) const
-    {
-#ifndef ASSERT_DISABLED
-        ASSERT(m_didPopulateCalled);
-#endif
-        auto it = map.find(key.impl());
-        return it != map.end() ? &amp;it-&gt;value : nullptr;
-    }
</del><ins>+    const Vector&lt;Element*&gt;* find(const StringToElementsMap&amp;, const AtomicString&amp; key) const;
+    static void append(StringToElementsMap&amp;, const AtomicString&amp; key, Element&amp;);
</ins><span class="cx"> 
</span><del>-    static void append(StringToElementsMap&amp; map, const AtomicString&amp; key, Element* element)
-    {
-        map.add(key.impl(), Vector&lt;Element*&gt;()).iterator-&gt;value.append(element);
-    }
</del><ins>+    StringToElementsMap m_idMap;
+    StringToElementsMap m_nameMap;
</ins><span class="cx"> 
</span><del>-    StringToElementsMap m_idToElementsMap;
-    StringToElementsMap m_nameToElementsMap;
-#ifndef ASSERT_DISABLED
-    bool m_didPopulateCalled;
</del><ins>+#if !ASSERT_DISABLED
+    bool m_didPopulate { false };
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -93,42 +65,32 @@
</span><span class="cx"> 
</span><span class="cx">     // DOM API
</span><span class="cx">     unsigned length() const;
</span><del>-    Node* item(unsigned offset) const;
-    virtual Node* namedItem(const AtomicString&amp; name) const;
</del><ins>+    Element* item(unsigned offset) const;
+    virtual Element* namedItem(const AtomicString&amp; name) const;
</ins><span class="cx">     PassRefPtr&lt;NodeList&gt; tags(const String&amp;);
</span><span class="cx"> 
</span><span class="cx">     // Non-DOM API
</span><span class="cx">     bool hasNamedItem(const AtomicString&amp; name) const;
</span><del>-    void namedItems(const AtomicString&amp; name, Vector&lt;Ref&lt;Element&gt;&gt;&amp;) const;
-    size_t memoryCost() const { return m_indexCache.memoryCost() + (m_namedElementCache ? m_namedElementCache-&gt;memoryCost() : 0); }
</del><ins>+    Vector&lt;Ref&lt;Element&gt;&gt; namedItems(const AtomicString&amp; name) const;
+    size_t memoryCost() const;
</ins><span class="cx"> 
</span><del>-    enum RootType {
-        IsRootedAtNode,
-        IsRootedAtDocument
-    };
-    bool isRootedAtDocument() const { return m_rootType == IsRootedAtDocument; }
-    NodeListInvalidationType invalidationType() const { return static_cast&lt;NodeListInvalidationType&gt;(m_invalidationType); }
-    CollectionType type() const { return static_cast&lt;CollectionType&gt;(m_collectionType); }
-    ContainerNode&amp; ownerNode() const { return const_cast&lt;ContainerNode&amp;&gt;(m_ownerNode.get()); }
-    void invalidateCache(const QualifiedName* attrName) const
-    {
-        if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *attrName))
-            invalidateCache(document());
-        else if (hasNamedElementCache() &amp;&amp; (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr))
-            invalidateNamedElementCache(document());
-    }
</del><ins>+    bool isRootedAtDocument() const;
+    NodeListInvalidationType invalidationType() const;
+    CollectionType type() const;
+    ContainerNode&amp; ownerNode() const;
+    void invalidateCache(const QualifiedName* attributeName) const;
</ins><span class="cx">     virtual void invalidateCache(Document&amp;) const;
</span><span class="cx"> 
</span><del>-    // For CollectionIndexCache
</del><ins>+    // For CollectionIndexCache; do not use elsewhere.
</ins><span class="cx">     Element* collectionBegin() const;
</span><span class="cx">     Element* collectionLast() const;
</span><del>-    Element* collectionEnd() const { return nullptr; }
</del><ins>+    Element* collectionEnd() const;
</ins><span class="cx">     void collectionTraverseForward(Element*&amp;, unsigned count, unsigned&amp; traversedCount) const;
</span><span class="cx">     void collectionTraverseBackward(Element*&amp;, unsigned count) const;
</span><del>-    bool collectionCanTraverseBackward() const { return !m_usesCustomForwardOnlyTraversal; }
-    void willValidateIndexCache() const { document().registerCollection(const_cast&lt;HTMLCollection&amp;&gt;(*this)); }
</del><ins>+    bool collectionCanTraverseBackward() const;
+    void willValidateIndexCache() const;
</ins><span class="cx"> 
</span><del>-    bool hasNamedElementCache() const { return !!m_namedElementCache; }
</del><ins>+    bool hasNamedElementCache() const;
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     enum ElementTraversalType { NormalTraversal, CustomForwardOnlyTraversal };
</span><span class="lines">@@ -136,34 +98,25 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void updateNamedElementCache() const;
</span><span class="cx"> 
</span><del>-    Document&amp; document() const { return m_ownerNode-&gt;document(); }
</del><ins>+    void setNamedItemCache(std::unique_ptr&lt;CollectionNamedElementCache&gt;) const;
+    const CollectionNamedElementCache&amp; namedItemCaches() const;
+
+private:
+    Document&amp; document() const;
</ins><span class="cx">     ContainerNode&amp; rootNode() const;
</span><del>-    bool usesCustomForwardOnlyTraversal() const { return m_usesCustomForwardOnlyTraversal; }
</del><ins>+    bool usesCustomForwardOnlyTraversal() const;
</ins><span class="cx"> 
</span><del>-    RootType rootType() const { return static_cast&lt;RootType&gt;(m_rootType); }
</del><ins>+    Element* iterateForPreviousElement(Element*) const;
+    Element* firstElement(ContainerNode&amp; root) const;
+    Element* traverseForward(Element&amp;, unsigned count, unsigned&amp; traversedCount, ContainerNode&amp; root) const;
</ins><span class="cx"> 
</span><del>-    void setNameItemCache(std::unique_ptr&lt;CollectionNamedElementCache&gt; cache) const
-    {
-        ASSERT(!m_namedElementCache);
-        m_namedElementCache = WTF::move(cache);
-        document().collectionCachedIdNameMap(*this);
-    }
</del><ins>+    virtual Element* customElementAfter(Element*) const;
</ins><span class="cx"> 
</span><del>-    const CollectionNamedElementCache&amp; namedItemCaches() const
-    {
-        ASSERT(!!m_namedElementCache);
-        return *m_namedElementCache;
-    }
</del><ins>+    void invalidateNamedElementCache(Document&amp;) const;
</ins><span class="cx"> 
</span><del>-private:
-    Element* iterateForPreviousElement(Element* current) const;
-    Element* firstElement(ContainerNode&amp; root) const;
-    Element* traverseForward(Element&amp; current, unsigned count, unsigned&amp; traversedCount, ContainerNode&amp; root) const;
</del><ins>+    enum RootType { IsRootedAtNode, IsRootedAtDocument };
+    static RootType rootTypeFromCollectionType(CollectionType);
</ins><span class="cx"> 
</span><del>-    virtual Element* customElementAfter(Element*) const { ASSERT_NOT_REACHED(); return nullptr; }
-    
-    void invalidateNamedElementCache(Document&amp;) const;
-
</del><span class="cx">     Ref&lt;ContainerNode&gt; m_ownerNode;
</span><span class="cx"> 
</span><span class="cx">     mutable CollectionIndexCache&lt;HTMLCollection, Element*&gt; m_indexCache;
</span><span class="lines">@@ -176,6 +129,125 @@
</span><span class="cx">     const unsigned m_usesCustomForwardOnlyTraversal : 1;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+inline const Vector&lt;Element*&gt;* CollectionNamedElementCache::findElementsWithId(const AtomicString&amp; id) const
+{
+    return find(m_idMap, id);
+}
+
+inline const Vector&lt;Element*&gt;* CollectionNamedElementCache::findElementsWithName(const AtomicString&amp; name) const
+{
+    return find(m_nameMap, name);
+}
+
+inline void CollectionNamedElementCache::appendToIdCache(const AtomicString&amp; id, Element&amp; element)
+{
+    return append(m_idMap, id, element);
+}
+
+inline void CollectionNamedElementCache::appendToNameCache(const AtomicString&amp; name, Element&amp; element)
+{
+    return append(m_nameMap, name, element);
+}
+
+inline size_t CollectionNamedElementCache::memoryCost() const
+{
+    return (m_idMap.size() + m_nameMap.size()) * sizeof(Element*);
+}
+
+inline void CollectionNamedElementCache::didPopulate()
+{
+#if !ASSERT_DISABLED
+    m_didPopulate = true;
+#endif
+    if (size_t cost = memoryCost())
+        reportExtraMemoryCostForCollectionIndexCache(cost);
+}
+
+inline const Vector&lt;Element*&gt;* CollectionNamedElementCache::find(const StringToElementsMap&amp; map, const AtomicString&amp; key) const
+{
+    ASSERT(m_didPopulate);
+    auto it = map.find(key.impl());
+    return it != map.end() ? &amp;it-&gt;value : nullptr;
+}
+
+inline void CollectionNamedElementCache::append(StringToElementsMap&amp; map, const AtomicString&amp; key, Element&amp; element)
+{
+    map.add(key.impl(), Vector&lt;Element*&gt;()).iterator-&gt;value.append(&amp;element);
+}
+
+inline size_t HTMLCollection::memoryCost() const
+{
+    return m_indexCache.memoryCost() + (m_namedElementCache ? m_namedElementCache-&gt;memoryCost() : 0);
+}
+
+inline bool HTMLCollection::isRootedAtDocument() const
+{
+    return m_rootType == IsRootedAtDocument;
+}
+
+inline NodeListInvalidationType HTMLCollection::invalidationType() const
+{
+    return static_cast&lt;NodeListInvalidationType&gt;(m_invalidationType);
+}
+
+inline CollectionType HTMLCollection::type() const
+{
+    return static_cast&lt;CollectionType&gt;(m_collectionType);
+}
+
+inline ContainerNode&amp; HTMLCollection::ownerNode() const
+{
+    return const_cast&lt;ContainerNode&amp;&gt;(m_ownerNode.get());
+}
+
+inline Document&amp; HTMLCollection::document() const
+{
+    return m_ownerNode-&gt;document();
+}
+
+inline void HTMLCollection::invalidateCache(const QualifiedName* attributeName) const
+{
+    if (!attributeName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *attributeName))
+        invalidateCache(document());
+    else if (hasNamedElementCache() &amp;&amp; (*attributeName == HTMLNames::idAttr || *attributeName == HTMLNames::nameAttr))
+        invalidateNamedElementCache(document());
+}
+
+inline Element* HTMLCollection::collectionEnd() const
+{
+    return nullptr;
+}
+
+inline bool HTMLCollection::collectionCanTraverseBackward() const
+{
+    return !m_usesCustomForwardOnlyTraversal;
+}
+
+inline void HTMLCollection::willValidateIndexCache() const
+{
+    document().registerCollection(const_cast&lt;HTMLCollection&amp;&gt;(*this));
+}
+
+inline bool HTMLCollection::hasNamedElementCache() const
+{
+    return !!m_namedElementCache;
+}
+
+inline void HTMLCollection::setNamedItemCache(std::unique_ptr&lt;CollectionNamedElementCache&gt; cache) const
+{
+    ASSERT(cache);
+    ASSERT(!m_namedElementCache);
+    cache-&gt;didPopulate();
+    m_namedElementCache = WTF::move(cache);
+    document().collectionCachedIdNameMap(*this);
+}
+
+inline const CollectionNamedElementCache&amp; HTMLCollection::namedItemCaches() const
+{
+    ASSERT(!!m_namedElementCache);
+    return *m_namedElementCache;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #define SPECIALIZE_TYPE_TRAITS_HTMLCOLLECTION(ClassName, Type) \
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlsCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -121,18 +121,17 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* HTMLFormControlsCollection::namedItem(const AtomicString&amp; name) const
</del><ins>+HTMLElement* HTMLFormControlsCollection::namedItem(const AtomicString&amp; name) const
</ins><span class="cx"> {
</span><span class="cx">     // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp
</span><span class="cx">     // This method first searches for an object with a matching id
</span><span class="cx">     // attribute. If a match is not found, the method then searches for an
</span><span class="cx">     // object with a matching name attribute, but only on those elements
</span><span class="cx">     // that are allowed a name attribute.
</span><del>-    const Vector&lt;HTMLImageElement*&gt;* imagesElements = is&lt;HTMLFieldSetElement&gt;(ownerNode()) ? nullptr : &amp;formImageElements();
-    if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements, idAttr, name))
</del><ins>+    auto* imageElements = is&lt;HTMLFieldSetElement&gt;(ownerNode()) ? nullptr : &amp;formImageElements();
+    if (HTMLElement* item = firstNamedItem(formControlElements(), imageElements, idAttr, name))
</ins><span class="cx">         return item;
</span><del>-
-    return firstNamedItem(formControlElements(), imagesElements, nameAttr, name);
</del><ins>+    return firstNamedItem(formControlElements(), imageElements, nameAttr, name);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLFormControlsCollection::updateNamedElementCache() const
</span><span class="lines">@@ -141,41 +140,41 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto cache = std::make_unique&lt;CollectionNamedElementCache&gt;();
</span><ins>+
+    bool ownerIsFormElement = is&lt;HTMLFormElement&gt;(ownerNode());
</ins><span class="cx">     HashSet&lt;AtomicStringImpl*&gt; foundInputElements;
</span><del>-    const Vector&lt;FormAssociatedElement*&gt;&amp; elementsArray = formControlElements();
</del><span class="cx"> 
</span><del>-    for (unsigned i = 0; i &lt; elementsArray.size(); ++i) {
-        FormAssociatedElement&amp; associatedElement = *elementsArray[i];
</del><ins>+    for (auto&amp; elementPtr : formControlElements()) {
+        FormAssociatedElement&amp; associatedElement = *elementPtr;
</ins><span class="cx">         if (associatedElement.isEnumeratable()) {
</span><span class="cx">             HTMLElement&amp; element = associatedElement.asHTMLElement();
</span><del>-            const AtomicString&amp; idAttrVal = element.getIdAttribute();
-            const AtomicString&amp; nameAttrVal = element.getNameAttribute();
-            if (!idAttrVal.isEmpty()) {
-                cache-&gt;appendIdCache(idAttrVal, &amp;element);
-                foundInputElements.add(idAttrVal.impl());
</del><ins>+            const AtomicString&amp; id = element.getIdAttribute();
+            if (!id.isEmpty()) {
+                cache-&gt;appendToIdCache(id, element);
+                if (ownerIsFormElement)
+                    foundInputElements.add(id.impl());
</ins><span class="cx">             }
</span><del>-            if (!nameAttrVal.isEmpty() &amp;&amp; idAttrVal != nameAttrVal) {
-                cache-&gt;appendNameCache(nameAttrVal, &amp;element);
-                foundInputElements.add(nameAttrVal.impl());
</del><ins>+            const AtomicString&amp; name = element.getNameAttribute();
+            if (!name.isEmpty() &amp;&amp; id != name) {
+                cache-&gt;appendToNameCache(name, element);
+                if (ownerIsFormElement)
+                    foundInputElements.add(name.impl());
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-
-    if (is&lt;HTMLFormElement&gt;(ownerNode())) {
-        const Vector&lt;HTMLImageElement*&gt;&amp; imageElementsArray = formImageElements();
-        for (unsigned i = 0; i &lt; imageElementsArray.size(); ++i) {
-            HTMLImageElement&amp; element = *imageElementsArray[i];
-            const AtomicString&amp; idAttrVal = element.getIdAttribute();
-            const AtomicString&amp; nameAttrVal = element.getNameAttribute();
-            if (!idAttrVal.isEmpty() &amp;&amp; !foundInputElements.contains(idAttrVal.impl()))
-                cache-&gt;appendIdCache(idAttrVal, &amp;element);
-            if (!nameAttrVal.isEmpty() &amp;&amp; idAttrVal != nameAttrVal &amp;&amp; !foundInputElements.contains(nameAttrVal.impl()))
-                cache-&gt;appendNameCache(nameAttrVal, &amp;element);
</del><ins>+    if (ownerIsFormElement) {
+        for (auto* elementPtr : formImageElements()) {
+            HTMLImageElement&amp; element = *elementPtr;
+            const AtomicString&amp; id = element.getIdAttribute();
+            if (!id.isEmpty() &amp;&amp; !foundInputElements.contains(id.impl()))
+                cache-&gt;appendToIdCache(id, element);
+            const AtomicString&amp; name = element.getNameAttribute();
+            if (!name.isEmpty() &amp;&amp; id != name &amp;&amp; !foundInputElements.contains(name.impl()))
+                cache-&gt;appendToNameCache(name, element);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    cache-&gt;didPopulate();
-    setNameItemCache(WTF::move(cache));
</del><ins>+    setNamedItemCache(WTF::move(cache));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLFormControlsCollection::invalidateCache(Document&amp; document) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlsCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlsCollection.h (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlsCollection.h        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLFormControlsCollection.h        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -24,13 +24,12 @@
</span><span class="cx"> #define HTMLFormControlsCollection_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;HTMLCollection.h&quot;
</span><ins>+#include &quot;HTMLElement.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class FormAssociatedElement;
</span><del>-class HTMLElement;
</del><span class="cx"> class HTMLImageElement;
</span><del>-class QualifiedName;
</del><span class="cx"> 
</span><span class="cx"> // This class is just a big hack to find form elements even in malformed HTML elements.
</span><span class="cx"> // The famous &lt;table&gt;&lt;tr&gt;&lt;form&gt;&lt;td&gt; problem.
</span><span class="lines">@@ -38,14 +37,12 @@
</span><span class="cx"> class HTMLFormControlsCollection final : public HTMLCollection {
</span><span class="cx"> public:
</span><span class="cx">     static PassRef&lt;HTMLFormControlsCollection&gt; create(ContainerNode&amp;, CollectionType);
</span><del>-
</del><span class="cx">     virtual ~HTMLFormControlsCollection();
</span><span class="cx"> 
</span><del>-    virtual Node* namedItem(const AtomicString&amp; name) const override;
-
</del><span class="cx"> private:
</span><span class="cx">     explicit HTMLFormControlsCollection(ContainerNode&amp;);
</span><span class="cx"> 
</span><ins>+    virtual HTMLElement* namedItem(const AtomicString&amp; name) const override;
</ins><span class="cx">     virtual void invalidateCache(Document&amp;) const override;
</span><span class="cx">     virtual void updateNamedElementCache() const override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormElement.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -792,17 +792,19 @@
</span><span class="cx">     return elements()-&gt;hasNamedItem(name) || elementFromPastNamesMap(name);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// FIXME: Use RefPtr&lt;HTMLElement&gt; for namedItems. elements()-&gt;namedItems never return non-HTMLElement nodes.
-void HTMLFormElement::getNamedElements(const AtomicString&amp; name, Vector&lt;Ref&lt;Element&gt;&gt;&amp; namedItems)
</del><ins>+// FIXME: Use Ref&lt;HTMLElement&gt; for the function result since there are no non-HTML elements returned here.
+Vector&lt;Ref&lt;Element&gt;&gt; HTMLFormElement::namedElements(const AtomicString&amp; name)
</ins><span class="cx"> {
</span><span class="cx">     // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#dom-form-nameditem
</span><del>-    elements()-&gt;namedItems(name, namedItems);
</del><ins>+    Vector&lt;Ref&lt;Element&gt;&gt; namedItems = elements()-&gt;namedItems(name);
</ins><span class="cx"> 
</span><span class="cx">     HTMLElement* elementFromPast = elementFromPastNamesMap(name);
</span><span class="cx">     if (namedItems.size() == 1 &amp;&amp; namedItems.first().ptr() != elementFromPast)
</span><span class="cx">         addToPastNamesMap(downcast&lt;HTMLElement&gt;(namedItems.first().get()).asFormNamedItem(), name);
</span><span class="cx">     else if (elementFromPast &amp;&amp; namedItems.isEmpty())
</span><span class="cx">         namedItems.append(*elementFromPast);
</span><ins>+
+    return namedItems;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLFormElement::documentDidResumeFromPageCache()
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormElement.h (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormElement.h        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLFormElement.h        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> 
</span><span class="cx">     PassRefPtr&lt;HTMLCollection&gt; elements();
</span><span class="cx">     bool hasNamedElement(const AtomicString&amp;);
</span><del>-    void getNamedElements(const AtomicString&amp;, Vector&lt;Ref&lt;Element&gt;&gt;&amp;);
</del><ins>+    Vector&lt;Ref&lt;Element&gt;&gt; namedElements(const AtomicString&amp;);
</ins><span class="cx"> 
</span><span class="cx">     unsigned length() const;
</span><span class="cx">     Node* item(unsigned index);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLNameCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLNameCollection.h (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLNameCollection.h        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLNameCollection.h        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx"> #define HTMLNameCollection_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;HTMLCollection.h&quot;
</span><del>-
</del><span class="cx"> #include &lt;wtf/text/AtomicString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSelectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSelectElement.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -427,14 +427,14 @@
</span><span class="cx">     setIntegralAttribute(sizeAttr, size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* HTMLSelectElement::namedItem(const AtomicString&amp; name)
</del><ins>+HTMLOptionElement* HTMLSelectElement::namedItem(const AtomicString&amp; name)
</ins><span class="cx"> {
</span><del>-    return options()-&gt;namedItem(name);
</del><ins>+    return downcast&lt;HTMLOptionElement&gt;(options()-&gt;namedItem(name));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* HTMLSelectElement::item(unsigned index)
</del><ins>+HTMLOptionElement* HTMLSelectElement::item(unsigned index)
</ins><span class="cx"> {
</span><del>-    return options()-&gt;item(index);
</del><ins>+    return downcast&lt;HTMLOptionElement&gt;(options()-&gt;item(index));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, ExceptionCode&amp; ec)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSelectElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSelectElement.h        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -28,12 +28,12 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Event.h&quot;
</span><span class="cx"> #include &quot;HTMLFormControlElementWithState.h&quot;
</span><ins>+#include &quot;HTMLOptionElement.h&quot;
</ins><span class="cx"> #include &quot;TypeAhead.h&quot;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class HTMLOptionElement;
</del><span class="cx"> class HTMLOptionsCollection;
</span><span class="cx"> 
</span><span class="cx"> class HTMLSelectElement : public HTMLFormControlElementWithState, public TypeAheadDataSource {
</span><span class="lines">@@ -87,8 +87,8 @@
</span><span class="cx">     void setOption(unsigned index, HTMLOptionElement*, ExceptionCode&amp;);
</span><span class="cx">     void setLength(unsigned, ExceptionCode&amp;);
</span><span class="cx"> 
</span><del>-    Node* namedItem(const AtomicString&amp; name);
-    Node* item(unsigned index);
</del><ins>+    HTMLOptionElement* namedItem(const AtomicString&amp; name);
+    HTMLOptionElement* item(unsigned index);
</ins><span class="cx"> 
</span><span class="cx">     void scrollToSelection();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingAxisScrollSnapOffsetscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (175946 => 175947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp        2014-11-11 17:33:43 UTC (rev 175946)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp        2014-11-11 17:35:29 UTC (rev 175947)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;AxisScrollSnapOffsets.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;ElementChildIterator.h&quot;
</ins><span class="cx"> #include &quot;HTMLCollection.h&quot;
</span><span class="cx"> #include &quot;HTMLElement.h&quot;
</span><span class="cx"> #include &quot;RenderBox.h&quot;
</span><span class="lines">@@ -38,16 +39,16 @@
</span><span class="cx"> 
</span><span class="cx"> static void appendChildSnapOffsets(HTMLElement&amp; parent, bool shouldAddHorizontalChildOffsets, Vector&lt;LayoutUnit&gt;&amp; horizontalSnapOffsetSubsequence, bool shouldAddVerticalChildOffsets, Vector&lt;LayoutUnit&gt;&amp; verticalSnapOffsetSubsequence)
</span><span class="cx"> {
</span><del>-    Element* child = parent.children()-&gt;collectionBegin();
</del><span class="cx">     // FIXME: Instead of traversing all children, register children with snap coordinates before appending to snapOffsetSubsequence.
</span><del>-    while (child) {
-        if (RenderBox* box = child-&gt;renderBox()) {
</del><ins>+    for (auto&amp; child : childrenOfType&lt;Element&gt;(parent)) {
+        if (RenderBox* box = child.renderBox()) {
</ins><span class="cx">             LayoutUnit viewWidth = box-&gt;width();
</span><span class="cx">             LayoutUnit viewHeight = box-&gt;height();
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-            // FIXME: Investigate why using localToContainerPoint gives the wrong offsets for iOS mainframe. Also, these offsets won't take transforms into account (make sure to test this!)
-            float left = child-&gt;offsetLeft();
-            float top = child-&gt;offsetTop();
</del><ins>+            // FIXME: Dangerous to call offsetLeft and offsetTop because they call updateLayoutIgnorePendingStylesheets, which can invalidate the RenderBox pointer we are holding.
+            // FIXME: Investigate why using localToContainerPoint gives the wrong offsets for iOS main frame. Also, these offsets won't take transforms into account (make sure to test this!).
+            float left = child.offsetLeft();
+            float top = child.offsetTop();
</ins><span class="cx"> #else
</span><span class="cx">             // FIXME: Check that localToContainerPoint works with CSS rotations.
</span><span class="cx">             FloatPoint position = box-&gt;localToContainerPoint(FloatPoint(), parent.renderBox());
</span><span class="lines">@@ -64,7 +65,6 @@
</span><span class="cx">                     verticalSnapOffsetSubsequence.append(lastPotentialSnapPositionY);
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        child = child-&gt;nextElementSibling();
</del><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>