mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:07:34 +00:00
LibWeb: Parse flex-basis
Flex-basis accepts either 'content' or a Length.
This commit is contained in:
parent
27704f5f9e
commit
ae3e6510d6
7 changed files with 39 additions and 0 deletions
|
@ -39,6 +39,11 @@ public:
|
||||||
float width { 0 };
|
float width { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FlexBasisData {
|
||||||
|
CSS::FlexBasis type { CSS::FlexBasis::Content };
|
||||||
|
CSS::Length length {};
|
||||||
|
};
|
||||||
|
|
||||||
class ComputedValues {
|
class ComputedValues {
|
||||||
public:
|
public:
|
||||||
CSS::Float float_() const { return m_noninherited.float_; }
|
CSS::Float float_() const { return m_noninherited.float_; }
|
||||||
|
@ -53,6 +58,7 @@ public:
|
||||||
CSS::WhiteSpace white_space() const { return m_inherited.white_space; }
|
CSS::WhiteSpace white_space() const { return m_inherited.white_space; }
|
||||||
CSS::FlexDirection flex_direction() const { return m_noninherited.flex_direction; }
|
CSS::FlexDirection flex_direction() const { return m_noninherited.flex_direction; }
|
||||||
CSS::FlexWrap flex_wrap() const { return m_noninherited.flex_wrap; }
|
CSS::FlexWrap flex_wrap() const { return m_noninherited.flex_wrap; }
|
||||||
|
FlexBasisData flex_basis() const { return m_noninherited.flex_basis; }
|
||||||
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; }
|
||||||
|
@ -130,6 +136,7 @@ protected:
|
||||||
CSS::Repeat background_repeat_y { InitialValues::background_repeat() };
|
CSS::Repeat background_repeat_y { InitialValues::background_repeat() };
|
||||||
CSS::FlexDirection flex_direction { InitialValues::flex_direction() };
|
CSS::FlexDirection flex_direction { InitialValues::flex_direction() };
|
||||||
CSS::FlexWrap flex_wrap { InitialValues::flex_wrap() };
|
CSS::FlexWrap flex_wrap { InitialValues::flex_wrap() };
|
||||||
|
CSS::FlexBasisData flex_basis {};
|
||||||
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;
|
||||||
|
@ -176,6 +183,7 @@ public:
|
||||||
BorderData& border_bottom() { return m_noninherited.border_bottom; }
|
BorderData& border_bottom() { return m_noninherited.border_bottom; }
|
||||||
void set_flex_direction(CSS::FlexDirection value) { m_noninherited.flex_direction = value; }
|
void set_flex_direction(CSS::FlexDirection value) { m_noninherited.flex_direction = value; }
|
||||||
void set_flex_wrap(CSS::FlexWrap value) { m_noninherited.flex_wrap = value; }
|
void set_flex_wrap(CSS::FlexWrap value) { m_noninherited.flex_wrap = value; }
|
||||||
|
void set_flex_basis(FlexBasisData value) { m_noninherited.flex_basis = value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
"col-resize",
|
"col-resize",
|
||||||
"column",
|
"column",
|
||||||
"column-reverse",
|
"column-reverse",
|
||||||
|
"content",
|
||||||
"context-menu",
|
"context-menu",
|
||||||
"copy",
|
"copy",
|
||||||
"crosshair",
|
"crosshair",
|
||||||
|
|
|
@ -203,6 +203,10 @@
|
||||||
"inherited": false,
|
"inherited": false,
|
||||||
"initial": "inline"
|
"initial": "inline"
|
||||||
},
|
},
|
||||||
|
"flex-basis": {
|
||||||
|
"inherited": false,
|
||||||
|
"initial": "content"
|
||||||
|
},
|
||||||
"flex-direction": {
|
"flex-direction": {
|
||||||
"inherited": false,
|
"inherited": false,
|
||||||
"initial": "row"
|
"initial": "row"
|
||||||
|
|
|
@ -257,6 +257,21 @@ Optional<CSS::FlexWrap> StyleProperties::flex_wrap() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<CSS::FlexBasisData> StyleProperties::flex_basis() const
|
||||||
|
{
|
||||||
|
auto value = property(CSS::PropertyID::FlexBasis);
|
||||||
|
if (!value.has_value())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
if (value.value()->is_identifier() && value.value()->to_identifier() == CSS::ValueID::Content)
|
||||||
|
return { { CSS::FlexBasis::Content, {} } };
|
||||||
|
|
||||||
|
if (value.value()->is_length())
|
||||||
|
return { { CSS::FlexBasis::Length, value.value()->to_length() } };
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
#include <LibGfx/Font.h>
|
#include <LibGfx/Font.h>
|
||||||
#include <LibGfx/Forward.h>
|
#include <LibGfx/Forward.h>
|
||||||
|
#include <LibWeb/CSS/ComputedValues.h>
|
||||||
#include <LibWeb/CSS/LengthBox.h>
|
#include <LibWeb/CSS/LengthBox.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/StyleValue.h>
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ public:
|
||||||
Optional<CSS::ListStyleType> list_style_type() const;
|
Optional<CSS::ListStyleType> list_style_type() const;
|
||||||
Optional<CSS::FlexDirection> flex_direction() const;
|
Optional<CSS::FlexDirection> flex_direction() const;
|
||||||
Optional<CSS::FlexWrap> flex_wrap() const;
|
Optional<CSS::FlexWrap> flex_wrap() const;
|
||||||
|
Optional<CSS::FlexBasisData> flex_basis() 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;
|
||||||
|
|
|
@ -86,6 +86,11 @@ enum class FlexWrap {
|
||||||
WrapReverse
|
WrapReverse
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class FlexBasis {
|
||||||
|
Content,
|
||||||
|
Length
|
||||||
|
};
|
||||||
|
|
||||||
enum class WhiteSpace {
|
enum class WhiteSpace {
|
||||||
Normal,
|
Normal,
|
||||||
Pre,
|
Pre,
|
||||||
|
|
|
@ -263,6 +263,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
if (flex_wrap.has_value())
|
if (flex_wrap.has_value())
|
||||||
computed_values.set_flex_wrap(flex_wrap.value());
|
computed_values.set_flex_wrap(flex_wrap.value());
|
||||||
|
|
||||||
|
auto flex_basis = specified_style.flex_basis();
|
||||||
|
if (flex_basis.has_value())
|
||||||
|
computed_values.set_flex_basis(flex_basis.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