1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 21:57:35 +00:00

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.
This commit is contained in:
Sam Atkins 2021-09-11 20:39:44 +01:00 committed by Andreas Kling
parent af58bddfc8
commit 3fa4f55f86
2 changed files with 5 additions and 0 deletions

View file

@ -2756,6 +2756,7 @@ RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id)
RefPtr<StyleValue> Parser::parse_css_value(PropertyID property_id, TokenStream<StyleComponentValueRule>& tokens)
{
m_context.set_current_property_id(property_id);
Vector<StyleComponentValueRule> component_values;
while (tokens.has_next_token()) {

View file

@ -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<typename T>