From 3fa4f55f860aa56f9cb8d6b941d3fe91ef18ffa1 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 11 Sep 2021 20:39:44 +0100 Subject: [PATCH] LibWeb: Add current_property_id to CSS ParsingContext After `parse_css_value(PropertyID, TokenStream)`, we only need to know the current PropertyID when checking for property-specific quirks, which will take place in only 2 places, which happen deep down. Making the current PropertyID part of the context means that those places can check it easily, without us having to pass it to every one of the parsing functions, which otherwise do not care. --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 1 + Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 11d59cbb44..7dda1f779b 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -2756,6 +2756,7 @@ RefPtr Parser::parse_as_css_value(PropertyID property_id) RefPtr Parser::parse_css_value(PropertyID property_id, TokenStream& tokens) { + m_context.set_current_property_id(property_id); Vector component_values; while (tokens.has_next_token()) { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index be1b5bb52b..4962735fd6 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -40,8 +40,12 @@ public: DOM::Document* document() const { return m_document; } URL complete_url(String const&) const; + PropertyID current_property_id() const { return m_current_property_id; } + void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; } + private: DOM::Document* m_document { nullptr }; + PropertyID m_current_property_id { PropertyID::Invalid }; }; template