Changeset 203460 in webkit


Ignore:
Timestamp:
Jul 20, 2016 11:01:26 AM (8 years ago)
Author:
Chris Dumez
Message:

CSSStyleDeclaration.setProperty() should be able to unset "important" on a property
https://bugs.webkit.org/show_bug.cgi?id=159959

Reviewed by Alexey Proskuryakov.

Source/WebCore:

CSSStyleDeclaration.setProperty() should be able to unsert "important"
on a property as per the latest specification:

Firefox and Chrome match the specification here but WebKit was ignoring calls
to setProperty() if there is already an "important" property wit this name
and if the new property does not have the "important" flag set.

This behavior was added a long time ago via Bug 60007. However, it does not
match the latest specification or other browsers.

Test: fast/css/CSSStyleDeclaration-setProperty-unset-important.html

  • css/StyleProperties.cpp:

(WebCore::MutableStyleProperties::addParsedProperty):
Drop code that was added via Bug 60007 as this behavior no longer matches the
specification or other browsers. The layout test added in Bug 60007 fails in
other browsers and was updated in this patch to match the specification.

LayoutTests:

  • fast/css/CSSStyleDeclaration-setProperty-unset-important-expected.txt: Added.
  • fast/css/CSSStyleDeclaration-setProperty-unset-important.html: Added.

Add layout test coverage.

  • fast/css/important-js-override.html:

The test covered our 'wrong' behavior and was failing in Firefox / Chrome.
I updated the test to match the behavior in the specification. The test
now passed in Chrome and Firefox.

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203459 r203460  
     12016-07-20  Chris Dumez  <cdumez@apple.com>
     2
     3        CSSStyleDeclaration.setProperty() should be able to unset "important" on a property
     4        https://bugs.webkit.org/show_bug.cgi?id=159959
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * fast/css/CSSStyleDeclaration-setProperty-unset-important-expected.txt: Added.
     9        * fast/css/CSSStyleDeclaration-setProperty-unset-important.html: Added.
     10        Add layout test coverage.
     11
     12        * fast/css/important-js-override.html:
     13        The test covered our 'wrong' behavior and was failing in Firefox / Chrome.
     14        I updated the test to match the behavior in the specification. The test
     15        now passed in Chrome and Firefox.
     16
    1172016-07-20  Commit Queue  <commit-queue@webkit.org>
    218
  • trunk/LayoutTests/fast/css/important-js-override.html

    r120683 r203460  
    1 <div id="a" style="background-color: green !important">The background of this element should be green. It is </div>
     1<div id="a" style="background-color: red !important">The background of this element should be green. It is </div>
    22<script>
    33    if (window.testRunner)
    44        testRunner.dumpAsText();
    55    var a = document.getElementById("a");
    6     a.style.backgroundColor = "red";
     6    a.style.backgroundColor = "green";
    77    a.innerHTML += a.style.backgroundColor;
    88</script>
  • trunk/Source/WebCore/ChangeLog

    r203459 r203460  
     12016-07-20  Chris Dumez  <cdumez@apple.com>
     2
     3        CSSStyleDeclaration.setProperty() should be able to unset "important" on a property
     4        https://bugs.webkit.org/show_bug.cgi?id=159959
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        CSSStyleDeclaration.setProperty() should be able to unsert "important"
     9        on a property as per the latest specification:
     10        - https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
     11        - https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-camel-cased-attribute
     12
     13        Firefox and Chrome match the specification here but WebKit was ignoring calls
     14        to setProperty() if there is already an "important" property wit this name
     15        and if the new property does not have the "important" flag set.
     16
     17        This behavior was added a long time ago via Bug 60007. However, it does not
     18        match the latest specification or other browsers.
     19
     20        Test: fast/css/CSSStyleDeclaration-setProperty-unset-important.html
     21
     22        * css/StyleProperties.cpp:
     23        (WebCore::MutableStyleProperties::addParsedProperty):
     24        Drop code that was added via Bug 60007 as this behavior no longer matches the
     25        specification or other browsers. The layout test added in Bug 60007 fails in
     26        other browsers and was updated in this patch to match the specification.
     27
    1282016-07-20  Commit Queue  <commit-queue@webkit.org>
    229
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r203380 r203460  
    884884        return false;
    885885    }
    886    
    887     // Only add properties that have no !important counterpart present
    888     if (!propertyIsImportant(property.id()) || property.isImportant())
    889         return setProperty(property);
    890    
    891     return false;
     886    return setProperty(property);
    892887}
    893888
Note: See TracChangeset for help on using the changeset viewer.