Parcourir la source

LibWeb: Allow creating a TokenStream from a single token

This is quite niche, but lets us convert parsing methods to accepting
TokenStream, while still being able to call them when we just have a
lone token. Specifically we'll use this in the next commit, but it's
likely to also be useful as a stop-gap measure when converting more
parsing methods.
Sam Atkins il y a 1 an
Parent
commit
a76f29e56b
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      Userland/Libraries/LibWeb/CSS/Parser/TokenStream.h

+ 5 - 0
Userland/Libraries/LibWeb/CSS/Parser/TokenStream.h

@@ -66,6 +66,11 @@ public:
     {
     }
 
+    static TokenStream<T> of_single_token(T const& token)
+    {
+        return TokenStream(Span<T const> { &token, 1 });
+    }
+
     TokenStream(TokenStream<T> const&) = delete;
     TokenStream(TokenStream<T>&&) = default;