diff options
author | Andreas Kling <kling@serenityos.org> | 2022-11-02 20:24:44 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-02 22:42:48 +0100 |
commit | f14ad0e8c1016cedaf2df4bfa18171c08eefb650 (patch) | |
tree | 29fbf61f51fb36aafc1c296d26b95e401a2769fb | |
parent | ab9aa9da0d6a2c8dd3150ce822bf039fea481103 (diff) | |
download | serenity-f14ad0e8c1016cedaf2df4bfa18171c08eefb650.zip |
LibWeb: Add helper functions to create CSS parser tokens
These will be used when resolving calc() values in StyleComputer.
It's indeed strange that calc() resolves to tokens, but it's how the
engine currently handles those things. There is room for improvement.
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Token.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Token.h b/Userland/Libraries/LibWeb/CSS/Parser/Token.h index 430b2033cf..4337f22d1b 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Token.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Token.h @@ -159,6 +159,22 @@ public: return token; } + static Token create_number(float value) + { + Token token; + token.m_type = Type::Number; + token.m_number_value = Number(Number::Type::Number, value); + return token; + } + + static Token create_percentage(float value) + { + Token token; + token.m_type = Type::Percentage; + token.m_number_value = Number(Number::Type::Number, value); + return token; + } + private: Type m_type { Type::Invalid }; |