LibWeb: Parse the CSS transform-box property

This commit is contained in:
Sam Atkins 2024-01-25 17:02:37 +00:00 committed by Andreas Kling
parent c3c7707de4
commit 391cfdc085
Notes: sideshowbarker 2024-07-17 08:59:18 +09:00
8 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -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<CSS::Transformation> 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<ShadowData> box_shadow {};
Vector<CSS::Transformation> 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<ShadowData>&& value) { m_noninherited.box_shadow = move(value); }
void set_transformations(Vector<CSS::Transformation> 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<CSS::VerticalAlign, CSS::LengthPercentage> value) { m_noninherited.vertical_align = move(value); }

View File

@ -396,6 +396,13 @@
"none",
"uppercase"
],
"transform-box": [
"content-box",
"border-box",
"fill-box",
"stroke-box",
"view-box "
],
"vertical-align": [
"baseline",
"bottom",

View File

@ -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",

View File

@ -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,

View File

@ -493,6 +493,12 @@ static Optional<LengthPercentage> length_percentage_for_style_value(StyleValue c
return {};
}
Optional<CSS::TransformBox> 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);

View File

@ -119,6 +119,7 @@ public:
static Vector<CSS::Transformation> transformations_for_style_value(StyleValue const& value);
Vector<CSS::Transformation> transformations() const;
Optional<CSS::TransformBox> transform_box() const;
CSS::TransformOrigin transform_origin() const;
Optional<CSS::MaskType> mask_type() const;

View File

@ -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);