Changeset 271866 in webkit


Ignore:
Timestamp:
Jan 25, 2021 3:32:13 PM (18 months ago)
Author:
weinig@apple.com
Message:

Support percentages when parsing color(srgb ...) and color(display-p3 ...) per-spec
https://bugs.webkit.org/show_bug.cgi?id=220940

Reviewed by Simon Fraser.

Add support for using percentages when using the color(srgb ) and color(display-p3 ) syntax. Also
fix color(lab ) to allow elliding parameters and defaulting them to 0 as per-spec.

Source/WebCore:

Unfails some WPT tests and adds additional parsing tests for lab to fast/css/parsing-lab-colors.html

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::parseColorFunctionForSRGBOrDisplayP3Parameters):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForLabParameters):

LayoutTests:

  • TestExpectations:
  • fast/css/parsing-lab-colors-expected.txt:
  • fast/css/parsing-lab-colors.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r271861 r271866  
     12021-01-25  Sam Weinig  <weinig@apple.com>
     2
     3        Support percentages when parsing color(srgb ...) and color(display-p3 ...) per-spec
     4        https://bugs.webkit.org/show_bug.cgi?id=220940
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add support for using percentages when using the color(srgb ) and color(display-p3 ) syntax. Also
     9        fix color(lab ) to allow elliding parameters and defaulting them to 0 as per-spec.
     10
     11        * TestExpectations:
     12        * fast/css/parsing-lab-colors-expected.txt:
     13        * fast/css/parsing-lab-colors.html:
     14
    1152021-01-25  Aditya Keerthi  <akeerthi@apple.com>
    216
  • trunk/LayoutTests/TestExpectations

    r271807 r271866  
    45774577
    45784578# Unsupported css color() variants
    4579 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-002.html [ ImageOnlyFailure ]
    4580 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-003.html [ ImageOnlyFailure ]
    4581 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-004.html [ ImageOnlyFailure ]
    4582 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-006.html [ ImageOnlyFailure ]
    4583 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-007.html [ ImageOnlyFailure ]
    4584 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-008.html [ ImageOnlyFailure ]
    4585 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-009.html [ ImageOnlyFailure ]
    4586 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-010.html [ ImageOnlyFailure ]
    4587 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-011.html [ ImageOnlyFailure ]
    4588 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-012.html [ ImageOnlyFailure ]
    4589 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-014.html [ ImageOnlyFailure ]
    4590 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-015.html [ ImageOnlyFailure ]
    4591 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-016.html [ ImageOnlyFailure ]
    4592 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-017.html [ ImageOnlyFailure ]
     4579webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-003.html [ ImageOnlyFailure ] # Invalid test, no colorspace specified
     4580webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-004.html [ ImageOnlyFailure ] # Invalid test, no colorspace specified
     4581webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-007.html [ ImageOnlyFailure ] # Requires a98-rgb support
     4582webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-008.html [ ImageOnlyFailure ] # Requires a98-rgb support
     4583webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-009.html [ ImageOnlyFailure ] # Requires prophoto-rgb support
     4584webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-010.html [ ImageOnlyFailure ] # Requires prophoto-rgb support
     4585webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-011.html [ ImageOnlyFailure ] # Requires rec2020 support
     4586webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-012.html [ ImageOnlyFailure ] # Requires rec2020 support
     4587webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-014.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support
     4588webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-015.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support (unclear if this makes sense)
     4589webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-016.html [ ImageOnlyFailure ] # Requires xyz support
     4590webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-017.html [ ImageOnlyFailure ] # Requires xyz support
  • trunk/LayoutTests/fast/css/parsing-lab-colors-expected.txt

    r271362 r271866  
    4747PASS computedStyle("background-color", "color(lab 0% 0 0 / 110%)") is "lab(0% 0 0)"
    4848PASS computedStyle("background-color", "color(lab 0% 0 0 / 300%)") is "lab(0% 0 0)"
     49PASS computedStyle("background-color", "color(lab 50% -200)") is "lab(50% -200 0)"
     50PASS computedStyle("background-color", "color(lab 50%)") is "lab(50% 0 0)"
     51PASS computedStyle("background-color", "color(lab)") is "lab(0% 0 0)"
     52PASS computedStyle("background-color", "color(lab 50% -200 / 0.5)") is "lab(50% -200 0 / 0.5)"
     53PASS computedStyle("background-color", "color(lab 50% / 0.5)") is "lab(50% 0 0 / 0.5)"
     54PASS computedStyle("background-color", "color(lab / 0.5)") is "lab(0% 0 0 / 0.5)"
    4955
    5056Test invalid values
  • trunk/LayoutTests/fast/css/parsing-lab-colors.html

    r271362 r271866  
    8181    testComputed("background-color", "color(lab 0% 0 0 / 110%)", "lab(0% 0 0)");
    8282    testComputed("background-color", "color(lab 0% 0 0 / 300%)", "lab(0% 0 0)");
     83    testComputed("background-color", "color(lab 50% -200)", "lab(50% -200 0)");
     84    testComputed("background-color", "color(lab 50%)", "lab(50% 0 0)");
     85    testComputed("background-color", "color(lab)", "lab(0% 0 0)");
     86    testComputed("background-color", "color(lab 50% -200 / 0.5)", "lab(50% -200 0 / 0.5)");
     87    testComputed("background-color", "color(lab 50% / 0.5)", "lab(50% 0 0 / 0.5)");
     88    testComputed("background-color", "color(lab / 0.5)", "lab(0% 0 0 / 0.5)");
    8389
    8490    debug('');
  • trunk/Source/WebCore/ChangeLog

    r271861 r271866  
     12021-01-25  Sam Weinig  <weinig@apple.com>
     2
     3        Support percentages when parsing color(srgb ...) and color(display-p3 ...) per-spec
     4        https://bugs.webkit.org/show_bug.cgi?id=220940
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add support for using percentages when using the color(srgb ) and color(display-p3 ) syntax. Also
     9        fix color(lab ) to allow elliding parameters and defaulting them to 0 as per-spec.
     10
     11        Unfails some WPT tests and adds additional parsing tests for lab to fast/css/parsing-lab-colors.html
     12
     13        * css/parser/CSSPropertyParserHelpers.cpp:
     14        (WebCore::CSSPropertyParserHelpers::parseColorFunctionForSRGBOrDisplayP3Parameters):
     15        (WebCore::CSSPropertyParserHelpers::parseColorFunctionForLabParameters):
     16
    1172021-01-25  Aditya Keerthi  <akeerthi@apple.com>
    218
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r271695 r271866  
    881881    consumeIdentRaw(args);
    882882
    883     double colorChannels[3] = { 0, 0, 0 };
     883    double channels[3] = { 0, 0, 0 };
    884884    for (int i = 0; i < 3; ++i) {
    885885        double value;
    886886        if (consumeNumberRaw(args, value))
    887             colorChannels[i] = value;
     887            channels[i] = value;
     888        else if (auto percent = consumePercentRaw(args))
     889            channels[i] = *percent / 100.0;
    888890        else
    889891            break;
     
    894896        return { };
    895897
    896     return ColorType { clampTo<float>(colorChannels[0], 0.0, 1.0), clampTo<float>(colorChannels[1], 0.0, 1.0), clampTo<float>(colorChannels[2], 0.0, 1.0), *alpha };
     898    return ColorType { clampTo<float>(channels[0], 0.0, 1.0), clampTo<float>(channels[1], 0.0, 1.0), clampTo<float>(channels[2], 0.0, 1.0), *alpha };
    897899}
    898900
     
    902904    consumeIdentRaw(args);
    903905
    904     auto lightness = consumePercentRaw(args, ValueRangeAll);
    905     if (!lightness)
    906         return { };
    907 
    908     double aValue;
    909     if (!consumeNumberRaw(args, aValue, ValueRangeAll))
    910         return { };
    911 
    912     double bValue;
    913     if (!consumeNumberRaw(args, bValue, ValueRangeAll))
    914         return { };
     906    double channels[3] = { 0, 0, 0 };
     907    [&] {
     908        auto lightness = consumePercentRaw(args, ValueRangeAll);
     909        if (!lightness)
     910            return;
     911        channels[0] = *lightness;
     912
     913        double aValue;
     914        if (!consumeNumberRaw(args, aValue, ValueRangeAll))
     915            return;
     916        channels[1] = aValue;
     917
     918        double bValue;
     919        if (!consumeNumberRaw(args, bValue, ValueRangeAll))
     920            return;
     921        channels[2] = bValue;
     922    }();
    915923
    916924    auto alpha = parseOptionalAlpha(args);
     
    918926        return { };
    919927
    920     return Lab<float> { static_cast<float>(*lightness), static_cast<float>(aValue), static_cast<float>(bValue), *alpha };
     928    return Lab<float> { static_cast<float>(channels[0]), static_cast<float>(channels[1]), static_cast<float>(channels[2]), *alpha };
    921929}
    922930
Note: See TracChangeset for help on using the changeset viewer.