<!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>[184034] 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/184034">184034</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2015-05-08 18:14:17 -0700 (Fri, 08 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Element Traversal is not just Elements anymore
https://bugs.webkit.org/show_bug.cgi?id=144822

Reviewed by Simon Fraser.

Source/WebCore:

Match other browsers and the new DOM spec at https://dom.spec.whatwg.org by
exposing the element traversal methods on non-Elements.

- Makes firstElementChild, lastElementChild and childElementCount available on
  Document and DocumentFragment in addition to Element.
- Makes nextElementSibling and previousElementSibling available on CharacterData
  in addition to Element.

Tests: fast/dom/element-traversal-on-character-data.html
       fast/dom/element-traversal-on-document-fragment.html
       fast/dom/element-traversal-on-document.html

* dom/CharacterData.idl:
Expose nextElementSibling and previousElementSibling.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::firstElementChild):
(WebCore::ContainerNode::lastElementChild):
(WebCore::ContainerNode::childElementCount):
* dom/ContainerNode.h:
Move implementations of firstElementChild, lastElementChild and childElementCount here
from Element to make them shareable.

* dom/Document.idl:
* dom/DocumentFragment.idl:
Expose firstElementChild, lastElementChild and childElementCount.

* dom/Element.cpp:
(WebCore::Element::firstElementChild): Deleted.
(WebCore::Element::lastElementChild): Deleted.
(WebCore::Element::previousElementSibling): Deleted.
(WebCore::Element::nextElementSibling): Deleted.
(WebCore::Element::childElementCount): Deleted.
* dom/Element.h:
Move element traversal functions down to Node and ContainerNode.

* dom/Element.idl:
Update comments to indicate where these functions are defined now.

* dom/Node.cpp:
(WebCore::Node::previousElementSibling):
(WebCore::Node::nextElementSibling):
* dom/Node.h:
Move implementations of nextElementSibling and previousElementSibling here
from Element to make them shareable.

LayoutTests:

Add new tests for element traversal functions on Document, DocumentFragment and CharacterData.

