Changeset 190983 in webkit


Ignore:
Timestamp:
Oct 13, 2015, 6:12:25 AM (9 years ago)
Author:
Antti Koivisto
Message:

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:

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.

Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190915 r190983  
     12015-10-12  Antti Koivisto  <antti@apple.com>
     2
     3        Implement iterator for traversing composed DOM
     4        https://bugs.webkit.org/show_bug.cgi?id=149997
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * TestExpectations:
     9
     10            Re-enable fast/html/details-replace-text.html which is fixed by this change.
     11
     12        * fast/forms/select-listbox-focus-displaynone-expected.txt:
     13        * fast/repaint/text-in-relative-positioned-inline-expected.txt:
     14        * fullscreen/full-screen-fixed-pos-parent-expected.txt:
     15        * platform/mac-mavericks/fast/html/details-open2-expected.txt:
     16        * platform/mac/fast/html/details-add-child-2-expected.txt:
     17        * platform/mac/fast/html/details-open2-expected.txt:
     18
     19            Non-visual whitespace changes.
     20
    1212015-10-12  Zalan Bujtas  <zalan@apple.com>
    222
  • trunk/LayoutTests/TestExpectations

    r190840 r190983  
    673673
    674674webkit.org/b/148695 fast/shadow-dom [ Failure ImageOnlyFailure ]
    675 webkit.org/b/149997 fast/html/details-replace-text.html [ Failure ]
    676675
    677676# Marks as flaky (see also https://bugs.webkit.org/show_bug.cgi?id=132388)
  • trunk/LayoutTests/fast/forms/select-listbox-focus-displaynone-expected.txt

    r166174 r190983  
    1   PASS
     1 PASS
  • trunk/LayoutTests/fast/repaint/text-in-relative-positioned-inline-expected.txt

    r166174 r190983  
    55    RenderBody {BODY} at (8,8) size 784x584
    66      RenderBlock {DIV} at (100,0) size 684x100
    7         RenderText {#text} at (0,0) size 0x0
    87      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
  • trunk/LayoutTests/fullscreen/full-screen-fixed-pos-parent-expected.txt

    r166174 r190983  
    11
    2 
  • trunk/LayoutTests/platform/mac-mavericks/fast/html/details-open2-expected.txt

    r190840 r190983  
    1111        RenderBlock (anonymous) at (0,18) size 784x23
    1212          RenderTextControl {INPUT} at (2,2) size 146x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     13          RenderText {#text} at (0,0) size 0x0
     14          RenderText {#text} at (0,0) size 0x0
    1315layer at (13,31) size 139x13
    1416  RenderBlock {DIV} at (3,3) size 140x13
  • trunk/LayoutTests/platform/mac/fast/html/details-add-child-2-expected.txt

    r190840 r190983  
    1313            RenderText {#text} at (0,0) size 144x18
    1414              text run at (0,0) width 144: "should have bold test"
     15          RenderText {#text} at (0,0) size 0x0
     16          RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/fast/html/details-open2-expected.txt

    r190840 r190983  
    1111        RenderBlock (anonymous) at (0,18) size 784x23
    1212          RenderTextControl {INPUT} at (2,2) size 137x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     13          RenderText {#text} at (0,0) size 0x0
     14          RenderText {#text} at (0,0) size 0x0
    1315layer at (13,31) size 130x13
    1416  RenderBlock {DIV} at (3,3) size 131x13
  • trunk/Source/WebCore/CMakeLists.txt

    r190884 r190983  
    14131413    dom/CollectionIndexCache.cpp
    14141414    dom/Comment.cpp
     1415    dom/ComposedTreeIterator.cpp
    14151416    dom/CompositionEvent.cpp
    14161417    dom/ContainerNode.cpp
  • trunk/Source/WebCore/ChangeLog

    r190970 r190983  
     12015-10-12  Antti Koivisto  <antti@apple.com>
     2
     3        Implement iterator for traversing composed DOM
     4        https://bugs.webkit.org/show_bug.cgi?id=149997
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        ComposedTreeIterator traverses the DOM in composed tree order. This means it enters
     9        shadow trees and follows slots created by Shadow DOM API correctly.
     10
     11        auto children = composedTreeChildren(containerNode);
     12        for (auto& composedChild : children)
     13            ...
     14
     15        auto descendants = composedTreeDescendants(containerNode);
     16        for (auto& composedDescendant : descendants)
     17            ...
     18
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * dom/ComposedTreeIterator.cpp: Added.
     21        (WebCore::ComposedTreeIterator::initializeShadowStack):
     22        (WebCore::ComposedTreeIterator::traverseNextInShadowTree):
     23        (WebCore::ComposedTreeIterator::traverseNextSiblingSlot):
     24        (WebCore::ComposedTreeIterator::traversePreviousSiblingSlot):
     25        (WebCore::ComposedTreeIterator::traverseParentInShadowTree):
     26        * dom/ComposedTreeIterator.h: Added.
     27        (WebCore::ComposedTreeIterator::operator*):
     28        (WebCore::ComposedTreeIterator::operator->):
     29        (WebCore::ComposedTreeIterator::operator==):
     30        (WebCore::ComposedTreeIterator::operator!=):
     31        (WebCore::ComposedTreeIterator::ShadowContext::ShadowContext):
     32        (WebCore::ComposedTreeIterator::ComposedTreeIterator):
     33        (WebCore::ComposedTreeIterator::traverseNext):
     34        (WebCore::ComposedTreeIterator::traverseNextSibling):
     35        (WebCore::ComposedTreeIterator::traversePreviousSibling):
     36        (WebCore::ComposedTreeIterator::traverseParent):
     37        (WebCore::ComposedTreeChildAdapter::Iterator::Iterator):
     38        (WebCore::ComposedTreeChildAdapter::Iterator::operator++):
     39        (WebCore::ComposedTreeChildAdapter::Iterator::operator--):
     40        (WebCore::ComposedTreeChildAdapter::ComposedTreeChildAdapter):
     41        (WebCore::ComposedTreeChildAdapter::begin):
     42        (WebCore::ComposedTreeChildAdapter::end):
     43        (WebCore::ComposedTreeChildAdapter::at):
     44        (WebCore::composedTreeChildren):
     45        * dom/NodeRenderingTraversal.cpp:
     46        (WebCore::NodeRenderingTraversal::parentSlow):
     47        (WebCore::NodeRenderingTraversal::nextInScope):
     48        (WebCore::NodeRenderingTraversal::firstChildSlow): Deleted.
     49        (WebCore::NodeRenderingTraversal::nextSiblingSlow): Deleted.
     50        (WebCore::NodeRenderingTraversal::previousSiblingSlow): Deleted.
     51        * dom/NodeRenderingTraversal.h:
     52        (WebCore::NodeRenderingTraversal::parent):
     53        (WebCore::NodeRenderingTraversal::firstChild): Deleted.
     54        (WebCore::NodeRenderingTraversal::nextSibling): Deleted.
     55        (WebCore::NodeRenderingTraversal::previousSibling): Deleted.
     56        * style/RenderTreePosition.cpp:
     57        (WebCore::RenderTreePosition::computeNextSibling):
     58
     59            Restore the full assert.
     60
     61        (WebCore::RenderTreePosition::invalidateNextSibling):
     62        (WebCore::RenderTreePosition::previousSiblingRenderer):
     63        (WebCore::RenderTreePosition::nextSiblingRenderer):
     64
     65            Make these member functions.
     66            Use the iterator. This is fixes some bugs and allows enabling a test case.
     67
     68        * style/RenderTreePosition.h:
     69        * style/StyleResolveTree.cpp:
     70        (WebCore::Style::textRendererIsNeeded):
     71
    1722015-10-13  ChangSeok Oh  <changseok.oh@collabora.com>
    273
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r190845 r190983  
    1 <?xml version="1.0" encoding="utf-8"?>
     1<?xml version="1.0" encoding="utf-8"?>
    22<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    33  <ItemGroup Label="ProjectConfigurations">
     
    1370513705      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
    1370613706      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     13707    </ClCompile>
     13708    <ClCompile Include="..\dom\ComposedTreeIterator.cpp">
     13709        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
     13710        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
     13711        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
     13712        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
     13713        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
     13714        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
     13715        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
     13716        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     13717        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
     13718        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
     13719        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
     13720        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
    1370713721    </ClCompile>
    1370813722    <ClCompile Include="..\dom\CompositionEvent.cpp">
     
    2195021964    <ClInclude Include="..\dom\CollectionIndexCache.h" />
    2195121965    <ClInclude Include="..\dom\Comment.h" />
     21966    <ClInclude Include="..\dom\ComposedTreeIterator.h" />
    2195221967    <ClInclude Include="..\dom\CompositionEvent.h" />
    2195321968    <ClInclude Include="..\dom\ContainerNode.h" />
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r190884 r190983  
    64236423                E44B4BB4141650D7002B1D8B /* SelectorChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = E44B4BB2141650D7002B1D8B /* SelectorChecker.h */; };
    64246424                E44EE3A817577EBD00EEE8CF /* FontGenericFamilies.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44EE3A617576E5500EEE8CF /* FontGenericFamilies.cpp */; };
     6425                E44FA1851BCA6B5A0091B6EF /* ComposedTreeIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E44FA1841BCA6B5A0091B6EF /* ComposedTreeIterator.h */; settings = {ASSET_TAGS = (); }; };
     6426                E44FA1871BCA91560091B6EF /* ComposedTreeIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44FA1861BCA91560091B6EF /* ComposedTreeIterator.cpp */; settings = {ASSET_TAGS = (); }; };
    64256427                E45322AB140CE267005A0F92 /* SelectorQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E45322A9140CE267005A0F92 /* SelectorQuery.cpp */; };
    64266428                E45322AC140CE267005A0F92 /* SelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = E45322AA140CE267005A0F92 /* SelectorQuery.h */; };
     
    1424114243                E44EE3A617576E5500EEE8CF /* FontGenericFamilies.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontGenericFamilies.cpp; sourceTree = "<group>"; };
    1424214244                E44EE3A717576E5500EEE8CF /* FontGenericFamilies.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontGenericFamilies.h; sourceTree = "<group>"; };
     14245                E44FA1841BCA6B5A0091B6EF /* ComposedTreeIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposedTreeIterator.h; sourceTree = "<group>"; };
     14246                E44FA1861BCA91560091B6EF /* ComposedTreeIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComposedTreeIterator.cpp; sourceTree = "<group>"; };
    1424314247                E45322A9140CE267005A0F92 /* SelectorQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorQuery.cpp; sourceTree = "<group>"; };
    1424414248                E45322AA140CE267005A0F92 /* SelectorQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorQuery.h; sourceTree = "<group>"; };
     
    2352623530                                6550B698099DF0270090D781 /* Comment.h */,
    2352723531                                85089CC70A98C22600A275AA /* Comment.idl */,
     23532                                E44FA1861BCA91560091B6EF /* ComposedTreeIterator.cpp */,
     23533                                E44FA1841BCA6B5A0091B6EF /* ComposedTreeIterator.h */,
    2352823534                                79F2F59E1091939A000D87CB /* CompositionEvent.cpp */,
    2352923535                                79F2F59F1091939A000D87CB /* CompositionEvent.h */,
     
    2612426130                                A83B79050CCAFF15000B0825 /* JSSVGFontFaceElement.h in Headers */,
    2612526131                                A83B79000CCAFF15000B0825 /* JSSVGFontFaceFormatElement.h in Headers */,
     26132                                E44FA1851BCA6B5A0091B6EF /* ComposedTreeIterator.h in Headers */,
    2612626133                                A83B79020CCAFF15000B0825 /* JSSVGFontFaceNameElement.h in Headers */,
    2612726134                                A83B78FE0CCAFF15000B0825 /* JSSVGFontFaceSrcElement.h in Headers */,
     
    2998129988                                A513B3D8114B166A001C429B /* KeyEventCocoa.mm in Sources */,
    2998229989                                2655413A1489811C000DFC5D /* KeyEventIOS.mm in Sources */,
     29990                                E44FA1871BCA91560091B6EF /* ComposedTreeIterator.cpp in Sources */,
    2998329991                                935C477009AC4D7300A6AAB4 /* KeyEventMac.mm in Sources */,
    2998429992                                316FE1190E6E1DA700BF6088 /* KeyframeAnimation.cpp in Sources */,
  • trunk/Source/WebCore/dom/DOMAllInOne.cpp

    r190840 r190983  
    4343#include "CollectionIndexCache.cpp"
    4444#include "Comment.cpp"
     45#include "ComposedTreeIterator.cpp"
    4546#include "CompositionEvent.cpp"
    4647#include "ContainerNode.cpp"
  • trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp

    r190845 r190983  
    9696}
    9797
    98 Node* firstChildSlow(const Node* node)
    99 {
    100     ASSERT(!node->isShadowRoot());
    101 
    102     return traverseFirstChild(node, DontCrossShadowRoot);
    103 }
    104 
    105 Node* nextSiblingSlow(const Node* node)
    106 {
    107     ASSERT(!node->isShadowRoot());
    108 
    109     return traverseNextSibling(node);
    110 }
    111 
    112 Node* previousSiblingSlow(const Node* node)
    113 {
    114     ASSERT(!node->isShadowRoot());
    115 
    116     return traversePreviousSibling(node);
    117 }
    118 
    11998Node* nextInScope(const Node* node)
    12099{
  • trunk/Source/WebCore/dom/NodeRenderingTraversal.h

    r165465 r190983  
    3636
    3737ContainerNode* parent(const Node*);
    38 Node* firstChild(const Node*);
    39 Node* nextSibling(const Node*);
    40 Node* previousSibling(const Node*);
    4138
    4239Node* nextInScope(const Node*);
     
    4643
    4744ContainerNode* parentSlow(const Node*);
    48 Node* firstChildSlow(const Node*);
    49 Node* nextSiblingSlow(const Node*);
    50 Node* previousSiblingSlow(const Node*);
    5145
    5246inline ContainerNode* parent(const Node* node)
     
    6054}
    6155
    62 inline Node* firstChild(const Node* node)
    63 {
    64     ASSERT(!node->isPseudoElement());
    65     if (node->needsNodeRenderingTraversalSlowPath())
    66         return firstChildSlow(node);
    67 
    68     ASSERT(nextSiblingSlow(node) == node->nextSibling());
    69     return node->firstChild();
    70 }
    71 
    72 inline Node* nextSibling(const Node* node)
    73 {
    74     ASSERT(!node->isPseudoElement());
    75     if (node->needsNodeRenderingTraversalSlowPath())
    76         return nextSiblingSlow(node);
    77 
    78     ASSERT(nextSiblingSlow(node) == node->nextSibling());
    79     return node->nextSibling();
    80 }
    81 
    82 inline Node* previousSibling(const Node* node)
    83 {
    84     ASSERT(!node->isPseudoElement());
    85     if (node->needsNodeRenderingTraversalSlowPath())
    86         return previousSiblingSlow(node);
    87 
    88     ASSERT(previousSiblingSlow(node) == node->previousSibling());
    89     return node->previousSibling();
    90 }
    91 
    9256}
    9357
  • trunk/Source/WebCore/style/RenderTreePosition.cpp

    r190840 r190983  
    2727#include "RenderTreePosition.h"
    2828
     29#include "ComposedTreeIterator.h"
    2930#include "NodeRenderingTraversal.h"
    3031#include "PseudoElement.h"
     
    4142        const unsigned oNSquaredAvoidanceLimit = 20;
    4243        bool skipAssert = m_parent.isRenderView() || ++m_assertionLimitCounter > oNSquaredAvoidanceLimit;
    43         // FIXME: Traversal needs to know about slots and this needs be removed.
    44         skipAssert = skipAssert || (node.parentElement() && node.parentElement()->shadowRoot());
    45 
    46         ASSERT(skipAssert || nextSiblingRenderer(node, m_parent) == m_nextSibling);
     44        ASSERT(skipAssert || nextSiblingRenderer(node) == m_nextSibling);
    4745#endif
    4846        return;
    4947    }
    50     m_nextSibling = nextSiblingRenderer(node, m_parent);
     48    m_nextSibling = nextSiblingRenderer(node);
    5149    m_hasValidNextSibling = true;
    5250}
     
    6058}
    6159
    62 RenderObject* RenderTreePosition::previousSiblingRenderer(const Text& textNode)
     60RenderObject* RenderTreePosition::previousSiblingRenderer(const Text& textNode) const
    6361{
    6462    if (textNode.renderer())
    6563        return textNode.renderer()->previousSibling();
    66     for (Node* sibling = NodeRenderingTraversal::previousSibling(&textNode); sibling; sibling = NodeRenderingTraversal::previousSibling(sibling)) {
    67         RenderObject* renderer = sibling->renderer();
     64
     65    auto* parentElement = m_parent.element();
     66
     67    auto composedChildren = composedTreeChildren(*parentElement);
     68    for (auto it = composedChildren.at(textNode), end = composedChildren.end(); it != end; --it) {
     69        RenderObject* renderer = it->renderer();
    6870        if (renderer && !RenderTreePosition::isRendererReparented(*renderer))
    6971            return renderer;
    7072    }
    71     if (auto* parent = textNode.parentElement()) {
    72         if (auto* before = parent->beforePseudoElement())
    73             return before->renderer();
    74     }
     73    if (auto* before = parentElement->beforePseudoElement())
     74        return before->renderer();
    7575    return nullptr;
    7676}
    7777
    78 RenderObject* RenderTreePosition::nextSiblingRenderer(const Node& node, const RenderElement& parentRenderer)
     78RenderObject* RenderTreePosition::nextSiblingRenderer(const Node& node) const
    7979{
    80     if (!parentRenderer.element())
     80    auto* parentElement = m_parent.element();
     81    if (!parentElement)
    8182        return nullptr;
    8283    if (node.isAfterPseudoElement())
    8384        return nullptr;
    84     Node* sibling = node.isBeforePseudoElement() ? NodeRenderingTraversal::firstChild(parentRenderer.element()) : NodeRenderingTraversal::nextSibling(&node);
    85     for (; sibling; sibling = NodeRenderingTraversal::nextSibling(sibling)) {
    86         RenderObject* renderer = sibling->renderer();
     85
     86    auto composedChildren = composedTreeChildren(*parentElement);
     87
     88    auto it = node.isBeforePseudoElement() ? composedChildren.begin() : composedChildren.at(node);
     89    for (auto end = composedChildren.end(); it != end; ++it) {
     90        RenderObject* renderer = it->renderer();
    8791        if (renderer && !isRendererReparented(*renderer))
    8892            return renderer;
    8993    }
    90     if (PseudoElement* after = parentRenderer.element()->afterPseudoElement())
     94    if (PseudoElement* after = parentElement->afterPseudoElement())
    9195        return after->renderer();
    9296    return nullptr;
  • trunk/Source/WebCore/style/RenderTreePosition.h

    r183160 r190983  
    6262    void invalidateNextSibling(const RenderObject&);
    6363
    64     static RenderObject* previousSiblingRenderer(const Text&);
    65     static RenderObject* nextSiblingRenderer(const Node&, const RenderElement& parentRenderer);
     64    RenderObject* previousSiblingRenderer(const Text&) const;
     65    RenderObject* nextSiblingRenderer(const Node&) const;
    6666    static bool isRendererReparented(const RenderObject&);
    6767
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r190840 r190983  
    3131#include "AuthorStyleSheets.h"
    3232#include "CSSFontSelector.h"
     33#include "ComposedTreeIterator.h"
    3334#include "ElementIterator.h"
    3435#include "ElementRareData.h"
     
    263264        return true;
    264265
    265     RenderObject* previousRenderer = RenderTreePosition::previousSiblingRenderer(textNode);
     266    RenderObject* previousRenderer = renderTreePosition.previousSiblingRenderer(textNode);
    266267    if (previousRenderer && previousRenderer->isBR()) // <span><br/> <br/></span>
    267268        return false;
     
    278279        while (first && first->isFloatingOrOutOfFlowPositioned())
    279280            first = first->nextSibling();
    280         RenderObject* nextRenderer = RenderTreePosition::nextSiblingRenderer(textNode, parentRenderer);
     281        RenderObject* nextRenderer = renderTreePosition.nextSiblingRenderer(textNode);
    281282        if (!first || nextRenderer == first) {
    282283            // Whitespace at the start of a block just goes away. Don't even make a render object for this text.
Note: See TracChangeset for help on using the changeset viewer.