1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

LibWeb: Implement and use BackgroundRepeatStyleValue

This wraps an x and y background-repeat value. Potentially, we could use
this in place of the background-repeat-x and background-repeat-y
pseudo-properties, but for now StyleResolver splits it into those
properties, like it did before.
This commit is contained in:
Sam Atkins 2021-08-10 10:21:42 +01:00 committed by Andreas Kling
parent e6c0cb5a7f
commit 6f9263de04
4 changed files with 114 additions and 45 deletions

View file

@ -230,6 +230,7 @@ public:
ComponentValueList,
Calculated,
Background,
BackgroundRepeat,
Border,
BorderRadius,
BoxShadow,
@ -256,6 +257,7 @@ public:
bool is_component_value_list() const { return type() == Type::ComponentValueList; }
bool is_calculated() const { return type() == Type::Calculated; }
bool is_background() const { return type() == Type::Background; }
bool is_background_repeat() const { return type() == Type::BackgroundRepeat; }
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; }
@ -687,6 +689,34 @@ private:
// FIXME: background-origin
};
class BackgroundRepeatStyleValue final : public StyleValue {
public:
static NonnullRefPtr<BackgroundRepeatStyleValue> create(NonnullRefPtr<StyleValue> repeat_x, NonnullRefPtr<StyleValue> repeat_y)
{
return adopt_ref(*new BackgroundRepeatStyleValue(repeat_x, repeat_y));
}
virtual ~BackgroundRepeatStyleValue() override { }
NonnullRefPtr<StyleValue> repeat_x() const { return m_repeat_x; }
NonnullRefPtr<StyleValue> repeat_y() const { return m_repeat_y; }
virtual String to_string() const override
{
return String::formatted("{} {}", m_repeat_x->to_string(), m_repeat_y->to_string());
}
private:
BackgroundRepeatStyleValue(NonnullRefPtr<StyleValue> repeat_x, NonnullRefPtr<StyleValue> repeat_y)
: StyleValue(Type::BackgroundRepeat)
, m_repeat_x(repeat_x)
, m_repeat_y(repeat_y)
{
}
NonnullRefPtr<StyleValue> m_repeat_x;
NonnullRefPtr<StyleValue> m_repeat_y;
};
class BorderStyleValue final : public StyleValue {
public:
static NonnullRefPtr<BorderStyleValue> create(