diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSKeyword.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSKeyword.cpp index dd20e46769d..c203f6dbdb0 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSKeyword.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSKeyword.cpp @@ -77,6 +77,7 @@ 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("revert-layer"sv) || name.equals_ignoring_ascii_case("unset"sv); } diff --git a/Tests/LibWeb/Text/expected/css/revert-layer.txt b/Tests/LibWeb/Text/expected/css/revert-layer.txt new file mode 100644 index 00000000000..27fa8adc20b --- /dev/null +++ b/Tests/LibWeb/Text/expected/css/revert-layer.txt @@ -0,0 +1,4 @@ + PASS: revert to base (first target) +PASS: revert to base (second target) +PASS: double revert (first target) +PASS: double revert (second target) diff --git a/Tests/LibWeb/Text/input/css/revert-layer.html b/Tests/LibWeb/Text/input/css/revert-layer.html new file mode 100644 index 00000000000..49244f37245 --- /dev/null +++ b/Tests/LibWeb/Text/input/css/revert-layer.html @@ -0,0 +1,47 @@ + + + + + diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h index 0b9e3de9bd5..45be2b702f9 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -326,10 +326,11 @@ public: // 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 is_css_wide_keyword() const { return is_inherit() || is_initial() || is_revert() || is_unset() || is_revert_layer(); } bool is_inherit() const { return to_keyword() == Keyword::Inherit; } bool is_initial() const { return to_keyword() == Keyword::Initial; } bool is_revert() const { return to_keyword() == Keyword::Revert; } + bool is_revert_layer() const { return to_keyword() == Keyword::RevertLayer; } bool is_unset() const { return to_keyword() == Keyword::Unset; } bool has_auto() const; diff --git a/Userland/Libraries/LibWeb/CSS/Keywords.json b/Userland/Libraries/LibWeb/CSS/Keywords.json index f2f60c8d898..645893775b7 100644 --- a/Userland/Libraries/LibWeb/CSS/Keywords.json +++ b/Userland/Libraries/LibWeb/CSS/Keywords.json @@ -293,6 +293,7 @@ "repeat-y", "reverse", "revert", + "revert-layer", "ridge", "right", "round", diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 84c9bf5f42a..4e744c5cd37 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1755,7 +1755,10 @@ RefPtr Parser::parse_builtin_value(TokenStream& t transaction.commit(); return CSSKeywordValue::create(Keyword::Revert); } - // FIXME: Implement `revert-layer` from CSS-CASCADE-5. + if (ident.equals_ignoring_ascii_case("revert-layer"sv)) { + transaction.commit(); + return CSSKeywordValue::create(Keyword::RevertLayer); + } } return nullptr; diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 5c5387ce9de..75e0de336d9 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -886,7 +886,7 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i void StyleComputer::set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, CSSStyleValue const& value, CSS::CSSStyleDeclaration const* declaration, StyleProperties const& style_for_revert, Important important) { for_each_property_expanding_shorthands(property_id, value, AllowUnresolved::No, [&](PropertyID shorthand_id, CSSStyleValue const& shorthand_value) { - if (shorthand_value.is_revert()) { + if (shorthand_value.is_revert() || shorthand_value.is_revert_layer()) { auto const& property_in_previous_cascade_origin = style_for_revert.m_data->m_property_values[to_underlying(shorthand_id)]; if (property_in_previous_cascade_origin) { style.set_property(shorthand_id, *property_in_previous_cascade_origin, StyleProperties::Inherited::No, important); @@ -906,7 +906,7 @@ void StyleComputer::set_all_properties(DOM::Element& element, Optionaldeclaration().custom_properties()) + for (auto const& it : matching_rule.rule->declaration().custom_properties()) { + auto style_value = it.value.value; + if (style_value->is_revert_layer()) + continue; custom_properties.set(it.key, it.value); + } } if (!pseudo_element.has_value()) { diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h index 099fb7ea1f9..966a6bbeffa 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h @@ -33,6 +33,10 @@ public: static ValueComparingNonnullRefPtr const revert_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Revert)); return revert_instance; } + case Keyword::RevertLayer: { + static ValueComparingNonnullRefPtr const revert_layer_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::RevertLayer)); + return revert_layer_instance; + } case Keyword::Unset: { static ValueComparingNonnullRefPtr const unset_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Unset)); return unset_instance;