Changeset 117716 in webkit


Ignore:
Timestamp:
May 20, 2012 5:50:01 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <tasak@google.com> 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 <tasak@google.com> on 2012-05-20
Reviewed by Hajime Morita.

  • fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html:
  • fast/dom/shadow/shadow-root-applyAuthorStyles.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117713 r117716  
     12012-05-20  Takashi Sakamoto  <tasak@google.com>
     2
     3        Needs style recalculation by changing applyAuthorStyles dynamically
     4        https://bugs.webkit.org/show_bug.cgi?id=84251
     5
     6        Reviewed by Hajime Morita.
     7
     8        * fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html:
     9        * fast/dom/shadow/shadow-root-applyAuthorStyles.html:
     10
    1112012-05-20  Philip Rogers  <pdr@google.com>
    212
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles-expected.html

    r116521 r117716  
    66<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>
    77<div id="try-to-overide-important"><input type="file" /></div>
     8<div id="change-apply-author-style-from-true-to-false"><div><span></span></div></div>
     9<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>
    810</body>
    911</html>
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html

    r116521 r117716  
    2626<div id="with-inline-style-declaration"></div>
    2727<div id="try-to-override-important"></div>
     28<div id="change-apply-author-style-from-true-to-false"></div>
     29<div id="change-apply-author-style-from-false-to-true"></div>
    2830
    2931<script>
     32function shouldBe(a, b)
     33{
     34   if (a != b) {
     35      throw "failure:" + a + ": should be " + b;
     36   }
     37}
     38
     39function shouldNotBe(a, b)
     40{
     41   if (a == b) {
     42      throw "failure:" + a + ": should not be " + b;
     43   }
     44}
     45
    3046function assertTrue(id, actual) {
    3147   if (!actual) {
     
    84100}
    85101
     102function testChangingApplyAuthorStyleFromTrueToFalse() {
     103    var div = document.createElement('div');
     104    document.getElementById('change-apply-author-style-from-true-to-false').appendChild(div);
     105
     106    var shadowRoot = new WebKitShadowRoot(div);
     107    assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
     108    shadowRoot.applyAuthorStyles = true;
     109    assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
     110    shadowRoot.innerHTML = '<div><span id="test1"></span></div>';
     111    div.offsetLeft;
     112    var target = shadowRoot.getElementById('test1');
     113    shouldBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
     114    shouldBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
     115
     116    shadowRoot.applyAuthorStyles = false;
     117    assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
     118    div.offsetLeft;
     119    shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
     120    shouldNotBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
     121}
     122
     123function testChangingApplyAuthorStyleFromFalseToTrue() {
     124    var div = document.createElement('div');
     125    document.getElementById('change-apply-author-style-from-false-to-true').appendChild(div);
     126
     127    var shadowRoot = new WebKitShadowRoot(div);
     128    shadowRoot.applyAuthorStyles = false;
     129    assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
     130    shadowRoot.innerHTML = '<div><span id="test2"></span></div>';
     131    div.offsetLeft;
     132    var target = shadowRoot.getElementById('test2');
     133    shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
     134    shouldNotBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
     135
     136    shadowRoot.applyAuthorStyles = true;
     137    assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
     138    div.offsetLeft;
     139    shouldBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
     140    shouldBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
     141}
     142
    86143renderApplyAuthorStyleCase();
    87144renderNoApplyAuthorStyleCase();
    88145renderApplyAuthorStyleWithInlineStyleDeclarationCase();
    89146renderApplyAuthorStyleWithOverridingImportantPropertyCase();
     147testChangingApplyAuthorStyleFromTrueToFalse();
     148testChangingApplyAuthorStyleFromFalseToTrue();
    90149</script>
    91150</body>
  • trunk/Source/WebCore/ChangeLog

    r117711 r117716  
     12012-05-20  Takashi Sakamoto  <tasak@google.com>
     2
     3        Needs style recalculation by changing applyAuthorStyles dynamically
     4        https://bugs.webkit.org/show_bug.cgi?id=84251
     5
     6        Modifying setApplyAuthorStyles to invoke owner()'s
     7        setNeedsRedistributing if applyAuthorStyles changes.
     8
     9        Reviewed by Hajime Morita.
     10
     11        No new tests. Adding new tests to existing
     12        fast/dom/shadow/shadow-root-applyAuthorStyles.html to test this
     13        feature.
     14
     15        * dom/ShadowRoot.cpp:
     16        (WebCore::ShadowRoot::setApplyAuthorStyles):
     17        If applyAuthorStyles changes, invoke owner's setNeedsRedistributing to
     18        recalculate styles of the shadow root's child elements.
     19
    1202012-05-20  Philip Rogers  <pdr@google.com>
    221
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r117421 r117716  
    189189void ShadowRoot::setApplyAuthorStyles(bool value)
    190190{
    191     m_applyAuthorStyles = value;
     191    if (m_applyAuthorStyles != value) {
     192        m_applyAuthorStyles = value;
     193        if (attached() && owner())
     194            owner()->setNeedsRedistributing();
     195    }
    192196}
    193197
Note: See TracChangeset for help on using the changeset viewer.