瀏覽代碼

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!
Sam Atkins 2 年之前
父節點
當前提交
7458cf4231
共有 1 個文件被更改,包括 11 次插入11 次删除
  1. 11 11
      Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

+ 11 - 11
Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

@@ -5128,17 +5128,6 @@ RefPtr<StyleValue> Parser::parse_flex_value(Vector<ComponentValue> 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<StyleValue> Parser::parse_flex_value(Vector<ComponentValue> 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;
     }