diff options
author | Tobias Christiansen <tobi@tobyase.de> | 2021-05-24 22:46:19 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-28 10:45:38 +0100 |
commit | f0c6160362b98f1110ab89f751206c431040f5b7 (patch) | |
tree | 15ca462d5af6440ccaee456b8ee4d9cd0fa926d4 /Userland/Libraries/LibWeb/CSS/StyleValue.h | |
parent | 8396099e0ee68b15966706acddba083ae1a5dcad (diff) | |
download | serenity-f0c6160362b98f1110ab89f751206c431040f5b7.zip |
LibWeb: Add CustomStyleValue
This extends StyleValue and can hold the identifier of the custom
property.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleValue.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 1a7ca22da2..b4de7d4779 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -195,6 +195,7 @@ public: Identifier, Image, Position, + CustomProperty, }; Type type() const { return m_type; } @@ -207,6 +208,7 @@ public: bool is_string() const { return type() == Type::String; } bool is_length() const { return type() == Type::Length; } bool is_position() const { return type() == Type::Position; } + bool is_custom_property() const { return type() == Type::CustomProperty; } virtual String to_string() const = 0; virtual Length to_length() const { return Length::make_auto(); } @@ -233,6 +235,26 @@ private: 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 { public: static NonnullRefPtr<StringStyleValue> create(const String& string) |