Implement iterator for traversing composed DOM
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 13:12:25 +0000 (13:12 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 13:12:25 +0000 (13:12 +0000)
commit41a524d8e88ec74bf0a3f58df5addd8d3c4d8564
tree094578cf5d277d171a11c61646b59038791c7b1c
parent30444a18821e581454412bed5dc6b87f64b4fded
Implement iterator for traversing composed DOM
https://bugs.webkit.org/show_bug.cgi?id=149997

Reviewed by Ryosuke Niwa.

Source/WebCore:

ComposedTreeIterator traverses the DOM in composed tree order. This means it enters
shadow trees and follows slots created by Shadow DOM API correctly.

auto children = composedTreeChildren(containerNode);
for (auto& composedChild : children)
    ...

auto descendants = composedTreeDescendants(containerNode);
for (auto& composedDescendant : descendants)
    ...

* WebCore.xcodeproj/project.pbxproj:
* dom/ComposedTreeIterator.cpp: Added.
(WebCore::ComposedTreeIterator::initializeShadowStack):
(WebCore::ComposedTreeIterator::traverseNextInShadowTree):
(WebCore::ComposedTreeIterator::traverseNextSiblingSlot):
(WebCore::ComposedTreeIterator::traversePreviousSiblingSlot):
(WebCore::ComposedTreeIterator::traverseParentInShadowTree):
* dom/ComposedTreeIterator.h: Added.
(WebCore::ComposedTreeIterator::operator*):
(WebCore::ComposedTreeIterator::operator->):
(WebCore::ComposedTreeIterator::operator==):
(WebCore::ComposedTreeIterator::operator!=):
(WebCore::ComposedTreeIterator::ShadowContext::ShadowContext):
(WebCore::ComposedTreeIterator::ComposedTreeIterator):
(WebCore::ComposedTreeIterator::traverseNext):
(WebCore::ComposedTreeIterator::traverseNextSibling):
(WebCore::ComposedTreeIterator::traversePreviousSibling):
(WebCore::ComposedTreeIterator::traverseParent):
(WebCore::ComposedTreeChildAdapter::Iterator::Iterator):
(WebCore::ComposedTreeChildAdapter::Iterator::operator++):
(WebCore::ComposedTreeChildAdapter::Iterator::operator--):
(WebCore::ComposedTreeChildAdapter::ComposedTreeChildAdapter):
(WebCore::ComposedTreeChildAdapter::begin):
(WebCore::ComposedTreeChildAdapter::end):
(WebCore::ComposedTreeChildAdapter::at):
(WebCore::composedTreeChildren):
* dom/NodeRenderingTraversal.cpp:
(WebCore::NodeRenderingTraversal::parentSlow):
(WebCore::NodeRenderingTraversal::nextInScope):
(WebCore::NodeRenderingTraversal::firstChildSlow): Deleted.
(WebCore::NodeRenderingTraversal::nextSiblingSlow): Deleted.
(WebCore::NodeRenderingTraversal::previousSiblingSlow): Deleted.
* dom/NodeRenderingTraversal.h:
(WebCore::NodeRenderingTraversal::parent):
(WebCore::NodeRenderingTraversal::firstChild): Deleted.
(WebCore::NodeRenderingTraversal::nextSibling): Deleted.
(WebCore::NodeRenderingTraversal::previousSibling): Deleted.
* style/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):

    Restore the full assert.

(WebCore::RenderTreePosition::invalidateNextSibling):
(WebCore::RenderTreePosition::previousSiblingRenderer):
(WebCore::RenderTreePosition::nextSiblingRenderer):

    Make these member functions.
    Use the iterator. This is fixes some bugs and allows enabling a test case.

* style/RenderTreePosition.h:
* style/StyleResolveTree.cpp:
(WebCore::Style::textRendererIsNeeded):

LayoutTests:

* TestExpectations:

    Re-enable fast/html/details-replace-text.html which is fixed by this change.

* fast/forms/select-listbox-focus-displaynone-expected.txt:
* fast/repaint/text-in-relative-positioned-inline-expected.txt:
* fullscreen/full-screen-fixed-pos-parent-expected.txt:
* platform/mac-mavericks/fast/html/details-open2-expected.txt:
* platform/mac/fast/html/details-add-child-2-expected.txt:
* platform/mac/fast/html/details-open2-expected.txt:

    Non-visual whitespace changes.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/forms/select-listbox-focus-displaynone-expected.txt
LayoutTests/fast/repaint/text-in-relative-positioned-inline-expected.txt
LayoutTests/fullscreen/full-screen-fixed-pos-parent-expected.txt
LayoutTests/platform/mac-mavericks/fast/html/details-open2-expected.txt
LayoutTests/platform/mac/fast/html/details-add-child-2-expected.txt
LayoutTests/platform/mac/fast/html/details-open2-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/ComposedTreeIterator.cpp [new file with mode: 0644]
Source/WebCore/dom/ComposedTreeIterator.h [new file with mode: 0644]
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/NodeRenderingTraversal.cpp
Source/WebCore/dom/NodeRenderingTraversal.h
Source/WebCore/style/RenderTreePosition.cpp
Source/WebCore/style/RenderTreePosition.h
Source/WebCore/style/StyleResolveTree.cpp