From 09eb3ef4054e44ce5e156b36bbb62cb5ac9c4b5f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 26 May 2023 18:58:06 +0200 Subject: [PATCH] LibWeb: Add fit-content as a valid size value for CSS width --- Userland/Libraries/LibWeb/CSS/Identifiers.json | 1 + Userland/Libraries/LibWeb/CSS/Properties.json | 3 ++- Userland/Libraries/LibWeb/CSS/Size.cpp | 6 ++++++ Userland/Libraries/LibWeb/CSS/Size.h | 1 + Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/Identifiers.json b/Userland/Libraries/LibWeb/CSS/Identifiers.json index 742f606c41..3110d40ee3 100644 --- a/Userland/Libraries/LibWeb/CSS/Identifiers.json +++ b/Userland/Libraries/LibWeb/CSS/Identifiers.json @@ -118,6 +118,7 @@ "fantasy", "fast", "fine", + "fit-content", "fixed", "flex", "flex-end", diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index d030544efa..05c7f79f83 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -1663,7 +1663,8 @@ "percentage [0,∞]" ], "valid-identifiers": [ - "auto" + "auto", + "fit-content" ], "quirks": [ "unitless-length" diff --git a/Userland/Libraries/LibWeb/CSS/Size.cpp b/Userland/Libraries/LibWeb/CSS/Size.cpp index 5df737b3be..53ccb60f97 100644 --- a/Userland/Libraries/LibWeb/CSS/Size.cpp +++ b/Userland/Libraries/LibWeb/CSS/Size.cpp @@ -64,6 +64,12 @@ Size Size::make_fit_content(Length available_space) return Size { Type::FitContent, move(available_space) }; } +Size Size::make_fit_content() +{ + // NOTE: We use "auto" as a stand-in for "stretch" here. + return Size { Type::FitContent, Length::make_auto() }; +} + Size Size::make_none() { return Size { Type::None, Length::make_auto() }; diff --git a/Userland/Libraries/LibWeb/CSS/Size.h b/Userland/Libraries/LibWeb/CSS/Size.h index ff12a824b1..59fe05809d 100644 --- a/Userland/Libraries/LibWeb/CSS/Size.h +++ b/Userland/Libraries/LibWeb/CSS/Size.h @@ -33,6 +33,7 @@ public: static Size make_min_content(); static Size make_max_content(); static Size make_fit_content(Length available_space); + static Size make_fit_content(); static Size make_none(); bool is_auto() const { return m_type == Type::Auto; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 0aa12da1d6..ee92870397 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -72,6 +72,8 @@ CSS::Size StyleProperties::size_value(CSS::PropertyID id) const return CSS::Size::make_min_content(); case ValueID::MaxContent: return CSS::Size::make_max_content(); + case ValueID::FitContent: + return CSS::Size::make_fit_content(); case ValueID::None: return CSS::Size::make_none(); default: