Title: [139325] trunk/Source/WebCore
Revision
139325
Author
morr...@google.com
Date
2013-01-10 09:44:05 -0800 (Thu, 10 Jan 2013)

Log Message

ComposedShadowTreeWalker shouldn't be exposed to non-ShadowDOM classes
https://bugs.webkit.org/show_bug.cgi?id=106505

Reviewed by Dimitri Glazkov.

This change hides ComposedShadowTreeWalker from non-ShadowDOM classes by

- introducing thin wrapper functions on NodeRenderingTraversal and relacing
  CSTW callsites with it,
- replacing ComposedShadowTreeWalker usage with AncestorChainWalker if possible and
- moving AncestorChainWalker to its own file and including it on files
  which needs only AncestorChainWalker. This eliminates ComposedShadowTreeWalker.h inclusions.

No new tests. No behavior change.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* dom/AncestorChainWalker.cpp: Added. Extracted from ComposedShadowTreeWalker.cpp
(WebCore):
(WebCore::AncestorChainWalker::AncestorChainWalker):
(WebCore::AncestorChainWalker::parent):
* dom/AncestorChainWalker.h: Added. Extracted from ComposedShadowTreeWalker.h
(WebCore):
(AncestorChainWalker):
(WebCore::AncestorChainWalker::get):
(WebCore::AncestorChainWalker::crossingInsertionPoint):
* dom/ComposedShadowTreeWalker.cpp:
* dom/ComposedShadowTreeWalker.h:
* dom/DOMAllInOne.cpp:
* dom/ElementShadow.h:
(WebCore::shadowOfParent):
(WebCore):
* dom/EventDispatcher.cpp:
* dom/Node.cpp:
* dom/NodeRenderingTraversal.cpp:
(WebCore::NodeRenderingTraversal::nextInScope):
(NodeRenderingTraversal):
(WebCore::NodeRenderingTraversal::previousInScope): Added.
(WebCore::NodeRenderingTraversal::parentInScope): Added.
(WebCore::NodeRenderingTraversal::lastChildInScope): Added.
* dom/NodeRenderingTraversal.h:
(NodeRenderingTraversal):
* dom/TreeScope.cpp:
* html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::attach):
* page/EventHandler.cpp:
* page/FocusController.cpp: Replacing CSTW with NRT
(WebCore):
(WebCore::FocusNavigationScope::focusNavigationScopeOf):
(WebCore::FocusController::findNodeWithExactTabIndex):
(WebCore::nextNodeWithGreaterTabIndex):
(WebCore::previousNodeWithLowerTabIndex):
(WebCore::FocusController::nextFocusableNode):
(WebCore::FocusController::previousFocusableNode):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (139324 => 139325)


--- trunk/Source/WebCore/CMakeLists.txt	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-01-10 17:44:05 UTC (rev 139325)
@@ -1109,6 +1109,7 @@
     css/WebKitCSSViewportRule.cpp
 
     dom/ActiveDOMObject.cpp
+    dom/AncestorChainWalker.cpp
     dom/Attr.cpp
     dom/BeforeTextInsertedEvent.cpp
     dom/BeforeUnloadEvent.cpp

Modified: trunk/Source/WebCore/ChangeLog (139324 => 139325)


--- trunk/Source/WebCore/ChangeLog	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/ChangeLog	2013-01-10 17:44:05 UTC (rev 139325)
@@ -1,3 +1,63 @@
+2013-01-10  Hajime Morrita  <morr...@google.com>
+
+        ComposedShadowTreeWalker shouldn't be exposed to non-ShadowDOM classes
+        https://bugs.webkit.org/show_bug.cgi?id=106505
+
+        Reviewed by Dimitri Glazkov.
+
+        This change hides ComposedShadowTreeWalker from non-ShadowDOM classes by
+
+        - introducing thin wrapper functions on NodeRenderingTraversal and relacing
+          CSTW callsites with it,
+        - replacing ComposedShadowTreeWalker usage with AncestorChainWalker if possible and
+        - moving AncestorChainWalker to its own file and including it on files
+          which needs only AncestorChainWalker. This eliminates ComposedShadowTreeWalker.h inclusions.
+
+        No new tests. No behavior change.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/AncestorChainWalker.cpp: Added. Extracted from ComposedShadowTreeWalker.cpp
+        (WebCore):
+        (WebCore::AncestorChainWalker::AncestorChainWalker):
+        (WebCore::AncestorChainWalker::parent):
+        * dom/AncestorChainWalker.h: Added. Extracted from ComposedShadowTreeWalker.h
+        (WebCore):
+        (AncestorChainWalker):
+        (WebCore::AncestorChainWalker::get):
+        (WebCore::AncestorChainWalker::crossingInsertionPoint):
+        * dom/ComposedShadowTreeWalker.cpp:
+        * dom/ComposedShadowTreeWalker.h:
+        * dom/DOMAllInOne.cpp:
+        * dom/ElementShadow.h:
+        (WebCore::shadowOfParent):
+        (WebCore):
+        * dom/EventDispatcher.cpp:
+        * dom/Node.cpp:
+        * dom/NodeRenderingTraversal.cpp:
+        (WebCore::NodeRenderingTraversal::nextInScope):
+        (NodeRenderingTraversal):
+        (WebCore::NodeRenderingTraversal::previousInScope): Added.
+        (WebCore::NodeRenderingTraversal::parentInScope): Added.
+        (WebCore::NodeRenderingTraversal::lastChildInScope): Added.
+        * dom/NodeRenderingTraversal.h:
+        (NodeRenderingTraversal):
+        * dom/TreeScope.cpp:
+        * html/HTMLLIElement.cpp:
+        (WebCore::HTMLLIElement::attach):
+        * page/EventHandler.cpp:
+        * page/FocusController.cpp: Replacing CSTW with NRT
+        (WebCore):
+        (WebCore::FocusNavigationScope::focusNavigationScopeOf):
+        (WebCore::FocusController::findNodeWithExactTabIndex):
+        (WebCore::nextNodeWithGreaterTabIndex):
+        (WebCore::previousNodeWithLowerTabIndex):
+        (WebCore::FocusController::nextFocusableNode):
+        (WebCore::FocusController::previousFocusableNode):
+
 2013-01-10  Zan Dobersek  <zandober...@gmail.com>
 
         Remove the ENABLE_ANIMATION_API feature define occurences

Modified: trunk/Source/WebCore/GNUmakefile.list.am (139324 => 139325)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-01-10 17:44:05 UTC (rev 139325)
@@ -2696,6 +2696,8 @@
 	Source/WebCore/css/WebKitCSSViewportRule.h \
 	Source/WebCore/dom/ActiveDOMObject.cpp \
 	Source/WebCore/dom/ActiveDOMObject.h \
+	Source/WebCore/dom/AncestorChainWalker.cpp \
+	Source/WebCore/dom/AncestorChainWalker.h \
 	Source/WebCore/dom/Attr.cpp \
 	Source/WebCore/dom/Attr.h \
 	Source/WebCore/dom/Attribute.h \

Modified: trunk/Source/WebCore/Target.pri (139324 => 139325)


--- trunk/Source/WebCore/Target.pri	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/Target.pri	2013-01-10 17:44:05 UTC (rev 139325)
@@ -335,6 +335,7 @@
     css/WebKitCSSTransformValue.cpp \
     css/WebKitCSSViewportRule.cpp \
     dom/ActiveDOMObject.cpp \
+    dom/AncestorChainWalker.cpp \
     dom/Attr.cpp \
     dom/BeforeTextInsertedEvent.cpp \
     dom/BeforeUnloadEvent.cpp \
@@ -1542,6 +1543,7 @@
     css/WebKitCSSTransformValue.h \
     css/WebKitCSSViewportRule.h \
     dom/ActiveDOMObject.h \
+    dom/AncestorChainWalker.h \
     dom/Attr.h \
     dom/Attribute.h \
     dom/BeforeTextInsertedEvent.h \

Modified: trunk/Source/WebCore/WebCore.gypi (139324 => 139325)


--- trunk/Source/WebCore/WebCore.gypi	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/WebCore.gypi	2013-01-10 17:44:05 UTC (rev 139325)
@@ -2704,6 +2704,8 @@
         ],
         'webcore_dom_files': [
             'dom/ActiveDOMObject.cpp',
+            'dom/AncestorChainWalker.cpp',
+            'dom/AncestorChainWalker.h',
             'dom/Attr.cpp',
             'dom/BeforeLoadEvent.h',
             'dom/BeforeTextInsertedEvent.cpp',

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (139324 => 139325)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-01-10 17:44:05 UTC (rev 139325)
@@ -3932,6 +3932,8 @@
 		A77E1FF014AACB6E005B7CB6 /* TreeScopeAdopter.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E1FEE14AACB6E005B7CB6 /* TreeScopeAdopter.h */; };
 		A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A781C6A613828B5D0012A62A /* DocumentMarker.cpp */; };
 		A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* Clipboard.cpp */; };
+		A78CDD2E169E91A1009136F3 /* AncestorChainWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75CBE43169E913D0003A60F /* AncestorChainWalker.cpp */; };
+		A78CDD30169E91A4009136F3 /* AncestorChainWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = A75CBE44169E913D0003A60F /* AncestorChainWalker.h */; };
 		A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */; };
 		A78E52701346BD1700AD9C31 /* MeterShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A78E526E1346BD1700AD9C31 /* MeterShadowElement.h */; };
 		A78FE13B12366B1000ACE8D0 /* SpellChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */; };
@@ -11283,6 +11285,8 @@
 		A73F95FC12C97BFE0031AAF9 /* RoundedRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RoundedRect.cpp; sourceTree = "<group>"; };
 		A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoundedRect.h; sourceTree = "<group>"; };
 		A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCodePlaceholder.h; sourceTree = "<group>"; };
+		A75CBE43169E913D0003A60F /* AncestorChainWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AncestorChainWalker.cpp; sourceTree = "<group>"; };
+		A75CBE44169E913D0003A60F /* AncestorChainWalker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AncestorChainWalker.h; sourceTree = "<group>"; };
 		A75E497410752ACB00C9B896 /* SerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedScriptValue.h; sourceTree = "<group>"; };
 		A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializedScriptValue.cpp; sourceTree = "<group>"; };
 		A75E8B800E1DE2D6007F2481 /* FEBlend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FEBlend.cpp; path = filters/FEBlend.cpp; sourceTree = "<group>"; };
@@ -21990,6 +21994,8 @@
 			children = (
 				E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */,
 				E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */,
+				A75CBE43169E913D0003A60F /* AncestorChainWalker.cpp */,
+				A75CBE44169E913D0003A60F /* AncestorChainWalker.h */,
 				A8C4A7FC09D563270003AC8D /* Attr.cpp */,
 				A8C4A7FB09D563270003AC8D /* Attr.h */,
 				93EEC1E509C2877700C515D1 /* Attr.idl */,
@@ -22763,6 +22769,7 @@
 				CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */,
 				CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */,
 				FD31603E12B0267600C1A359 /* AnalyserNode.h in Headers */,
+				A78CDD30169E91A4009136F3 /* AncestorChainWalker.h in Headers */,
 				490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */,
 				49E912AB0EFAC906009D0CAF /* Animation.h in Headers */,
 				316FE1120E6E1DA700BF6088 /* AnimationBase.h in Headers */,
@@ -26444,6 +26451,7 @@
 				CE08C3D1152B599A0021B8C2 /* AlternativeTextController.cpp in Sources */,
 				CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */,
 				FD31603D12B0267600C1A359 /* AnalyserNode.cpp in Sources */,
+				A78CDD2E169E91A1009136F3 /* AncestorChainWalker.cpp in Sources */,
 				490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
 				49E912AA0EFAC906009D0CAF /* Animation.cpp in Sources */,
 				316FE1110E6E1DA700BF6088 /* AnimationBase.cpp in Sources */,

Added: trunk/Source/WebCore/dom/AncestorChainWalker.cpp (0 => 139325)


--- trunk/Source/WebCore/dom/AncestorChainWalker.cpp	                        (rev 0)
+++ trunk/Source/WebCore/dom/AncestorChainWalker.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "AncestorChainWalker.h"
+
+#include "ContentDistributor.h"
+#include "InsertionPoint.h"
+#include "ShadowRoot.h"
+
+namespace WebCore {
+
+AncestorChainWalker::AncestorChainWalker(const Node* node)
+    : m_node(node)
+    , m_distributedNode(node)
+    , m_isCrossingInsertionPoint(false)
+{
+    ASSERT(node);
+}
+
+void AncestorChainWalker::parent()
+{
+    ASSERT(m_node);
+    ASSERT(m_distributedNode);
+    if (ElementShadow* shadow = shadowOfParent(m_node)) {
+        if (InsertionPoint* insertionPoint = shadow->distributor().findInsertionPointFor(m_distributedNode)) {
+            m_node = insertionPoint;
+            m_isCrossingInsertionPoint = true;
+            return;
+        }
+    }
+    if (!m_node->isShadowRoot()) {
+        m_node = m_node->parentNode();
+        if (!(m_node && m_node->isShadowRoot() && ScopeContentDistribution::assignedTo(toShadowRoot(m_node))))
+            m_distributedNode = m_node;
+        m_isCrossingInsertionPoint = false;
+        return;
+    }
+
+    const ShadowRoot* shadowRoot = toShadowRoot(m_node);
+    if (InsertionPoint* insertionPoint = ScopeContentDistribution::assignedTo(shadowRoot)) {
+        m_node = insertionPoint;
+        m_isCrossingInsertionPoint = true;
+        return;
+    }
+    m_node = shadowRoot->host();
+    m_distributedNode = m_node;
+    m_isCrossingInsertionPoint = false;
+}
+
+} // namespace

Added: trunk/Source/WebCore/dom/AncestorChainWalker.h (0 => 139325)


--- trunk/Source/WebCore/dom/AncestorChainWalker.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/AncestorChainWalker.h	2013-01-10 17:44:05 UTC (rev 139325)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 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 AncestorChainWalker_h
+#define AncestorChainWalker_h
+
+namespace WebCore {
+
+class Node;
+
+class AncestorChainWalker {
+public:
+    explicit AncestorChainWalker(const Node*);
+    void parent();
+    Node* get() const { return const_cast<Node*>(m_node); }
+    bool crossingInsertionPoint() { return m_isCrossingInsertionPoint; }
+
+private:
+    const Node* m_node;
+    const Node* m_distributedNode;
+    bool m_isCrossingInsertionPoint;
+};
+
+} // namespace
+
+#endif

Modified: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp (139324 => 139325)


--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -45,16 +45,6 @@
     return 0;
 }
 
-static inline ElementShadow* shadowOfParent(const Node* node)
-{
-    if (!node)
-        return 0;
-    if (Node* parent = node->parentNode())
-        if (parent->isElementNode())
-            return toElement(parent)->shadow();
-    return 0;
-}
-
 static inline bool nodeCanBeDistributed(const Node* node)
 {
     ASSERT(node);
@@ -322,42 +312,4 @@
     assertPostcondition();
 }
 
-AncestorChainWalker::AncestorChainWalker(const Node* node)
-    : m_node(node)
-    , m_distributedNode(node)
-    , m_isCrossingInsertionPoint(false)
-{
-    ASSERT(node);
-}
-
-void AncestorChainWalker::parent()
-{
-    ASSERT(m_node);
-    ASSERT(m_distributedNode);
-    if (ElementShadow* shadow = shadowOfParent(m_node)) {
-        if (InsertionPoint* insertionPoint = shadow->distributor().findInsertionPointFor(m_distributedNode)) {
-            m_node = insertionPoint;
-            m_isCrossingInsertionPoint = true;
-            return;
-        }
-    }
-    if (!m_node->isShadowRoot()) {
-        m_node = m_node->parentNode();
-        if (!(m_node && m_node->isShadowRoot() && ScopeContentDistribution::assignedTo(toShadowRoot(m_node))))
-            m_distributedNode = m_node;
-        m_isCrossingInsertionPoint = false;
-        return;
-    }
-
-    const ShadowRoot* shadowRoot = toShadowRoot(m_node);
-    if (InsertionPoint* insertionPoint = ScopeContentDistribution::assignedTo(shadowRoot)) {
-        m_node = insertionPoint;
-        m_isCrossingInsertionPoint = true;
-        return;
-    }
-    m_node = shadowRoot->host();
-    m_distributedNode = m_node;
-    m_isCrossingInsertionPoint = false;
-}
-
 } // namespace

