Changeset 184034 in webkit
- Timestamp:
- May 8, 2015, 6:14:17 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 12 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/element-traversal-on-character-data-expected.txt (added)
-
LayoutTests/fast/dom/element-traversal-on-character-data.html (added)
-
LayoutTests/fast/dom/element-traversal-on-document-expected.txt (added)
-
LayoutTests/fast/dom/element-traversal-on-document-fragment-expected.txt (added)
-
LayoutTests/fast/dom/element-traversal-on-document-fragment.html (added)
-
LayoutTests/fast/dom/element-traversal-on-document.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/CharacterData.idl (modified) (1 diff)
-
Source/WebCore/dom/ContainerNode.cpp (modified) (1 diff)
-
Source/WebCore/dom/ContainerNode.h (modified) (1 diff)
-
Source/WebCore/dom/Document.idl (modified) (2 diffs)
-
Source/WebCore/dom/DocumentFragment.idl (modified) (2 diffs)
-
Source/WebCore/dom/Element.cpp (modified) (1 diff)
-
Source/WebCore/dom/Element.h (modified) (1 diff)
-
Source/WebCore/dom/Element.idl (modified) (1 diff)
-
Source/WebCore/dom/Node.cpp (modified) (2 diffs)
-
Source/WebCore/dom/Node.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r184031 r184034 1 2015-05-08 Sam Weinig <sam@webkit.org> 2 3 Element Traversal is not just Elements anymore 4 https://bugs.webkit.org/show_bug.cgi?id=144822 5 6 Reviewed by Simon Fraser. 7 8 Add new tests for element traversal functions on Document, DocumentFragment and CharacterData. 9 10 * fast/dom/element-traversal-on-character-data-expected.txt: Added. 11 * fast/dom/element-traversal-on-character-data.html: Added. 12 * fast/dom/element-traversal-on-document-expected.txt: Added. 13 * fast/dom/element-traversal-on-document-fragment-expected.txt: Added. 14 * fast/dom/element-traversal-on-document-fragment.html: Added. 15 * fast/dom/element-traversal-on-document.html: Added. 16 1 17 2015-05-08 Martin Robinson <mrobinson@igalia.com> 2 18 -
trunk/Source/WebCore/ChangeLog
r184010 r184034 1 2015-05-08 Sam Weinig <sam@webkit.org> 2 3 Element Traversal is not just Elements anymore 4 https://bugs.webkit.org/show_bug.cgi?id=144822 5 6 Reviewed by Simon Fraser. 7 8 Match other browsers and the new DOM spec at https://dom.spec.whatwg.org by 9 exposing the element traversal methods on non-Elements. 10 11 - Makes firstElementChild, lastElementChild and childElementCount available on 12 Document and DocumentFragment in addition to Element. 13 - Makes nextElementSibling and previousElementSibling available on CharacterData 14 in addition to Element. 15 16 Tests: fast/dom/element-traversal-on-character-data.html 17 fast/dom/element-traversal-on-document-fragment.html 18 fast/dom/element-traversal-on-document.html 19 20 * dom/CharacterData.idl: 21 Expose nextElementSibling and previousElementSibling. 22 23 * dom/ContainerNode.cpp: 24 (WebCore::ContainerNode::firstElementChild): 25 (WebCore::ContainerNode::lastElementChild): 26 (WebCore::ContainerNode::childElementCount): 27 * dom/ContainerNode.h: 28 Move implementations of firstElementChild, lastElementChild and childElementCount here 29 from Element to make them shareable. 30 31 * dom/Document.idl: 32 * dom/DocumentFragment.idl: 33 Expose firstElementChild, lastElementChild and childElementCount. 34 35 * dom/Element.cpp: 36 (WebCore::Element::firstElementChild): Deleted. 37 (WebCore::Element::lastElementChild): Deleted. 38 (WebCore::Element::previousElementSibling): Deleted. 39 (WebCore::Element::nextElementSibling): Deleted. 40 (WebCore::Element::childElementCount): Deleted. 41 * dom/Element.h: 42 Move element traversal functions down to Node and ContainerNode. 43 44 * dom/Element.idl: 45 Update comments to indicate where these functions are defined now. 46 47 * dom/Node.cpp: 48 (WebCore::Node::previousElementSibling): 49 (WebCore::Node::nextElementSibling): 50 * dom/Node.h: 51 Move implementations of nextElementSibling and previousElementSibling here 52 from Element to make them shareable. 53 1 54 2015-05-08 Michael Catanzaro <mcatanzaro@igalia.com>, Martin Robinson <mrobinson@igalia.com> 2 55 -
trunk/Source/WebCore/dom/CharacterData.idl
r159061 r184034 38 38 [IsIndex, Default=Undefined] optional unsigned long length, 39 39 [Default=Undefined] optional DOMString data); 40 41 // From the NonDocumentTypeChildNode interface - https://dom.spec.whatwg.org/#nondocumenttypechildnode 42 // FIXME: Move this to a seperate NonDocumentTypeChildNode IDL file when one exists. 43 readonly attribute Element previousElementSibling; 44 readonly attribute Element nextElementSibling; 40 45 }; 41 46 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r183064 r184034 912 912 } 913 913 914 Element* ContainerNode::firstElementChild() const 915 { 916 ASSERT(is<Document>(*this) || is<DocumentFragment>(*this) || is<Element>(*this)); 917 918 return ElementTraversal::firstChild(*this); 919 } 920 921 Element* ContainerNode::lastElementChild() const 922 { 923 ASSERT(is<Document>(*this) || is<DocumentFragment>(*this) || is<Element>(*this)); 924 925 return ElementTraversal::lastChild(*this); 926 } 927 928 unsigned ContainerNode::childElementCount() const 929 { 930 ASSERT(is<Document>(*this) || is<DocumentFragment>(*this) || is<Element>(*this)); 931 932 unsigned count = 0; 933 Node* n = firstChild(); 934 while (n) { 935 count += n->isElementNode(); 936 n = n->nextSibling(); 937 } 938 return count; 939 } 940 914 941 } // namespace WebCore -
trunk/Source/WebCore/dom/ContainerNode.h
r183169 r184034 146 146 RefPtr<RadioNodeList> radioNodeList(const AtomicString&); 147 147 148 // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode 149 Element* firstElementChild() const; 150 Element* lastElementChild() const; 151 unsigned childElementCount() const; 152 148 153 protected: 149 154 explicit ContainerNode(Document&, ConstructionType = CreateContainer); -
trunk/Source/WebCore/dom/Document.idl
r183967 r184034 1 1 /* 2 * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2011, 2015 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> 4 4 * … … 343 343 readonly attribute DOMString origin; 344 344 345 // http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement 345 346 readonly attribute Element scrollingElement; 347 348 // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode 349 // FIXME: Move this to a seperate ParentNode IDL file when one exists. 350 readonly attribute Element firstElementChild; 351 readonly attribute Element lastElementChild; 352 readonly attribute unsigned long childElementCount; 346 353 }; 347 354 -
trunk/Source/WebCore/dom/DocumentFragment.idl
r177864 r184034 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 25 25 [RaisesException] Element querySelector(DOMString selectors); 26 26 [RaisesException] NodeList querySelectorAll(DOMString selectors); 27 28 // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode 29 // FIXME: Move this to a seperate ParentNode IDL file when one exists. 30 readonly attribute Element firstElementChild; 31 readonly attribute Element lastElementChild; 32 readonly attribute unsigned long childElementCount; 27 33 }; 28 34 -
trunk/Source/WebCore/dom/Element.cpp
r183706 r184034 2620 2620 } 2621 2621 2622 // ElementTraversal API2623 Element* Element::firstElementChild() const2624 {2625 return ElementTraversal::firstChild(*this);2626 }2627 2628 Element* Element::lastElementChild() const2629 {2630 return ElementTraversal::lastChild(*this);2631 }2632 2633 Element* Element::previousElementSibling() const2634 {2635 return ElementTraversal::previousSibling(*this);2636 }2637 2638 Element* Element::nextElementSibling() const2639 {2640 return ElementTraversal::nextSibling(*this);2641 }2642 2643 unsigned Element::childElementCount() const2644 {2645 unsigned count = 0;2646 Node* n = firstChild();2647 while (n) {2648 count += n->isElementNode();2649 n = n->nextSibling();2650 }2651 return count;2652 }2653 2654 2622 bool Element::matchesReadWritePseudoClass() const 2655 2623 { -
trunk/Source/WebCore/dom/Element.h
r183436 r184034 372 372 void didShadowTreeAwareChildrenChange(); 373 373 374 // ElementTraversal API375 Element* firstElementChild() const;376 Element* lastElementChild() const;377 Element* previousElementSibling() const;378 Element* nextElementSibling() const;379 unsigned childElementCount() const;380 381 374 virtual bool matchesReadWritePseudoClass() const; 382 375 bool matches(const String& selectors, ExceptionCode&); -
trunk/Source/WebCore/dom/Element.idl
r183021 r184034 128 128 [ImplementedAs=matches, RaisesException] boolean webkitMatchesSelector(DOMString selectors); 129 129 130 // ElementTraversal API 130 // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode 131 // FIXME: Move this to a seperate ParentNode IDL file when one exists. 131 132 readonly attribute Element firstElementChild; 132 133 readonly attribute Element lastElementChild; 134 readonly attribute unsigned long childElementCount; 135 136 // From the NonDocumentTypeChildNode interface - https://dom.spec.whatwg.org/#nondocumenttypechildnode 137 // FIXME: Move this to a seperate NonDocumentTypeChildNode IDL file when one exists. 133 138 readonly attribute Element previousElementSibling; 134 139 readonly attribute Element nextElementSibling; 135 readonly attribute unsigned long childElementCount;136 140 137 141 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT -
trunk/Source/WebCore/dom/Node.cpp
r183064 r184034 44 44 #include "ElementIterator.h" 45 45 #include "ElementRareData.h" 46 #include "ElementTraversal.h" 46 47 #include "EventDispatcher.h" 47 48 #include "EventException.h" … … 430 431 } 431 432 433 Element* Node::previousElementSibling() const 434 { 435 ASSERT(is<CharacterData>(*this) || is<Element>(*this)); 436 437 return ElementTraversal::previousSibling(*this); 438 } 439 440 Element* Node::nextElementSibling() const 441 { 442 ASSERT(is<CharacterData>(*this) || is<Element>(*this)); 443 444 return ElementTraversal::nextSibling(*this); 445 } 446 432 447 bool Node::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& ec) 433 448 { -
trunk/Source/WebCore/dom/Node.h
r183906 r184034 224 224 Node* firstDescendant() const; 225 225 226 // From the NonDocumentTypeChildNode - https://dom.spec.whatwg.org/#nondocumenttypechildnode 227 Element* previousElementSibling() const; 228 Element* nextElementSibling() const; 229 226 230 // Other methods (not part of DOM) 227 231
Note:
See TracChangeset
for help on using the changeset viewer.