mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
LibWeb: Add CustomStyleValue
This extends StyleValue and can hold the identifier of the custom property.
This commit is contained in:
parent
8396099e0e
commit
f0c6160362
1 changed files with 22 additions and 0 deletions
|
@ -195,6 +195,7 @@ public:
|
||||||
Identifier,
|
Identifier,
|
||||||
Image,
|
Image,
|
||||||
Position,
|
Position,
|
||||||
|
CustomProperty,
|
||||||
};
|
};
|
||||||
|
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
|
@ -207,6 +208,7 @@ public:
|
||||||
bool is_string() const { return type() == Type::String; }
|
bool is_string() const { return type() == Type::String; }
|
||||||
bool is_length() const { return type() == Type::Length; }
|
bool is_length() const { return type() == Type::Length; }
|
||||||
bool is_position() const { return type() == Type::Position; }
|
bool is_position() const { return type() == Type::Position; }
|
||||||
|
bool is_custom_property() const { return type() == Type::CustomProperty; }
|
||||||
|
|
||||||
virtual String to_string() const = 0;
|
virtual String to_string() const = 0;
|
||||||
virtual Length to_length() const { return Length::make_auto(); }
|
virtual Length to_length() const { return Length::make_auto(); }
|
||||||
|
@ -233,6 +235,26 @@ private:
|
||||||
Type m_type { Type::Invalid };
|
Type m_type { Type::Invalid };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: Allow for fallback
|
||||||
|
class CustomStyleValue : public StyleValue {
|
||||||
|
public:
|
||||||
|
static NonnullRefPtr<CustomStyleValue> create(const String& custom_property_name)
|
||||||
|
{
|
||||||
|
return adopt_ref(*new CustomStyleValue(custom_property_name));
|
||||||
|
}
|
||||||
|
String custom_property_name() const { return m_custom_property_name; }
|
||||||
|
String to_string() const override { return m_custom_property_name; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit CustomStyleValue(const String& custom_property_name)
|
||||||
|
: StyleValue(Type::CustomProperty)
|
||||||
|
, m_custom_property_name(custom_property_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
String m_custom_property_name {};
|
||||||
|
};
|
||||||
|
|
||||||
class StringStyleValue : public StyleValue {
|
class StringStyleValue : public StyleValue {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<StringStyleValue> create(const String& string)
|
static NonnullRefPtr<StringStyleValue> create(const String& string)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue