From 7458cf4231d08703746c8b091259e95d80e4c492 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 19 Apr 2023 14:36:08 +0100 Subject: [PATCH] LibWeb: Check flex longhands first when parsing flex shorthand Currently, `property_accepts_value()` always returns `true` if the property is a shorthand. (This is a bug, and should actually be fixed properly at some point...) This means that all identifiers are caught here, including `auto`, which should be handled by the `flex-basis` branch instead. This works currently because `auto` is a LengthStyleValue, but that's about to change! --- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 23e67e9e4d..1daa720a9a 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5128,17 +5128,6 @@ RefPtr Parser::parse_flex_value(Vector const& compon if (!value) return nullptr; - if (value->is_identifier() && property_accepts_value(PropertyID::Flex, *value)) { - switch (value->to_identifier()) { - case ValueID::None: { - auto zero = NumericStyleValue::create_integer(0); - return FlexStyleValue::create(zero, zero, IdentifierStyleValue::create(ValueID::Auto)); - } - default: - return value; - } - } - if (property_accepts_value(PropertyID::FlexGrow, *value)) { // NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%. // https://github.com/w3c/csswg-drafts/issues/5742 @@ -5152,6 +5141,17 @@ RefPtr Parser::parse_flex_value(Vector const& compon return FlexStyleValue::create(one, one, *value); } + if (value->is_identifier() && property_accepts_value(PropertyID::Flex, *value)) { + switch (value->to_identifier()) { + case ValueID::None: { + auto zero = NumericStyleValue::create_integer(0); + return FlexStyleValue::create(zero, zero, IdentifierStyleValue::create(ValueID::Auto)); + } + default: + return value; + } + } + return nullptr; }