<!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>[184435] trunk</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/184435">184435</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2015-05-16 11:16:26 -0700 (Sat, 16 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add getElementById to DocumentFragment
https://bugs.webkit.org/show_bug.cgi?id=145094

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Match the latest DOM standard and other browsers by adding getElementById
to DocumentFragment in addition to Document and SVGSVGElement. Add NonElementParentNode
interface that the DOM standard defines.

Test: fast/dom/DocumentFragment/getElementById.html

* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
Add NonElementParentNode.idl

* dom/Document.idl:
Mark Document as implementing NonElementParentNode and remove now redundant getElementById
declaration.

* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::getElementById):
* dom/DocumentFragment.h:
Add implementation of getElementById for DocumentFragments. Add a fast path for ShadowRoots
which can take advantage of the fact that they are TreeScopes to use the elements by id cache
in TreeScrope.

* dom/DocumentFragment.idl:
Mark DocumentFragment as implementing NonElementParentNode.

* dom/NonElementParentNode.idl: Copied from Source/WebCore/dom/NonDocumentTypeChildNode.idl.
Added.

* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
* svg/SVGSVGElement.h:
* svg/SVGSVGElement.idl:
Convert to taking an AtomicString to match other getElementByIds.

LayoutTests:

* fast/dom/DocumentFragment/getElementById-expected.txt: Added.
* fast/dom/DocumentFragment/getElementById.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
<li><a href="#trunkSourceWebCoredomDocumentFragmentcpp">trunk/Source/WebCore/dom/DocumentFragment.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentFragmenth">trunk/Source/WebCore/dom/DocumentFragment.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentFragmentidl">trunk/Source/WebCore/dom/DocumentFragment.idl</a></li>
<li><a href="#trunkSourceWebCoresvgSVGSVGElementcpp">trunk/Source/WebCore/svg/SVGSVGElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGSVGElementh">trunk/Source/WebCore/svg/SVGSVGElement.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGSVGElementidl">trunk/Source/WebCore/svg/SVGSVGElement.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomDocumentFragmentgetElementByIdexpectedtxt">trunk/LayoutTests/fast/dom/DocumentFragment/getElementById-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomDocumentFragmentgetElementByIdhtml">trunk/LayoutTests/fast/dom/DocumentFragment/getElementById.html</a></li>
<li><a href="#trunkSourceWebCoredomNonElementParentNodeidl">trunk/Source/WebCore/dom/NonElementParentNode.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/LayoutTests/ChangeLog        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-05-15  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Add getElementById to DocumentFragment
+        https://bugs.webkit.org/show_bug.cgi?id=145094
+
+        Reviewed by Alexey Proskuryakov.
+
+        * fast/dom/DocumentFragment/getElementById-expected.txt: Added.
+        * fast/dom/DocumentFragment/getElementById.html: Added.
+
</ins><span class="cx"> 2015-05-15  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         When redirecting to data URL use HTTP response for same origin policy checks
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomDocumentFragmentgetElementByIdexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/DocumentFragment/getElementById-expected.txt (0 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/DocumentFragment/getElementById-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/DocumentFragment/getElementById-expected.txt        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Tests that getElementById() API is exposed on DocumentFragment nodes.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS fragment.getElementById('divID') is div
+PASS fragment.getElementById('aID') is a
+PASS fragment.getElementById('notInFragment') is null
+PASS fragment.getElementById('doesNotExist') is null
+PASS fragment.getElementById('duplicateId1') is span
+PASS fragment.getElementById('duplicateId2') is h1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomDocumentFragmentgetElementByIdhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/DocumentFragment/getElementById.html (0 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/DocumentFragment/getElementById.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/DocumentFragment/getElementById.html        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;notInFragment&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;duplicateId1&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+description(&quot;Tests that getElementById() API is exposed on DocumentFragment nodes.&quot;);
+
+var fragment = new DocumentFragment();
+var div = document.createElement(&quot;div&quot;);
+div.id = &quot;divID&quot;;
+fragment.appendChild(div);
+var a = document.createElement(&quot;a&quot;);
+a.id = &quot;aID&quot;;
+div.appendChild(a);
+var span = document.createElement(&quot;span&quot;);
+span.id = &quot;duplicateId1&quot;;
+div.appendChild(span);
+var h1 = document.createElement(&quot;h1&quot;);
+h1.id = &quot;duplicateId2&quot;;
+div.appendChild(h1);
+var h2 = document.createElement(&quot;h2&quot;);
+h2.id = &quot;duplicateId2&quot;;
+div.appendChild(h2);
+
+shouldBe(&quot;fragment.getElementById('divID')&quot;, &quot;div&quot;);
+shouldBe(&quot;fragment.getElementById('aID')&quot;, &quot;a&quot;);
+shouldBeNull(&quot;fragment.getElementById('notInFragment')&quot;);
+shouldBeNull(&quot;fragment.getElementById('doesNotExist')&quot;);
+
+// Duplicate ID cases.
+shouldBe(&quot;fragment.getElementById('duplicateId1')&quot;, &quot;span&quot;); // Should return the Element *inside* the DocumentFragment.
+shouldBe(&quot;fragment.getElementById('duplicateId2')&quot;, &quot;h1&quot;); // Should return the first matching Element in case of duplicate.
+
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -411,6 +411,7 @@
</span><span class="cx">     dom/NodeFilter.idl
</span><span class="cx">     dom/NodeIterator.idl
</span><span class="cx">     dom/NodeList.idl
</span><ins>+    dom/NonElementParentNode.idl
</ins><span class="cx">     dom/NonDocumentTypeChildNode.idl
</span><span class="cx">     dom/OverflowEvent.idl
</span><span class="cx">     dom/PageTransitionEvent.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/ChangeLog        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2015-05-15  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Add getElementById to DocumentFragment
+        https://bugs.webkit.org/show_bug.cgi?id=145094
+
+        Reviewed by Alexey Proskuryakov.
+
+        Match the latest DOM standard and other browsers by adding getElementById
+        to DocumentFragment in addition to Document and SVGSVGElement. Add NonElementParentNode
+        interface that the DOM standard defines.
+
+        Test: fast/dom/DocumentFragment/getElementById.html
+
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        Add NonElementParentNode.idl
+
+        * dom/Document.idl:
+        Mark Document as implementing NonElementParentNode and remove now redundant getElementById
+        declaration.
+
+        * dom/DocumentFragment.cpp:
+        (WebCore::DocumentFragment::getElementById):
+        * dom/DocumentFragment.h:
+        Add implementation of getElementById for DocumentFragments. Add a fast path for ShadowRoots
+        which can take advantage of the fact that they are TreeScopes to use the elements by id cache
+        in TreeScrope.
+
+        * dom/DocumentFragment.idl:
+        Mark DocumentFragment as implementing NonElementParentNode.
+
+        * dom/NonElementParentNode.idl: Copied from Source/WebCore/dom/NonDocumentTypeChildNode.idl.
+        Added.
+
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::getElementById):
+        * svg/SVGSVGElement.h:
+        * svg/SVGSVGElement.idl:
+        Convert to taking an AtomicString to match other getElementByIds.
+
</ins><span class="cx"> 2015-05-15  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         When redirecting to data URL use HTTP response for same origin policy checks
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/DerivedSources.make        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -299,6 +299,7 @@
</span><span class="cx">     $(WebCore)/dom/NodeFilter.idl \
</span><span class="cx">     $(WebCore)/dom/NodeIterator.idl \
</span><span class="cx">     $(WebCore)/dom/NodeList.idl \
</span><ins>+    $(WebCore)/dom/NonElementParentNode.idl \
</ins><span class="cx">     $(WebCore)/dom/NonDocumentTypeChildNode.idl \
</span><span class="cx">     $(WebCore)/dom/OverflowEvent.idl \
</span><span class="cx">     $(WebCore)/dom/PageTransitionEvent.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -9818,6 +9818,7 @@
</span><span class="cx">                 7C6136F71710C35200FF4A57 /* InFilesCompiler.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = InFilesCompiler.pm; path = scripts/InFilesCompiler.pm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C6136F81710C35200FF4A57 /* InFilesParser.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = InFilesParser.pm; path = scripts/InFilesParser.pm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C6136F91710C35200FF4A57 /* StaticString.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = StaticString.pm; path = scripts/StaticString.pm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7C6752BA1B06E82000C279CB /* NonElementParentNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NonElementParentNode.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7C73FB05191EF416007DE061 /* UserMessageHandlersNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandlersNamespace.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C73FB06191EF417007DE061 /* UserMessageHandlersNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlersNamespace.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C73FB09191EF49F007DE061 /* UserMessageHandlersNamespace.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = UserMessageHandlersNamespace.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -23171,6 +23172,7 @@
</span><span class="cx">                                 E43105BA16750F1600DB2FB8 /* NodeTraversal.h */,
</span><span class="cx">                                 9382AAB10D8C386100F357A6 /* NodeWithIndex.h */,
</span><span class="cx">                                 8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */,
</span><ins>+                                7C6752BA1B06E82000C279CB /* NonElementParentNode.idl */,
</ins><span class="cx">                                 1A0D57340A5C77FE007EDD4C /* OverflowEvent.cpp */,
</span><span class="cx">                                 1A0D57350A5C77FE007EDD4C /* OverflowEvent.h */,
</span><span class="cx">                                 1A0D57380A5C7812007EDD4C /* OverflowEvent.idl */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/dom/Document.idl        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -52,7 +52,6 @@
</span><span class="cx">                                                                           [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
</span><span class="cx">     [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
</span><span class="cx">                                                    [Default=Undefined] optional DOMString localName);
</span><del>-    Element getElementById([Default=Undefined,ObjCExplicitAtomicString,RequiresExistingAtomicString] optional DOMString elementId);
</del><span class="cx"> 
</span><span class="cx">     // DOM Level 3 Core
</span><span class="cx"> 
</span><span class="lines">@@ -343,3 +342,4 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> Document implements ParentNode;
</span><ins>+Document implements NonElementParentNode;
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDocumentFragmentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentFragment.cpp (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentFragment.cpp        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/dom/DocumentFragment.cpp        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #include &quot;DocumentFragment.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Document.h&quot;
</span><ins>+#include &quot;ElementDescendantIterator.h&quot;
</ins><span class="cx"> #include &quot;HTMLDocumentParser.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="lines">@@ -91,4 +92,19 @@
</span><span class="cx">     return XMLDocumentParser::parseDocumentFragment(source, *this, contextElement, parserContentPolicy);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Element* DocumentFragment::getElementById(const AtomicString&amp; id) const
+{
+    // Fast path for ShadowRoot, where we are both a DocumentFragment and a TreeScope.
+    if (isTreeScope())
+        return treeScope().getElementById(id);
+
+    // Otherwise, fall back to iterating all of the element descendants.
+    for (auto&amp; element : elementDescendants(*this)) {
+        if (element.getIdAttribute() == id)
+            return const_cast&lt;Element*&gt;(&amp;element);
+    }
+
+    return nullptr;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDocumentFragmenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentFragment.h (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentFragment.h        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/dom/DocumentFragment.h        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -39,6 +39,9 @@
</span><span class="cx">     virtual bool canContainRangeEndPoint() const override final { return true; }
</span><span class="cx">     virtual bool isTemplateContent() const { return false; }
</span><span class="cx"> 
</span><ins>+    // From the NonElementParentNode interface - https://dom.spec.whatwg.org/#interface-nonelementparentnode
+    Element* getElementById(const AtomicString&amp;) const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     DocumentFragment(Document&amp;, ConstructionType = CreateContainer);
</span><span class="cx">     virtual String nodeName() const override final;
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentFragmentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentFragment.idl (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentFragment.idl        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/dom/DocumentFragment.idl        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -17,10 +17,11 @@
</span><span class="cx">  * Boston, MA 02110-1301, USA.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>- [
</del><ins>+[
</ins><span class="cx">     Constructor,
</span><span class="cx">     ConstructorCallWith=Document
</span><del>- ] interface DocumentFragment : Node {
</del><ins>+] interface DocumentFragment : Node {
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> DocumentFragment implements ParentNode;
</span><ins>+DocumentFragment implements NonElementParentNode;
</ins></span></pre></div>
<a id="trunkSourceWebCoredomNonElementParentNodeidlfromrev184419trunkSourceWebCoredomNonDocumentTypeChildNodeidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/NonElementParentNode.idl (from rev 184419, trunk/Source/WebCore/dom/NonDocumentTypeChildNode.idl) (0 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/NonElementParentNode.idl                                (rev 0)
+++ trunk/Source/WebCore/dom/NonElementParentNode.idl        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+// https://dom.spec.whatwg.org/#interface-nonelementparentnode
+[
+    NoInterfaceObject,
+] interface NonElementParentNode {
+    Element getElementById([Default=Undefined,ObjCExplicitAtomicString,RequiresExistingAtomicString] optional DOMString elementId);
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoresvgSVGSVGElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGSVGElement.cpp        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -670,7 +670,7 @@
</span><span class="cx"> 
</span><span class="cx"> // getElementById on SVGSVGElement is restricted to only the child subtree defined by the &lt;svg&gt; element.
</span><span class="cx"> // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement
</span><del>-Element* SVGSVGElement::getElementById(const String&amp; id)
</del><ins>+Element* SVGSVGElement::getElementById(const AtomicString&amp; id)
</ins><span class="cx"> {
</span><span class="cx">     Element* element = treeScope().getElementById(id);
</span><span class="cx">     if (element &amp;&amp; element-&gt;isDescendantOf(this))
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGSVGElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGSVGElement.h (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGSVGElement.h        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/svg/SVGSVGElement.h        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx">     static SVGTransform createSVGTransform();
</span><span class="cx">     static SVGTransform createSVGTransformFromMatrix(const SVGMatrix&amp;);
</span><span class="cx"> 
</span><del>-    Element* getElementById(const String&amp;);
</del><ins>+    Element* getElementById(const AtomicString&amp;);
</ins><span class="cx"> 
</span><span class="cx">     SVGZoomAndPanType zoomAndPan() const;
</span><span class="cx">     void setZoomAndPan(unsigned short);
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGSVGElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGSVGElement.idl (184434 => 184435)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGSVGElement.idl        2015-05-16 13:53:21 UTC (rev 184434)
+++ trunk/Source/WebCore/svg/SVGSVGElement.idl        2015-05-16 18:16:26 UTC (rev 184435)
</span><span class="lines">@@ -67,7 +67,8 @@
</span><span class="cx">     SVGRect createSVGRect();
</span><span class="cx">     SVGTransform createSVGTransform();
</span><span class="cx">     SVGTransform createSVGTransformFromMatrix([Default=Undefined] optional SVGMatrix matrix);
</span><del>-    Element getElementById([Default=Undefined] optional DOMString elementId);
</del><ins>+
+    Element getElementById([Default=Undefined, RequiresExistingAtomicString] optional DOMString elementId);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> SVGSVGElement implements SVGExternalResourcesRequired;
</span></span></pre>
</div>
</div>

</body>
</html>