From 6f45df5ced19ee9b661b3001e3847beee9e8bf67 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 31 Aug 2023 14:29:09 +0100 Subject: [PATCH] LibWeb: Add more CSS Token factory methods The way we currently deal with `attr()` means having to manufacture Tokens, so we need a way to do that from StyleComputer. --- Userland/Libraries/LibWeb/CSS/Parser/Token.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Token.h b/Userland/Libraries/LibWeb/CSS/Parser/Token.h index 0d959e1e0f..f205b9ff39 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Token.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Token.h @@ -151,7 +151,7 @@ public: Position const& start_position() const { return m_start_position; } Position const& end_position() const { return m_end_position; } - static Token of_string(FlyString str) + static Token create_string(FlyString str) { Token token; token.m_type = Type::String; @@ -184,6 +184,22 @@ public: return token; } + static Token create_ident(FlyString ident) + { + Token token; + token.m_type = Type::Ident; + token.m_value = move(ident); + return token; + } + + static Token create_url(FlyString url) + { + Token token; + token.m_type = Type::Url; + token.m_value = move(url); + return token; + } + private: Type m_type { Type::Invalid };