From 1c4a05f8a4e91e3a42bf34f9009838bdc43bc5f5 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 20 Sep 2023 16:58:45 +0100 Subject: [PATCH] LibWeb: Treat "revert" as a CSS-wide keyword This isn't included in the base definition of a CSS-wide keyword, but the CASCADE-4 spec which adds it says: > The revert CSS-wide keyword rolls back the cascade to the cascaded value of the earlier origin. So it is one. While I'm at it, rename `is_builtin()` to match the spec terminology. It's not used currently, but will be in the next commit. --- Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp | 2 ++ Userland/Libraries/LibWeb/CSS/StyleValue.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp index 1aa5067ea0..bc3d65ea96 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp @@ -71,10 +71,12 @@ Optional value_id_from_string(StringView); StringView string_from_value_id(ValueID); // https://www.w3.org/TR/css-values-4/#common-keywords +// https://drafts.csswg.org/css-cascade-4/#valdef-all-revert inline bool is_css_wide_keyword(StringView name) { return name.equals_ignoring_ascii_case("inherit"sv) || name.equals_ignoring_ascii_case("initial"sv) + || name.equals_ignoring_ascii_case("revert"sv) || name.equals_ignoring_ascii_case("unset"sv); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 8ad3d80fc9..f7e3c49b26 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -157,7 +157,9 @@ public: AbstractImageStyleValue const& as_abstract_image() const; AbstractImageStyleValue& as_abstract_image() { return const_cast(const_cast(*this).as_abstract_image()); } - bool is_builtin() const { return is_inherit() || is_initial() || is_unset(); } + // https://www.w3.org/TR/css-values-4/#common-keywords + // https://drafts.csswg.org/css-cascade-4/#valdef-all-revert + bool is_css_wide_keyword() const { return is_inherit() || is_initial() || is_revert() || is_unset(); } bool has_auto() const; virtual bool has_color() const { return false; }