Changeset 155292 in webkit


Ignore:
Timestamp:
Sep 8, 2013, 1:56:17 AM (11 years ago)
Author:
Antti Koivisto
Message:

Remove ComposedShadowTreeWalker
https://bugs.webkit.org/show_bug.cgi?id=120997

Reviewed by Andreas Kling.

Move the code to NodeRenderingTraversal which is the only client besides Internals.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.exp.in:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/ComposedShadowTreeWalker.cpp: Removed.
  • dom/ComposedShadowTreeWalker.h: Removed.
  • dom/NodeRenderingTraversal.cpp:

(WebCore::NodeRenderingTraversal::nodeCanBeDistributed):
(WebCore::NodeRenderingTraversal::findFirstSiblingEnteringInsertionPoints):
(WebCore::NodeRenderingTraversal::findFirstEnteringInsertionPoints):
(WebCore::NodeRenderingTraversal::findFirstFromDistributedNode):
(WebCore::NodeRenderingTraversal::findLastSiblingEnteringInsertionPoints):
(WebCore::NodeRenderingTraversal::findLastEnteringInsertionPoints):
(WebCore::NodeRenderingTraversal::findLastFromDistributedNode):
(WebCore::NodeRenderingTraversal::traverseParent):
(WebCore::NodeRenderingTraversal::traverseFirstChild):
(WebCore::NodeRenderingTraversal::traverseLastChild):
(WebCore::NodeRenderingTraversal::traverseNextSibling):
(WebCore::NodeRenderingTraversal::traversePreviousSibling):

Make former members of ComposedShadowTreeWalker standalone functions in NodeRenderingTraversal.

(WebCore::NodeRenderingTraversal::parentSlow):
(WebCore::NodeRenderingTraversal::nextSiblingSlow):
(WebCore::NodeRenderingTraversal::previousSiblingSlow):
(WebCore::NodeRenderingTraversal::nextInScope):
(WebCore::NodeRenderingTraversal::previousInScope):
(WebCore::NodeRenderingTraversal::parentInScope):
(WebCore::NodeRenderingTraversal::lastChildInScope):

  • testing/Internals.cpp:
  • testing/Internals.h:
  • testing/Internals.idl:
Location:
trunk/Source/WebCore
Files:
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r155248 r155292  
    11231123    dom/ClipboardEvent.cpp
    11241124    dom/Comment.cpp
    1125     dom/ComposedShadowTreeWalker.cpp
    11261125    dom/CompositionEvent.cpp
    11271126    dom/ContainerNode.cpp
  • trunk/Source/WebCore/ChangeLog

    r155289 r155292  
     12013-09-08  Antti Koivisto  <antti@apple.com>
     2
     3        Remove ComposedShadowTreeWalker
     4        https://bugs.webkit.org/show_bug.cgi?id=120997
     5
     6        Reviewed by Andreas Kling.
     7
     8        Move the code to NodeRenderingTraversal which is the only client besides Internals.
     9
     10        * CMakeLists.txt:
     11        * GNUmakefile.list.am:
     12        * Target.pri:
     13        * WebCore.exp.in:
     14        * WebCore.vcxproj/WebCore.vcxproj:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * dom/ComposedShadowTreeWalker.cpp: Removed.
     17        * dom/ComposedShadowTreeWalker.h: Removed.
     18        * dom/NodeRenderingTraversal.cpp:
     19        (WebCore::NodeRenderingTraversal::nodeCanBeDistributed):
     20        (WebCore::NodeRenderingTraversal::findFirstSiblingEnteringInsertionPoints):
     21        (WebCore::NodeRenderingTraversal::findFirstEnteringInsertionPoints):
     22        (WebCore::NodeRenderingTraversal::findFirstFromDistributedNode):
     23        (WebCore::NodeRenderingTraversal::findLastSiblingEnteringInsertionPoints):
     24        (WebCore::NodeRenderingTraversal::findLastEnteringInsertionPoints):
     25        (WebCore::NodeRenderingTraversal::findLastFromDistributedNode):
     26        (WebCore::NodeRenderingTraversal::traverseParent):
     27        (WebCore::NodeRenderingTraversal::traverseFirstChild):
     28        (WebCore::NodeRenderingTraversal::traverseLastChild):
     29        (WebCore::NodeRenderingTraversal::traverseNextSibling):
     30        (WebCore::NodeRenderingTraversal::traversePreviousSibling):
     31       
     32            Make former members of ComposedShadowTreeWalker standalone functions in NodeRenderingTraversal.
     33
     34        (WebCore::NodeRenderingTraversal::parentSlow):
     35        (WebCore::NodeRenderingTraversal::nextSiblingSlow):
     36        (WebCore::NodeRenderingTraversal::previousSiblingSlow):
     37        (WebCore::NodeRenderingTraversal::nextInScope):
     38        (WebCore::NodeRenderingTraversal::previousInScope):
     39        (WebCore::NodeRenderingTraversal::parentInScope):
     40        (WebCore::NodeRenderingTraversal::lastChildInScope):
     41        * testing/Internals.cpp:
     42        * testing/Internals.h:
     43        * testing/Internals.idl:
     44
    1452013-09-08  Andreas Kling  <akling@apple.com>
    246
  • trunk/Source/WebCore/GNUmakefile.list.am

    r155248 r155292  
    27982798        Source/WebCore/dom/Comment.cpp \
    27992799        Source/WebCore/dom/Comment.h \
    2800         Source/WebCore/dom/ComposedShadowTreeWalker.cpp \
    2801         Source/WebCore/dom/ComposedShadowTreeWalker.h \
    28022800        Source/WebCore/dom/CompositionEvent.cpp \
    28032801        Source/WebCore/dom/CompositionEvent.h \
  • trunk/Source/WebCore/Target.pri

    r155211 r155292  
    371371    dom/ClipboardEvent.cpp \
    372372    dom/Comment.cpp \
    373     dom/ComposedShadowTreeWalker.cpp \
    374373    dom/CompositionEvent.cpp \
    375374    dom/ContainerNode.cpp \
     
    15841583    dom/Clipboard.h \
    15851584    dom/Comment.h \
    1586     dom/ComposedShadowTreeWalker.h \
    15871585    dom/ContainerNode.h \
    15881586    dom/ContainerNodeAlgorithms.h \
  • trunk/Source/WebCore/WebCore.exp.in

    r155283 r155292  
    773773__ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
    774774__ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
    775 __ZN7WebCore24ComposedShadowTreeWalker10firstChildEv
    776 __ZN7WebCore24ComposedShadowTreeWalker11nextSiblingEv
    777 __ZN7WebCore24ComposedShadowTreeWalker4nextEv
    778 __ZN7WebCore24ComposedShadowTreeWalker8previousEv
    779 __ZN7WebCore24ComposedShadowTreeWalker9lastChildEv
    780775__ZN7WebCore24DocumentMarkerController10markersForEPNS_4NodeENS_14DocumentMarker11MarkerTypesE
    781776__ZN7WebCore24DocumentMarkerController13removeMarkersENS_14DocumentMarker11MarkerTypesE
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r155226 r155292  
    1216712167      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
    1216812168    </ClCompile>
    12169     <ClCompile Include="..\dom\ComposedShadowTreeWalker.cpp" />
    1217012169    <ClCompile Include="..\dom\CompositionEvent.cpp">
    1217112170      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
     
    2026520264    <ClInclude Include="..\dom\ClipboardEvent.h" />
    2026620265    <ClInclude Include="..\dom\Comment.h" />
    20267     <ClInclude Include="..\dom\ComposedShadowTreeWalker.h" />
    2026820266    <ClInclude Include="..\dom\CompositionEvent.h" />
    2026920267    <ClInclude Include="..\dom\ContainerNode.h" />
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r155229 r155292  
    15061506                4A5CB1C516C3A5FD00AB2886 /* EventRetargeter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A5CB1C316C3A5FD00AB2886 /* EventRetargeter.cpp */; };
    15071507                4A5CB1C616C3A5FD00AB2886 /* EventRetargeter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A5CB1C416C3A5FD00AB2886 /* EventRetargeter.h */; };
    1508                 4A6A0C5B15232F2400B09C6E /* ComposedShadowTreeWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */; };
    1509                 4A6A0C5C15232F2400B09C6E /* ComposedShadowTreeWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6A0C5A15232F2400B09C6E /* ComposedShadowTreeWalker.h */; };
    15101508                4A6E9FC313C17D1D0046A7F8 /* FontFeatureValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */; };
    15111509                4A6E9FC413C17D1D0046A7F8 /* FontFeatureValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    80228020                4A5CB1C316C3A5FD00AB2886 /* EventRetargeter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventRetargeter.cpp; sourceTree = "<group>"; };
    80238021                4A5CB1C416C3A5FD00AB2886 /* EventRetargeter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventRetargeter.h; sourceTree = "<group>"; };
    8024                 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComposedShadowTreeWalker.cpp; sourceTree = "<group>"; };
    8025                 4A6A0C5A15232F2400B09C6E /* ComposedShadowTreeWalker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposedShadowTreeWalker.h; sourceTree = "<group>"; };
    80268022                4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureValue.cpp; sourceTree = "<group>"; };
    80278023                4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFeatureValue.h; sourceTree = "<group>"; };
     
    2063020626                                6550B698099DF0270090D781 /* Comment.h */,
    2063120627                                85089CC70A98C22600A275AA /* Comment.idl */,
    20632                                 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */,
    20633                                 4A6A0C5A15232F2400B09C6E /* ComposedShadowTreeWalker.h */,
    2063420628                                79F2F59E1091939A000D87CB /* CompositionEvent.cpp */,
    2063520629                                79F2F59F1091939A000D87CB /* CompositionEvent.h */,
     
    2159521589                                979DC03716A7992E00807794 /* CompactHTMLToken.h in Headers */,
    2159621590                                37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */,
    21597                                 4A6A0C5C15232F2400B09C6E /* ComposedShadowTreeWalker.h in Headers */,
    2159821591                                316FE1160E6E1DA700BF6088 /* CompositeAnimation.h in Headers */,
    2159921592                                93309DDD099E64920056E581 /* CompositeEditCommand.h in Headers */,
     
    2510325096                                37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */,
    2510425097                                37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */,
    25105                                 4A6A0C5B15232F2400B09C6E /* ComposedShadowTreeWalker.cpp in Sources */,
    2510625098                                316FE1150E6E1DA700BF6088 /* CompositeAnimation.cpp in Sources */,
    2510725099                                93309DDC099E64920056E581 /* CompositeEditCommand.cpp in Sources */,
  • trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp

    r154541 r155292  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
     3 * Copyright (C) 2013 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2829#include "NodeRenderingTraversal.h"
    2930
    30 #include "ComposedShadowTreeWalker.h"
     31#include "InsertionPoint.h"
    3132#include "PseudoElement.h"
     33#include "ShadowRoot.h"
    3234
    3335namespace WebCore {
     
    3537namespace NodeRenderingTraversal {
    3638
     39static Node* findFirstSiblingEnteringInsertionPoints(const Node*);
     40static Node* findFirstEnteringInsertionPoints(const Node*);
     41static Node* findFirstFromDistributedNode(const Node*, const InsertionPoint*);
     42static Node* findLastSiblingEnteringInsertionPoints(const Node*);
     43static Node* findLastEnteringInsertionPoints(const Node*);
     44static Node* findLastFromDistributedNode(const Node*, const InsertionPoint*);
     45
     46static inline bool nodeCanBeDistributed(const Node* node)
     47{
     48    ASSERT(node);
     49    Node* parent = parentNodeForDistribution(node);
     50    if (!parent)
     51        return false;
     52
     53    if (parent->isShadowRoot())
     54        return false;
     55
     56    if (parent->isElementNode() && toElement(parent)->shadowRoot())
     57        return true;
     58   
     59    return false;
     60}
     61
     62static Node* findFirstSiblingEnteringInsertionPoints(const Node* node)
     63{
     64    for (const Node* sibling = node; sibling; sibling = sibling->nextSibling()) {
     65        if (Node* found = findFirstEnteringInsertionPoints(sibling))
     66            return found;
     67    }
     68    return nullptr;
     69}
     70
     71static Node* findFirstEnteringInsertionPoints(const Node* node)
     72{
     73    ASSERT(node);
     74    if (!isActiveInsertionPoint(node))
     75        return const_cast<Node*>(node);
     76    const InsertionPoint* insertionPoint = toInsertionPoint(node);
     77    if (Node* found = findFirstFromDistributedNode(insertionPoint->firstDistributed(), insertionPoint))
     78        return found;
     79    return findFirstSiblingEnteringInsertionPoints(node->firstChild());
     80}
     81
     82static Node* findFirstFromDistributedNode(const Node* node, const InsertionPoint* insertionPoint)
     83{
     84    for (const Node* next = node; next; next = insertionPoint->nextDistributedTo(next)) {
     85        if (Node* found = findFirstEnteringInsertionPoints(next))
     86            return found;
     87    }
     88    return nullptr;
     89}
     90
     91static Node* findLastSiblingEnteringInsertionPoints(const Node* node)
     92{
     93    for (const Node* sibling = node; sibling; sibling = sibling->previousSibling()) {
     94        if (Node* found = findLastEnteringInsertionPoints(sibling))
     95            return found;
     96    }
     97    return nullptr;
     98}
     99
     100static Node* findLastEnteringInsertionPoints(const Node* node)
     101{
     102    ASSERT(node);
     103    if (!isActiveInsertionPoint(node))
     104        return const_cast<Node*>(node);
     105    const InsertionPoint* insertionPoint = toInsertionPoint(node);
     106    if (Node* found = findLastFromDistributedNode(insertionPoint->lastDistributed(), insertionPoint))
     107        return found;
     108    return findLastSiblingEnteringInsertionPoints(node->lastChild());
     109}
     110
     111static Node* findLastFromDistributedNode(const Node* node, const InsertionPoint* insertionPoint)
     112{
     113    for (const Node* next = node; next; next = insertionPoint->previousDistributedTo(next)) {
     114        if (Node* found = findLastEnteringInsertionPoints(next))
     115            return found;
     116    }
     117    return nullptr;
     118}
     119
     120enum ShadowRootCrossing { CrossShadowRoot, DontCrossShadowRoot };
     121
     122static ContainerNode* traverseParent(const Node* node, ShadowRootCrossing shadowRootCrossing)
     123{
     124    if (node->isPseudoElement())
     125        return toPseudoElement(node)->hostElement();
     126
     127    if (shadowRootCrossing == DontCrossShadowRoot  && node->isShadowRoot())
     128        return 0;
     129
     130    if (nodeCanBeDistributed(node)) {
     131        if (InsertionPoint* insertionPoint = findInsertionPointOf(node))
     132            return traverseParent(insertionPoint, shadowRootCrossing);
     133        return nullptr;
     134    }
     135    ContainerNode* parent = node->parentNode();
     136    if (!parent)
     137        return nullptr;
     138
     139    if (parent->isShadowRoot())
     140        return shadowRootCrossing == CrossShadowRoot ? toShadowRoot(parent)->hostElement() : parent;
     141
     142    if (parent->isInsertionPoint()) {
     143        const InsertionPoint* insertionPoint = toInsertionPoint(parent);
     144        if (insertionPoint->hasDistribution())
     145            return nullptr;
     146        if (insertionPoint->isActive())
     147            return traverseParent(parent, shadowRootCrossing);
     148    }
     149    return parent;
     150}
     151
     152static Node* traverseFirstChild(const Node* node, ShadowRootCrossing shadowRootCrossing)
     153{
     154    ASSERT(node);
     155    if (node->shadowRoot()) {
     156        if (shadowRootCrossing == DontCrossShadowRoot)
     157            return nullptr;
     158        node = node->shadowRoot();
     159    }
     160    return findFirstSiblingEnteringInsertionPoints(node->firstChild());
     161}
     162
     163static Node* traverseLastChild(const Node* node, ShadowRootCrossing shadowRootCrossing)
     164{
     165    ASSERT(node);
     166    if (node->shadowRoot()) {
     167        if (shadowRootCrossing == DontCrossShadowRoot)
     168            return nullptr;
     169        node = node->shadowRoot();
     170    }
     171    return findLastSiblingEnteringInsertionPoints(node->lastChild());
     172}
     173
     174static Node* traverseNextSibling(const Node* node)
     175{
     176    ASSERT(node);
     177
     178    InsertionPoint* insertionPoint;
     179    if (nodeCanBeDistributed(node) && (insertionPoint = findInsertionPointOf(node))) {
     180        Node* found = findFirstFromDistributedNode(insertionPoint->nextDistributedTo(node), insertionPoint);
     181        if (found)
     182            return found;
     183        return traverseNextSibling(insertionPoint);
     184    }
     185
     186    for (const Node* sibling = node->nextSibling(); sibling; sibling = sibling->nextSibling()) {
     187        if (Node* found = findFirstEnteringInsertionPoints(sibling))
     188            return found;
     189    }
     190    if (node->parentNode() && isActiveInsertionPoint(node->parentNode()))
     191        return traverseNextSibling(node->parentNode());
     192
     193    return nullptr;
     194}
     195
     196static Node* traversePreviousSibling(const Node* node)
     197{
     198    ASSERT(node);
     199
     200    InsertionPoint* insertionPoint;
     201    if (nodeCanBeDistributed(node) && (insertionPoint = findInsertionPointOf(node))) {
     202        Node* found = findLastFromDistributedNode(insertionPoint->previousDistributedTo(node), insertionPoint);
     203        if (found)
     204            return found;
     205        return traversePreviousSibling(insertionPoint);
     206    }
     207
     208    for (const Node* sibling = node->previousSibling(); sibling; sibling = sibling->previousSibling()) {
     209        if (Node* found = findLastEnteringInsertionPoints(sibling))
     210            return found;
     211    }
     212    if (node->parentNode() && isActiveInsertionPoint(node->parentNode()))
     213        return traversePreviousSibling(node->parentNode());
     214
     215    return nullptr;
     216}
     217
    37218ContainerNode* parentSlow(const Node* node)
    38219{
    39     ComposedShadowTreeWalker walker(node, ComposedShadowTreeWalker::CrossUpperBoundary, ComposedShadowTreeWalker::CanStartFromShadowBoundary);
    40     return toContainerNode(walker.traverseParent(walker.get()));
     220    ASSERT(!node->isShadowRoot());
     221
     222    return traverseParent(node, CrossShadowRoot);
    41223}
    42224
    43225Node* nextSiblingSlow(const Node* node)
    44226{
    45     ComposedShadowTreeWalker walker(node);
     227    ASSERT(!node->isShadowRoot());
     228
     229    // FIXME: Why do these functions deal with before/after when other code here doesn't?
     230    Node* nextSibling = 0;
    46231    if (node->isBeforePseudoElement()) {
    47         walker.parent();
    48         walker.firstChild();
     232        nextSibling = traverseParent(node, CrossShadowRoot);
     233        nextSibling = traverseFirstChild(nextSibling, CrossShadowRoot);
    49234    } else
    50         walker.nextSibling();
    51 
    52     if (walker.get() || node->isAfterPseudoElement())
    53         return walker.get();
    54 
    55     Node* parent = walker.traverseParent(node);
     235        nextSibling = traverseNextSibling(node);
     236
     237    if (nextSibling || node->isAfterPseudoElement())
     238        return nextSibling;
     239
     240    Node* parent = traverseParent(node, CrossShadowRoot);
    56241    if (parent && parent->isElementNode())
    57242        return toElement(parent)->afterPseudoElement();
     
    62247Node* previousSiblingSlow(const Node* node)
    63248{
    64     ComposedShadowTreeWalker walker(node);
     249    ASSERT(!node->isShadowRoot());
     250
     251    Node* previousSibling = 0;
    65252    if (node->isAfterPseudoElement()) {
    66         walker.parent();
    67         walker.lastChild();
     253        ContainerNode* parent = traverseParent(node, CrossShadowRoot);
     254        previousSibling = traverseLastChild(parent, CrossShadowRoot);
    68255    } else
    69         walker.previousSibling();
    70 
    71     if (walker.get() || node->isBeforePseudoElement())
    72         return walker.get();
    73 
    74     Node* parent = walker.traverseParent(node);
     256        previousSibling = traversePreviousSibling(node);
     257
     258    if (previousSibling || node->isBeforePseudoElement())
     259        return previousSibling;
     260
     261    ContainerNode* parent = traverseParent(node, CrossShadowRoot);
    75262    if (parent && parent->isElementNode())
    76263        return toElement(parent)->beforePseudoElement();
     
    81268Node* nextInScope(const Node* node)
    82269{
    83     // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
    84     ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
    85     walker.next();
    86     return walker.get();
     270    ASSERT(!isActiveInsertionPoint(node));
     271
     272    if (Node* next = traverseFirstChild(node, DontCrossShadowRoot))
     273        return next;
     274    if (Node* next = traverseNextSibling(node))
     275        return next;
     276    const Node* current = node;
     277    while (current && !traverseNextSibling(current))
     278        current = traverseParent(current, DontCrossShadowRoot);
     279    return current ? traverseNextSibling(current) : 0;
    87280}
    88281
    89282Node* previousInScope(const Node* node)
    90283{
    91     // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
    92     ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
    93     walker.previous();
    94     return walker.get();
     284    ASSERT(!isActiveInsertionPoint(node));
     285
     286    if (Node* current = traversePreviousSibling(node)) {
     287        while (Node* child = traverseLastChild(current, DontCrossShadowRoot))
     288            current = child;
     289        return current;
     290    }
     291    return traverseParent(node, DontCrossShadowRoot);
    95292}
    96293
    97294Node* parentInScope(const Node* node)
    98295{
    99     // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
    100     ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
    101     walker.parent();
    102     return walker.get();
     296    ASSERT(!isActiveInsertionPoint(node));
     297
     298    return traverseParent(node, DontCrossShadowRoot);
    103299}
    104300
    105301Node* lastChildInScope(const Node* node)
    106302{
    107     // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
    108     ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
    109     walker.lastChild();
    110     return walker.get();
     303    ASSERT(!isActiveInsertionPoint(node));
     304
     305    return traverseLastChild(node, DontCrossShadowRoot);
    111306}
    112307
  • trunk/Source/WebCore/testing/Internals.cpp

    r155228 r155292  
    3535#include "ClientRect.h"
    3636#include "ClientRectList.h"
    37 #include "ComposedShadowTreeWalker.h"
    3837#include "ContentDistributor.h"
    3938#include "Cursor.h"
     
    511510}
    512511
    513 Node* Internals::nextSiblingByWalker(Node* node, ExceptionCode& ec)
    514 {
    515     if (!node) {
    516         ec = INVALID_ACCESS_ERR;
    517         return 0;
    518     }
    519     ComposedShadowTreeWalker walker(node);
    520     walker.nextSibling();
    521     return walker.get();
    522 }
    523 
    524 Node* Internals::firstChildByWalker(Node* node, ExceptionCode& ec)
    525 {
    526     if (!node) {
    527         ec = INVALID_ACCESS_ERR;
    528         return 0;
    529     }
    530     ComposedShadowTreeWalker walker(node);
    531     walker.firstChild();
    532     return walker.get();
    533 }
    534 
    535 Node* Internals::lastChildByWalker(Node* node, ExceptionCode& ec)
    536 {
    537     if (!node) {
    538         ec = INVALID_ACCESS_ERR;
    539         return 0;
    540     }
    541     ComposedShadowTreeWalker walker(node);
    542     walker.lastChild();
    543     return walker.get();
    544 }
    545 
    546 Node* Internals::nextNodeByWalker(Node* node, ExceptionCode& ec)
    547 {
    548     if (!node) {
    549         ec = INVALID_ACCESS_ERR;
    550         return 0;
    551     }
    552     ComposedShadowTreeWalker walker(node);
    553     walker.next();
    554     return walker.get();
    555 }
    556 
    557 Node* Internals::previousNodeByWalker(Node* node, ExceptionCode& ec)
    558 {
    559     if (!node) {
    560         ec = INVALID_ACCESS_ERR;
    561         return 0;
    562     }
    563     ComposedShadowTreeWalker walker(node);
    564     walker.previous();
    565     return walker.get();
    566 }
    567 
    568512String Internals::elementRenderTreeAsText(Element* element, ExceptionCode& ec)
    569513{
  • trunk/Source/WebCore/testing/Internals.h

    r154921 r155292  
    121121    bool attached(Node*, ExceptionCode&);
    122122
    123     // FIXME: Rename these functions if walker is prefered.
    124     Node* nextSiblingByWalker(Node*, ExceptionCode&);
    125     Node* firstChildByWalker(Node*, ExceptionCode&);
    126     Node* lastChildByWalker(Node*, ExceptionCode&);
    127     Node* nextNodeByWalker(Node*, ExceptionCode&);
    128     Node* previousNodeByWalker(Node*, ExceptionCode&);
    129 
    130123    String visiblePlaceholder(Element*);
    131124#if ENABLE(INPUT_TYPE_COLOR)
  • trunk/Source/WebCore/testing/Internals.idl

    r154921 r155292  
    7070    [RaisesException] boolean pauseTransitionAtTimeOnPseudoElement(DOMString property, double pauseTime, Element element, DOMString pseudoId);
    7171
    72     [RaisesException] Node nextSiblingByWalker(Node node);
    73     [RaisesException] Node firstChildByWalker(Node node);
    74     [RaisesException] Node lastChildByWalker(Node node);
    75     [RaisesException] Node nextNodeByWalker(Node node);
    76     [RaisesException] Node previousNodeByWalker(Node node);
    77 
    7872    [RaisesException] boolean attached(Node node);
    7973
Note: See TracChangeset for help on using the changeset viewer.