* fast/dom/element-traversal-on-character-data-expected.txt: Added.
* fast/dom/element-traversal-on-character-data.html: Added.
* fast/dom/element-traversal-on-document-expected.txt: Added.
* fast/dom/element-traversal-on-document-fragment-expected.txt: Added.
* fast/dom/element-traversal-on-document-fragment.html: Added.
* fast/dom/element-traversal-on-document.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomCharacterDataidl">trunk/Source/WebCore/dom/CharacterData.idl</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodecpp">trunk/Source/WebCore/dom/ContainerNode.cpp</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodeh">trunk/Source/WebCore/dom/ContainerNode.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
<li><a href="#trunkSourceWebCoredomDocumentFragmentidl">trunk/Source/WebCore/dom/DocumentFragment.idl</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoredomElementidl">trunk/Source/WebCore/dom/Element.idl</a></li>
<li><a href="#trunkSourceWebCoredomNodecpp">trunk/Source/WebCore/dom/Node.cpp</a></li>
<li><a href="#trunkSourceWebCoredomNodeh">trunk/Source/WebCore/dom/Node.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomelementtraversaloncharacterdataexpectedtxt">trunk/LayoutTests/fast/dom/element-traversal-on-character-data-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomelementtraversaloncharacterdatahtml">trunk/LayoutTests/fast/dom/element-traversal-on-character-data.html</a></li>
<li><a href="#trunkLayoutTestsfastdomelementtraversalondocumentexpectedtxt">trunk/LayoutTests/fast/dom/element-traversal-on-document-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomelementtraversalondocumentfragmentexpectedtxt">trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomelementtraversalondocumentfragmenthtml">trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment.html</a></li>
<li><a href="#trunkLayoutTestsfastdomelementtraversalondocumenthtml">trunk/LayoutTests/fast/dom/element-traversal-on-document.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/LayoutTests/ChangeLog        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-05-08  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Element Traversal is not just Elements anymore
+        https://bugs.webkit.org/show_bug.cgi?id=144822
+
+        Reviewed by Simon Fraser.
+
+        Add new tests for element traversal functions on Document, DocumentFragment and CharacterData.
+
+        * fast/dom/element-traversal-on-character-data-expected.txt: Added.
+        * fast/dom/element-traversal-on-character-data.html: Added.
+        * fast/dom/element-traversal-on-document-expected.txt: Added.
+        * fast/dom/element-traversal-on-document-fragment-expected.txt: Added.
+        * fast/dom/element-traversal-on-document-fragment.html: Added.
+        * fast/dom/element-traversal-on-document.html: Added.
+
</ins><span class="cx"> 2015-05-08  Martin Robinson  &lt;mrobinson@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed GTK+ gardening
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomelementtraversaloncharacterdataexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-traversal-on-character-data-expected.txt (0 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-traversal-on-character-data-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-traversal-on-character-data-expected.txt        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+This test checks the implementation of the element traversal APIs on CharacterData as part of the NonDocumentTypeChildNode interface.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS firstTextNode.previousElementSibling is null
+PASS firstTextNode.nextElementSibling is element
+PASS firstTextNode.nextElementSibling.nextElementSibling is null
+PASS lastTextNode.previousElementSibling is element
+PASS lastTextNode.previousElementSibling.previousElementSibling is null
+PASS lastTextNode.nextElementSibling is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomelementtraversaloncharacterdatahtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-traversal-on-character-data.html (0 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-traversal-on-character-data.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-traversal-on-character-data.html        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -0,0 +1,32 @@
</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;script&gt;
+
+description(&quot;This test checks the implementation of the element traversal APIs on CharacterData as part of the NonDocumentTypeChildNode interface.&quot;);
+
+var children = document.createElement('div');
+var firstTextNode = document.createTextNode('first text node');
+children.appendChild(firstTextNode);
+var element = document.createElement('p');
+children.appendChild(element);
+children.appendChild(document.createComment(&quot;a comment&quot;));
+var lastTextNode = document.createTextNode('last text node');
+children.appendChild(lastTextNode);
+children.appendChild(document.createComment(&quot;last comment&quot;));
+
+shouldBe(&quot;firstTextNode.previousElementSibling&quot;, &quot;null&quot;);
+shouldBe(&quot;firstTextNode.nextElementSibling&quot;, &quot;element&quot;);
+shouldBe(&quot;firstTextNode.nextElementSibling.nextElementSibling&quot;, &quot;null&quot;);
+shouldBe(&quot;lastTextNode.previousElementSibling&quot;, &quot;element&quot;);
+shouldBe(&quot;lastTextNode.previousElementSibling.previousElementSibling&quot;, &quot;null&quot;);
+shouldBe(&quot;lastTextNode.nextElementSibling&quot;, &quot;null&quot;);
+
+&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="trunkLayoutTestsfastdomelementtraversalondocumentexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-traversal-on-document-expected.txt (0 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-traversal-on-document-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-traversal-on-document-expected.txt        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+This test checks the implementation of the element traversal APIs on Document as part of the ParentNode interface.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Test with no children
+PASS noChildren.firstElementChild is null
+PASS noChildren.lastElementChild is null
+PASS noChildren.childElementCount is 0
+Test with no element children
+PASS noElementChildren.firstElementChild is null
+PASS noElementChildren.lastElementChild is null
+PASS noElementChildren.childElementCount is 0
+Test with elements
+PASS children.firstElementChild is child
+PASS children.lastElementChild is child
+PASS children.childElementCount is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomelementtraversalondocumentfragmentexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment-expected.txt (0 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment-expected.txt        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+This test checks the implementation of the element traversal APIs on DocumentFragment as part of the ParentNode interface.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Test with no children
+PASS noChildren.firstElementChild is null
+PASS noChildren.lastElementChild is null
+PASS noChildren.childElementCount is 0
+Test with no element children
+PASS noElementChildren.firstElementChild is null
+PASS noElementChildren.lastElementChild is null
+PASS noElementChildren.childElementCount is 0
+Test with elements
+PASS children.firstElementChild is first
+PASS children.lastElementChild is last
+PASS children.childElementCount is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomelementtraversalondocumentfragmenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment.html (0 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-traversal-on-document-fragment.html        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -0,0 +1,44 @@
</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;script&gt;
+
+description(&quot;This test checks the implementation of the element traversal APIs on DocumentFragment as part of the ParentNode interface.&quot;);
+
+debug('Test with no children');
+var noChildren = document.createDocumentFragment();
+shouldBe(&quot;noChildren.firstElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noChildren.lastElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noChildren.childElementCount&quot;, &quot;0&quot;);
+
+debug('Test with no element children');
+var noElementChildren = document.createDocumentFragment();
+noElementChildren.appendChild(document.createComment(&quot;comment but not an element&quot;));
+noElementChildren.appendChild(document.createTextNode(&quot;no elements here&quot;));
+
+shouldBe(&quot;noElementChildren.firstElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noElementChildren.lastElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noElementChildren.childElementCount&quot;, &quot;0&quot;);
+
+debug('Test with elements');
+var children = document.createDocumentFragment();
+children.appendChild(document.createComment(&quot;first comment&quot;));
+var first = document.createElement('p');
+children.appendChild(first);
+children.appendChild(document.createComment(&quot;a comment&quot;));
+var last = document.createElement('p');
+children.appendChild(last);
+children.appendChild(document.createComment(&quot;last comment&quot;));
+
+shouldBe(&quot;children.firstElementChild&quot;, &quot;first&quot;);
+shouldBe(&quot;children.lastElementChild&quot;, &quot;last&quot;);
+shouldBe(&quot;children.childElementCount&quot;, &quot;2&quot;);
+
+&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="trunkLayoutTestsfastdomelementtraversalondocumenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-traversal-on-document.html (0 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-traversal-on-document.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-traversal-on-document.html        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -0,0 +1,49 @@
</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;script&gt;
+
+description(&quot;This test checks the implementation of the element traversal APIs on Document as part of the ParentNode interface.&quot;);
+
+function createEmptyDocument()
+{
+    var doc = document.implementation.createHTMLDocument();
+    while (doc.firstChild) {
+        doc.removeChild(doc.firstChild);
+    }
+    return doc;
+}
+
+debug('Test with no children');
+var noChildren = createEmptyDocument();
+shouldBe(&quot;noChildren.firstElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noChildren.lastElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noChildren.childElementCount&quot;, &quot;0&quot;);
+
+debug('Test with no element children');
+var noElementChildren = createEmptyDocument();
+noElementChildren.appendChild(document.createComment(&quot;comment but not an element&quot;));
+
+shouldBe(&quot;noElementChildren.firstElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noElementChildren.lastElementChild&quot;, &quot;null&quot;);
+shouldBe(&quot;noElementChildren.childElementCount&quot;, &quot;0&quot;);
+
+debug('Test with elements');
+var children = createEmptyDocument();
+children.appendChild(document.createComment(&quot;first comment&quot;));
+var child = document.createElement('p');
+children.appendChild(child);
+children.appendChild(document.createComment(&quot;a comment&quot;));
+
+shouldBe(&quot;children.firstElementChild&quot;, &quot;child&quot;);
+shouldBe(&quot;children.lastElementChild&quot;, &quot;child&quot;);
+shouldBe(&quot;children.childElementCount&quot;, &quot;1&quot;);
+
+&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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/ChangeLog        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2015-05-08  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Element Traversal is not just Elements anymore
+        https://bugs.webkit.org/show_bug.cgi?id=144822
+
+        Reviewed by Simon Fraser.
+
+        Match other browsers and the new DOM spec at https://dom.spec.whatwg.org by
+        exposing the element traversal methods on non-Elements.
+
+        - Makes firstElementChild, lastElementChild and childElementCount available on
+          Document and DocumentFragment in addition to Element.
+        - Makes nextElementSibling and previousElementSibling available on CharacterData
+          in addition to Element.
+
+        Tests: fast/dom/element-traversal-on-character-data.html
+               fast/dom/element-traversal-on-document-fragment.html
+               fast/dom/element-traversal-on-document.html
+
+        * dom/CharacterData.idl:
+        Expose nextElementSibling and previousElementSibling.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::firstElementChild):
+        (WebCore::ContainerNode::lastElementChild):
+        (WebCore::ContainerNode::childElementCount):
+        * dom/ContainerNode.h:
+        Move implementations of firstElementChild, lastElementChild and childElementCount here
+        from Element to make them shareable.
+
+        * dom/Document.idl:
+        * dom/DocumentFragment.idl:
+        Expose firstElementChild, lastElementChild and childElementCount.
+
+        * dom/Element.cpp:
+        (WebCore::Element::firstElementChild): Deleted.
+        (WebCore::Element::lastElementChild): Deleted.
+        (WebCore::Element::previousElementSibling): Deleted.
+        (WebCore::Element::nextElementSibling): Deleted.
+        (WebCore::Element::childElementCount): Deleted.
+        * dom/Element.h:
+        Move element traversal functions down to Node and ContainerNode.
+
+        * dom/Element.idl:
+        Update comments to indicate where these functions are defined now.
+
+        * dom/Node.cpp:
+        (WebCore::Node::previousElementSibling):
+        (WebCore::Node::nextElementSibling):
+        * dom/Node.h:
+        Move implementations of nextElementSibling and previousElementSibling here
+        from Element to make them shareable.
+
</ins><span class="cx"> 2015-05-08  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;, Martin Robinson &lt;mrobinson@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Checks for DEVELOPMENT_BUILD are all wrong
</span></span></pre></div>
<a id="trunkSourceWebCoredomCharacterDataidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CharacterData.idl (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CharacterData.idl        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/CharacterData.idl        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -37,6 +37,11 @@
</span><span class="cx">     [ObjCLegacyUnnamedParameters, RaisesException] void replaceData([IsIndex, Default=Undefined] optional unsigned long offset, 
</span><span class="cx">                                     [IsIndex, Default=Undefined] optional unsigned long length,
</span><span class="cx">                                     [Default=Undefined] optional DOMString data);
</span><ins>+
+    // From the NonDocumentTypeChildNode interface - https://dom.spec.whatwg.org/#nondocumenttypechildnode
+    // FIXME: Move this to a seperate NonDocumentTypeChildNode IDL file when one exists.
+    readonly attribute Element previousElementSibling;
+    readonly attribute Element nextElementSibling;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> CharacterData implements ChildNode;
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.cpp        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -911,4 +911,31 @@
</span><span class="cx">     return ensureRareData().ensureNodeLists().addCacheWithAtomicName&lt;RadioNodeList&gt;(*this, name);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Element* ContainerNode::firstElementChild() const
+{
+    ASSERT(is&lt;Document&gt;(*this) || is&lt;DocumentFragment&gt;(*this) || is&lt;Element&gt;(*this));
+
+    return ElementTraversal::firstChild(*this);
+}
+
+Element* ContainerNode::lastElementChild() const
+{
+    ASSERT(is&lt;Document&gt;(*this) || is&lt;DocumentFragment&gt;(*this) || is&lt;Element&gt;(*this));
+
+    return ElementTraversal::lastChild(*this);
+}
+
+unsigned ContainerNode::childElementCount() const
+{
+    ASSERT(is&lt;Document&gt;(*this) || is&lt;DocumentFragment&gt;(*this) || is&lt;Element&gt;(*this));
+
+    unsigned count = 0;
+    Node* n = firstChild();
+    while (n) {
+        count += n-&gt;isElementNode();
+        n = n-&gt;nextSibling();
+    }
+    return count;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.h (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.h        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/ContainerNode.h        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -145,6 +145,11 @@
</span><span class="cx">     RefPtr&lt;NodeList&gt; getElementsByClassName(const AtomicString&amp; classNames);
</span><span class="cx">     RefPtr&lt;RadioNodeList&gt; radioNodeList(const AtomicString&amp;);
</span><span class="cx"> 
</span><ins>+    // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode
+    Element* firstElementChild() const;
+    Element* lastElementChild() const;
+    unsigned childElementCount() const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     explicit ContainerNode(Document&amp;, ConstructionType = CreateContainer);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/Document.idl        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2011, 2015 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2006, 2007 Samuel Weinig &lt;sam@webkit.org&gt;
</span><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -342,6 +342,13 @@
</span><span class="cx">     // http://www.w3.org/TR/2014/WD-dom-20140204/#dom-document-origin
</span><span class="cx">     readonly attribute DOMString origin;
</span><span class="cx"> 
</span><ins>+    // http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement
</ins><span class="cx">     readonly attribute Element scrollingElement;
</span><ins>+
+    // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode
+    // FIXME: Move this to a seperate ParentNode IDL file when one exists.
+    readonly attribute Element firstElementChild;
+    readonly attribute Element lastElementChild;
+    readonly attribute unsigned long childElementCount;
</ins><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentFragmentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentFragment.idl (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentFragment.idl        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/DocumentFragment.idl        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2008, 2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -24,5 +24,11 @@
</span><span class="cx">     // NodeSelector - Selector API
</span><span class="cx">     [RaisesException] Element querySelector(DOMString selectors);
</span><span class="cx">     [RaisesException] NodeList querySelectorAll(DOMString selectors);
</span><ins>+    
+    // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode
+    // FIXME: Move this to a seperate ParentNode IDL file when one exists.
+    readonly attribute Element firstElementChild;
+    readonly attribute Element lastElementChild;
+    readonly attribute unsigned long childElementCount;
</ins><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/Element.cpp        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -2619,38 +2619,6 @@
</span><span class="cx">     elementRareData()-&gt;setAfterPseudoElement(nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// ElementTraversal API
-Element* Element::firstElementChild() const
-{
-    return ElementTraversal::firstChild(*this);
-}
-
-Element* Element::lastElementChild() const
-{
-    return ElementTraversal::lastChild(*this);
-}
-
-Element* Element::previousElementSibling() const
-{
-    return ElementTraversal::previousSibling(*this);
-}
-
-Element* Element::nextElementSibling() const
-{
-    return ElementTraversal::nextSibling(*this);
-}
-
-unsigned Element::childElementCount() const
-{
-    unsigned count = 0;
-    Node* n = firstChild();
-    while (n) {
-        count += n-&gt;isElementNode();
-        n = n-&gt;nextSibling();
-    }
-    return count;
-}
-
</del><span class="cx"> bool Element::matchesReadWritePseudoClass() const
</span><span class="cx"> {
</span><span class="cx">     return false;
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/Element.h        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -371,13 +371,6 @@
</span><span class="cx">     bool childNeedsShadowWalker() const;
</span><span class="cx">     void didShadowTreeAwareChildrenChange();
</span><span class="cx"> 
</span><del>-    // ElementTraversal API
-    Element* firstElementChild() const;
-    Element* lastElementChild() const;
-    Element* previousElementSibling() const;
-    Element* nextElementSibling() const;
-    unsigned childElementCount() const;
-
</del><span class="cx">     virtual bool matchesReadWritePseudoClass() const;
</span><span class="cx">     bool matches(const String&amp; selectors, ExceptionCode&amp;);
</span><span class="cx">     Element* closest(const String&amp; selectors, ExceptionCode&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.idl (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.idl        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/Element.idl        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -127,12 +127,16 @@
</span><span class="cx">     [RaisesException] Element closest(DOMString selectors);    
</span><span class="cx">     [ImplementedAs=matches, RaisesException] boolean webkitMatchesSelector(DOMString selectors);
</span><span class="cx"> 
</span><del>-    // ElementTraversal API
</del><ins>+    // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode
+    // FIXME: Move this to a seperate ParentNode IDL file when one exists.
</ins><span class="cx">     readonly attribute Element firstElementChild;
</span><span class="cx">     readonly attribute Element lastElementChild;
</span><ins>+    readonly attribute unsigned long childElementCount;
+
+    // From the NonDocumentTypeChildNode interface - https://dom.spec.whatwg.org/#nondocumenttypechildnode
+    // FIXME: Move this to a seperate NonDocumentTypeChildNode IDL file when one exists.
</ins><span class="cx">     readonly attribute Element previousElementSibling;
</span><span class="cx">     readonly attribute Element nextElementSibling;
</span><del>-    readonly attribute unsigned long childElementCount;
</del><span class="cx"> 
</span><span class="cx"> #if defined(LANGUAGE_JAVASCRIPT) &amp;&amp; LANGUAGE_JAVASCRIPT
</span><span class="cx">     // CSSOM View Module API
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.cpp (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.cpp        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/Node.cpp        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include &quot;DocumentType.h&quot;
</span><span class="cx"> #include &quot;ElementIterator.h&quot;
</span><span class="cx"> #include &quot;ElementRareData.h&quot;
</span><ins>+#include &quot;ElementTraversal.h&quot;
</ins><span class="cx"> #include &quot;EventDispatcher.h&quot;
</span><span class="cx"> #include &quot;EventException.h&quot;
</span><span class="cx"> #include &quot;EventHandler.h&quot;
</span><span class="lines">@@ -429,6 +430,20 @@
</span><span class="cx">     return n;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Element* Node::previousElementSibling() const
+{
+    ASSERT(is&lt;CharacterData&gt;(*this) || is&lt;Element&gt;(*this));
+
+    return ElementTraversal::previousSibling(*this);
+}
+
+Element* Node::nextElementSibling() const
+{
+    ASSERT(is&lt;CharacterData&gt;(*this) || is&lt;Element&gt;(*this));
+
+    return ElementTraversal::nextSibling(*this);
+}
+
</ins><span class="cx"> bool Node::insertBefore(PassRefPtr&lt;Node&gt; newChild, Node* refChild, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     if (!is&lt;ContainerNode&gt;(*this)) {
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.h (184033 => 184034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.h        2015-05-09 00:33:37 UTC (rev 184033)
+++ trunk/Source/WebCore/dom/Node.h        2015-05-09 01:14:17 UTC (rev 184034)
</span><span class="lines">@@ -223,6 +223,10 @@
</span><span class="cx">     Node* lastDescendant() const;
</span><span class="cx">     Node* firstDescendant() const;
</span><span class="cx"> 
</span><ins>+    // From the NonDocumentTypeChildNode - https://dom.spec.whatwg.org/#nondocumenttypechildnode
+    Element* previousElementSibling() const;
+    Element* nextElementSibling() const;
+
</ins><span class="cx">     // Other methods (not part of DOM)
</span><span class="cx"> 
</span><span class="cx">     bool isElementNode() const { return getFlag(IsElementFlag); }
</span></span></pre>
</div>
</div>

</body>
</html>