Title: [136675] trunk/Source/WebCore
Revision
136675
Author
[email protected]
Date
2012-12-05 05:11:58 -0800 (Wed, 05 Dec 2012)

Log Message

ShadowRoot should recalcStyle for itself
https://bugs.webkit.org/show_bug.cgi?id=103933

Patch by Elliott Sprehn <[email protected]> on 2012-12-05
Reviewed by Hajime Morita.

ShadowRoot should support recalcStyle just like Element instead of
having the code inside ElementShadow. This was once the case and
the dead method prototype for recalcShadowTreeStyle is still in
ShadowRoot.h.

No new tests, just refactoring.

* dom/ElementShadow.cpp:
(WebCore::ElementShadow::recalcStyle):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::recalcStyle):
* dom/ShadowRoot.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136674 => 136675)


--- trunk/Source/WebCore/ChangeLog	2012-12-05 12:56:29 UTC (rev 136674)
+++ trunk/Source/WebCore/ChangeLog	2012-12-05 13:11:58 UTC (rev 136675)
@@ -1,3 +1,23 @@
+2012-12-05  Elliott Sprehn  <[email protected]>
+
+        ShadowRoot should recalcStyle for itself
+        https://bugs.webkit.org/show_bug.cgi?id=103933
+
+        Reviewed by Hajime Morita.
+
+        ShadowRoot should support recalcStyle just like Element instead of
+        having the code inside ElementShadow. This was once the case and
+        the dead method prototype for recalcShadowTreeStyle is still in
+        ShadowRoot.h.
+
+        No new tests, just refactoring.
+
+        * dom/ElementShadow.cpp:
+        (WebCore::ElementShadow::recalcStyle):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::recalcStyle):
+        * dom/ShadowRoot.h:
+
 2012-12-05  Keishi Hattori  <[email protected]>
 
         Fix text direction in datalist popup for time controls

Modified: trunk/Source/WebCore/dom/ElementShadow.cpp (136674 => 136675)


--- trunk/Source/WebCore/dom/ElementShadow.cpp	2012-12-05 12:56:29 UTC (rev 136674)
+++ trunk/Source/WebCore/dom/ElementShadow.cpp	2012-12-05 13:11:58 UTC (rev 136675)
@@ -37,7 +37,6 @@
 #include "InspectorInstrumentation.h"
 #include "ShadowRoot.h"
 #include "StyleResolver.h"
-#include "Text.h"
 
 namespace WebCore {
 
@@ -158,21 +157,8 @@
 
 void ElementShadow::recalcStyle(Node::StyleChange change)
 {
-    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
-        StyleResolver* styleResolver = root->document()->styleResolver();
-        styleResolver->pushParentShadowRoot(root);
-
-        for (Node* n = root->firstChild(); n; n = n->nextSibling()) {
-            if (n->isElementNode())
-                static_cast<Element*>(n)->recalcStyle(change);
-            else if (n->isTextNode())
-                toText(n)->recalcTextStyle(change);
-        }
-
-        styleResolver->popParentShadowRoot(root);
-        root->clearNeedsStyleRecalc();
-        root->clearChildNeedsStyleRecalc();
-    }
+    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
+        root->recalcStyle(change);
 }
 
 void ElementShadow::ensureDistribution()

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (136674 => 136675)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-12-05 12:56:29 UTC (rev 136674)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-12-05 13:11:58 UTC (rev 136675)
@@ -44,6 +44,7 @@
 #include "RuntimeEnabledFeatures.h"
 #include "SVGNames.h"
 #include "StyleResolver.h"
+#include "Text.h"
 #include "markup.h"
 
 // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
@@ -198,6 +199,26 @@
     }
 }
 
+void ShadowRoot::recalcStyle(StyleChange change)
+{
+    // ShadowRoot doesn't support custom callbacks.
+    ASSERT(!hasCustomCallbacks());
+
+    StyleResolver* styleResolver = document()->styleResolver();
+    styleResolver->pushParentShadowRoot(this);
+
+    for (Node* child = firstChild(); child; child = child->nextSibling()) {
+        if (child->isElementNode())
+            static_cast<Element*>(child)->recalcStyle(change);
+        else if (child->isTextNode())
+            toText(child)->recalcTextStyle(change);
+    }
+
+    styleResolver->popParentShadowRoot(this);
+    clearNeedsStyleRecalc();
+    clearChildNeedsStyleRecalc();
+}
+
 ElementShadow* ShadowRoot::owner() const
 {
     if (host())

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (136674 => 136675)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2012-12-05 12:56:29 UTC (rev 136674)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2012-12-05 13:11:58 UTC (rev 136675)
@@ -58,7 +58,7 @@
     };
     static PassRefPtr<ShadowRoot> create(Element*, ShadowRootType, ExceptionCode& = ASSERT_NO_EXCEPTION);
 
-    void recalcShadowTreeStyle(StyleChange);
+    void recalcStyle(StyleChange);
 
     virtual bool applyAuthorStyles() const OVERRIDE;
     void setApplyAuthorStyles(bool);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to