Changeset 285015 in webkit


Ignore:
Timestamp:
Oct 28, 2021 7:19:51 PM (9 months ago)
Author:
Nikos Mouchtaris
Message:

if border-radius includes a var(), the value is not readable from .style
https://bugs.webkit.org/show_bug.cgi?id=230389

Reviewed by Myles Maxfield.
Source/WebCore:

Return correct string for shorthand CSS values set by var. Add extra checks for if all
longhand properties are pending values and if the requested shorthand property was set
to a variable.

Test: css3/short-hand-var-serialization.html

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::getPropertyValue const):

LayoutTests:

  • css3/short-hand-var-serialization-expected.txt: Added.
  • css3/short-hand-var-serialization.html: Added.
Location:
trunk
Files:
2 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285011 r285015  
     12021-10-28  Nikos Mouchtaris  <nmouchtaris@apple.com>
     2
     3        if border-radius includes a var(), the value is not readable from .style
     4        https://bugs.webkit.org/show_bug.cgi?id=230389
     5
     6        Reviewed by Myles Maxfield.
     7
     8        * css3/short-hand-var-serialization-expected.txt: Added.
     9        * css3/short-hand-var-serialization.html: Added.
     10
    1112021-10-28  Arcady Goldmints-Orlov  <agoldmints@igalia.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-variables-expected.txt

    r276837 r285015  
    22PASS Logical longhands with variables - margin-inline-start
    33PASS Logical longhands with variables - margin-inline-end
    4 FAIL Logical longhands with variables - margin-inline assert_equals: Specified value expected "" but got "var(--one) var(--two)"
     4PASS Logical longhands with variables - margin-inline
    55PASS Logical shorthand with 1 variable - margin-inline-start
    66PASS Logical shorthand with 1 variable - margin-inline-end
    7 FAIL Logical shorthand with 1 variable - margin-inline assert_equals: Specified value expected "var(--one)" but got ""
     7PASS Logical shorthand with 1 variable - margin-inline
    88PASS Logical shorthand with 2 variables - margin-inline-start
    99PASS Logical shorthand with 2 variables - margin-inline-end
    10 FAIL Logical shorthand with 2 variables - margin-inline assert_equals: Specified value expected "var(--one) var(--two)" but got ""
     10PASS Logical shorthand with 2 variables - margin-inline
    1111PASS Logical shorthand with 1 variable and 1 length - margin-inline-start
    1212PASS Logical shorthand with 1 variable and 1 length - margin-inline-end
    13 FAIL Logical shorthand with 1 variable and 1 length - margin-inline assert_equals: Specified value expected "var(--one) 2px" but got ""
     13PASS Logical shorthand with 1 variable and 1 length - margin-inline
    1414
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-reference-shorthands-cssom-expected.txt

    r271706 r285015  
    11
    2 FAIL CSS variable references - shorthand properties - via CSSOM assert_equals: margin property value after calling setProperty expected "var(--prop)" but got ""
     2PASS CSS variable references - shorthand properties - via CSSOM
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-reference-shorthands-expected.txt

    r271706 r285015  
    11
    2 FAIL target1 margin assert_equals: expected "" but got "10px"
     2PASS target1 margin
    33PASS target1 margin-left
    44PASS target1 margin-top
    55PASS target1 margin-right
    66PASS target1 margin-bottom
    7 FAIL target2 margin assert_equals: expected "var(--prop)" but got ""
     7PASS target2 margin
    88PASS target2 margin-left
    99PASS target2 margin-top
     
    1515PASS target3 margin-right
    1616PASS target3 margin-bottom
    17 FAIL target4 background assert_equals: expected "var(--prop)" but got ""
     17PASS target4 background
    1818
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/shorthand-serialization-expected.txt

    r267650 r285015  
    99PASS Shorthand serialization with shorthand and longhands mixed.
    1010PASS Shorthand serialization with just longhands.
    11 FAIL Shorthand serialization with variable and variable from other shorthand. assert_equals: expected "var(--a)" but got ""
     11PASS Shorthand serialization with variable and variable from other shorthand.
    1212PASS Shorthand serialization after setting
    1313FAIL Shorthand serialization with 'initial' value. assert_equals: expected "margin: initial;" but got ""
  • trunk/Source/WebCore/ChangeLog

    r285012 r285015  
     12021-10-28  Nikos Mouchtaris  <nmouchtaris@apple.com>
     2
     3        if border-radius includes a var(), the value is not readable from .style
     4        https://bugs.webkit.org/show_bug.cgi?id=230389
     5
     6        Reviewed by Myles Maxfield.
     7       
     8        Return correct string for shorthand CSS values set by var. Add extra checks for if all
     9        longhand properties are pending values and if the requested shorthand property was set
     10        to a variable.
     11
     12        Test: css3/short-hand-var-serialization.html
     13
     14        * css/StyleProperties.cpp:
     15        (WebCore::StyleProperties::getPropertyValue const):
     16
    1172021-10-28  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r284857 r285015  
    126126}
    127127
     128bool StyleProperties::shorthandHasVariableReference(CSSPropertyID propertyID, String& shorthandValue) const
     129{
     130    auto shorthand = shorthandForProperty(propertyID);
     131    if (shorthand.length()) {
     132        size_t numSetFromShorthand = 0;
     133        // Checks for shorthand property if any of its longhand properties have set to a variable
     134        // or are all pending substitution
     135        for (size_t i = 0; i < shorthand.length(); i++) {
     136            auto cssPropertyValue =  getPropertyCSSValue(shorthand.properties()[i]);
     137           
     138            auto hasBeenSetFromLonghand = is<CSSVariableReferenceValue>(cssPropertyValue);
     139            auto hasBeenSetFromShorthand = is<CSSPendingSubstitutionValue>(cssPropertyValue);
     140            auto hasNotBeenSetFromRequestedShorthand = hasBeenSetFromShorthand && downcast<CSSPendingSubstitutionValue>(*cssPropertyValue).shorthandPropertyId() != propertyID;
     141           
     142            // Request for shorthand value should return empty string if any longhand values have been
     143            // set to a variable or if they were set to a variable by a different shorthand.
     144            if (hasBeenSetFromLonghand || hasNotBeenSetFromRequestedShorthand)
     145                return true;
     146            if (hasBeenSetFromShorthand)
     147                numSetFromShorthand += 1;
     148        }
     149        if (numSetFromShorthand) {
     150            if (numSetFromShorthand != shorthand.length())
     151                return true;
     152            shorthandValue = downcast<CSSPendingSubstitutionValue>(* getPropertyCSSValue(shorthand.properties()[0])).shorthandValue().cssText();
     153            return true;
     154        }
     155    }
     156    return false;
     157}
     158
    128159String StyleProperties::getPropertyValue(CSSPropertyID propertyID) const
    129160{
     
    145176
    146177    {
    147         auto shorthand = shorthandForProperty(propertyID);
    148         if (shorthand.length() && is<CSSPendingSubstitutionValue>(getPropertyCSSValue(shorthand.properties()[0])))
    149             return String();
     178        auto shorthandValue = String();
     179        if (shorthandHasVariableReference(propertyID, shorthandValue))
     180            return shorthandValue;
    150181    }
    151182
  • trunk/Source/WebCore/css/StyleProperties.h

    r284857 r285015  
    176176    String textDecorationSkipValue() const;
    177177    void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const;
     178    bool shorthandHasVariableReference(CSSPropertyID, String&) const;
    178179
    179180    friend class PropertySetCSSStyleDeclaration;
Note: See TracChangeset for help on using the changeset viewer.