summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-11-18 12:04:05 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-19 22:35:05 +0100
commit9286aa77bc58b1aac5ab2952e9ae3f94ff194c42 (patch)
tree315179aac3458caa23aae450b2731be91a845392 /Userland
parentd37f62fd547325773c06fba46296894ca013d466 (diff)
downloadserenity-9286aa77bc58b1aac5ab2952e9ae3f94ff194c42.zip
LibWeb: Break friendship between CSS Token and Parser :^(
The Parser no longer needs to mess with Token's internals, since we have getter functions that are safer.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Token.h7
2 files changed, 9 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index d14aee291b..6248325a0f 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -1288,7 +1288,7 @@ NonnullRefPtr<StyleFunctionRule> Parser::consume_a_function(TokenStream<T>& toke
{
auto name_ident = tokens.current_token();
VERIFY(name_ident.is(Token::Type::Function));
- auto function = make_ref_counted<StyleFunctionRule>(((Token)name_ident).m_value.to_string());
+ auto function = make_ref_counted<StyleFunctionRule>(((Token)name_ident).function());
for (;;) {
auto& token = tokens.next_token();
@@ -1903,7 +1903,7 @@ Optional<Length> Parser::parse_length(StyleComponentValueRule const& component_v
if (component_value.is(Token::Type::Dimension)) {
numeric_value = component_value.token().dimension_value();
- auto unit_string = component_value.token().m_unit.string_view();
+ auto unit_string = component_value.token().dimension_unit();
if (unit_string.equals_ignoring_case("px")) {
type = Length::Type::Px;
@@ -2022,7 +2022,7 @@ Optional<Color> Parser::parse_color(StyleComponentValueRule const& component_val
return color;
} else if (component_value.is(Token::Type::Hash)) {
- auto color = Color::from_string(String::formatted("#{}", component_value.token().m_value.to_string()));
+ auto color = Color::from_string(String::formatted("#{}", component_value.token().hash_value()));
if (color.has_value())
return color;
return {};
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Token.h b/Userland/Libraries/LibWeb/CSS/Parser/Token.h
index dcb5bca35d..9289aa122f 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Token.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Token.h
@@ -14,7 +14,6 @@
namespace Web::CSS {
class Token {
- friend class Parser;
friend class Tokenizer;
public:
@@ -71,6 +70,12 @@ public:
return m_value.string_view();
}
+ StringView function() const
+ {
+ VERIFY(m_type == Type::Function);
+ return m_value.string_view();
+ }
+
StringView delim() const
{
VERIFY(m_type == Type::Delim);