Truly independent web browser
LibWeb: Accept flex units for implicit grid tracks
Andreas Kling9c0a785dd219
diff --git a/Libraries/LibWeb/CSS/CSSMathValue.cpp b/Libraries/LibWeb/CSS/CSSMathValue.cppindex 51f3d5207ec..68764c7eb55 100644--- a/Libraries/LibWeb/CSS/CSSMathValue.cpp+++ b/Libraries/LibWeb/CSS/CSSMathValue.cpp@@ -36,8 +36,11 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSMathValue::create_an_intauto matches = [&] {if (type().matches_angle(context.percentages_resolve_as))return property_accepts_type(property.id(), ValueType::Angle);- if (type().matches_flex(context.percentages_resolve_as))- return property_accepts_type(property.id(), ValueType::Flex);+ if (type().matches_flex(context.percentages_resolve_as)) {+ // https://drafts.csswg.org/css-grid-2/#fr-unit+ // NB: <flex> values "cannot be represented in or combined with other unit types in calc() expressions".+ return property.is_custom_property() && property_accepts_type(property.id(), ValueType::Flex);+ }if (type().matches_frequency(context.percentages_resolve_as))return property_accepts_type(property.id(), ValueType::Frequency);if (type().matches_length(context.percentages_resolve_as))diff --git a/Libraries/LibWeb/CSS/CSSUnitValue.cpp b/Libraries/LibWeb/CSS/CSSUnitValue.cppindex dbb6e6539c7..b770f89cb23 100644--- a/Libraries/LibWeb/CSS/CSSUnitValue.cpp+++ b/Libraries/LibWeb/CSS/CSSUnitValue.cpp@@ -430,11 +430,9 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_intreturn {};},[&](Flex const& flex) -> RefPtr<StyleValue const> {- if (property_accepts_type(property.id(), ValueType::Flex)) {- if (property_accepts_flex(property.id(), flex))- return FlexStyleValue::create(flex);- return wrap_in_math_sum(flex);- }+ // NB: Out-of-range flex values cannot be deferred in a calculation.+ if (property_accepts_type(property.id(), ValueType::Flex) && property_accepts_flex(property.id(), flex))+ return FlexStyleValue::create(flex);return {};},[&](Frequency const& frequency) -> RefPtr<StyleValue const> {diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.jsonindex b3fac91bc0e..bad464dd471 100644--- a/Libraries/LibWeb/CSS/Properties.json+++ b/Libraries/LibWeb/CSS/Properties.json@@ -2835,6 +2835,7 @@"auto"],"valid-types": [+ "flex [0,∞]","length [0,∞]","percentage [0,∞]","string"@@ -2858,6 +2859,7 @@"auto"],"valid-types": [+ "flex [0,∞]","length [0,∞]","percentage [0,∞]","string"diff --git a/Meta/Generators/generate_libweb_css_property_id.py b/Meta/Generators/generate_libweb_css_property_id.pyindex a42b6bb81c8..73c30b8d7f3 100755--- a/Meta/Generators/generate_libweb_css_property_id.py+++ b/Meta/Generators/generate_libweb_css_property_id.py@@ -389,6 +389,7 @@ def write_implementation_file(out: TextIO, properties: dict, logical_property_gr#include <AK/CharacterTypes.h>#include <AK/NeverDestroyed.h>#include <LibWeb/CSS/Enums.h>+#include <LibWeb/CSS/Flex.h>#include <LibWeb/CSS/Parser/Parser.h>#include <LibWeb/CSS/PropertyID.h>#include <LibWeb/CSS/PropertyName.h>diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/grid-auto-columns-rows.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/grid-auto-columns-rows.txtindex 76631627b98..f9adb447812 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/grid-auto-columns-rows.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/grid-auto-columns-rows.txt@@ -2,8 +2,7 @@ Harness status: OKFound 72 tests-68 Pass-4 Fail+72 PassPass Can set 'grid-auto-columns' to CSS-wide keywords: initialPass Can set 'grid-auto-columns' to CSS-wide keywords: inheritPass Can set 'grid-auto-columns' to CSS-wide keywords: unset@@ -20,8 +19,8 @@ Pass Can set 'grid-auto-columns' to a percent: 0%Pass Can set 'grid-auto-columns' to a percent: -3.14%Pass Can set 'grid-auto-columns' to a percent: 3.14%Pass Can set 'grid-auto-columns' to a percent: calc(0% + 0%)-Fail Can set 'grid-auto-columns' to a flexible length: 0fr-Fail Can set 'grid-auto-columns' to a flexible length: 1fr+Pass Can set 'grid-auto-columns' to a flexible length: 0fr+Pass Can set 'grid-auto-columns' to a flexible length: 1frPass Setting 'grid-auto-columns' to a time: 0s throws TypeErrorPass Setting 'grid-auto-columns' to a time: -3.14ms throws TypeErrorPass Setting 'grid-auto-columns' to a time: 3.14s throws TypeError@@ -56,8 +55,8 @@ Pass Can set 'grid-auto-rows' to a percent: 0%Pass Can set 'grid-auto-rows' to a percent: -3.14%Pass Can set 'grid-auto-rows' to a percent: 3.14%Pass Can set 'grid-auto-rows' to a percent: calc(0% + 0%)-Fail Can set 'grid-auto-rows' to a flexible length: 0fr-Fail Can set 'grid-auto-rows' to a flexible length: 1fr+Pass Can set 'grid-auto-rows' to a flexible length: 0fr+Pass Can set 'grid-auto-rows' to a flexible length: 1frPass Setting 'grid-auto-rows' to a time: 0s throws TypeErrorPass Setting 'grid-auto-rows' to a time: -3.14ms throws TypeErrorPass Setting 'grid-auto-rows' to a time: 3.14s throws TypeError