Title: [150713] trunk/Source/WebCore
Revision
150713
Author
[email protected]
Date
2013-05-26 05:10:23 -0700 (Sun, 26 May 2013)

Log Message

TreeScope::rootNode() should return a ContainerNode.
<http://webkit.org/b/116782>

Reviewed by Antti Koivisto.

The rootNode() of a TreeScope is always a ContainerNode, so update pointer types to reflect that.
This lets us take advantage of Antti's optimized traversal functions.

* dom/ContainerNode.h:
(WebCore::Node::isTreeScope):
* dom/Document.cpp:
(WebCore::Document::buildAccessKeyMap):
* dom/Node.cpp:
(WebCore::Node::containingShadowRoot):
* dom/Node.h:
* dom/TreeScope.h:
(WebCore::TreeScope::rootNode):
(TreeScope):
* page/FocusController.cpp:
(WebCore::FocusNavigationScope::rootNode):
(WebCore::FocusNavigationScope::owner):
* page/FocusController.h:
(FocusNavigationScope):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150712 => 150713)


--- trunk/Source/WebCore/ChangeLog	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/ChangeLog	2013-05-26 12:10:23 UTC (rev 150713)
@@ -1,5 +1,31 @@
 2013-05-26  Andreas Kling  <[email protected]>
 
+        TreeScope::rootNode() should return a ContainerNode.
+        <http://webkit.org/b/116782>
+
+        Reviewed by Antti Koivisto.
+
+        The rootNode() of a TreeScope is always a ContainerNode, so update pointer types to reflect that.
+        This lets us take advantage of Antti's optimized traversal functions.
+
+        * dom/ContainerNode.h:
+        (WebCore::Node::isTreeScope):
+        * dom/Document.cpp:
+        (WebCore::Document::buildAccessKeyMap):
+        * dom/Node.cpp:
+        (WebCore::Node::containingShadowRoot):
+        * dom/Node.h:
+        * dom/TreeScope.h:
+        (WebCore::TreeScope::rootNode):
+        (TreeScope):
+        * page/FocusController.cpp:
+        (WebCore::FocusNavigationScope::rootNode):
+        (WebCore::FocusNavigationScope::owner):
+        * page/FocusController.h:
+        (FocusNavigationScope):
+
+2013-05-26  Andreas Kling  <[email protected]>
+
         FocusController::setFocusedNode() should be setFocusedElement().
         <http://webkit.org/b/116780>
 

Modified: trunk/Source/WebCore/dom/ContainerNode.h (150712 => 150713)


--- trunk/Source/WebCore/dom/ContainerNode.h	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/dom/ContainerNode.h	2013-05-26 12:10:23 UTC (rev 150713)
@@ -260,6 +260,11 @@
     return parent && parent->getFlag(NeedsShadowTreeWalkerFlag);
 }
 
+inline bool Node::isTreeScope() const
+{
+    return treeScope()->rootNode() == this;
+}
+
 // This constant controls how much buffer is initially allocated
 // for a Node Vector that is used to store child Nodes of a given Node.
 // FIXME: Optimize the value.

Modified: trunk/Source/WebCore/dom/Document.cpp (150712 => 150713)


--- trunk/Source/WebCore/dom/Document.cpp	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-05-26 12:10:23 UTC (rev 150713)
@@ -711,7 +711,7 @@
 void Document::buildAccessKeyMap(TreeScope* scope)
 {
     ASSERT(scope);
-    Node* rootNode = scope->rootNode();
+    ContainerNode* rootNode = scope->rootNode();
     for (Element* element = ElementTraversal::firstWithin(rootNode); element; element = ElementTraversal::next(element, rootNode)) {
         const AtomicString& accessKey = element->getAttribute(accesskeyAttr);
         if (!accessKey.isEmpty())

Modified: trunk/Source/WebCore/dom/Node.cpp (150712 => 150713)


--- trunk/Source/WebCore/dom/Node.cpp	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/dom/Node.cpp	2013-05-26 12:10:23 UTC (rev 150713)
@@ -1223,7 +1223,7 @@
 
 ShadowRoot* Node::containingShadowRoot() const
 {
-    Node* root = treeScope()->rootNode();
+    ContainerNode* root = treeScope()->rootNode();
     return root && root->isShadowRoot() ? toShadowRoot(root) : 0;
 }
 

Modified: trunk/Source/WebCore/dom/Node.h (150712 => 150713)


--- trunk/Source/WebCore/dom/Node.h	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/dom/Node.h	2013-05-26 12:10:23 UTC (rev 150713)
@@ -258,7 +258,7 @@
     virtual bool isInsertionPointNode() const { return false; }
 
     bool isDocumentNode() const;
-    bool isTreeScope() const { return treeScope()->rootNode() == this; }
+    bool isTreeScope() const;
     bool isDocumentFragment() const { return getFlag(IsDocumentFragmentFlag); }
     bool isShadowRoot() const { return isDocumentFragment() && isTreeScope(); }
     bool isInsertionPoint() const { return getFlag(NeedsShadowTreeWalkerFlag) && isInsertionPointNode(); }

Modified: trunk/Source/WebCore/dom/TreeScope.h (150712 => 150713)


--- trunk/Source/WebCore/dom/TreeScope.h	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/dom/TreeScope.h	2013-05-26 12:10:23 UTC (rev 150713)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2011 Google Inc. All Rights Reserved.
- * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2012, 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
@@ -99,7 +99,7 @@
     // Used by the basic DOM mutation methods (e.g., appendChild()).
     void adoptIfNeeded(Node*);
 
-    Node* rootNode() const { return m_rootNode; }
+    ContainerNode* rootNode() const { return m_rootNode; }
 
     IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTargetObserverRegistry.get(); }
 
@@ -162,7 +162,7 @@
     void beginDeletion() { }
 #endif
 
-    Node* m_rootNode;
+    ContainerNode* m_rootNode;
     Document* m_documentScope;
     TreeScope* m_parentTreeScope;
     int m_guardRefCount;

Modified: trunk/Source/WebCore/page/FocusController.cpp (150712 => 150713)


--- trunk/Source/WebCore/page/FocusController.cpp	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/page/FocusController.cpp	2013-05-26 12:10:23 UTC (rev 150713)
@@ -72,14 +72,14 @@
     ASSERT(treeScope);
 }
 
-Node* FocusNavigationScope::rootNode() const
+ContainerNode* FocusNavigationScope::rootNode() const
 {
     return m_rootTreeScope->rootNode();
 }
 
 Element* FocusNavigationScope::owner() const
 {
-    Node* root = rootNode();
+    ContainerNode* root = rootNode();
     if (root->isShadowRoot())
         return toShadowRoot(root)->host();
     if (Frame* frame = root->document()->frame())

Modified: trunk/Source/WebCore/page/FocusController.h (150712 => 150713)


--- trunk/Source/WebCore/page/FocusController.h	2013-05-26 11:39:01 UTC (rev 150712)
+++ trunk/Source/WebCore/page/FocusController.h	2013-05-26 12:10:23 UTC (rev 150713)
@@ -35,6 +35,7 @@
 namespace WebCore {
 
 struct FocusCandidate;
+class ContainerNode;
 class Document;
 class Element;
 class Frame;
@@ -47,7 +48,7 @@
 
 class FocusNavigationScope {
 public:
-    Node* rootNode() const;
+    ContainerNode* rootNode() const;
     Element* owner() const;
     static FocusNavigationScope focusNavigationScopeOf(Node*);
     static FocusNavigationScope focusNavigationScopeOwnedByShadowHost(Node*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to