mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
LibWeb: Implement and use BackgroundStyleValue
This one represents one secton of a `background` property, since it can have multiple background values separated by commas. Eventually, we will represent that as a List of BackgroundStyleValues. Also modified some background-foo properties in StyleResolver so that the is_background_x() functions could be removed. I realized that our handling of var() in shorthand properties is wrong, so have been removing the is_builtin_or_dynamic() calls from the parsing code for shorthands. This broke our var() test page, so I have replaced the use of 'background' with 'background-color' there.
This commit is contained in:
parent
59501f1940
commit
dcbfb61816
5 changed files with 184 additions and 130 deletions
|
@ -229,6 +229,7 @@ public:
|
|||
ValueList,
|
||||
ComponentValueList,
|
||||
Calculated,
|
||||
Background,
|
||||
BoxShadow,
|
||||
Font,
|
||||
};
|
||||
|
@ -247,6 +248,7 @@ public:
|
|||
bool is_value_list() const { return type() == Type::ValueList; }
|
||||
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_box_shadow() const { return type() == Type::BoxShadow; }
|
||||
bool is_font() const { return type() == Type::Font; }
|
||||
|
||||
|
@ -625,6 +627,52 @@ private:
|
|||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
class BackgroundStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<BackgroundStyleValue> create(
|
||||
NonnullRefPtr<StyleValue> color,
|
||||
NonnullRefPtr<StyleValue> image,
|
||||
NonnullRefPtr<StyleValue> repeat_x,
|
||||
NonnullRefPtr<StyleValue> repeat_y)
|
||||
{
|
||||
return adopt_ref(*new BackgroundStyleValue(color, image, repeat_x, repeat_y));
|
||||
}
|
||||
virtual ~BackgroundStyleValue() override { }
|
||||
|
||||
NonnullRefPtr<StyleValue> color() const { return m_color; }
|
||||
NonnullRefPtr<StyleValue> image() const { return m_image; }
|
||||
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("Background color: {}, image: {}, repeat: {}/{}", m_color->to_string(), m_image->to_string(), m_repeat_x->to_string(), m_repeat_y->to_string());
|
||||
}
|
||||
|
||||
private:
|
||||
BackgroundStyleValue(
|
||||
NonnullRefPtr<StyleValue> color,
|
||||
NonnullRefPtr<StyleValue> image,
|
||||
NonnullRefPtr<StyleValue> repeat_x,
|
||||
NonnullRefPtr<StyleValue> repeat_y)
|
||||
: StyleValue(Type::Background)
|
||||
, m_color(color)
|
||||
, m_image(image)
|
||||
, m_repeat_x(repeat_x)
|
||||
, m_repeat_y(repeat_y)
|
||||
{
|
||||
}
|
||||
NonnullRefPtr<StyleValue> m_color;
|
||||
NonnullRefPtr<StyleValue> m_image;
|
||||
// FIXME: background-position
|
||||
// FIXME: background-size
|
||||
NonnullRefPtr<StyleValue> m_repeat_x;
|
||||
NonnullRefPtr<StyleValue> m_repeat_y;
|
||||
// FIXME: background-attachment
|
||||
// FIXME: background-clip
|
||||
// FIXME: background-origin
|
||||
};
|
||||
|
||||
class FontStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<FontStyleValue> create(NonnullRefPtr<StyleValue> font_style, NonnullRefPtr<StyleValue> font_weight, NonnullRefPtr<StyleValue> font_size, NonnullRefPtr<StyleValue> line_height, NonnullRefPtrVector<StyleValue>&& font_families) { return adopt_ref(*new FontStyleValue(font_style, font_weight, font_size, line_height, move(font_families))); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue