Title: [116255] trunk
Revision
116255
Author
[email protected]
Date
2012-05-06 18:11:15 -0700 (Sun, 06 May 2012)

Log Message

[Shadow DOM] Node distribution should be refreshed before style recalc.
https://bugs.webkit.org/show_bug.cgi?id=85259

Reviewed by Dimitri Glazkov.

Source/WebCore:

Element::recalcStyle() calls child element's recalcStyle()
recursively, following ShadowTree::recalcShadowTreeStyle(). But
recalcShadowTreeStyle() should be called before such recursion if
necessary.

This is because style calculation and following renderer attachment
of each child element depends on up-to-date node distribution result
which is computed during the recalcShadowTreeStyle().

Test: fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html

* dom/Element.cpp: Moved recalcShadowTreeStyle() before child traversals.
(WebCore::Element::recalcStyle):

LayoutTests:

* fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector-expected.txt: Added.
* fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116254 => 116255)


--- trunk/LayoutTests/ChangeLog	2012-05-07 00:53:33 UTC (rev 116254)
+++ trunk/LayoutTests/ChangeLog	2012-05-07 01:11:15 UTC (rev 116255)
@@ -1,3 +1,13 @@
+2012-05-06  MORITA Hajime  <[email protected]>
+
+        [Shadow DOM] Node distribution should be refreshed before style recalc.
+        https://bugs.webkit.org/show_bug.cgi?id=85259
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector-expected.txt: Added.
+        * fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html: Added.
+
 2012-05-06  Adam Barth  <[email protected]>
 
         CSP should let sites both enforce one policy and monitor another

Added: trunk/LayoutTests/fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector-expected.txt (0 => 116255)


--- trunk/LayoutTests/fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector-expected.txt	2012-05-07 01:11:15 UTC (rev 116255)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html (0 => 116255)


--- trunk/LayoutTests/fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html	2012-05-07 01:11:15 UTC (rev 116255)
@@ -0,0 +1,32 @@
+<style>
+.baz:nth-last-child(odd) { display: block;  }
+</style>
+<script>
+function test() {
+    var foo = document.createElement('div');
+    document.documentElement.appendChild(foo);
+
+    var bar = document.createElement('div');
+    var barShadow = new WebKitShadowRoot(bar);
+    bar.setAttribute('class', 'bar');
+    document.documentElement.appendChild(bar);
+
+    baz = document.createElement('span');
+    baz.setAttribute('class', 'baz');
+    bar.appendChild(baz);
+
+    var qux = document.createElement('div');
+    bar.appendChild(qux);
+
+    var ip = document.createElement('shadow');
+    barShadow.appendChild(ip);
+
+    document.documentElement.offsetLeft;
+    foo.appendChild(qux);
+    layoutTestController.notifyDone();
+}
+
+layoutTestController.waitUntilDone();
+layoutTestController.dumpAsText();
+window._onload_ = test;
+</script>

Modified: trunk/Source/WebCore/ChangeLog (116254 => 116255)


--- trunk/Source/WebCore/ChangeLog	2012-05-07 00:53:33 UTC (rev 116254)
+++ trunk/Source/WebCore/ChangeLog	2012-05-07 01:11:15 UTC (rev 116255)
@@ -1,3 +1,24 @@
+2012-05-06  MORITA Hajime  <[email protected]>
+
+        [Shadow DOM] Node distribution should be refreshed before style recalc.
+        https://bugs.webkit.org/show_bug.cgi?id=85259
+
+        Reviewed by Dimitri Glazkov.
+
+        Element::recalcStyle() calls child element's recalcStyle()
+        recursively, following ShadowTree::recalcShadowTreeStyle(). But
+        recalcShadowTreeStyle() should be called before such recursion if
+        necessary.
+
+        This is because style calculation and following renderer attachment
+        of each child element depends on up-to-date node distribution result
+        which is computed during the recalcShadowTreeStyle().
+
+        Test: fast/dom/shadow/shadow-dynamic-style-change-via-mutation-and-selector.html
+
+        * dom/Element.cpp: Moved recalcShadowTreeStyle() before child traversals.
+        (WebCore::Element::recalcStyle):
+
 2012-05-06  Adam Barth  <[email protected]>
 
         CSP should let sites both enforce one policy and monitor another

Modified: trunk/Source/WebCore/dom/Element.cpp (116254 => 116255)


--- trunk/Source/WebCore/dom/Element.cpp	2012-05-07 00:53:33 UTC (rev 116254)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-05-07 01:11:15 UTC (rev 116255)
@@ -1154,6 +1154,16 @@
         }
     }
     StyleResolverParentPusher parentPusher(this);
+
+    // FIXME: This does not care about sibling combinators. Will be necessary in XBL2 world.
+    if (hasShadowRoot()) {
+        ShadowTree* tree = shadowTree();
+        if (change >= Inherit || tree->childNeedsStyleRecalc() || tree->needsStyleRecalc()) {
+            parentPusher.push();
+            tree->recalcShadowTreeStyle(change);
+        }
+    }
+
     // FIXME: This check is good enough for :hover + foo, but it is not good enough for :hover + foo + bar.
     // For now we will just worry about the common case, since it's a lot trickier to get the second case right
     // without doing way too much re-resolution.
@@ -1177,14 +1187,6 @@
         forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
         forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);
     }
-    // FIXME: This does not care about sibling combinators. Will be necessary in XBL2 world.
-    if (hasShadowRoot()) {
-        ShadowTree* tree = shadowTree();
-        if (change >= Inherit || tree->childNeedsStyleRecalc() || tree->needsStyleRecalc()) {
-            parentPusher.push();
-            tree->recalcShadowTreeStyle(change);
-        }
-    }
 
     clearNeedsStyleRecalc();
     clearChildNeedsStyleRecalc();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to