summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-13 17:25:32 +0000
committerTim Flynn <trflynn89@pm.me>2023-02-15 12:48:26 -0500
commit8af65108e4cff13993cd69d74b44acd5d3e9ee32 (patch)
tree70ddc31dca785bf56a45722a7657f08dc913497f
parentd6075ef5b52fcf281270c192f01aa59d821a6528 (diff)
downloadserenity-8af65108e4cff13993cd69d74b44acd5d3e9ee32.zip
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.
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp2
5 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index c10e6086c3..b41441d9f0 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -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())
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index 6d33d1d3e4..d97f98f7ec 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -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);
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp
index e94ef6e9ae..c11732687f 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp
@@ -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);
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h
index 7d271632b0..83b24d11ea 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h
@@ -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();
diff --git a/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp b/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
index 560c4fa409..e922c204ee 100644
--- a/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
+++ b/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
@@ -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))