Diff
Modified: trunk/LayoutTests/ChangeLog (272908 => 272909)
--- trunk/LayoutTests/ChangeLog 2021-02-16 16:59:26 UTC (rev 272908)
+++ trunk/LayoutTests/ChangeLog 2021-02-16 17:26:02 UTC (rev 272909)
@@ -1,3 +1,17 @@
+2021-02-16 Sam Weinig <wei...@apple.com>
+
+ lab() and lch() are not clamping out of bounds values at parse time
+ https://bugs.webkit.org/show_bug.cgi?id=221947
+
+ Reviewed by Simon Fraser.
+
+ The model level assertions caught this (yay). The spec requires that we
+ clamp negative lightness values to 0 for lab(), lch() and color(lab)
+ and negative chroma values to 0 for lch().
+
+ * fast/css/parsing-lab-colors-expected.txt:
+ * fast/css/parsing-lab-colors.html:
+
2021-02-16 Chris Gambrell <cgambr...@apple.com>
[LayoutTests] Convert http/tests/in-app-browser-privacy convert PHP to Python
Modified: trunk/LayoutTests/fast/css/parsing-lab-colors-expected.txt (272908 => 272909)
--- trunk/LayoutTests/fast/css/parsing-lab-colors-expected.txt 2021-02-16 16:59:26 UTC (rev 272908)
+++ trunk/LayoutTests/fast/css/parsing-lab-colors-expected.txt 2021-02-16 17:26:02 UTC (rev 272909)
@@ -15,6 +15,9 @@
PASS computedStyle("background-color", "lab(0% 0 0 / -10%)") is "lab(0% 0 0 / 0)"
PASS computedStyle("background-color", "lab(0% 0 0 / 110%)") is "lab(0% 0 0)"
PASS computedStyle("background-color", "lab(0% 0 0 / 300%)") is "lab(0% 0 0)"
+PASS computedStyle("background-color", "lab(-40% 0 0)") is "lab(0% 0 0)"
+PASS computedStyle("background-color", "lab(50% -20 0)") is "lab(50% -20 0)"
+PASS computedStyle("background-color", "lab(50% 0 -20)") is "lab(50% 0 -20)"
lch()
PASS computedStyle("background-color", "lch(0% 0 0deg)") is "lab(0% 0 0)"
@@ -30,6 +33,8 @@
PASS computedStyle("background-color", "lch(10% 20 -340deg)") is "lab(10% 18.793852 6.8404026)"
PASS computedStyle("background-color", "lch(10% 20 740deg)") is "lab(10% 18.793852 6.8404026)"
PASS computedStyle("background-color", "lch(10% 20 -700deg)") is "lab(10% 18.793852 6.8404026)"
+PASS computedStyle("background-color", "lch(-40% 0 0)") is "lab(0% 0 0)"
+PASS computedStyle("background-color", "lch(20% -20 0)") is "lab(20% 0 0)"
PASS computedStyle("background-color", "lch(0% 0 0 / 0.5)") is "lab(0% 0 0 / 0.5)"
PASS computedStyle("background-color", "lch(10% 20 20 / 110%)") is "lab(10% 18.793852 6.8404026)"
PASS computedStyle("background-color", "lch(10% 20 -700)") is "lab(10% 18.793852 6.8404026)"
@@ -52,6 +57,9 @@
PASS computedStyle("background-color", "color(lab 50% -200 / 0.5)") is "lab(50% -200 0 / 0.5)"
PASS computedStyle("background-color", "color(lab 50% / 0.5)") is "lab(50% 0 0 / 0.5)"
PASS computedStyle("background-color", "color(lab / 0.5)") is "lab(0% 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(lab -40% 0 0)") is "lab(0% 0 0)"
+PASS computedStyle("background-color", "color(lab 50% -20 0)") is "lab(50% -20 0)"
+PASS computedStyle("background-color", "color(lab 50% 0 -20)") is "lab(50% 0 -20)"
Test invalid values
PASS computedStyle("background-color", "lab(0 0 0)") is "rgba(0, 0, 0, 0)"
Modified: trunk/LayoutTests/fast/css/parsing-lab-colors.html (272908 => 272909)
--- trunk/LayoutTests/fast/css/parsing-lab-colors.html 2021-02-16 16:59:26 UTC (rev 272908)
+++ trunk/LayoutTests/fast/css/parsing-lab-colors.html 2021-02-16 17:26:02 UTC (rev 272909)
@@ -46,6 +46,9 @@
testComputed("background-color", "lab(0% 0 0 / -10%)", "lab(0% 0 0 / 0)");
testComputed("background-color", "lab(0% 0 0 / 110%)", "lab(0% 0 0)");
testComputed("background-color", "lab(0% 0 0 / 300%)", "lab(0% 0 0)");
+ testComputed("background-color", "lab(-40% 0 0)", "lab(0% 0 0)");
+ testComputed("background-color", "lab(50% -20 0)", "lab(50% -20 0)");
+ testComputed("background-color", "lab(50% 0 -20)", "lab(50% 0 -20)");
debug('');
debug('lch()');
@@ -62,6 +65,8 @@
testComputed("background-color", "lch(10% 20 -340deg)", "lab(10% 18.793852 6.8404026)");
testComputed("background-color", "lch(10% 20 740deg)", "lab(10% 18.793852 6.8404026)");
testComputed("background-color", "lch(10% 20 -700deg)", "lab(10% 18.793852 6.8404026)");
+ testComputed("background-color", "lch(-40% 0 0)", "lab(0% 0 0)");
+ testComputed("background-color", "lch(20% -20 0)", "lab(20% 0 0)");
// hue (the third argument) can be either an angle or number, with number interpreted as degrees.
testComputed("background-color", "lch(0% 0 0 / 0.5)", "lab(0% 0 0 / 0.5)");
testComputed("background-color", "lch(10% 20 20 / 110%)", "lab(10% 18.793852 6.8404026)");
@@ -86,6 +91,9 @@
testComputed("background-color", "color(lab 50% -200 / 0.5)", "lab(50% -200 0 / 0.5)");
testComputed("background-color", "color(lab 50% / 0.5)", "lab(50% 0 0 / 0.5)");
testComputed("background-color", "color(lab / 0.5)", "lab(0% 0 0 / 0.5)");
+ testComputed("background-color", "color(lab -40% 0 0)", "lab(0% 0 0)");
+ testComputed("background-color", "color(lab 50% -20 0)", "lab(50% -20 0)");
+ testComputed("background-color", "color(lab 50% 0 -20)", "lab(50% 0 -20)");
debug('');
debug('Test invalid values');
Modified: trunk/Source/WebCore/ChangeLog (272908 => 272909)
--- trunk/Source/WebCore/ChangeLog 2021-02-16 16:59:26 UTC (rev 272908)
+++ trunk/Source/WebCore/ChangeLog 2021-02-16 17:26:02 UTC (rev 272909)
@@ -1,3 +1,19 @@
+2021-02-16 Sam Weinig <wei...@apple.com>
+
+ lab() and lch() are not clamping out of bounds values at parse time
+ https://bugs.webkit.org/show_bug.cgi?id=221947
+
+ Reviewed by Simon Fraser.
+
+ The model level assertions caught this (yay). The spec requires that we
+ clamp negative lightness values to 0 for lab(), lch() and color(lab)
+ and negative chroma values to 0 for lch().
+
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::parseLabParameters):
+ (WebCore::CSSPropertyParserHelpers::parseLCHParameters):
+ (WebCore::CSSPropertyParserHelpers::parseColorFunctionForLabParameters):
+
2021-02-16 Alex Christensen <achristen...@webkit.org>
Synthesize range responses if needed in WebCoreNSURLSession
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (272908 => 272909)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-02-16 16:59:26 UTC (rev 272908)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-02-16 17:26:02 UTC (rev 272909)
@@ -926,7 +926,9 @@
if (!args.atEnd())
return { };
- return Lab<float> { static_cast<float>(*lightness), static_cast<float>(*aValue), static_cast<float>(*bValue), static_cast<float>(*alpha) };
+ auto normalizedLightness = std::max(0.0, *lightness);
+
+ return Lab<float> { static_cast<float>(normalizedLightness), static_cast<float>(*aValue), static_cast<float>(*bValue), static_cast<float>(*alpha) };
}
static Color parseLCHParameters(CSSParserTokenRange& range, const CSSParserContext& context)
@@ -953,9 +955,11 @@
if (!args.atEnd())
return { };
+ auto normalizedLightness = std::max(0.0, *lightness);
+ auto normalizedChroma = std::max(0.0, *chroma);
auto normalizedHue = normalizeHue(*hue);
- return convertColor<Lab<float>>(LCHA<float> { static_cast<float>(*lightness), static_cast<float>(*chroma), static_cast<float>(normalizedHue), static_cast<float>(*alpha) });
+ return convertColor<Lab<float>>(LCHA<float> { static_cast<float>(normalizedLightness), static_cast<float>(normalizedChroma), static_cast<float>(normalizedHue), static_cast<float>(*alpha) });
}
template<typename ColorType> static Color parseColorFunctionForRGBTypes(CSSParserTokenRange& args)
@@ -1005,7 +1009,9 @@
if (!alpha)
return { };
- return Lab<float> { static_cast<float>(channels[0]), static_cast<float>(channels[1]), static_cast<float>(channels[2]), static_cast<float>(*alpha) };
+ auto normalizedLightness = std::max(0.0, channels[0]);
+
+ return Lab<float> { static_cast<float>(normalizedLightness), static_cast<float>(channels[1]), static_cast<float>(channels[2]), static_cast<float>(*alpha) };
}
static Color parseColorFunctionForXYZParameters(CSSParserTokenRange& args)