From 8b57e56d6627a6e8c82629617ec4181c4b6aa1c9 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 15 Oct 2021 19:25:27 +0100 Subject: [PATCH] LibWeb: Parse "none" value for box-shadow property Previously, `box-shadow: none` would fail to parse, meaning that in this example: ```css p { box-shadow: 20px 10px 5px magenta; } p.foo { box-shadow: none; } ``` ... a `

` would still have a box-shadow, when it should not have one. Now, we handle the `none` value. :^) --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 7 +++++++ Userland/Libraries/LibWeb/CSS/Properties.json | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index fe6162559e..2f3326d21e 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -2571,6 +2571,13 @@ RefPtr Parser::parse_border_radius_shorthand_value(ParsingContext co RefPtr Parser::parse_box_shadow_value(ParsingContext const& context, Vector const& component_values) { + // "none" + if (component_values.size() == 1 && component_values.first().is(Token::Type::Ident)) { + auto ident = parse_identifier_value(context, component_values.first()); + if (ident && ident->to_identifier() == ValueID::None) + return ident; + } + // FIXME: Also support inset, spread-radius and multiple comma-separated box-shadows Length offset_x {}; Length offset_y {}; diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index d53dcfcd21..c35022d31c 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -415,7 +415,10 @@ }, "box-shadow": { "inherited": false, - "initial": "none" + "initial": "none", + "valid-identifiers": [ + "none" + ] }, "box-sizing": { "inherited": false,