Changeset 291537 in webkit


Ignore:
Timestamp:
Mar 19, 2022 8:18:09 PM (4 months ago)
Author:
Oriol Brufau
Message:

[cssom] Implement border-image serialization
https://bugs.webkit.org/show_bug.cgi?id=238102

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Let the test accept some equivalent serializations.
Expect it to pass.

  • web-platform-tests/css/css-backgrounds/parsing/border-image-valid-expected.txt:
  • web-platform-tests/css/css-backgrounds/parsing/border-image-valid.html:

Source/WebCore:

Add logic for serializing border-image at specified-value time.

Tests: fast/css/parse-border-image-repeat-null-crash.html

imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-image-valid.html

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::getPropertyValue const):
(WebCore::StyleProperties::borderImagePropertyValue const):
(WebCore::StyleProperties::asText const):

  • css/StyleProperties.h:

LayoutTests:

Expect cssText to serialize border-image instead of longhands.

  • fast/css/parse-border-image-repeat-null-crash-expected.txt:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r291536 r291537  
     12022-03-19  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [cssom] Implement border-image serialization
     4        https://bugs.webkit.org/show_bug.cgi?id=238102
     5
     6        Reviewed by Darin Adler.
     7
     8        Expect cssText to serialize border-image instead of longhands.
     9
     10        * fast/css/parse-border-image-repeat-null-crash-expected.txt:
     11
    1122022-03-19  Oriol Brufau  <obrufau@igalia.com>
    213
  • trunk/LayoutTests/fast/css/parse-border-image-repeat-null-crash-expected.txt

    r279050 r291537  
    1 CONSOLE MESSAGE: border-image-source: url("images/shadow-border.png"); border-image-slice: 10; border-image-repeat: stretch;
     1CONSOLE MESSAGE: border-image: url("images/shadow-border.png") 10 stretch;
    22This test should not crash
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291527 r291537  
     12022-03-19  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [cssom] Implement border-image serialization
     4        https://bugs.webkit.org/show_bug.cgi?id=238102
     5
     6        Reviewed by Darin Adler.
     7
     8        Let the test accept some equivalent serializations.
     9        Expect it to pass.
     10
     11        * web-platform-tests/css/css-backgrounds/parsing/border-image-valid-expected.txt:
     12        * web-platform-tests/css/css-backgrounds/parsing/border-image-valid.html:
     13
    1142022-03-19  Antoine Quint  <graouts@webkit.org>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-image-valid-expected.txt

    r255239 r291537  
    11
    2 FAIL e.style['border-image'] = "none" should set the property value assert_not_equals: property should be set got disallowed value ""
    3 FAIL e.style['border-image'] = "stretch" should set the property value assert_not_equals: property should be set got disallowed value ""
    4 FAIL e.style['border-image'] = "none 100% / 1 / 0 stretch" should set the property value assert_not_equals: property should be set got disallowed value ""
    5 FAIL e.style['border-image'] = "url(\"http://www.example.com/\") 1 2 3 4 fill" should set the property value assert_not_equals: property should be set got disallowed value ""
    6 FAIL e.style['border-image'] = "url(\"http://www.example.com/\") 1 2 3 4 fill / 1 / 0 stretch" should set the property value assert_not_equals: property should be set got disallowed value ""
    7 FAIL e.style['border-image'] = "url(\"http://www.example.com/\")" should set the property value assert_not_equals: property should be set got disallowed value ""
    8 FAIL e.style['border-image'] = "repeat round" should set the property value assert_not_equals: property should be set got disallowed value ""
    9 FAIL e.style['border-image'] = "none repeat round" should set the property value assert_not_equals: property should be set got disallowed value ""
    10 FAIL e.style['border-image'] = "space" should set the property value assert_not_equals: property should be set got disallowed value ""
    11 FAIL e.style['border-image'] = "none space space" should set the property value assert_not_equals: property should be set got disallowed value ""
    12 FAIL e.style['border-image'] = "none 100% / 1 / 0 space" should set the property value assert_not_equals: property should be set got disallowed value ""
    13 FAIL e.style['border-image'] = "1" should set the property value assert_not_equals: property should be set got disallowed value ""
    14 FAIL e.style['border-image'] = "none 1 1 1 1" should set the property value assert_not_equals: property should be set got disallowed value ""
    15 FAIL e.style['border-image'] = "none 1 / 1 / 0 stretch" should set the property value assert_not_equals: property should be set got disallowed value ""
    16 FAIL e.style['border-image'] = "url(\"http://www.example.com/\") 1 2% 3 4%" should set the property value assert_not_equals: property should be set got disallowed value ""
    17 FAIL e.style['border-image'] = "url(\"http://www.example.com/\") 1 2% 3 4% fill" should set the property value assert_not_equals: property should be set got disallowed value ""
    18 FAIL e.style['border-image'] = "url(\"http://www.example.com/\") fill 1 2% 3 4%" should set the property value assert_not_equals: property should be set got disallowed value ""
    19 FAIL e.style['border-image'] = "1 / 1px" should set the property value assert_not_equals: property should be set got disallowed value ""
    20 FAIL e.style['border-image'] = "1 2% 3 4% / 2%" should set the property value assert_not_equals: property should be set got disallowed value ""
    21 FAIL e.style['border-image'] = "1 2% 3 4% fill / 3" should set the property value assert_not_equals: property should be set got disallowed value ""
    22 FAIL e.style['border-image'] = "fill 1 2% 3 4% / auto" should set the property value assert_not_equals: property should be set got disallowed value ""
    23 FAIL e.style['border-image'] = "1 / 1px 2% 3 auto" should set the property value assert_not_equals: property should be set got disallowed value ""
    24 FAIL e.style['border-image'] = "1 / / 1px" should set the property value assert_not_equals: property should be set got disallowed value ""
    25 FAIL e.style['border-image'] = "1 2% 3 4% / / 2" should set the property value assert_not_equals: property should be set got disallowed value ""
    26 FAIL e.style['border-image'] = "url(\"http://www.example.com/\") 1 2% 3 4% fill / / 1px 2 3px 4" should set the property value assert_not_equals: property should be set got disallowed value ""
    27 FAIL e.style['border-image'] = "1 / 1px / 1px" should set the property value assert_not_equals: property should be set got disallowed value ""
    28 FAIL e.style['border-image'] = "1 2% 3 4% / 2% / 2" should set the property value assert_not_equals: property should be set got disallowed value ""
    29 FAIL e.style['border-image'] = "1 2% 3 4% fill / 3 / 1px 2 3px 4" should set the property value assert_not_equals: property should be set got disallowed value ""
    30 FAIL e.style['border-image'] = "1 / auto / 1px" should set the property value assert_not_equals: property should be set got disallowed value ""
    31 FAIL e.style['border-image'] = "1 2% 3 4% / 1px 2% 3 auto / 2" should set the property value assert_not_equals: property should be set got disallowed value ""
     2PASS e.style['border-image'] = "none" should set the property value
     3PASS e.style['border-image'] = "stretch" should set the property value
     4PASS e.style['border-image'] = "none 100% / 1 / 0 stretch" should set the property value
     5PASS e.style['border-image'] = "url(\"http://www.example.com/\") 1 2 3 4 fill" should set the property value
     6PASS e.style['border-image'] = "url(\"http://www.example.com/\") 1 2 3 4 fill / 1 / 0 stretch" should set the property value
     7PASS e.style['border-image'] = "url(\"http://www.example.com/\")" should set the property value
     8PASS e.style['border-image'] = "repeat round" should set the property value
     9PASS e.style['border-image'] = "none repeat round" should set the property value
     10PASS e.style['border-image'] = "space" should set the property value
     11PASS e.style['border-image'] = "none space space" should set the property value
     12PASS e.style['border-image'] = "none 100% / 1 / 0 space" should set the property value
     13PASS e.style['border-image'] = "1" should set the property value
     14PASS e.style['border-image'] = "none 1 1 1 1" should set the property value
     15PASS e.style['border-image'] = "none 1 / 1 / 0 stretch" should set the property value
     16PASS e.style['border-image'] = "url(\"http://www.example.com/\") 1 2% 3 4%" should set the property value
     17PASS e.style['border-image'] = "url(\"http://www.example.com/\") 1 2% 3 4% fill" should set the property value
     18PASS e.style['border-image'] = "url(\"http://www.example.com/\") fill 1 2% 3 4%" should set the property value
     19PASS e.style['border-image'] = "1 / 1px" should set the property value
     20PASS e.style['border-image'] = "1 2% 3 4% / 2%" should set the property value
     21PASS e.style['border-image'] = "1 2% 3 4% fill / 3" should set the property value
     22PASS e.style['border-image'] = "fill 1 2% 3 4% / auto" should set the property value
     23PASS e.style['border-image'] = "1 / 1px 2% 3 auto" should set the property value
     24PASS e.style['border-image'] = "1 / / 1px" should set the property value
     25PASS e.style['border-image'] = "1 2% 3 4% / / 2" should set the property value
     26PASS e.style['border-image'] = "url(\"http://www.example.com/\") 1 2% 3 4% fill / / 1px 2 3px 4" should set the property value
     27PASS e.style['border-image'] = "1 / 1px / 1px" should set the property value
     28PASS e.style['border-image'] = "1 2% 3 4% / 2% / 2" should set the property value
     29PASS e.style['border-image'] = "1 2% 3 4% fill / 3 / 1px 2 3px 4" should set the property value
     30PASS e.style['border-image'] = "1 / auto / 1px" should set the property value
     31PASS e.style['border-image'] = "1 2% 3 4% / 1px 2% 3 auto / 2" should set the property value
    3232
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-image-valid.html

    r255239 r291537  
    1717// "none" in Edge, "none 100% / 1 / 0 stretch" in Firefox and Blink.
    1818test_valid_value("border-image", "none", ["none", "none 100% / 1 / 0 stretch"]);
    19 test_valid_value("border-image", "stretch", ["none", "none 100% / 1 / 0 stretch"]);
     19test_valid_value("border-image", "stretch", ["stretch", "none", "none 100% / 1 / 0 stretch"]);
    2020test_valid_value("border-image", "none 100% / 1 / 0 stretch", ["none", "none 100% / 1 / 0 stretch"]);
    2121
     
    2929
    3030test_valid_value("border-image", "space", ["space", "none space space", "none 100% / 1 / 0 space"]);
    31 test_valid_value("border-image", "none space space", ["space", "none space space", "none 100% / 1 / 0 space"]);
     31test_valid_value("border-image", "none space space", ["space", "none space space", "none space", "none 100% / 1 / 0 space"]);
    3232test_valid_value("border-image", "none 100% / 1 / 0 space", ["space", "none space space", "none 100% / 1 / 0 space"]);
    3333
    3434test_valid_value("border-image", "1", ["1", "none 1 1 1 1", "none 1 / 1 / 0 stretch"]);
    35 test_valid_value("border-image", "none 1 1 1 1", ["1", "none 1 1 1 1", "none 1 / 1 / 0 stretch"]);
     35test_valid_value("border-image", "none 1 1 1 1", ["1", "none 1 1 1 1", "none 1", "none 1 / 1 / 0 stretch"]);
    3636test_valid_value("border-image", "none 1 / 1 / 0 stretch", ["1", "none 1 1 1 1", "none 1 / 1 / 0 stretch"]);
    3737
  • trunk/Source/WebCore/ChangeLog

    r291536 r291537  
     12022-03-19  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [cssom] Implement border-image serialization
     4        https://bugs.webkit.org/show_bug.cgi?id=238102
     5
     6        Reviewed by Darin Adler.
     7
     8        Add logic for serializing border-image at specified-value time.
     9
     10        Tests: fast/css/parse-border-image-repeat-null-crash.html
     11               imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-image-valid.html
     12
     13        * css/StyleProperties.cpp:
     14        (WebCore::StyleProperties::getPropertyValue const):
     15        (WebCore::StyleProperties::borderImagePropertyValue const):
     16        (WebCore::StyleProperties::asText const):
     17        * css/StyleProperties.h:
     18
    1192022-03-19  Oriol Brufau  <obrufau@igalia.com>
    220
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r291244 r291537  
    3838#include "Document.h"
    3939#include "PropertySetCSSStyleDeclaration.h"
     40#include "Rect.h"
    4041#include "StylePropertyShorthand.h"
    4142#include "StylePropertyShorthandFunctions.h"
     
    218219    case CSSPropertyBorderBlockEnd:
    219220        return getShorthandValue(borderBlockEndShorthand());
     221    case CSSPropertyBorderImage:
     222        return borderImagePropertyValue();
    220223    case CSSPropertyBorderInline:
    221224        return borderPropertyValue(borderInlineWidthShorthand(), borderInlineStyleShorthand(), borderInlineColorShorthand());
     
    901904}
    902905
     906String StyleProperties::borderImagePropertyValue() const
     907{
     908    const StylePropertyShorthand& shorthand = borderImageShorthand();
     909    StringBuilder result;
     910    bool lastPropertyWasImportant = false;
     911    bool omittedSlice = false;
     912    bool omittedWidth = false;
     913    String commonWideValueText;
     914    auto separator = "";
     915    for (unsigned i = 0; i < shorthand.length(); ++i) {
     916        // All longhands should have the same importance.
     917        auto longhand = shorthand.properties()[i];
     918        bool currentPropertyIsImportant = propertyIsImportant(longhand);
     919        if (i && lastPropertyWasImportant != currentPropertyIsImportant)
     920            return String();
     921        lastPropertyWasImportant = currentPropertyIsImportant;
     922
     923        // All longhands should be present.
     924        auto value = getPropertyCSSValue(longhand);
     925        if (!value)
     926            return String();
     927
     928        // Omit implicit initial values. However, border-image-width and border-image-outset require border-image-slice.
     929        if (value->isInitialValue() && isPropertyImplicit(longhand)) {
     930            if (longhand == CSSPropertyBorderImageSlice)
     931                omittedSlice = true;
     932            else if (longhand == CSSPropertyBorderImageWidth)
     933                omittedWidth = true;
     934            continue;
     935        }
     936        if (omittedSlice && (longhand == CSSPropertyBorderImageWidth || longhand == CSSPropertyBorderImageOutset))
     937            return String();
     938
     939        // If a longhand is set to a css-wide keyword, the others should be the same.
     940        String valueText = value->cssText();
     941        if (isCSSWideValueKeyword(valueText)) {
     942            if (!i)
     943                commonWideValueText = valueText;
     944            else if (commonWideValueText != valueText)
     945                return String();
     946            continue;
     947        }
     948        if (!commonWideValueText.isNull())
     949            return String();
     950
     951        // Append separator and text.
     952        if (longhand == CSSPropertyBorderImageWidth)
     953            separator = " / ";
     954        else if (longhand == CSSPropertyBorderImageOutset)
     955            separator = omittedWidth ? " / / " : " / ";
     956        result.append(separator, valueText);
     957        separator = " ";
     958    }
     959    if (!commonWideValueText.isNull())
     960        return commonWideValueText;
     961    return result.toString();
     962}
     963
    903964String StyleProperties::borderPropertyValue(const StylePropertyShorthand& width, const StylePropertyShorthand& style, const StylePropertyShorthand& color) const
    904965{
     
    13441405                shorthandPropertyID = CSSPropertyBorderSpacing;
    13451406                break;
     1407            case CSSPropertyBorderImageSource:
     1408            case CSSPropertyBorderImageSlice:
     1409            case CSSPropertyBorderImageWidth:
     1410            case CSSPropertyBorderImageOutset:
     1411            case CSSPropertyBorderImageRepeat:
     1412                shorthandPropertyID = CSSPropertyBorderImage;
     1413                break;
    13461414            case CSSPropertyFontFamily:
    13471415            case CSSPropertyLineHeight:
  • trunk/Source/WebCore/css/StyleProperties.h

    r289876 r291537  
    166166    String getCommonValue(const StylePropertyShorthand&) const;
    167167    String getAlignmentShorthandValue(const StylePropertyShorthand&) const;
     168    String borderImagePropertyValue() const;
    168169    String borderPropertyValue(const StylePropertyShorthand&, const StylePropertyShorthand&, const StylePropertyShorthand&) const;
    169170    String pageBreakPropertyValue(const StylePropertyShorthand&) const;
Note: See TracChangeset for help on using the changeset viewer.