Changeset 272909 in webkit
- Timestamp:
- Feb 16, 2021 9:26:02 AM (17 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/css/parsing-lab-colors-expected.txt (modified) (3 diffs)
-
LayoutTests/fast/css/parsing-lab-colors.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r272907 r272909 1 2021-02-16 Sam Weinig <weinig@apple.com> 2 3 lab() and lch() are not clamping out of bounds values at parse time 4 https://bugs.webkit.org/show_bug.cgi?id=221947 5 6 Reviewed by Simon Fraser. 7 8 The model level assertions caught this (yay). The spec requires that we 9 clamp negative lightness values to 0 for lab(), lch() and color(lab) 10 and negative chroma values to 0 for lch(). 11 12 * fast/css/parsing-lab-colors-expected.txt: 13 * fast/css/parsing-lab-colors.html: 14 1 15 2021-02-16 Chris Gambrell <cgambrell@apple.com> 2 16 -
trunk/LayoutTests/fast/css/parsing-lab-colors-expected.txt
r271866 r272909 16 16 PASS computedStyle("background-color", "lab(0% 0 0 / 110%)") is "lab(0% 0 0)" 17 17 PASS computedStyle("background-color", "lab(0% 0 0 / 300%)") is "lab(0% 0 0)" 18 PASS computedStyle("background-color", "lab(-40% 0 0)") is "lab(0% 0 0)" 19 PASS computedStyle("background-color", "lab(50% -20 0)") is "lab(50% -20 0)" 20 PASS computedStyle("background-color", "lab(50% 0 -20)") is "lab(50% 0 -20)" 18 21 19 22 lch() … … 31 34 PASS computedStyle("background-color", "lch(10% 20 740deg)") is "lab(10% 18.793852 6.8404026)" 32 35 PASS computedStyle("background-color", "lch(10% 20 -700deg)") is "lab(10% 18.793852 6.8404026)" 36 PASS computedStyle("background-color", "lch(-40% 0 0)") is "lab(0% 0 0)" 37 PASS computedStyle("background-color", "lch(20% -20 0)") is "lab(20% 0 0)" 33 38 PASS computedStyle("background-color", "lch(0% 0 0 / 0.5)") is "lab(0% 0 0 / 0.5)" 34 39 PASS computedStyle("background-color", "lch(10% 20 20 / 110%)") is "lab(10% 18.793852 6.8404026)" … … 53 58 PASS computedStyle("background-color", "color(lab 50% / 0.5)") is "lab(50% 0 0 / 0.5)" 54 59 PASS computedStyle("background-color", "color(lab / 0.5)") is "lab(0% 0 0 / 0.5)" 60 PASS computedStyle("background-color", "color(lab -40% 0 0)") is "lab(0% 0 0)" 61 PASS computedStyle("background-color", "color(lab 50% -20 0)") is "lab(50% -20 0)" 62 PASS computedStyle("background-color", "color(lab 50% 0 -20)") is "lab(50% 0 -20)" 55 63 56 64 Test invalid values -
trunk/LayoutTests/fast/css/parsing-lab-colors.html
r271866 r272909 47 47 testComputed("background-color", "lab(0% 0 0 / 110%)", "lab(0% 0 0)"); 48 48 testComputed("background-color", "lab(0% 0 0 / 300%)", "lab(0% 0 0)"); 49 testComputed("background-color", "lab(-40% 0 0)", "lab(0% 0 0)"); 50 testComputed("background-color", "lab(50% -20 0)", "lab(50% -20 0)"); 51 testComputed("background-color", "lab(50% 0 -20)", "lab(50% 0 -20)"); 49 52 50 53 debug(''); … … 63 66 testComputed("background-color", "lch(10% 20 740deg)", "lab(10% 18.793852 6.8404026)"); 64 67 testComputed("background-color", "lch(10% 20 -700deg)", "lab(10% 18.793852 6.8404026)"); 68 testComputed("background-color", "lch(-40% 0 0)", "lab(0% 0 0)"); 69 testComputed("background-color", "lch(20% -20 0)", "lab(20% 0 0)"); 65 70 // hue (the third argument) can be either an angle or number, with number interpreted as degrees. 66 71 testComputed("background-color", "lch(0% 0 0 / 0.5)", "lab(0% 0 0 / 0.5)"); … … 87 92 testComputed("background-color", "color(lab 50% / 0.5)", "lab(50% 0 0 / 0.5)"); 88 93 testComputed("background-color", "color(lab / 0.5)", "lab(0% 0 0 / 0.5)"); 94 testComputed("background-color", "color(lab -40% 0 0)", "lab(0% 0 0)"); 95 testComputed("background-color", "color(lab 50% -20 0)", "lab(50% -20 0)"); 96 testComputed("background-color", "color(lab 50% 0 -20)", "lab(50% 0 -20)"); 89 97 90 98 debug(''); -
trunk/Source/WebCore/ChangeLog
r272908 r272909 1 2021-02-16 Sam Weinig <weinig@apple.com> 2 3 lab() and lch() are not clamping out of bounds values at parse time 4 https://bugs.webkit.org/show_bug.cgi?id=221947 5 6 Reviewed by Simon Fraser. 7 8 The model level assertions caught this (yay). The spec requires that we 9 clamp negative lightness values to 0 for lab(), lch() and color(lab) 10 and negative chroma values to 0 for lch(). 11 12 * css/parser/CSSPropertyParserHelpers.cpp: 13 (WebCore::CSSPropertyParserHelpers::parseLabParameters): 14 (WebCore::CSSPropertyParserHelpers::parseLCHParameters): 15 (WebCore::CSSPropertyParserHelpers::parseColorFunctionForLabParameters): 16 1 17 2021-02-16 Alex Christensen <achristensen@webkit.org> 2 18 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r272876 r272909 927 927 return { }; 928 928 929 return Lab<float> { static_cast<float>(*lightness), static_cast<float>(*aValue), static_cast<float>(*bValue), static_cast<float>(*alpha) }; 929 auto normalizedLightness = std::max(0.0, *lightness); 930 931 return Lab<float> { static_cast<float>(normalizedLightness), static_cast<float>(*aValue), static_cast<float>(*bValue), static_cast<float>(*alpha) }; 930 932 } 931 933 … … 954 956 return { }; 955 957 958 auto normalizedLightness = std::max(0.0, *lightness); 959 auto normalizedChroma = std::max(0.0, *chroma); 956 960 auto normalizedHue = normalizeHue(*hue); 957 961 958 return convertColor<Lab<float>>(LCHA<float> { static_cast<float>( *lightness), static_cast<float>(*chroma), static_cast<float>(normalizedHue), static_cast<float>(*alpha) });962 return convertColor<Lab<float>>(LCHA<float> { static_cast<float>(normalizedLightness), static_cast<float>(normalizedChroma), static_cast<float>(normalizedHue), static_cast<float>(*alpha) }); 959 963 } 960 964 … … 1006 1010 return { }; 1007 1011 1008 return Lab<float> { static_cast<float>(channels[0]), static_cast<float>(channels[1]), static_cast<float>(channels[2]), static_cast<float>(*alpha) }; 1012 auto normalizedLightness = std::max(0.0, channels[0]); 1013 1014 return Lab<float> { static_cast<float>(normalizedLightness), static_cast<float>(channels[1]), static_cast<float>(channels[2]), static_cast<float>(*alpha) }; 1009 1015 } 1010 1016
Note: See TracChangeset
for help on using the changeset viewer.