1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:17:44 +00:00

LibWeb: Add CombinedBoderRadiusStyleValue for CSS border-radius

This style value can hold all four border radii and format them into
valid CSS for the `border-radius` property.
This commit is contained in:
kleines Filmröllchen 2021-09-14 00:37:43 +02:00 committed by Andreas Kling
parent dc026db800
commit 6865a5a447

View file

@ -233,6 +233,7 @@ public:
BackgroundRepeat,
Border,
BorderRadius,
CombinedBorderRadius,
BoxShadow,
Flex,
FlexFlow,
@ -814,6 +815,40 @@ private:
Length m_vertical_radius;
};
class CombinedBorderRadiusStyleValue final : public StyleValue {
public:
static NonnullRefPtr<CombinedBorderRadiusStyleValue> create(NonnullRefPtr<BorderRadiusStyleValue> top_left, NonnullRefPtr<BorderRadiusStyleValue> top_right, NonnullRefPtr<BorderRadiusStyleValue> bottom_right, NonnullRefPtr<BorderRadiusStyleValue> bottom_left)
{
return adopt_ref(*new CombinedBorderRadiusStyleValue(top_left, top_right, bottom_right, bottom_left));
}
virtual ~CombinedBorderRadiusStyleValue() override { }
NonnullRefPtr<BorderRadiusStyleValue> top_left() const { return m_top_left; }
NonnullRefPtr<BorderRadiusStyleValue> top_right() const { return m_top_right; }
NonnullRefPtr<BorderRadiusStyleValue> bottom_right() const { return m_bottom_right; }
NonnullRefPtr<BorderRadiusStyleValue> bottom_left() const { return m_bottom_left; }
virtual String to_string() const override
{
return String::formatted("{} {} {} {} / {} {} {} {}", m_top_left->horizontal_radius().to_string(), m_top_right->horizontal_radius().to_string(), m_bottom_right->horizontal_radius().to_string(), m_bottom_left->horizontal_radius().to_string(), m_top_left->vertical_radius().to_string(), m_top_right->vertical_radius().to_string(), m_bottom_right->vertical_radius().to_string(), m_bottom_left->vertical_radius().to_string());
}
private:
CombinedBorderRadiusStyleValue(NonnullRefPtr<BorderRadiusStyleValue> top_left, NonnullRefPtr<BorderRadiusStyleValue> top_right, NonnullRefPtr<BorderRadiusStyleValue> bottom_right, NonnullRefPtr<BorderRadiusStyleValue> bottom_left)
: StyleValue(Type::CombinedBorderRadius)
, m_top_left(top_left)
, m_top_right(top_right)
, m_bottom_right(bottom_right)
, m_bottom_left(bottom_left)
{
}
NonnullRefPtr<BorderRadiusStyleValue> m_top_left;
NonnullRefPtr<BorderRadiusStyleValue> m_top_right;
NonnullRefPtr<BorderRadiusStyleValue> m_bottom_right;
NonnullRefPtr<BorderRadiusStyleValue> m_bottom_left;
};
class FlexStyleValue final : public StyleValue {
public:
static NonnullRefPtr<FlexStyleValue> create(