From 733b74af7c12e0404f74cba5dacbc18f549d3cd3 Mon Sep 17 00:00:00 2001 From: Karthik Karanth Date: Tue, 23 May 2023 00:29:01 -0700 Subject: [PATCH] LibWeb: Support min-inline-size & max-inline-size Currently this assumes that writing-mode is horizontal, and therefore only affects the min-width/max-width --- Userland/Libraries/LibWeb/CSS/Properties.json | 10 ++++++++++ .../Libraries/LibWeb/CSS/StyleComputer.cpp | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index cc586bf9e6..38d884c8c0 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -1227,6 +1227,11 @@ "unitless-length" ] }, + "max-inline-size": { + "logical-alias-for": "max-width", + "__comment": "Also a logical alias for max-height", + "initial": "none" + }, "max-width": { "inherited": false, "initial": "none", @@ -1257,6 +1262,11 @@ "unitless-length" ] }, + "min-inline-size": { + "logical-alias-for": "min-width", + "__comment": "Also a logical alias for min-height", + "initial": "0" + }, "min-width": { "inherited": false, "initial": "auto", diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index f666efcfac..4fd9c2b5b1 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -675,6 +675,26 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } + if (property_id == CSS::PropertyID::MaxInlineSize || property_id == CSS::PropertyID::MinInlineSize) { + // FIXME: Use writing-mode to determine if we should set width or height. + bool is_horizontal = true; + + if (is_horizontal) { + if (property_id == CSS::PropertyID::MaxInlineSize) { + style.set_property(CSS::PropertyID::MaxWidth, value); + } else { + style.set_property(CSS::PropertyID::MinWidth, value); + } + } else { + if (property_id == CSS::PropertyID::MaxInlineSize) { + style.set_property(CSS::PropertyID::MaxHeight, value); + } else { + style.set_property(CSS::PropertyID::MinHeight, value); + } + } + return; + } + style.set_property(property_id, value); }