Modified: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h (139324 => 139325)


--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h	2013-01-10 17:44:05 UTC (rev 139325)
@@ -141,19 +141,6 @@
 #endif
 }
 
-class AncestorChainWalker {
-public:
-    explicit AncestorChainWalker(const Node*);
-    void parent();
-    Node* get() const { return const_cast<Node*>(m_node); }
-    bool crossingInsertionPoint() { return m_isCrossingInsertionPoint; }
-
-private:
-    const Node* m_node;
-    const Node* m_distributedNode;
-    bool m_isCrossingInsertionPoint;
-};
-
 } // namespace
 
 #endif

Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (139324 => 139325)


--- trunk/Source/WebCore/dom/DOMAllInOne.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -26,6 +26,7 @@
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
 #include "ActiveDOMObject.cpp"
+#include "AncestorChainWalker.cpp"
 #include "Attr.cpp"
 #include "BeforeTextInsertedEvent.cpp"
 #include "BeforeUnloadEvent.cpp"

Modified: trunk/Source/WebCore/dom/ElementShadow.h (139324 => 139325)


--- trunk/Source/WebCore/dom/ElementShadow.h	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/ElementShadow.h	2013-01-10 17:44:05 UTC (rev 139325)
@@ -130,6 +130,17 @@
     }
 };
 
+inline ElementShadow* shadowOfParent(const Node* node)
+{
+    if (!node)
+        return 0;
+    if (Node* parent = node->parentNode())
+        if (parent->isElementNode())
+            return toElement(parent)->shadow();
+    return 0;
+}
+
+
 } // namespace
 
 #endif

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (139324 => 139325)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "EventDispatcher.h"
 
-#include "ComposedShadowTreeWalker.h"
+#include "AncestorChainWalker.h"
 #include "ContainerNode.h"
 #include "ElementShadow.h"
 #include "EventContext.h"

Modified: trunk/Source/WebCore/dom/Node.cpp (139324 => 139325)


--- trunk/Source/WebCore/dom/Node.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/Node.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -40,7 +40,6 @@
 #include "CSSStyleSheet.h"
 #include "ChildNodeList.h"
 #include "ClassNodeList.h"
-#include "ComposedShadowTreeWalker.h"
 #include "ContainerNodeAlgorithms.h"
 #include "ContextMenuController.h"
 #include "DOMImplementation.h"

Modified: trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp (139324 => 139325)


--- trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -92,6 +92,38 @@
     return 0;
 }
 
+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();
 }
 
+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();
+}
+
+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();
+}
+
+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();
+}
+
+}
+
 } // namespace

Modified: trunk/Source/WebCore/dom/NodeRenderingTraversal.h (139324 => 139325)


--- trunk/Source/WebCore/dom/NodeRenderingTraversal.h	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/NodeRenderingTraversal.h	2013-01-10 17:44:05 UTC (rev 139325)
@@ -71,6 +71,10 @@
 Node* previousSibling(const Node*);
 Node* previousSiblingSlow(const Node*);
 
+Node* nextInScope(const Node*);
+Node* previousInScope(const Node*);
+Node* parentInScope(const Node*);
+Node* lastChildInScope(const Node*);
 
 inline ContainerNode* parent(const Node* node, ParentDetails* details)
 {

Modified: trunk/Source/WebCore/dom/TreeScope.cpp (139324 => 139325)


--- trunk/Source/WebCore/dom/TreeScope.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/dom/TreeScope.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "TreeScope.h"
 
-#include "ComposedShadowTreeWalker.h"
+#include "AncestorChainWalker.h"
 #include "ContainerNode.h"
 #include "DOMSelection.h"
 #include "DOMWindow.h"

Modified: trunk/Source/WebCore/html/HTMLLIElement.cpp (139324 => 139325)


--- trunk/Source/WebCore/html/HTMLLIElement.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/html/HTMLLIElement.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -23,10 +23,10 @@
 #include "config.h"
 #include "HTMLLIElement.h"
 
+#include "AncestorChainWalker.h"
 #include "Attribute.h"
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
-#include "ComposedShadowTreeWalker.h"
 #include "HTMLNames.h"
 #include "RenderListItem.h"
 
@@ -96,7 +96,7 @@
 
         // Find the enclosing list node.
         Node* listNode = 0;
-        ComposedShadowTreeWalker walker(this);
+        AncestorChainWalker walker(this);
         while (!listNode) {
             walker.parent();
             if (!walker.get())

Modified: trunk/Source/WebCore/page/EventHandler.cpp (139324 => 139325)


--- trunk/Source/WebCore/page/EventHandler.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -29,11 +29,11 @@
 #include "EventHandler.h"
 
 #include "AXObjectCache.h"
+#include "AncestorChainWalker.h"
 #include "AutoscrollController.h"
 #include "CachedImage.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
-#include "ComposedShadowTreeWalker.h"
 #include "Cursor.h"
 #include "CursorList.h"
 #include "Document.h"

Modified: trunk/Source/WebCore/page/FocusController.cpp (139324 => 139325)


--- trunk/Source/WebCore/page/FocusController.cpp	2013-01-10 17:29:45 UTC (rev 139324)
+++ trunk/Source/WebCore/page/FocusController.cpp	2013-01-10 17:44:05 UTC (rev 139325)
@@ -29,7 +29,6 @@
 
 #include "AXObjectCache.h"
 #include "Chrome.h"
-#include "ComposedShadowTreeWalker.h"
 #include "Document.h"
 #include "Editor.h"
 #include "EditorClient.h"
@@ -48,6 +47,7 @@
 #include "HTMLNames.h"
 #include "HitTestResult.h"
 #include "KeyboardEvent.h"
+#include "NodeRenderingTraversal.h"
 #include "NodeTraversal.h"
 #include "Page.h"
 #include "Range.h"
@@ -66,35 +66,6 @@
 using namespace HTMLNames;
 using namespace std;
 
-static inline ComposedShadowTreeWalker walkerFrom(const Node* node)
-{
-    return ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
-}
-
-static inline ComposedShadowTreeWalker walkerFromNext(const Node* node)
-{
-    ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
-    walker.next();
-    return walker;
-}
-
-static inline ComposedShadowTreeWalker walkerFromPrevious(const Node* node)
-{
-    ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
-    walker.previous();
-    return walker;
-}
-
-static inline Node* nextNode(const Node* node)
-{
-    return walkerFromNext(node).get();
-}
-
-static inline Node* previousNode(const Node* node)
-{
-    return walkerFromPrevious(node).get();
-}
-
 FocusNavigationScope::FocusNavigationScope(TreeScope* treeScope)
     : m_rootTreeScope(treeScope)
 {
@@ -120,12 +91,9 @@
 FocusNavigationScope FocusNavigationScope::focusNavigationScopeOf(Node* node)
 {
     ASSERT(node);
-    ComposedShadowTreeWalker walker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);
     Node* root = node;
-    while (walker.get()) {
-        root = walker.get();
-        walker.parent();
-    }
+    for (Node* n = node; n; n = NodeRenderingTraversal::parentInScope(n))
+        root = n;
     // The result is not always a ShadowRoot nor a DocumentNode since
     // a starting node is in an orphaned tree in composed shadow tree.
     return FocusNavigationScope(root->treeScope());
@@ -449,9 +417,10 @@
 Node* FocusController::findNodeWithExactTabIndex(Node* start, int tabIndex, KeyboardEvent* event, FocusDirection direction)
 {
     // Search is inclusive of start
-    for (ComposedShadowTreeWalker walker = walkerFrom(start); walker.get(); direction == FocusDirectionForward ? walker.next() : walker.previous()) {
-        if (shouldVisit(walker.get(), event) && adjustedTabIndex(walker.get(), event) == tabIndex)
-            return walker.get();
+    using namespace NodeRenderingTraversal;
+    for (Node* node = start; node; node = direction == FocusDirectionForward ? nextInScope(node) : previousInScope(node)) {
+        if (shouldVisit(node, event) && adjustedTabIndex(node, event) == tabIndex)
+            return node;
     }
     return 0;
 }
@@ -461,8 +430,7 @@
     // Search is inclusive of start
     int winningTabIndex = std::numeric_limits<short>::max() + 1;
     Node* winner = 0;
-    for (ComposedShadowTreeWalker walker = walkerFrom(start); walker.get(); walker.next()) {
-        Node* node = walker.get();
+    for (Node* node = start; node; node = NodeRenderingTraversal::nextInScope(node)) {
         if (shouldVisit(node, event) && node->tabIndex() > tabIndex && node->tabIndex() < winningTabIndex) {
             winner = node;
             winningTabIndex = node->tabIndex();
@@ -477,8 +445,7 @@
     // Search is inclusive of start
     int winningTabIndex = 0;
     Node* winner = 0;
-    for (ComposedShadowTreeWalker walker = walkerFrom(start); walker.get(); walker.previous()) {
-        Node* node = walker.get();
+    for (Node* node = start; node; node = NodeRenderingTraversal::previousInScope(node)) {
         int currentTabIndex = adjustedTabIndex(node, event);
         if ((shouldVisit(node, event) || isNonFocusableShadowHost(node, event)) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) {
             winner = node;
@@ -490,18 +457,20 @@
 
 Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start, KeyboardEvent* event)
 {
+    using namespace NodeRenderingTraversal;
+
     if (start) {
         int tabIndex = adjustedTabIndex(start, event);
         // If a node is excluded from the normal tabbing cycle, the next focusable node is determined by tree order
         if (tabIndex < 0) {
-            for (ComposedShadowTreeWalker walker = walkerFromNext(start); walker.get(); walker.next()) {
-                if (shouldVisit(walker.get(), event) && adjustedTabIndex(walker.get(), event) >= 0)
-                    return walker.get();
+            for (Node* node = nextInScope(start); node; node = nextInScope(node)) {
+                if (shouldVisit(node, event) && adjustedTabIndex(node, event) >= 0)
+                    return node;
             }
         }
 
         // First try to find a node with the same tabindex as start that comes after start in the scope.
-        if (Node* winner = findNodeWithExactTabIndex(nextNode(start), tabIndex, event, FocusDirectionForward))
+        if (Node* winner = findNodeWithExactTabIndex(nextInScope(start), tabIndex, event, FocusDirectionForward))
             return winner;
 
         if (!tabIndex)
@@ -522,9 +491,11 @@
 
 Node* FocusController::previousFocusableNode(FocusNavigationScope scope, Node* start, KeyboardEvent* event)
 {
+    using namespace NodeRenderingTraversal;
+
     Node* last = 0;
-    for (ComposedShadowTreeWalker walker = walkerFrom(scope.rootNode()); walker.get(); walker.lastChild())
-        last = walker.get();
+    for (Node* node = scope.rootNode(); node; node = lastChildInScope(node))
+        last = node;
     ASSERT(last);
 
     // First try to find the last node in the scope that comes before start and has the same tabindex as start.
@@ -532,7 +503,7 @@
     Node* startingNode;
     int startingTabIndex;
     if (start) {
-        startingNode = previousNode(start);
+        startingNode = previousInScope(start);
         startingTabIndex = adjustedTabIndex(start, event);
     } else {
         startingNode = last;
@@ -541,9 +512,9 @@
 
     // However, if a node is excluded from the normal tabbing cycle, the previous focusable node is determined by tree order
     if (startingTabIndex < 0) {
-        for (ComposedShadowTreeWalker walker = walkerFrom(startingNode); walker.get(); walker.previous()) {
-            if (shouldVisit(walker.get(), event) && adjustedTabIndex(walker.get(), event) >= 0)
-                return walker.get();
+        for (Node* node = startingNode; node; node = previousInScope(node)) {
+            if (shouldVisit(node, event) && adjustedTabIndex(node, event) >= 0)
+                return node;
         }
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to