mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 13:17:35 +00:00
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.
This commit is contained in:
parent
d37f62fd54
commit
9286aa77bc
2 changed files with 9 additions and 4 deletions
|
@ -1288,7 +1288,7 @@ NonnullRefPtr<StyleFunctionRule> Parser::consume_a_function(TokenStream<T>& toke
|
||||||
{
|
{
|
||||||
auto name_ident = tokens.current_token();
|
auto name_ident = tokens.current_token();
|
||||||
VERIFY(name_ident.is(Token::Type::Function));
|
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 (;;) {
|
for (;;) {
|
||||||
auto& token = tokens.next_token();
|
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)) {
|
if (component_value.is(Token::Type::Dimension)) {
|
||||||
numeric_value = component_value.token().dimension_value();
|
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")) {
|
if (unit_string.equals_ignoring_case("px")) {
|
||||||
type = Length::Type::Px;
|
type = Length::Type::Px;
|
||||||
|
@ -2022,7 +2022,7 @@ Optional<Color> Parser::parse_color(StyleComponentValueRule const& component_val
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
} else if (component_value.is(Token::Type::Hash)) {
|
} 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())
|
if (color.has_value())
|
||||||
return color;
|
return color;
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class Token {
|
class Token {
|
||||||
friend class Parser;
|
|
||||||
friend class Tokenizer;
|
friend class Tokenizer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -71,6 +70,12 @@ public:
|
||||||
return m_value.string_view();
|
return m_value.string_view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringView function() const
|
||||||
|
{
|
||||||
|
VERIFY(m_type == Type::Function);
|
||||||
|
return m_value.string_view();
|
||||||
|
}
|
||||||
|
|
||||||
StringView delim() const
|
StringView delim() const
|
||||||
{
|
{
|
||||||
VERIFY(m_type == Type::Delim);
|
VERIFY(m_type == Type::Delim);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue