diff options
author | Sam Atkins <atkinssj@gmail.com> | 2021-08-20 19:52:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-25 12:14:34 +0200 |
commit | b92a6d654296718fd3e49a7bf37fda3ade4263ed (patch) | |
tree | 1cf20a0734660184b3ea2f374e76e5a3ddb16b14 /Userland/Libraries/LibWeb/CSS/StyleValue.h | |
parent | 3296fd70b315c85b2cae8577f0170dfe3271a341 (diff) | |
download | serenity-b92a6d654296718fd3e49a7bf37fda3ade4263ed.zip |
LibWeb: Implement CSS `unset` builtin value
This is equivalent to `initial` or `inherit`, depending on if the
property is inherited by default.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleValue.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index fb53235286..1ff81ecfca 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -219,6 +219,7 @@ public: Invalid, Inherit, Initial, + Unset, String, Length, Color, @@ -245,6 +246,7 @@ public: bool is_inherit() const { return type() == Type::Inherit; } bool is_initial() const { return type() == Type::Initial; } + bool is_unset() const { return type() == Type::Unset; } bool is_color() const { return type() == Type::Color; } bool is_identifier() const { return type() == Type::Identifier || is_auto(); } bool is_image() const { return type() == Type::Image; } @@ -266,11 +268,11 @@ public: bool is_overflow() const { return type() == Type::Overflow; } bool is_text_decoration() const { return type() == Type::TextDecoration; } - bool is_builtin() const { return is_inherit() || is_initial(); } + bool is_builtin() const { return is_inherit() || is_initial() || is_unset(); } bool is_builtin_or_dynamic() const { - return is_inherit() || is_initial() || is_custom_property() || is_calculated(); + return is_builtin() || is_custom_property() || is_calculated(); } virtual String to_string() const = 0; @@ -568,6 +570,24 @@ private: } }; +class UnsetStyleValue final : public StyleValue { +public: + static NonnullRefPtr<UnsetStyleValue> the() + { + static NonnullRefPtr<UnsetStyleValue> instance = adopt_ref(*new UnsetStyleValue); + return instance; + } + virtual ~UnsetStyleValue() override { } + + String to_string() const override { return "unset"; } + +private: + UnsetStyleValue() + : StyleValue(Type::Unset) + { + } +}; + class ColorStyleValue : public StyleValue { public: static NonnullRefPtr<ColorStyleValue> create(Color color) |