Title: [112978] trunk/Source/WebCore
Revision
112978
Author
[email protected]
Date
2012-04-02 20:00:48 -0700 (Mon, 02 Apr 2012)

Log Message

Remove TreeScope::isShadowRoot.
https://bugs.webkit.org/show_bug.cgi?id=82879

Reviewed by Dimitri Glazkov.

This patch removes TreeScope::isShadowRoot(). To make code fast, TreeScope::isShadowRoot
is implemented in ShadowRoot.h. So when using TreeScope::isShadowRoot(), ShadowRoot.h is
always required. In some case,  this might bring unnecessary dependency.

Since TreeScope::rootNode() is inlined, the overall performance won't change.

No new tests, simple refactoring.

* dom/ShadowRoot.h:
* dom/TreeScope.h:
* html/shadow/HTMLShadowElement.cpp:
(WebCore::HTMLShadowElement::doesSelectFromHostChildren):
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::attach):
(WebCore::InsertionPoint::assignedFrom):
(WebCore::InsertionPoint::isShadowBoundary):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112977 => 112978)


--- trunk/Source/WebCore/ChangeLog	2012-04-03 02:44:44 UTC (rev 112977)
+++ trunk/Source/WebCore/ChangeLog	2012-04-03 03:00:48 UTC (rev 112978)
@@ -1,3 +1,27 @@
+2012-04-02  Shinya Kawanaka  <[email protected]>
+
+        Remove TreeScope::isShadowRoot.
+        https://bugs.webkit.org/show_bug.cgi?id=82879
+
+        Reviewed by Dimitri Glazkov.
+
+        This patch removes TreeScope::isShadowRoot(). To make code fast, TreeScope::isShadowRoot
+        is implemented in ShadowRoot.h. So when using TreeScope::isShadowRoot(), ShadowRoot.h is
+        always required. In some case,  this might bring unnecessary dependency.
+
+        Since TreeScope::rootNode() is inlined, the overall performance won't change.
+
+        No new tests, simple refactoring.
+
+        * dom/ShadowRoot.h:
+        * dom/TreeScope.h:
+        * html/shadow/HTMLShadowElement.cpp:
+        (WebCore::HTMLShadowElement::doesSelectFromHostChildren):
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::attach):
+        (WebCore::InsertionPoint::assignedFrom):
+        (WebCore::InsertionPoint::isShadowBoundary):
+
 2012-04-02  Emil A Eklund  <[email protected]>
 
         Fix usage of LayoutUnits and pixel snapping in RenderLayer

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (112977 => 112978)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2012-04-03 02:44:44 UTC (rev 112977)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2012-04-03 03:00:48 UTC (rev 112978)
@@ -139,18 +139,6 @@
     return const_cast<ShadowRoot*>(toShadowRoot(static_cast<const Node*>(node)));
 }
 
-inline ShadowRoot* toShadowRoot(TreeScope* scope)
-{
-    ASSERT(!scope || scope->isShadowRoot());
-    return static_cast<ShadowRoot*>(scope);
-}
-
-// Put this TreeScope method here to inline it.
-inline bool TreeScope::isShadowRoot() const
-{
-    return m_rootNode->isShadowRoot();
-}
-
 } // namespace
 
 #endif

Modified: trunk/Source/WebCore/dom/TreeScope.h (112977 => 112978)


--- trunk/Source/WebCore/dom/TreeScope.h	2012-04-03 02:44:44 UTC (rev 112977)
+++ trunk/Source/WebCore/dom/TreeScope.h	2012-04-03 03:00:48 UTC (rev 112978)
@@ -61,7 +61,6 @@
     void addNodeListCache() { ++m_numNodeListCaches; }
     void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }
     bool hasNodeListCaches() const { return m_numNodeListCaches; }
-    bool isShadowRoot() const;
 
     // Find first anchor with the given name.
     // First searches for an element with the given ID, but if that fails, then looks
@@ -107,4 +106,3 @@
 } // namespace WebCore
 
 #endif // TreeScope_h
-

Modified: trunk/Source/WebCore/html/shadow/HTMLShadowElement.cpp (112977 => 112978)


--- trunk/Source/WebCore/html/shadow/HTMLShadowElement.cpp	2012-04-03 02:44:44 UTC (rev 112977)
+++ trunk/Source/WebCore/html/shadow/HTMLShadowElement.cpp	2012-04-03 03:00:48 UTC (rev 112978)
@@ -63,8 +63,8 @@
 {
     TreeScope* scope = treeScope();
 
-    if (scope->isShadowRoot())
-        return toShadowRoot(scope)->isOldest();
+    if (scope->rootNode()->isShadowRoot())
+        return toShadowRoot(scope->rootNode())->isOldest();
     return false;
 }
 

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (112977 => 112978)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2012-04-03 02:44:44 UTC (rev 112977)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2012-04-03 03:00:48 UTC (rev 112978)
@@ -49,8 +49,8 @@
 void InsertionPoint::attach()
 {
     TreeScope* scope = treeScope();
-    if (scope->isShadowRoot()) {
-        ShadowRoot* root = toShadowRoot(scope);
+    if (scope->rootNode()->isShadowRoot()) {
+        ShadowRoot* root = toShadowRoot(scope->rootNode());
         if (doesSelectFromHostChildren()) {
             distributeHostChildren(root->tree());
             attachDistributedNode();
@@ -85,11 +85,11 @@
 
 ShadowRoot* InsertionPoint::assignedFrom() const
 {
-    TreeScope* scope = treeScope();
-    if (!scope->isShadowRoot())
+    Node* treeScopeRoot = treeScope()->rootNode();
+    if (!treeScopeRoot->isShadowRoot())
         return 0;
 
-    ShadowRoot* olderShadowRoot = toShadowRoot(scope)->olderShadowRoot();
+    ShadowRoot* olderShadowRoot = toShadowRoot(treeScopeRoot)->olderShadowRoot();
     if (olderShadowRoot && olderShadowRoot->assignedTo() == this)
         return olderShadowRoot;
     return 0;
@@ -97,9 +97,7 @@
 
 bool InsertionPoint::isShadowBoundary() const
 {
-    if (TreeScope* scope = treeScope())
-        return scope->isShadowRoot();
-    return false;
+    return treeScope()->rootNode()->isShadowRoot();
 }
 
 bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to