Title: [117716] trunk
Revision
117716
Author
[email protected]
Date
2012-05-20 17:50:01 -0700 (Sun, 20 May 2012)

Log Message

Needs style recalculation by changing applyAuthorStyles dynamically
https://bugs.webkit.org/show_bug.cgi?id=84251

Source/WebCore:

Modifying setApplyAuthorStyles to invoke owner()'s
setNeedsRedistributing if applyAuthorStyles changes.

Patch by Takashi Sakamoto <[email protected]> on 2012-05-20
Reviewed by Hajime Morita.

No new tests. Adding new tests to existing
fast/dom/shadow/shadow-root-applyAuthorStyles.html to test this
feature.

* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::setApplyAuthorStyles):
If applyAuthorStyles changes, invoke owner's setNeedsRedistributing to
recalculate styles of the shadow root's child elements.

LayoutTests:

Patch by Takashi Sakamoto <[email protected]> on 2012-05-20
Reviewed by Hajime Morita.

* fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html:
* fast/dom/shadow/shadow-root-applyAuthorStyles.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (117715 => 117716)


--- trunk/LayoutTests/ChangeLog	2012-05-20 23:32:43 UTC (rev 117715)
+++ trunk/LayoutTests/ChangeLog	2012-05-21 00:50:01 UTC (rev 117716)
@@ -1,3 +1,13 @@
+2012-05-20  Takashi Sakamoto  <[email protected]>
+
+        Needs style recalculation by changing applyAuthorStyles dynamically
+        https://bugs.webkit.org/show_bug.cgi?id=84251
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html:
+        * fast/dom/shadow/shadow-root-applyAuthorStyles.html:
+
 2012-05-20  Philip Rogers  <[email protected]>
 
         Skip failing hit testing tests

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html (117715 => 117716)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html	2012-05-20 23:32:43 UTC (rev 117715)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html	2012-05-21 00:50:01 UTC (rev 117716)
@@ -5,5 +5,7 @@
 <div id="no-apply-author-style"><span></span></div>
 <div id="with-inline-style-declaration"><span style="background-color:#eef;border:none;color:#daa;display:boxed-inline;font-size:18px;margin:2px;outline-color:#f00;padding-left:5px;text-align:start;text-decoration:none;"></span></div>
 <div id="try-to-overide-important"><input type="file" /></div>
+<div id="change-apply-author-style-from-true-to-false"><div><span></span></div></div>
+<div id="change-apply-author-style-from-false-to-true"><div><span style="background-color:#eef;border:solid;color:#fee;display:boxed-inline;font-size:24px;margin:2px;outline-color:#f00;padding-left:5px;text-align:start;text-decoration:underline;"></span></div></div>
 </body>
 </html>

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html (117715 => 117716)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html	2012-05-20 23:32:43 UTC (rev 117715)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html	2012-05-21 00:50:01 UTC (rev 117716)
@@ -25,8 +25,24 @@
 <div id="no-apply-author-style"></div>
 <div id="with-inline-style-declaration"></div>
 <div id="try-to-override-important"></div>
+<div id="change-apply-author-style-from-true-to-false"></div>
+<div id="change-apply-author-style-from-false-to-true"></div>
 
 <script>
+function shouldBe(a, b)
+{
+   if (a != b) {
+      throw "failure:" + a + ": should be " + b;
+   }
+}
+
+function shouldNotBe(a, b)
+{
+   if (a == b) {
+      throw "failure:" + a + ": should not be " + b;
+   }
+}
+
 function assertTrue(id, actual) {
    if (!actual) {
        throw "failure:" + id +  ": assertTrue failed";
@@ -83,10 +99,53 @@
     shadowRoot.innerHTML = '<input type="file" />';
 }
 
+function testChangingApplyAuthorStyleFromTrueToFalse() {
+    var div = document.createElement('div');
+    document.getElementById('change-apply-author-style-from-true-to-false').appendChild(div);
+
+    var shadowRoot = new WebKitShadowRoot(div);
+    assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
+    shadowRoot.applyAuthorStyles = true;
+    assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+    shadowRoot.innerHTML = '<div><span id="test1"></span></div>';
+    div.offsetLeft;
+    var target = shadowRoot.getElementById('test1');
+    shouldBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+    shouldBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+
+    shadowRoot.applyAuthorStyles = false;
+    assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
+    div.offsetLeft;
+    shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+    shouldNotBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+}
+
+function testChangingApplyAuthorStyleFromFalseToTrue() {
+    var div = document.createElement('div');
+    document.getElementById('change-apply-author-style-from-false-to-true').appendChild(div);
+
+    var shadowRoot = new WebKitShadowRoot(div);
+    shadowRoot.applyAuthorStyles = false;
+    assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
+    shadowRoot.innerHTML = '<div><span id="test2"></span></div>';
+    div.offsetLeft;
+    var target = shadowRoot.getElementById('test2');
+    shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+    shouldNotBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+
+    shadowRoot.applyAuthorStyles = true;
+    assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+    div.offsetLeft;
+    shouldBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+    shouldBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+}
+
 renderApplyAuthorStyleCase();
 renderNoApplyAuthorStyleCase();
 renderApplyAuthorStyleWithInlineStyleDeclarationCase();
 renderApplyAuthorStyleWithOverridingImportantPropertyCase();
+testChangingApplyAuthorStyleFromTrueToFalse();
+testChangingApplyAuthorStyleFromFalseToTrue();
 </script>
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (117715 => 117716)


--- trunk/Source/WebCore/ChangeLog	2012-05-20 23:32:43 UTC (rev 117715)
+++ trunk/Source/WebCore/ChangeLog	2012-05-21 00:50:01 UTC (rev 117716)
@@ -1,3 +1,22 @@
+2012-05-20  Takashi Sakamoto  <[email protected]>
+
+        Needs style recalculation by changing applyAuthorStyles dynamically
+        https://bugs.webkit.org/show_bug.cgi?id=84251
+
+        Modifying setApplyAuthorStyles to invoke owner()'s
+        setNeedsRedistributing if applyAuthorStyles changes.
+
+        Reviewed by Hajime Morita.
+
+        No new tests. Adding new tests to existing
+        fast/dom/shadow/shadow-root-applyAuthorStyles.html to test this
+        feature.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::setApplyAuthorStyles):
+        If applyAuthorStyles changes, invoke owner's setNeedsRedistributing to
+        recalculate styles of the shadow root's child elements.
+
 2012-05-20  Philip Rogers  <[email protected]>
 
         Accumulate SVG animations into first contributing element

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (117715 => 117716)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-05-20 23:32:43 UTC (rev 117715)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-05-21 00:50:01 UTC (rev 117716)
@@ -188,7 +188,11 @@
 
 void ShadowRoot::setApplyAuthorStyles(bool value)
 {
-    m_applyAuthorStyles = value;
+    if (m_applyAuthorStyles != value) {
+        m_applyAuthorStyles = value;
+        if (attached() && owner())
+            owner()->setNeedsRedistributing();
+    }
 }
 
 void ShadowRoot::attach()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to