Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283536 => 283537)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-10-05 05:10:51 UTC (rev 283537)
@@ -1,5 +1,20 @@
2021-10-04 Myles C. Maxfield <mmaxfi...@apple.com>
+ Stop parsing context-sensitive colors in override-color
+ https://bugs.webkit.org/show_bug.cgi?id=231052
+ <rdar://problem/83746258>
+
+ Reviewed by Simon Fraser.
+
+ These are being upstreamed in https://github.com/web-platform-tests/wpt/pull/31078.
+
+ * web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt:
+ * web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html:
+ * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt:
+ * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html:
+
+2021-10-04 Myles C. Maxfield <mmaxfi...@apple.com>
+
Remove the "none" value from font-palette
https://bugs.webkit.org/show_bug.cgi?id=231050
<rdar://problem/83745650>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt (283536 => 283537)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt 2021-10-05 05:10:51 UTC (rev 283537)
@@ -19,4 +19,5 @@
PASS CSS Fonts Module Level 4: parsing @font-palette-values 17
PASS CSS Fonts Module Level 4: parsing @font-palette-values 18
PASS CSS Fonts Module Level 4: parsing @font-palette-values 19
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 20
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html (283536 => 283537)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html 2021-10-05 05:10:51 UTC (rev 283537)
@@ -110,6 +110,11 @@
base-palette: -1;
override-color: -1 #123;
}
+
+/* 18 */
+@font-palette-values --A {
+ override-colors: 0 canvas;
+}
</style>
</head>
<body>
@@ -116,7 +121,7 @@
<script>
let rules = document.getElementById("style").sheet.cssRules;
test(function() {
- assert_equals(rules.length, 18);
+ assert_equals(rules.length, 19);
});
test(function() {
@@ -270,6 +275,14 @@
assert_equals(rule.basePalette, "");
assert_equals(rule.overrideColors, "");
});
+
+test(function() {
+ let text = rules[18].cssText;
+ let rule = rules[18];
+ assert_equals(text.indexOf("override-colors"), -1);
+ assert_equals(rule.basePalette, "");
+ assert_equals(rule.overrideColors, "");
+});
</script>
</body>
</html>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt (283536 => 283537)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt 2021-10-05 05:10:51 UTC (rev 283537)
@@ -27,4 +27,6 @@
PASS CSS Fonts Module Level 4: parsing @font-palette-values 25
PASS CSS Fonts Module Level 4: parsing @font-palette-values 26
PASS CSS Fonts Module Level 4: parsing @font-palette-values 27
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 28
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 29
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html (283536 => 283537)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html 2021-10-05 05:10:51 UTC (rev 283537)
@@ -89,6 +89,11 @@
@font-palette-values --N {
override-colors: 0 color(display-p3 100% 100% 100%);
}
+
+/* 14 */
+@font-palette-values --O {
+ override-colors: 0 transparent;
+}
</style>
</head>
<body>
@@ -321,6 +326,19 @@
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("display-p3"), -1);
});
+
+test(function() {
+ let text = rules[14].cssText;
+ assert_not_equals(text.indexOf("override-colors"), -1);
+});
+
+test(function() {
+ let rule = rules[14];
+ assert_equals(rule.name, "--O");
+ assert_equals(rule.fontFamily, "");
+ assert_equals(rule.basePalette, "");
+ assert_not_equals(rule.overrideColors, "");
+});
</script>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (283536 => 283537)
--- trunk/Source/WebCore/ChangeLog 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/ChangeLog 2021-10-05 05:10:51 UTC (rev 283537)
@@ -1,5 +1,45 @@
2021-10-04 Myles C. Maxfield <mmaxfi...@apple.com>
+ Stop parsing context-sensitive colors in override-color
+ https://bugs.webkit.org/show_bug.cgi?id=231052
+ <rdar://problem/83746258>
+
+ Reviewed by Simon Fraser.
+
+ The spec has split the <color> production into two halves:
+ absolute colors and non-absolute colors. This patch adds a new
+ enum argument to consumeColor() to distinguish which production
+ you want.
+
+ Tests: imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html
+ imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html
+
+ * css/StyleColor.cpp:
+ (WebCore::StyleColor::colorFromKeyword):
+ (WebCore::isVGAPaletteColor):
+ (WebCore::isNonVGANamedColor):
+ (WebCore::StyleColor::isAbsoluteColorKeyword):
+ (WebCore::StyleColor::isSystemColorKeyword):
+ (WebCore::StyleColor::isColorKeyword):
+ (WebCore::StyleColor::isSystemColor): Deleted.
+ * css/StyleColor.h:
+ (WebCore::StyleColor::isColorKeyword):
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParser::parseSystemColor):
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeOverrideColorsDescriptor):
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::consumeOriginColor):
+ (WebCore::CSSPropertyParserHelpers::consumeColorWorkerSafe):
+ (WebCore::CSSPropertyParserHelpers::consumeColor):
+ * css/parser/CSSPropertyParserHelpers.h:
+ (WebCore::CSSPropertyParserHelpers::consumeColor):
+ * platform/ColorData.gperf:
+ * testing/Internals.cpp:
+ (WebCore::Internals::systemColorForCSSValue):
+
+2021-10-04 Myles C. Maxfield <mmaxfi...@apple.com>
+
Remove the "none" value from font-palette
https://bugs.webkit.org/show_bug.cgi?id=231050
<rdar://problem/83745650>
Modified: trunk/Source/WebCore/css/StyleColor.cpp (283536 => 283537)
--- trunk/Source/WebCore/css/StyleColor.cpp 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/css/StyleColor.cpp 2021-10-05 05:10:51 UTC (rev 283537)
@@ -44,17 +44,41 @@
return asSRGBA(PackedColor::ARGB { namedColor->ARGBValue });
}
+ ASSERT(!isAbsoluteColorKeyword(keyword));
return RenderTheme::singleton().systemColor(keyword, options);
}
-bool StyleColor::isColorKeyword(CSSValueID id)
+static bool isVGAPaletteColor(CSSValueID id)
{
- return (id >= CSSValueAlpha && id <= CSSValueWebkitText) || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen) || isSystemColor(id);
+ // https://drafts.csswg.org/css-color-4/#named-colors
+ // "16 of CSS’s named colors come from the VGA palette originally, and were then adopted into HTML"
+ return (id >= CSSValueAqua && id <= CSSValueYellow) || id == CSSValueGrey;
}
-bool StyleColor::isSystemColor(CSSValueID id)
+static bool isNonVGANamedColor(CSSValueID id)
{
- return (id >= CSSValueWebkitLink && id <= CSSValueWebkitFocusRingColor) || id == CSSValueMenu || id == CSSValueText;
+ // https://drafts.csswg.org/css-color-4/#named-colors
+ return id >= CSSValueAliceblue && id <= CSSValueYellowgreen;
}
+bool StyleColor::isAbsoluteColorKeyword(CSSValueID id)
+{
+ // https://drafts.csswg.org/css-color-4/#typedef-absolute-color
+ return isVGAPaletteColor(id) || isNonVGANamedColor(id) || id == CSSValueAlpha || id == CSSValueTransparent;
+}
+
+bool StyleColor::isSystemColorKeyword(CSSValueID id)
+{
+ // https://drafts.csswg.org/css-color-4/#css-system-colors
+ // https://drafts.csswg.org/css-color-4/#deprecated-system-colors
+ return (id >= CSSValueWebkitLink && id <= CSSValueWebkitFocusRingColor) || id == CSSValueWebkitText || id == CSSValueMenu || id == CSSValueText;
+}
+
+bool StyleColor::isColorKeyword(CSSValueID id, OptionSet<CSSColorType> allowedColorTypes)
+{
+ return (allowedColorTypes.contains(CSSColorType::Absolute) && isAbsoluteColorKeyword(id))
+ || (allowedColorTypes.contains(CSSColorType::Current) && id == CSSValueCurrentcolor)
+ || (allowedColorTypes.contains(CSSColorType::System) && isSystemColorKeyword(id));
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/StyleColor.h (283536 => 283537)
--- trunk/Source/WebCore/css/StyleColor.h 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/css/StyleColor.h 2021-10-05 05:10:51 UTC (rev 283537)
@@ -46,8 +46,16 @@
};
static Color colorFromKeyword(CSSValueID, OptionSet<Options>);
- static bool isColorKeyword(CSSValueID);
- WEBCORE_EXPORT static bool isSystemColor(CSSValueID);
+ static bool isAbsoluteColorKeyword(CSSValueID);
+ WEBCORE_EXPORT static bool isSystemColorKeyword(CSSValueID);
+
+ enum class CSSColorType : uint8_t {
+ Absolute = 1 << 0,
+ Current = 1 << 1,
+ System = 1 << 2,
+ };
+ // https://drafts.csswg.org/css-color-4/#typedef-color
+ static bool isColorKeyword(CSSValueID, OptionSet<CSSColorType> = { CSSColorType::Absolute, CSSColorType::Current, CSSColorType::System });
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (283536 => 283537)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2021-10-05 05:10:51 UTC (rev 283537)
@@ -111,7 +111,7 @@
Color CSSParser::parseSystemColor(StringView string)
{
auto keyword = cssValueKeywordID(string);
- if (!StyleColor::isSystemColor(keyword))
+ if (!StyleColor::isSystemColorKeyword(keyword))
return { };
return RenderTheme::singleton().systemColor(keyword, { });
}
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (283536 => 283537)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2021-10-05 05:10:51 UTC (rev 283537)
@@ -4867,7 +4867,7 @@
if (!key)
return nullptr;
- auto color = consumeColor(range, context);
+ auto color = consumeColor(range, context, false, { StyleColor::CSSColorType::Absolute });
if (!color)
return nullptr;
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (283536 => 283537)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-10-05 05:10:51 UTC (rev 283537)
@@ -1424,7 +1424,7 @@
// FIXME: We don't have enough context in the parser to resolving a system keyword
// correctly. We should package up the relative color parameters and resolve the
// whole thing at the appropriate time when the origin color is a system keyword.
- if (StyleColor::isSystemColor(keyword))
+ if (StyleColor::isSystemColorKeyword(keyword))
return { };
return StyleColor::colorFromKeyword(keyword, { });
@@ -2580,7 +2580,7 @@
if (StyleColor::isColorKeyword(keyword)) {
// FIXME: Need a worker-safe way to compute the system colors.
// For now, we detect the system color, but then intentionally fail parsing.
- if (StyleColor::isSystemColor(keyword))
+ if (StyleColor::isSystemColorKeyword(keyword))
return { };
if (!isValueAllowedInMode(keyword, context.mode))
return { };
@@ -2599,10 +2599,10 @@
return result;
}
-RefPtr<CSSPrimitiveValue> consumeColor(CSSParserTokenRange& range, const CSSParserContext& context, bool acceptQuirkyColors)
+RefPtr<CSSPrimitiveValue> consumeColor(CSSParserTokenRange& range, const CSSParserContext& context, bool acceptQuirkyColors, OptionSet<StyleColor::CSSColorType> allowedColorTypes)
{
auto keyword = range.peek().id();
- if (StyleColor::isColorKeyword(keyword)) {
+ if (StyleColor::isColorKeyword(keyword, allowedColorTypes)) {
if (!isValueAllowedInMode(keyword, context.mode))
return nullptr;
return consumeIdent(range);
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h (283536 => 283537)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h 2021-10-05 05:10:51 UTC (rev 283537)
@@ -36,6 +36,7 @@
#include "CSSShadowValue.h"
#include "CSSValuePool.h"
#include "Length.h" // For ValueRange
+#include "StyleColor.h"
#include <wtf/OptionSet.h>
#include <wtf/Variant.h>
#include <wtf/Vector.h>
@@ -115,7 +116,7 @@
RefPtr<CSSPrimitiveValue> consumeUrl(CSSParserTokenRange&);
Color consumeColorWorkerSafe(CSSParserTokenRange&, const CSSParserContext&);
-RefPtr<CSSPrimitiveValue> consumeColor(CSSParserTokenRange&, const CSSParserContext&, bool acceptQuirkyColors = false);
+RefPtr<CSSPrimitiveValue> consumeColor(CSSParserTokenRange&, const CSSParserContext&, bool acceptQuirkyColors = false, OptionSet<StyleColor::CSSColorType> = { StyleColor::CSSColorType::Absolute, StyleColor::CSSColorType::Current, StyleColor::CSSColorType::System });
enum class PositionSyntax {
Position, // <position>
Modified: trunk/Source/WebCore/platform/ColorData.gperf (283536 => 283537)
--- trunk/Source/WebCore/platform/ColorData.gperf 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/platform/ColorData.gperf 2021-10-05 05:10:51 UTC (rev 283537)
@@ -23,6 +23,7 @@
%enum
%%
aliceblue, 0xfff0f8ff
+alpha, 0x00000000
antiquewhite, 0xfffaebd7
aqua, 0xff00ffff
aquamarine, 0xff7fffd4
Modified: trunk/Source/WebCore/testing/Internals.cpp (283536 => 283537)
--- trunk/Source/WebCore/testing/Internals.cpp 2021-10-05 03:52:13 UTC (rev 283536)
+++ trunk/Source/WebCore/testing/Internals.cpp 2021-10-05 05:10:51 UTC (rev 283537)
@@ -6122,7 +6122,7 @@
String Internals::systemColorForCSSValue(const String& cssValue, bool useDarkModeAppearance, bool useElevatedUserInterfaceLevel)
{
CSSValueID id = cssValueKeywordID(cssValue);
- RELEASE_ASSERT(StyleColor::isSystemColor(id));
+ RELEASE_ASSERT(StyleColor::isSystemColorKeyword(id));
OptionSet<StyleColor::Options> options;
if (useDarkModeAppearance)