diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt index a9d420ba256..e56b55f896a 100644 --- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt +++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt @@ -156,6 +156,7 @@ text-shadow: none text-transform: none top: auto transform: none +transform-box: view-box transform-origin: 50% 50% transition-delay: 0s user-select: auto diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 330529294dd..27b32a30ae0 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -160,6 +160,7 @@ public: static CSS::Length outline_width() { return CSS::Length::make_px(3); } static CSS::TableLayout table_layout() { return CSS::TableLayout::Auto; } static QuotesData quotes() { return QuotesData { .type = QuotesData::Type::Auto }; } + static CSS::TransformBox transform_box() { return CSS::TransformBox::ViewBox; } static CSS::MaskType mask_type() { return CSS::MaskType::Luminance; } static CSS::MathShift math_shift() { return CSS::MathShift::Normal; } @@ -387,6 +388,7 @@ public: CSS::MaskType mask_type() const { return m_noninherited.mask_type; } Vector const& transformations() const { return m_noninherited.transformations; } + CSS::TransformBox const& transform_box() const { return m_noninherited.transform_box; } CSS::TransformOrigin const& transform_origin() const { return m_noninherited.transform_origin; } Gfx::FontCascadeList const& font_list() const { return *m_inherited.font_list; } @@ -508,6 +510,7 @@ protected: float opacity { InitialValues::opacity() }; Vector box_shadow {}; Vector transformations {}; + CSS::TransformBox transform_box { InitialValues::transform_box() }; CSS::TransformOrigin transform_origin {}; CSS::BoxSizing box_sizing { InitialValues::box_sizing() }; CSS::ContentData content; @@ -620,6 +623,7 @@ public: void set_justify_self(CSS::JustifySelf value) { m_noninherited.justify_self = value; } void set_box_shadow(Vector&& value) { m_noninherited.box_shadow = move(value); } void set_transformations(Vector value) { m_noninherited.transformations = move(value); } + void set_transform_box(CSS::TransformBox value) { m_noninherited.transform_box = value; } void set_transform_origin(CSS::TransformOrigin value) { m_noninherited.transform_origin = value; } void set_box_sizing(CSS::BoxSizing value) { m_noninherited.box_sizing = value; } void set_vertical_align(Variant value) { m_noninherited.vertical_align = move(value); } diff --git a/Userland/Libraries/LibWeb/CSS/Enums.json b/Userland/Libraries/LibWeb/CSS/Enums.json index cfe9b8d83bb..53ece172449 100644 --- a/Userland/Libraries/LibWeb/CSS/Enums.json +++ b/Userland/Libraries/LibWeb/CSS/Enums.json @@ -396,6 +396,13 @@ "none", "uppercase" ], + "transform-box": [ + "content-box", + "border-box", + "fill-box", + "stroke-box", + "view-box " + ], "vertical-align": [ "baseline", "bottom", diff --git a/Userland/Libraries/LibWeb/CSS/Identifiers.json b/Userland/Libraries/LibWeb/CSS/Identifiers.json index e5714c53273..258575478e0 100644 --- a/Userland/Libraries/LibWeb/CSS/Identifiers.json +++ b/Userland/Libraries/LibWeb/CSS/Identifiers.json @@ -153,6 +153,7 @@ "fieldtext", "fine", "fill", + "fill-box", "fit-content", "fixed", "flex", @@ -333,6 +334,7 @@ "static", "sticky", "stretch", + "stroke-box", "sub", "subtractive", "super", @@ -377,6 +379,7 @@ "upper-roman", "uppercase", "vertical-text", + "view-box", "visible", "visitedtext", "w-resize", diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index ebdef6fa0ae..5238e672bd0 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -2082,6 +2082,14 @@ "affects-layout": false, "affects-stacking-context": true }, + "transform-box": { + "inherited": false, + "initial": "view-box", + "affects-layout": false, + "valid-types": [ + "transform-box" + ] + }, "transform-origin": { "affects-layout": false, "inherited": false, diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 820404e0e11..cff065d557f 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -493,6 +493,12 @@ static Optional length_percentage_for_style_value(StyleValue c return {}; } +Optional StyleProperties::transform_box() const +{ + auto value = property(CSS::PropertyID::TransformBox); + return value_id_to_transform_box(value->to_identifier()); +} + CSS::TransformOrigin StyleProperties::transform_origin() const { auto value = property(CSS::PropertyID::TransformOrigin); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index 05a4b6aa988..01798b87822 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -119,6 +119,7 @@ public: static Vector transformations_for_style_value(StyleValue const& value); Vector transformations() const; + Optional transform_box() const; CSS::TransformOrigin transform_origin() const; Optional mask_type() const; diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 72a611bc8ef..3ed407bbe92 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -669,6 +669,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) computed_values.set_box_shadow(computed_style.box_shadow(*this)); computed_values.set_transformations(computed_style.transformations()); + if (auto transform_box = computed_style.transform_box(); transform_box.has_value()) + computed_values.set_transform_box(transform_box.value()); computed_values.set_transform_origin(computed_style.transform_origin()); auto transition_delay_property = computed_style.property(CSS::PropertyID::TransitionDelay);