mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Construct CSS Tokenizer and Parser with a StringView encoding
This doesn't need to be a full (Deprecated)String, so let's not force it to be.
This commit is contained in:
parent
d6075ef5b5
commit
8af65108e4
Notes:
sideshowbarker
2024-07-17 06:51:40 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/8af65108e4 Pull-request: https://github.com/SerenityOS/serenity/pull/17478 Reviewed-by: https://github.com/trflynn89 ✅
5 changed files with 6 additions and 6 deletions
|
@ -82,7 +82,7 @@ AK::URL ParsingContext::complete_url(DeprecatedString const& addr) const
|
|||
return m_url.complete_url(addr);
|
||||
}
|
||||
|
||||
Parser::Parser(ParsingContext const& context, StringView input, DeprecatedString const& encoding)
|
||||
Parser::Parser(ParsingContext const& context, StringView input, StringView encoding)
|
||||
: m_context(context)
|
||||
, m_tokenizer(input, encoding)
|
||||
, m_tokens(m_tokenizer.parse())
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
|
||||
class Parser {
|
||||
public:
|
||||
Parser(ParsingContext const&, StringView input, DeprecatedString const& encoding = "utf-8");
|
||||
Parser(ParsingContext const&, StringView input, StringView encoding = "utf-8"sv);
|
||||
~Parser() = default;
|
||||
|
||||
CSSStyleSheet* parse_as_css_stylesheet(Optional<AK::URL> location);
|
||||
|
|
|
@ -195,10 +195,10 @@ static inline bool is_E(u32 code_point)
|
|||
return code_point == 0x45;
|
||||
}
|
||||
|
||||
Tokenizer::Tokenizer(StringView input, DeprecatedString const& encoding)
|
||||
Tokenizer::Tokenizer(StringView input, StringView encoding)
|
||||
{
|
||||
// https://www.w3.org/TR/css-syntax-3/#css-filter-code-points
|
||||
auto filter_code_points = [](StringView input, auto const& encoding) -> DeprecatedString {
|
||||
auto filter_code_points = [](StringView input, auto encoding) -> DeprecatedString {
|
||||
auto* decoder = TextCodec::decoder_for(encoding);
|
||||
VERIFY(decoder);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
class Tokenizer {
|
||||
|
||||
public:
|
||||
explicit Tokenizer(StringView input, DeprecatedString const& encoding);
|
||||
explicit Tokenizer(StringView input, StringView encoding);
|
||||
|
||||
[[nodiscard]] Vector<Token> parse();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
false);
|
||||
};
|
||||
|
||||
CSS::Parser::Tokenizer tokenizer { text, "utf-8" };
|
||||
CSS::Parser::Tokenizer tokenizer { text, "utf-8"sv };
|
||||
auto tokens = tokenizer.parse();
|
||||
for (auto const& token : tokens) {
|
||||
if (token.is(Parser::Token::Type::EndOfFile))
|
||||
|
|
Loading…
Add table
Reference in a new issue