mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:37:35 +00:00
LibWeb: Add parsing for the justify-content property
This commit is contained in:
parent
fb66feef5e
commit
80a44c3891
7 changed files with 45 additions and 0 deletions
|
@ -29,6 +29,7 @@ public:
|
||||||
static CSS::ListStyleType list_style_type() { return CSS::ListStyleType::Disc; }
|
static CSS::ListStyleType list_style_type() { return CSS::ListStyleType::Disc; }
|
||||||
static CSS::FlexDirection flex_direction() { return CSS::FlexDirection::Row; }
|
static CSS::FlexDirection flex_direction() { return CSS::FlexDirection::Row; }
|
||||||
static CSS::FlexWrap flex_wrap() { return CSS::FlexWrap::Nowrap; }
|
static CSS::FlexWrap flex_wrap() { return CSS::FlexWrap::Nowrap; }
|
||||||
|
static CSS::JustifyContent justify_content() { return CSS::JustifyContent::FlexStart; }
|
||||||
static CSS::Overflow overflow() { return CSS::Overflow::Visible; }
|
static CSS::Overflow overflow() { return CSS::Overflow::Visible; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,6 +62,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::JustifyContent justify_content() const { return m_noninherited.justify_content; }
|
||||||
const CSS::Length& width() const { return m_noninherited.width; }
|
const CSS::Length& width() const { return m_noninherited.width; }
|
||||||
const CSS::Length& min_width() const { return m_noninherited.min_width; }
|
const CSS::Length& min_width() const { return m_noninherited.min_width; }
|
||||||
const CSS::Length& max_width() const { return m_noninherited.max_width; }
|
const CSS::Length& max_width() const { return m_noninherited.max_width; }
|
||||||
|
@ -141,6 +143,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::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() };
|
||||||
} m_noninherited;
|
} m_noninherited;
|
||||||
|
@ -190,6 +193,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_justify_content(CSS::JustifyContent value) { m_noninherited.justify_content = value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,8 @@
|
||||||
"ew-resize",
|
"ew-resize",
|
||||||
"fixed",
|
"fixed",
|
||||||
"flex",
|
"flex",
|
||||||
|
"flex-start",
|
||||||
|
"flex-end",
|
||||||
"full-size-kana",
|
"full-size-kana",
|
||||||
"full-width",
|
"full-width",
|
||||||
"grab",
|
"grab",
|
||||||
|
@ -145,6 +147,8 @@
|
||||||
"smaller",
|
"smaller",
|
||||||
"solid",
|
"solid",
|
||||||
"space",
|
"space",
|
||||||
|
"space-around",
|
||||||
|
"space-between",
|
||||||
"square",
|
"square",
|
||||||
"s-resize",
|
"s-resize",
|
||||||
"static",
|
"static",
|
||||||
|
|
|
@ -272,6 +272,10 @@
|
||||||
"inherited": false,
|
"inherited": false,
|
||||||
"initial": "auto"
|
"initial": "auto"
|
||||||
},
|
},
|
||||||
|
"justify-content": {
|
||||||
|
"inherited": false,
|
||||||
|
"initial": "flex-start"
|
||||||
|
},
|
||||||
"left": {
|
"left": {
|
||||||
"inherited": false,
|
"inherited": false,
|
||||||
"initial": "auto"
|
"initial": "auto"
|
||||||
|
|
|
@ -298,6 +298,26 @@ Optional<float> StyleProperties::flex_shrink_factor() const
|
||||||
auto numeric = verify_cast<CSS::NumericStyleValue>(value.value().ptr());
|
auto numeric = verify_cast<CSS::NumericStyleValue>(value.value().ptr());
|
||||||
return numeric->value();
|
return numeric->value();
|
||||||
}
|
}
|
||||||
|
Optional<CSS::JustifyContent> StyleProperties::justify_content() const
|
||||||
|
{
|
||||||
|
auto value = property(CSS::PropertyID::JustifyContent);
|
||||||
|
if (!value.has_value())
|
||||||
|
return {};
|
||||||
|
switch (value.value()->to_identifier()) {
|
||||||
|
case CSS::ValueID::FlexStart:
|
||||||
|
return CSS::JustifyContent::FlexStart;
|
||||||
|
case CSS::ValueID::FlexEnd:
|
||||||
|
return CSS::JustifyContent::FlexEnd;
|
||||||
|
case CSS::ValueID::Center:
|
||||||
|
return CSS::JustifyContent::Center;
|
||||||
|
case CSS::ValueID::SpaceBetween:
|
||||||
|
return CSS::JustifyContent::SpaceBetween;
|
||||||
|
case CSS::ValueID::SpaceAround:
|
||||||
|
return CSS::JustifyContent::SpaceAround;
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Optional<CSS::Position> StyleProperties::position() const
|
Optional<CSS::Position> StyleProperties::position() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,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::JustifyContent> justify_content() const;
|
||||||
Optional<CSS::Overflow> overflow_x() const;
|
Optional<CSS::Overflow> overflow_x() const;
|
||||||
Optional<CSS::Overflow> overflow_y() const;
|
Optional<CSS::Overflow> overflow_y() const;
|
||||||
Optional<CSS::Repeat> background_repeat_x() const;
|
Optional<CSS::Repeat> background_repeat_x() const;
|
||||||
|
|
|
@ -195,6 +195,14 @@ enum class Repeat : u8 {
|
||||||
Space,
|
Space,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class JustifyContent {
|
||||||
|
FlexStart,
|
||||||
|
FlexEnd,
|
||||||
|
Center,
|
||||||
|
SpaceBetween,
|
||||||
|
SpaceAround,
|
||||||
|
};
|
||||||
|
|
||||||
class StyleValue : public RefCounted<StyleValue> {
|
class StyleValue : public RefCounted<StyleValue> {
|
||||||
public:
|
public:
|
||||||
virtual ~StyleValue();
|
virtual ~StyleValue();
|
||||||
|
|
|
@ -271,6 +271,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
computed_values.set_flex_grow_factor(specified_style.flex_grow_factor());
|
computed_values.set_flex_grow_factor(specified_style.flex_grow_factor());
|
||||||
computed_values.set_flex_shrink_factor(specified_style.flex_shrink_factor());
|
computed_values.set_flex_shrink_factor(specified_style.flex_shrink_factor());
|
||||||
|
|
||||||
|
auto justify_content = specified_style.justify_content();
|
||||||
|
if (justify_content.has_value())
|
||||||
|
computed_values.set_justify_content(justify_content.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