Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (155291 => 155292)
--- trunk/Source/WebCore/CMakeLists.txt 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/CMakeLists.txt 2013-09-08 08:56:17 UTC (rev 155292)
@@ -1122,7 +1122,6 @@
dom/Clipboard.cpp
dom/ClipboardEvent.cpp
dom/Comment.cpp
- dom/ComposedShadowTreeWalker.cpp
dom/CompositionEvent.cpp
dom/ContainerNode.cpp
dom/ContainerNodeAlgorithms.cpp
Modified: trunk/Source/WebCore/ChangeLog (155291 => 155292)
--- trunk/Source/WebCore/ChangeLog 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/ChangeLog 2013-09-08 08:56:17 UTC (rev 155292)
@@ -1,3 +1,47 @@
+2013-09-08 Antti Koivisto <[email protected]>
+
+ 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:
+
2013-09-08 Andreas Kling <[email protected]>
FrameLoader::policyChecker() should return a reference.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (155291 => 155292)
--- trunk/Source/WebCore/GNUmakefile.list.am 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2013-09-08 08:56:17 UTC (rev 155292)
@@ -2797,8 +2797,6 @@
Source/WebCore/dom/Clipboard.h \
Source/WebCore/dom/Comment.cpp \
Source/WebCore/dom/Comment.h \
- Source/WebCore/dom/ComposedShadowTreeWalker.cpp \
- Source/WebCore/dom/ComposedShadowTreeWalker.h \
Source/WebCore/dom/CompositionEvent.cpp \
Source/WebCore/dom/CompositionEvent.h \
Source/WebCore/dom/ContainerNodeAlgorithms.h \
Modified: trunk/Source/WebCore/Target.pri (155291 => 155292)
--- trunk/Source/WebCore/Target.pri 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/Target.pri 2013-09-08 08:56:17 UTC (rev 155292)
@@ -370,7 +370,6 @@
dom/Clipboard.cpp \
dom/ClipboardEvent.cpp \
dom/Comment.cpp \
- dom/ComposedShadowTreeWalker.cpp \
dom/CompositionEvent.cpp \
dom/ContainerNode.cpp \
dom/ContainerNodeAlgorithms.cpp \
@@ -1583,7 +1582,6 @@
dom/ClipboardEvent.h \
dom/Clipboard.h \
dom/Comment.h \
- dom/ComposedShadowTreeWalker.h \
dom/ContainerNode.h \
dom/ContainerNodeAlgorithms.h \
dom/ContextFeatures.h \
Modified: trunk/Source/WebCore/WebCore.exp.in (155291 => 155292)
--- trunk/Source/WebCore/WebCore.exp.in 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/WebCore.exp.in 2013-09-08 08:56:17 UTC (rev 155292)
@@ -772,11 +772,6 @@
__ZN7WebCore23eventTimeStampSince1970EP7NSEvent
__ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
__ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
-__ZN7WebCore24ComposedShadowTreeWalker10firstChildEv
-__ZN7WebCore24ComposedShadowTreeWalker11nextSiblingEv
-__ZN7WebCore24ComposedShadowTreeWalker4nextEv
-__ZN7WebCore24ComposedShadowTreeWalker8previousEv
-__ZN7WebCore24ComposedShadowTreeWalker9lastChildEv
__ZN7WebCore24DocumentMarkerController10markersForEPNS_4NodeENS_14DocumentMarker11MarkerTypesE
__ZN7WebCore24DocumentMarkerController13removeMarkersENS_14DocumentMarker11MarkerTypesE
__ZN7WebCore24DocumentMarkerController18addTextMatchMarkerEPKNS_5RangeEb
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (155291 => 155292)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2013-09-08 08:56:17 UTC (rev 155292)
@@ -12166,7 +12166,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\dom\ComposedShadowTreeWalker.cpp" />
<ClCompile Include="..\dom\CompositionEvent.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -20264,7 +20263,6 @@
<ClInclude Include="..\dom\ClipboardAccessPolicy.h" />
<ClInclude Include="..\dom\ClipboardEvent.h" />
<ClInclude Include="..\dom\Comment.h" />
- <ClInclude Include="..\dom\ComposedShadowTreeWalker.h" />
<ClInclude Include="..\dom\CompositionEvent.h" />
<ClInclude Include="..\dom\ContainerNode.h" />
<ClInclude Include="..\dom\ContextDestructionObserver.h" />
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (155291 => 155292)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-09-08 08:56:17 UTC (rev 155292)
@@ -1505,8 +1505,6 @@
4A5A2ADC161E7E00005889DD /* WebSocketExtensionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A5A2ADA161E7E00005889DD /* WebSocketExtensionParser.h */; };
4A5CB1C516C3A5FD00AB2886 /* EventRetargeter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A5CB1C316C3A5FD00AB2886 /* EventRetargeter.cpp */; };
4A5CB1C616C3A5FD00AB2886 /* EventRetargeter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A5CB1C416C3A5FD00AB2886 /* EventRetargeter.h */; };
- 4A6A0C5B15232F2400B09C6E /* ComposedShadowTreeWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */; };
- 4A6A0C5C15232F2400B09C6E /* ComposedShadowTreeWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6A0C5A15232F2400B09C6E /* ComposedShadowTreeWalker.h */; };
4A6E9FC313C17D1D0046A7F8 /* FontFeatureValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */; };
4A6E9FC413C17D1D0046A7F8 /* FontFeatureValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */; };
@@ -8021,8 +8019,6 @@
4A5A2ADA161E7E00005889DD /* WebSocketExtensionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketExtensionParser.h; path = Modules/websockets/WebSocketExtensionParser.h; sourceTree = "<group>"; };
4A5CB1C316C3A5FD00AB2886 /* EventRetargeter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventRetargeter.cpp; sourceTree = "<group>"; };
4A5CB1C416C3A5FD00AB2886 /* EventRetargeter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventRetargeter.h; sourceTree = "<group>"; };
- 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComposedShadowTreeWalker.cpp; sourceTree = "<group>"; };
- 4A6A0C5A15232F2400B09C6E /* ComposedShadowTreeWalker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposedShadowTreeWalker.h; sourceTree = "<group>"; };
4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureValue.cpp; sourceTree = "<group>"; };
4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFeatureValue.h; sourceTree = "<group>"; };
4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureSettings.cpp; sourceTree = "<group>"; };
@@ -20629,8 +20625,6 @@
6550B697099DF0270090D781 /* Comment.cpp */,
6550B698099DF0270090D781 /* Comment.h */,
85089CC70A98C22600A275AA /* Comment.idl */,
- 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */,
- 4A6A0C5A15232F2400B09C6E /* ComposedShadowTreeWalker.h */,
79F2F59E1091939A000D87CB /* CompositionEvent.cpp */,
79F2F59F1091939A000D87CB /* CompositionEvent.h */,
79F2F5A01091939A000D87CB /* CompositionEvent.idl */,
@@ -21594,7 +21588,6 @@
6550B6A2099DF0270090D781 /* Comment.h in Headers */,
979DC03716A7992E00807794 /* CompactHTMLToken.h in Headers */,
37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */,
- 4A6A0C5C15232F2400B09C6E /* ComposedShadowTreeWalker.h in Headers */,
316FE1160E6E1DA700BF6088 /* CompositeAnimation.h in Headers */,
93309DDD099E64920056E581 /* CompositeEditCommand.h in Headers */,
79F2F5A21091939A000D87CB /* CompositionEvent.h in Headers */,
@@ -25102,7 +25095,6 @@
6550B6A1099DF0270090D781 /* Comment.cpp in Sources */,
37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */,
37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */,
- 4A6A0C5B15232F2400B09C6E /* ComposedShadowTreeWalker.cpp in Sources */,
316FE1150E6E1DA700BF6088 /* CompositeAnimation.cpp in Sources */,
93309DDC099E64920056E581 /* CompositeEditCommand.cpp in Sources */,
79F2F5A11091939A000D87CB /* CompositionEvent.cpp in Sources */,
Deleted: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp (155291 => 155292)
--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp 2013-09-08 08:56:17 UTC (rev 155292)
@@ -1,280 +0,0 @@
-
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ComposedShadowTreeWalker.h"
-
-#include "ContentDistributor.h"
-#include "Element.h"
-#include "HTMLContentElement.h"
-#include "InsertionPoint.h"
-#include "PseudoElement.h"
-
-namespace WebCore {
-
-static inline bool nodeCanBeDistributed(const Node* node)
-{
- ASSERT(node);
- Node* parent = parentNodeForDistribution(node);
- if (!parent)
- return false;
-
- if (parent->isShadowRoot())
- return false;
-
- if (parent->isElementNode() && toElement(parent)->shadowRoot())
- return true;
-
- return false;
-}
-
-static Node* findFirstSiblingEnteringInsertionPoints(const Node*);
-static Node* findFirstEnteringInsertionPoints(const Node*);
-static Node* findFirstFromDistributedNode(const Node*, const InsertionPoint*);
-static Node* findLastSiblingEnteringInsertionPoints(const Node*);
-static Node* findLastEnteringInsertionPoints(const Node*);
-static Node* findLastFromDistributedNode(const Node*, const InsertionPoint*);
-
-static Node* findFirstSiblingEnteringInsertionPoints(const Node* node)
-{
- for (const Node* sibling = node; sibling; sibling = sibling->nextSibling()) {
- if (Node* found = findFirstEnteringInsertionPoints(sibling))
- return found;
- }
- return nullptr;
-}
-
-static Node* findFirstEnteringInsertionPoints(const Node* node)
-{
- ASSERT(node);
- if (!isActiveInsertionPoint(node))
- return const_cast<Node*>(node);
- const InsertionPoint* insertionPoint = toInsertionPoint(node);
- if (Node* found = findFirstFromDistributedNode(insertionPoint->firstDistributed(), insertionPoint))
- return found;
- return findFirstSiblingEnteringInsertionPoints(node->firstChild());
-}
-
-static Node* findFirstFromDistributedNode(const Node* node, const InsertionPoint* insertionPoint)
-{
- for (const Node* next = node; next; next = insertionPoint->nextDistributedTo(next)) {
- if (Node* found = findFirstEnteringInsertionPoints(next))
- return found;
- }
- return nullptr;
-}
-
-static Node* findLastSiblingEnteringInsertionPoints(const Node* node)
-{
- for (const Node* sibling = node; sibling; sibling = sibling->previousSibling()) {
- if (Node* found = findLastEnteringInsertionPoints(sibling))
- return found;
- }
- return nullptr;
-}
-
-static Node* findLastEnteringInsertionPoints(const Node* node)
-{
- ASSERT(node);
- if (!isActiveInsertionPoint(node))
- return const_cast<Node*>(node);
- const InsertionPoint* insertionPoint = toInsertionPoint(node);
- if (Node* found = findLastFromDistributedNode(insertionPoint->lastDistributed(), insertionPoint))
- return found;
- return findLastSiblingEnteringInsertionPoints(node->lastChild());
-}
-
-static Node* findLastFromDistributedNode(const Node* node, const InsertionPoint* insertionPoint)
-{
- for (const Node* next = node; next; next = insertionPoint->previousDistributedTo(next)) {
- if (Node* found = findLastEnteringInsertionPoints(next))
- return found;
- }
- return nullptr;
-}
-
-void ComposedShadowTreeWalker::firstChild()
-{
- assertPrecondition();
- m_node = traverseFirstChild(m_node);
- assertPostcondition();
-}
-
-Node* ComposedShadowTreeWalker::traverseFirstChild(const Node* node) const
-{
- ASSERT(node);
- if (node->shadowRoot()) {
- if (!canCrossUpperBoundary())
- return nullptr;
- node = node->shadowRoot();
- }
- return findFirstSiblingEnteringInsertionPoints(node->firstChild());
-}
-
-void ComposedShadowTreeWalker::lastChild()
-{
- assertPrecondition();
- m_node = traverseLastChild(m_node);
- assertPostcondition();
-}
-
-Node* ComposedShadowTreeWalker::traverseLastChild(const Node* node) const
-{
- ASSERT(node);
- if (node->shadowRoot()) {
- if (!canCrossUpperBoundary())
- return nullptr;
- node = node->shadowRoot();
- }
- return findLastSiblingEnteringInsertionPoints(node->lastChild());
-}
-
-void ComposedShadowTreeWalker::nextSibling()
-{
- assertPrecondition();
- m_node = traverseNextSibling(m_node);
- assertPostcondition();
-}
-
-void ComposedShadowTreeWalker::previousSibling()
-{
- assertPrecondition();
- m_node = traversePreviousSibling(m_node);
- assertPostcondition();
-}
-
-void ComposedShadowTreeWalker::parent()
-{
- assertPrecondition();
- m_node = traverseParent(m_node);
- assertPostcondition();
-}
-
-Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const
-{
- if (node->isPseudoElement())
- return toPseudoElement(node)->hostElement();
-
- if (!canCrossUpperBoundary() && node->isShadowRoot())
- return 0;
-
- if (nodeCanBeDistributed(node)) {
- if (InsertionPoint* insertionPoint = findInsertionPointOf(node))
- return traverseParent(insertionPoint);
- return nullptr;
- }
- ContainerNode* parent = node->parentNode();
- if (!parent)
- return nullptr;
-
- if (parent->isShadowRoot())
- return canCrossUpperBoundary() ? toShadowRoot(parent)->hostElement() : parent;
-
- if (parent->isInsertionPoint()) {
- const InsertionPoint* insertionPoint = toInsertionPoint(parent);
- if (insertionPoint->hasDistribution())
- return nullptr;
- if (insertionPoint->isActive())
- return traverseParent(parent);
- }
- return parent;
-}
-
-Node* ComposedShadowTreeWalker::traverseNextSibling(const Node* node)
-{
- ASSERT(node);
-
- InsertionPoint* insertionPoint;
- if (nodeCanBeDistributed(node) && (insertionPoint = findInsertionPointOf(node))) {
- Node* found = findFirstFromDistributedNode(insertionPoint->nextDistributedTo(node), insertionPoint);
- if (found)
- return found;
- return traverseNextSibling(insertionPoint);
- }
-
- for (const Node* sibling = node->nextSibling(); sibling; sibling = sibling->nextSibling()) {
- if (Node* found = findFirstEnteringInsertionPoints(sibling))
- return found;
- }
- if (node->parentNode() && isActiveInsertionPoint(node->parentNode()))
- return traverseNextSibling(node->parentNode());
-
- return nullptr;
-}
-
-Node* ComposedShadowTreeWalker::traversePreviousSibling(const Node* node)
-{
- ASSERT(node);
-
- InsertionPoint* insertionPoint;
- if (nodeCanBeDistributed(node) && (insertionPoint = findInsertionPointOf(node))) {
- Node* found = findLastFromDistributedNode(insertionPoint->previousDistributedTo(node), insertionPoint);
- if (found)
- return found;
- return traversePreviousSibling(insertionPoint);
- }
-
- for (const Node* sibling = node->previousSibling(); sibling; sibling = sibling->previousSibling()) {
- if (Node* found = findLastEnteringInsertionPoints(sibling))
- return found;
- }
- if (node->parentNode() && isActiveInsertionPoint(node->parentNode()))
- return traversePreviousSibling(node->parentNode());
-
- return nullptr;
-}
-
-void ComposedShadowTreeWalker::next()
-{
- assertPrecondition();
- if (Node* next = traverseFirstChild(m_node))
- m_node = next;
- else if (Node* next = traverseNextSibling(m_node))
- m_node = next;
- else {
- const Node* n = m_node;
- while (n && !traverseNextSibling(n))
- n = traverseParent(n);
- m_node = n ? traverseNextSibling(n) : 0;
- }
- assertPostcondition();
-}
-
-void ComposedShadowTreeWalker::previous()
-{
- assertPrecondition();
- if (Node* n = traversePreviousSibling(m_node)) {
- while (Node* child = traverseLastChild(n))
- n = child;
- m_node = n;
- } else
- m_node = traverseParent(m_node);
- assertPostcondition();
-}
-
-} // namespace
Deleted: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h (155291 => 155292)
--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h 2013-09-08 08:56:17 UTC (rev 155292)
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ComposedShadowTreeWalker_h
-#define ComposedShadowTreeWalker_h
-
-#include "InsertionPoint.h"
-#include "NodeRenderingTraversal.h"
-#include "ShadowRoot.h"
-
-namespace WebCore {
-
-class Node;
-class ShadowRoot;
-
-// FIXME: Make some functions inline to optimise the performance.
-// https://bugs.webkit.org/show_bug.cgi?id=82702
-class ComposedShadowTreeWalker {
-public:
- enum Policy {
- CrossUpperBoundary,
- DoNotCrossUpperBoundary,
- };
-
- enum StartPolicy {
- CanStartFromShadowBoundary,
- CannotStartFromShadowBoundary
- };
-
- ComposedShadowTreeWalker(const Node*, Policy = CrossUpperBoundary, StartPolicy = CannotStartFromShadowBoundary);
-
- Node* get() const { return const_cast<Node*>(m_node); }
-
- void firstChild();
- void lastChild();
-
- void nextSibling();
- void previousSibling();
-
- void parent();
-
- void next();
- void previous();
-
- Node* traverseParent(const Node*) const;
-
-private:
- bool canCrossUpperBoundary() const { return m_policy == CrossUpperBoundary; }
-
- void assertPrecondition() const
- {
-#ifndef NDEBUG
- ASSERT(m_node);
- if (canCrossUpperBoundary())
- ASSERT(!m_node->isShadowRoot());
- ASSERT(!isActiveInsertionPoint(m_node));
-#endif
- }
-
- void assertPostcondition() const
- {
-#ifndef NDEBUG
- if (m_node)
- assertPrecondition();
-#endif
- }
-
- Node* traverseFirstChild(const Node*) const;
- Node* traverseLastChild(const Node*) const;
-
- static Node* traverseNextSibling(const Node*);
- static Node* traversePreviousSibling(const Node*);
-
- const Node* m_node;
- Policy m_policy;
-};
-
-inline ComposedShadowTreeWalker::ComposedShadowTreeWalker(const Node* node, Policy policy, StartPolicy startPolicy)
- : m_node(node)
- , m_policy(policy)
-{
- UNUSED_PARAM(startPolicy);
-#ifndef NDEBUG
- if (m_node && startPolicy == CannotStartFromShadowBoundary)
- assertPrecondition();
-#endif
-}
-
-} // namespace
-
-#endif
Modified: trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp (155291 => 155292)
--- trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp 2013-09-08 08:56:17 UTC (rev 155292)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -27,32 +28,216 @@
#include "config.h"
#include "NodeRenderingTraversal.h"
-#include "ComposedShadowTreeWalker.h"
+#include "InsertionPoint.h"
#include "PseudoElement.h"
+#include "ShadowRoot.h"
namespace WebCore {
namespace NodeRenderingTraversal {
+static Node* findFirstSiblingEnteringInsertionPoints(const Node*);
+static Node* findFirstEnteringInsertionPoints(const Node*);
+static Node* findFirstFromDistributedNode(const Node*, const InsertionPoint*);
+static Node* findLastSiblingEnteringInsertionPoints(const Node*);
+static Node* findLastEnteringInsertionPoints(const Node*);
+static Node* findLastFromDistributedNode(const Node*, const InsertionPoint*);
+
+static inline bool nodeCanBeDistributed(const Node* node)
+{
+ ASSERT(node);
+ Node* parent = parentNodeForDistribution(node);
+ if (!parent)
+ return false;
+
+ if (parent->isShadowRoot())
+ return false;
+
+ if (parent->isElementNode() && toElement(parent)->shadowRoot())
+ return true;
+
+ return false;
+}
+
+static Node* findFirstSiblingEnteringInsertionPoints(const Node* node)
+{
+ for (const Node* sibling = node; sibling; sibling = sibling->nextSibling()) {
+ if (Node* found = findFirstEnteringInsertionPoints(sibling))
+ return found;
+ }
+ return nullptr;
+}
+
+static Node* findFirstEnteringInsertionPoints(const Node* node)
+{
+ ASSERT(node);
+ if (!isActiveInsertionPoint(node))
+ return const_cast<Node*>(node);
+ const InsertionPoint* insertionPoint = toInsertionPoint(node);
+ if (Node* found = findFirstFromDistributedNode(insertionPoint->firstDistributed(), insertionPoint))
+ return found;
+ return findFirstSiblingEnteringInsertionPoints(node->firstChild());
+}
+
+static Node* findFirstFromDistributedNode(const Node* node, const InsertionPoint* insertionPoint)
+{
+ for (const Node* next = node; next; next = insertionPoint->nextDistributedTo(next)) {
+ if (Node* found = findFirstEnteringInsertionPoints(next))
+ return found;
+ }
+ return nullptr;
+}
+
+static Node* findLastSiblingEnteringInsertionPoints(const Node* node)
+{
+ for (const Node* sibling = node; sibling; sibling = sibling->previousSibling()) {
+ if (Node* found = findLastEnteringInsertionPoints(sibling))
+ return found;
+ }
+ return nullptr;
+}
+
+static Node* findLastEnteringInsertionPoints(const Node* node)
+{
+ ASSERT(node);
+ if (!isActiveInsertionPoint(node))
+ return const_cast<Node*>(node);
+ const InsertionPoint* insertionPoint = toInsertionPoint(node);
+ if (Node* found = findLastFromDistributedNode(insertionPoint->lastDistributed(), insertionPoint))
+ return found;
+ return findLastSiblingEnteringInsertionPoints(node->lastChild());
+}
+
+static Node* findLastFromDistributedNode(const Node* node, const InsertionPoint* insertionPoint)
+{
+ for (const Node* next = node; next; next = insertionPoint->previousDistributedTo(next)) {
+ if (Node* found = findLastEnteringInsertionPoints(next))
+ return found;
+ }
+ return nullptr;
+}
+
+enum ShadowRootCrossing { CrossShadowRoot, DontCrossShadowRoot };
+
+static ContainerNode* traverseParent(const Node* node, ShadowRootCrossing shadowRootCrossing)
+{
+ if (node->isPseudoElement())
+ return toPseudoElement(node)->hostElement();
+
+ if (shadowRootCrossing == DontCrossShadowRoot && node->isShadowRoot())
+ return 0;
+
+ if (nodeCanBeDistributed(node)) {
+ if (InsertionPoint* insertionPoint = findInsertionPointOf(node))
+ return traverseParent(insertionPoint, shadowRootCrossing);
+ return nullptr;
+ }
+ ContainerNode* parent = node->parentNode();
+ if (!parent)
+ return nullptr;
+
+ if (parent->isShadowRoot())
+ return shadowRootCrossing == CrossShadowRoot ? toShadowRoot(parent)->hostElement() : parent;
+
+ if (parent->isInsertionPoint()) {
+ const InsertionPoint* insertionPoint = toInsertionPoint(parent);
+ if (insertionPoint->hasDistribution())
+ return nullptr;
+ if (insertionPoint->isActive())
+ return traverseParent(parent, shadowRootCrossing);
+ }
+ return parent;
+}
+
+static Node* traverseFirstChild(const Node* node, ShadowRootCrossing shadowRootCrossing)
+{
+ ASSERT(node);
+ if (node->shadowRoot()) {
+ if (shadowRootCrossing == DontCrossShadowRoot)
+ return nullptr;
+ node = node->shadowRoot();
+ }
+ return findFirstSiblingEnteringInsertionPoints(node->firstChild());
+}
+
+static Node* traverseLastChild(const Node* node, ShadowRootCrossing shadowRootCrossing)
+{
+ ASSERT(node);
+ if (node->shadowRoot()) {
+ if (shadowRootCrossing == DontCrossShadowRoot)
+ return nullptr;
+ node = node->shadowRoot();
+ }
+ return findLastSiblingEnteringInsertionPoints(node->lastChild());
+}
+
+static Node* traverseNextSibling(const Node* node)
+{
+ ASSERT(node);
+
+ InsertionPoint* insertionPoint;
+ if (nodeCanBeDistributed(node) && (insertionPoint = findInsertionPointOf(node))) {
+ Node* found = findFirstFromDistributedNode(insertionPoint->nextDistributedTo(node), insertionPoint);
+ if (found)
+ return found;
+ return traverseNextSibling(insertionPoint);
+ }
+
+ for (const Node* sibling = node->nextSibling(); sibling; sibling = sibling->nextSibling()) {
+ if (Node* found = findFirstEnteringInsertionPoints(sibling))
+ return found;
+ }
+ if (node->parentNode() && isActiveInsertionPoint(node->parentNode()))
+ return traverseNextSibling(node->parentNode());
+
+ return nullptr;
+}
+
+static Node* traversePreviousSibling(const Node* node)
+{
+ ASSERT(node);
+
+ InsertionPoint* insertionPoint;
+ if (nodeCanBeDistributed(node) && (insertionPoint = findInsertionPointOf(node))) {
+ Node* found = findLastFromDistributedNode(insertionPoint->previousDistributedTo(node), insertionPoint);
+ if (found)
+ return found;
+ return traversePreviousSibling(insertionPoint);
+ }
+
+ for (const Node* sibling = node->previousSibling(); sibling; sibling = sibling->previousSibling()) {
+ if (Node* found = findLastEnteringInsertionPoints(sibling))
+ return found;
+ }
+ if (node->parentNode() && isActiveInsertionPoint(node->parentNode()))
+ return traversePreviousSibling(node->parentNode());
+
+ return nullptr;
+}
+
ContainerNode* parentSlow(const Node* node)
{
- ComposedShadowTreeWalker walker(node, ComposedShadowTreeWalker::CrossUpperBoundary, ComposedShadowTreeWalker::CanStartFromShadowBoundary);
- return toContainerNode(walker.traverseParent(walker.get()));
+ ASSERT(!node->isShadowRoot());
+
+ return traverseParent(node, CrossShadowRoot);
}
Node* nextSiblingSlow(const Node* node)
{
- ComposedShadowTreeWalker walker(node);
+ ASSERT(!node->isShadowRoot());
+
+ // FIXME: Why do these functions deal with before/after when other code here doesn't?
+ Node* nextSibling = 0;
if (node->isBeforePseudoElement()) {
- walker.parent();
- walker.firstChild();
+ nextSibling = traverseParent(node, CrossShadowRoot);
+ nextSibling = traverseFirstChild(nextSibling, CrossShadowRoot);
} else
- walker.nextSibling();
+ nextSibling = traverseNextSibling(node);
- if (walker.get() || node->isAfterPseudoElement())
- return walker.get();
+ if (nextSibling || node->isAfterPseudoElement())
+ return nextSibling;
- Node* parent = walker.traverseParent(node);
+ Node* parent = traverseParent(node, CrossShadowRoot);
if (parent && parent->isElementNode())
return toElement(parent)->afterPseudoElement();
@@ -61,17 +246,19 @@
Node* previousSiblingSlow(const Node* node)
{
- ComposedShadowTreeWalker walker(node);
+ ASSERT(!node->isShadowRoot());
+
+ Node* previousSibling = 0;
if (node->isAfterPseudoElement()) {
- walker.parent();
- walker.lastChild();
+ ContainerNode* parent = traverseParent(node, CrossShadowRoot);
+ previousSibling = traverseLastChild(parent, CrossShadowRoot);
} else
- walker.previousSibling();
+ previousSibling = traversePreviousSibling(node);
- if (walker.get() || node->isBeforePseudoElement())
- return walker.get();
+ if (previousSibling || node->isBeforePseudoElement())
+ return previousSibling;
- Node* parent = walker.traverseParent(node);
+ ContainerNode* parent = traverseParent(node, CrossShadowRoot);
if (parent && parent->isElementNode())
return toElement(parent)->beforePseudoElement();
@@ -80,34 +267,42 @@
Node* nextInScope(const Node* node)
{
- // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
- ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
- walker.next();
- return walker.get();
+ ASSERT(!isActiveInsertionPoint(node));
+
+ if (Node* next = traverseFirstChild(node, DontCrossShadowRoot))
+ return next;
+ if (Node* next = traverseNextSibling(node))
+ return next;
+ const Node* current = node;
+ while (current && !traverseNextSibling(current))
+ current = traverseParent(current, DontCrossShadowRoot);
+ return current ? traverseNextSibling(current) : 0;
}
Node* previousInScope(const Node* node)
{
- // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
- ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
- walker.previous();
- return walker.get();
+ ASSERT(!isActiveInsertionPoint(node));
+
+ if (Node* current = traversePreviousSibling(node)) {
+ while (Node* child = traverseLastChild(current, DontCrossShadowRoot))
+ current = child;
+ return current;
+ }
+ return traverseParent(node, DontCrossShadowRoot);
}
Node* parentInScope(const Node* node)
{
- // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
- ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
- walker.parent();
- return walker.get();
+ ASSERT(!isActiveInsertionPoint(node));
+
+ return traverseParent(node, DontCrossShadowRoot);
}
Node* lastChildInScope(const Node* node)
{
- // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339
- ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
- walker.lastChild();
- return walker.get();
+ ASSERT(!isActiveInsertionPoint(node));
+
+ return traverseLastChild(node, DontCrossShadowRoot);
}
}
Modified: trunk/Source/WebCore/testing/Internals.cpp (155291 => 155292)
--- trunk/Source/WebCore/testing/Internals.cpp 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/testing/Internals.cpp 2013-09-08 08:56:17 UTC (rev 155292)
@@ -34,7 +34,6 @@
#include "ChromeClient.h"
#include "ClientRect.h"
#include "ClientRectList.h"
-#include "ComposedShadowTreeWalker.h"
#include "ContentDistributor.h"
#include "Cursor.h"
#include "DOMStringList.h"
@@ -510,61 +509,6 @@
return node->attached();
}
-Node* Internals::nextSiblingByWalker(Node* node, ExceptionCode& ec)
-{
- if (!node) {
- ec = INVALID_ACCESS_ERR;
- return 0;
- }
- ComposedShadowTreeWalker walker(node);
- walker.nextSibling();
- return walker.get();
-}
-
-Node* Internals::firstChildByWalker(Node* node, ExceptionCode& ec)
-{
- if (!node) {
- ec = INVALID_ACCESS_ERR;
- return 0;
- }
- ComposedShadowTreeWalker walker(node);
- walker.firstChild();
- return walker.get();
-}
-
-Node* Internals::lastChildByWalker(Node* node, ExceptionCode& ec)
-{
- if (!node) {
- ec = INVALID_ACCESS_ERR;
- return 0;
- }
- ComposedShadowTreeWalker walker(node);
- walker.lastChild();
- return walker.get();
-}
-
-Node* Internals::nextNodeByWalker(Node* node, ExceptionCode& ec)
-{
- if (!node) {
- ec = INVALID_ACCESS_ERR;
- return 0;
- }
- ComposedShadowTreeWalker walker(node);
- walker.next();
- return walker.get();
-}
-
-Node* Internals::previousNodeByWalker(Node* node, ExceptionCode& ec)
-{
- if (!node) {
- ec = INVALID_ACCESS_ERR;
- return 0;
- }
- ComposedShadowTreeWalker walker(node);
- walker.previous();
- return walker.get();
-}
-
String Internals::elementRenderTreeAsText(Element* element, ExceptionCode& ec)
{
if (!element) {
Modified: trunk/Source/WebCore/testing/Internals.h (155291 => 155292)
--- trunk/Source/WebCore/testing/Internals.h 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/testing/Internals.h 2013-09-08 08:56:17 UTC (rev 155292)
@@ -120,13 +120,6 @@
bool attached(Node*, ExceptionCode&);
- // FIXME: Rename these functions if walker is prefered.
- Node* nextSiblingByWalker(Node*, ExceptionCode&);
- Node* firstChildByWalker(Node*, ExceptionCode&);
- Node* lastChildByWalker(Node*, ExceptionCode&);
- Node* nextNodeByWalker(Node*, ExceptionCode&);
- Node* previousNodeByWalker(Node*, ExceptionCode&);
-
String visiblePlaceholder(Element*);
#if ENABLE(INPUT_TYPE_COLOR)
void selectColorInColorChooser(Element*, const String& colorValue);
Modified: trunk/Source/WebCore/testing/Internals.idl (155291 => 155292)
--- trunk/Source/WebCore/testing/Internals.idl 2013-09-08 08:49:09 UTC (rev 155291)
+++ trunk/Source/WebCore/testing/Internals.idl 2013-09-08 08:56:17 UTC (rev 155292)
@@ -69,12 +69,6 @@
[RaisesException] boolean pauseTransitionAtTimeOnElement(DOMString propertyName, double pauseTime, Element element);
[RaisesException] boolean pauseTransitionAtTimeOnPseudoElement(DOMString property, double pauseTime, Element element, DOMString pseudoId);
- [RaisesException] Node nextSiblingByWalker(Node node);
- [RaisesException] Node firstChildByWalker(Node node);
- [RaisesException] Node lastChildByWalker(Node node);
- [RaisesException] Node nextNodeByWalker(Node node);
- [RaisesException] Node previousNodeByWalker(Node node);
-
[RaisesException] boolean attached(Node node);
DOMString visiblePlaceholder(Element element);