mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
LibWeb: Implement new StyleValueList
StyleValueList is a list of StyleValues of the same type, for use in properties like `margin` which accept a variable number of arguments. I had originally hoped to simply swap the old ValueListStyleValue from being a list of ComponentValues to one of StyleValues, but I can see now that I will need to have both for a little while, so renamed the old is_value_list() to is_component_value_list() temporarily.
This commit is contained in:
parent
81527f5eba
commit
21c9825caf
3 changed files with 50 additions and 19 deletions
|
@ -227,6 +227,7 @@ public:
|
|||
CustomProperty,
|
||||
Numeric,
|
||||
ValueList,
|
||||
ComponentValueList,
|
||||
Calculated,
|
||||
BoxShadow,
|
||||
};
|
||||
|
@ -243,8 +244,9 @@ public:
|
|||
bool is_custom_property() const { return type() == Type::CustomProperty; }
|
||||
bool is_numeric() const { return type() == Type::Numeric; }
|
||||
bool is_value_list() const { return type() == Type::ValueList; }
|
||||
bool is_box_shadow() const { return type() == Type::BoxShadow; }
|
||||
bool is_component_value_list() const { return type() == Type::ComponentValueList; }
|
||||
bool is_calculated() const { return type() == Type::Calculated; }
|
||||
bool is_box_shadow() const { return type() == Type::BoxShadow; }
|
||||
|
||||
bool is_builtin() const { return is_inherit() || is_initial(); }
|
||||
|
||||
|
@ -621,6 +623,35 @@ private:
|
|||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
class StyleValueList final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<StyleValueList> create(NonnullRefPtrVector<StyleValue>&& values) { return adopt_ref(*new StyleValueList(move(values))); }
|
||||
|
||||
NonnullRefPtrVector<StyleValue> const& values() const { return m_values; }
|
||||
|
||||
virtual String to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.appendff("List[{}](", m_values.size());
|
||||
for (size_t i = 0; i < m_values.size(); ++i) {
|
||||
if (i)
|
||||
builder.append(',');
|
||||
builder.append(m_values[i].to_string());
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
private:
|
||||
StyleValueList(NonnullRefPtrVector<StyleValue>&& values)
|
||||
: StyleValue(Type::ValueList)
|
||||
, m_values(move(values))
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<StyleValue> m_values;
|
||||
};
|
||||
|
||||
class ValueListStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<ValueListStyleValue> create(Vector<StyleComponentValueRule>&& values) { return adopt_ref(*new ValueListStyleValue(move(values))); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue