LibWeb/CSS: Make ParsingContext's Realm optional

We only need a Realm to allocate CSSOM objects on the GC heap. Style
values are not such objects, and over time, we'll be changing the
parser to only produce non-CSSOM objects.
This commit is contained in:
Sam Atkins 2024-12-05 10:41:19 +00:00 committed by Alexander Kalenik
parent 861f6e3965
commit 863ce746dc
Notes: github-actions[bot] 2024-12-05 19:01:02 +00:00
2 changed files with 12 additions and 2 deletions

View file

@ -13,6 +13,11 @@
namespace Web::CSS::Parser {
ParsingContext::ParsingContext(Mode mode)
: m_mode(mode)
{
}
ParsingContext::ParsingContext(JS::Realm& realm, Mode mode)
: m_realm(realm)
, m_mode(mode)

View file

@ -19,6 +19,7 @@ public:
SVGPresentationAttribute, // See https://svgwg.org/svg2-draft/types.html#presentation-attribute-css-value
};
explicit ParsingContext(Mode = Mode::Normal);
explicit ParsingContext(JS::Realm&, Mode = Mode::Normal);
explicit ParsingContext(JS::Realm&, URL::URL, Mode = Mode::Normal);
explicit ParsingContext(DOM::Document const&, Mode = Mode::Normal);
@ -36,10 +37,14 @@ public:
PropertyID current_property_id() const { return m_current_property_id; }
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
JS::Realm& realm() const { return m_realm; }
JS::Realm& realm() const
{
VERIFY(m_realm);
return *m_realm;
}
private:
GC::Ref<JS::Realm> m_realm;
GC::Ptr<JS::Realm> m_realm;
GC::Ptr<DOM::Document const> m_document;
PropertyID m_current_property_id { PropertyID::Invalid };
URL::URL m_url;