Element Traversal is not just Elements anymore
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 May 2015 01:14:17 +0000 (01:14 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 May 2015 01:14:17 +0000 (01:14 +0000)
commite193c17cda15dd860826aeadffd3078f2dd12aad
treeb0a55d49bfd4438a46d570efc0a36bbe2efdbc9a
parentf817a68be3e23ad0bfbcf0580c7c65eed75cd193
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/element-traversal-on-character-data-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/element-traversal-on-character-data.html [new file with mode: 0644]
LayoutTests/fast/dom/element-traversal-on-document-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/element-traversal-on-document-fragment-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/element-traversal-on-document-fragment.html [new file with mode: 0644]
LayoutTests/fast/dom/element-traversal-on-document.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/CharacterData.idl
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNode.h
Source/WebCore/dom/Document.idl
Source/WebCore/dom/DocumentFragment.idl
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h