mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
LibWeb: Implement and use BorderRadiusStyleValue
This parses the elliptical border-radius values, though currently we only support circular ones. So, to_length() is overloaded to return the horizontal-radius. This means the code in Layout/Node.cpp does not need to change for now.
This commit is contained in:
parent
e3cbd366c7
commit
168865dbdc
5 changed files with 159 additions and 45 deletions
|
@ -231,6 +231,7 @@ public:
|
|||
Calculated,
|
||||
Background,
|
||||
Border,
|
||||
BorderRadius,
|
||||
BoxShadow,
|
||||
Flex,
|
||||
FlexFlow,
|
||||
|
@ -255,6 +256,7 @@ public:
|
|||
bool is_calculated() const { return type() == Type::Calculated; }
|
||||
bool is_background() const { return type() == Type::Background; }
|
||||
bool is_border() const { return type() == Type::Border; }
|
||||
bool is_border_radius() const { return type() == Type::BorderRadius; }
|
||||
bool is_box_shadow() const { return type() == Type::BoxShadow; }
|
||||
bool is_flex() const { return type() == Type::Flex; }
|
||||
bool is_flex_flow() const { return type() == Type::FlexFlow; }
|
||||
|
@ -720,6 +722,40 @@ private:
|
|||
NonnullRefPtr<StyleValue> m_border_color;
|
||||
};
|
||||
|
||||
class BorderRadiusStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<BorderRadiusStyleValue> create(Length const& horizontal_radius, Length const& vertical_radius)
|
||||
{
|
||||
return adopt_ref(*new BorderRadiusStyleValue(horizontal_radius, vertical_radius));
|
||||
}
|
||||
virtual ~BorderRadiusStyleValue() override { }
|
||||
|
||||
Length const& horizontal_radius() const { return m_horizontal_radius; }
|
||||
Length const& vertical_radius() const { return m_vertical_radius; }
|
||||
bool is_elliptical() const { return m_is_elliptical; }
|
||||
|
||||
// FIXME: Remove this once we support elliptical border-radius in Layout/Node.
|
||||
virtual Length to_length() const override { return horizontal_radius(); }
|
||||
|
||||
virtual String to_string() const override
|
||||
{
|
||||
return String::formatted("{} / {}", m_horizontal_radius.to_string(), m_vertical_radius.to_string());
|
||||
}
|
||||
|
||||
private:
|
||||
BorderRadiusStyleValue(Length const& horizontal_radius, Length const& vertical_radius)
|
||||
: StyleValue(Type::BorderRadius)
|
||||
, m_horizontal_radius(horizontal_radius)
|
||||
, m_vertical_radius(vertical_radius)
|
||||
{
|
||||
m_is_elliptical = (m_horizontal_radius != m_vertical_radius);
|
||||
}
|
||||
|
||||
bool m_is_elliptical;
|
||||
Length m_horizontal_radius;
|
||||
Length m_vertical_radius;
|
||||
};
|
||||
|
||||
class FlexStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<FlexStyleValue> create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue