mirror of
https://github.com/RGBCube/serenity
synced 2025-07-17 11:17:36 +00:00
LibWeb: Add proper parsing of the AlignItems property
This teaches all the relevant places about 'align-items'.
This commit is contained in:
parent
51b42e0463
commit
307f90b675
5 changed files with 37 additions and 0 deletions
|
@ -69,6 +69,7 @@ public:
|
||||||
FlexBasisData flex_basis() const { return m_noninherited.flex_basis; }
|
FlexBasisData flex_basis() const { return m_noninherited.flex_basis; }
|
||||||
Optional<float> flex_grow_factor() const { return m_noninherited.flex_grow_factor; }
|
Optional<float> flex_grow_factor() const { return m_noninherited.flex_grow_factor; }
|
||||||
Optional<float> flex_shrink_factor() const { return m_noninherited.flex_shrink_factor; }
|
Optional<float> flex_shrink_factor() const { return m_noninherited.flex_shrink_factor; }
|
||||||
|
CSS::AlignItems align_items() const { return m_noninherited.align_items; }
|
||||||
Optional<float> opacity() const { return m_noninherited.opacity; }
|
Optional<float> opacity() const { return m_noninherited.opacity; }
|
||||||
CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; }
|
CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; }
|
||||||
Optional<BoxShadowData> box_shadow() const { return m_noninherited.box_shadow; }
|
Optional<BoxShadowData> box_shadow() const { return m_noninherited.box_shadow; }
|
||||||
|
@ -152,6 +153,7 @@ protected:
|
||||||
CSS::FlexBasisData flex_basis {};
|
CSS::FlexBasisData flex_basis {};
|
||||||
Optional<float> flex_grow_factor;
|
Optional<float> flex_grow_factor;
|
||||||
Optional<float> flex_shrink_factor;
|
Optional<float> flex_shrink_factor;
|
||||||
|
CSS::AlignItems align_items;
|
||||||
CSS::JustifyContent justify_content { InitialValues::justify_content() };
|
CSS::JustifyContent justify_content { InitialValues::justify_content() };
|
||||||
CSS::Overflow overflow_x { InitialValues::overflow() };
|
CSS::Overflow overflow_x { InitialValues::overflow() };
|
||||||
CSS::Overflow overflow_y { InitialValues::overflow() };
|
CSS::Overflow overflow_y { InitialValues::overflow() };
|
||||||
|
@ -204,6 +206,7 @@ public:
|
||||||
void set_flex_basis(FlexBasisData value) { m_noninherited.flex_basis = value; }
|
void set_flex_basis(FlexBasisData value) { m_noninherited.flex_basis = value; }
|
||||||
void set_flex_grow_factor(Optional<float> value) { m_noninherited.flex_grow_factor = value; }
|
void set_flex_grow_factor(Optional<float> value) { m_noninherited.flex_grow_factor = value; }
|
||||||
void set_flex_shrink_factor(Optional<float> value) { m_noninherited.flex_shrink_factor = value; }
|
void set_flex_shrink_factor(Optional<float> value) { m_noninherited.flex_shrink_factor = value; }
|
||||||
|
void set_align_items(CSS::AlignItems value) { m_noninherited.align_items = value; }
|
||||||
void set_opacity(Optional<float> value) { m_noninherited.opacity = value; }
|
void set_opacity(Optional<float> value) { m_noninherited.opacity = value; }
|
||||||
void set_justify_content(CSS::JustifyContent value) { m_noninherited.justify_content = value; }
|
void set_justify_content(CSS::JustifyContent value) { m_noninherited.justify_content = value; }
|
||||||
void set_box_shadow(Optional<BoxShadowData> value) { m_noninherited.box_shadow = move(value); }
|
void set_box_shadow(Optional<BoxShadowData> value) { m_noninherited.box_shadow = move(value); }
|
||||||
|
|
|
@ -424,6 +424,27 @@ Optional<CSS::JustifyContent> StyleProperties::justify_content() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<CSS::AlignItems> StyleProperties::align_items() const
|
||||||
|
{
|
||||||
|
auto value = property(CSS::PropertyID::AlignItems);
|
||||||
|
if (!value.has_value())
|
||||||
|
return {};
|
||||||
|
switch (value.value()->to_identifier()) {
|
||||||
|
case CSS::ValueID::FlexStart:
|
||||||
|
return CSS::AlignItems::FlexStart;
|
||||||
|
case CSS::ValueID::FlexEnd:
|
||||||
|
return CSS::AlignItems::FlexEnd;
|
||||||
|
case CSS::ValueID::Center:
|
||||||
|
return CSS::AlignItems::Center;
|
||||||
|
case CSS::ValueID::Baseline:
|
||||||
|
return CSS::AlignItems::Baseline;
|
||||||
|
case CSS::ValueID::Stretch:
|
||||||
|
return CSS::AlignItems::Stretch;
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Optional<CSS::Position> StyleProperties::position() const
|
Optional<CSS::Position> StyleProperties::position() const
|
||||||
{
|
{
|
||||||
auto value = property(CSS::PropertyID::Position);
|
auto value = property(CSS::PropertyID::Position);
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
Optional<CSS::FlexBasisData> flex_basis() const;
|
Optional<CSS::FlexBasisData> flex_basis() const;
|
||||||
Optional<float> flex_grow_factor() const;
|
Optional<float> flex_grow_factor() const;
|
||||||
Optional<float> flex_shrink_factor() const;
|
Optional<float> flex_shrink_factor() const;
|
||||||
|
Optional<CSS::AlignItems> align_items() const;
|
||||||
Optional<float> opacity() const;
|
Optional<float> opacity() const;
|
||||||
Optional<CSS::JustifyContent> justify_content() const;
|
Optional<CSS::JustifyContent> justify_content() const;
|
||||||
Optional<CSS::Overflow> overflow_x() const;
|
Optional<CSS::Overflow> overflow_x() const;
|
||||||
|
|
|
@ -211,6 +211,14 @@ enum class JustifyContent {
|
||||||
SpaceAround,
|
SpaceAround,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class AlignItems {
|
||||||
|
FlexStart,
|
||||||
|
FlexEnd,
|
||||||
|
Center,
|
||||||
|
Baseline,
|
||||||
|
Stretch,
|
||||||
|
};
|
||||||
|
|
||||||
class StyleValue : public RefCounted<StyleValue> {
|
class StyleValue : public RefCounted<StyleValue> {
|
||||||
public:
|
public:
|
||||||
virtual ~StyleValue();
|
virtual ~StyleValue();
|
||||||
|
|
|
@ -269,6 +269,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
if (justify_content.has_value())
|
if (justify_content.has_value())
|
||||||
computed_values.set_justify_content(justify_content.value());
|
computed_values.set_justify_content(justify_content.value());
|
||||||
|
|
||||||
|
auto align_items = specified_style.align_items();
|
||||||
|
if (align_items.has_value())
|
||||||
|
computed_values.set_align_items(align_items.value());
|
||||||
|
|
||||||
auto position = specified_style.position();
|
auto position = specified_style.position();
|
||||||
if (position.has_value()) {
|
if (position.has_value()) {
|
||||||
computed_values.set_position(position.value());
|
computed_values.set_position(position.value());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue