mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:47:34 +00:00
LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
This commit is contained in:
parent
7bd8fd000f
commit
834202aeb9
339 changed files with 1294 additions and 187 deletions
|
@ -14,7 +14,6 @@ namespace Web::CSS {
|
|||
CSSConditionRule::CSSConditionRule(JS::Realm& realm, CSSRuleList& rules)
|
||||
: CSSGroupingRule(realm, rules)
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSConditionRulePrototype>(realm, "CSSConditionRule"));
|
||||
}
|
||||
|
||||
void CSSConditionRule::for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const
|
||||
|
@ -23,4 +22,10 @@ void CSSConditionRule::for_each_effective_style_rule(Function<void(CSSStyleRule
|
|||
CSSGroupingRule::for_each_effective_style_rule(callback);
|
||||
}
|
||||
|
||||
void CSSConditionRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSConditionRulePrototype>(realm, "CSSConditionRule"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
|
||||
protected:
|
||||
CSSConditionRule(JS::Realm&, CSSRuleList&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,11 @@ CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face)
|
|||
: CSSRule(realm)
|
||||
, m_font_face(move(font_face))
|
||||
{
|
||||
}
|
||||
|
||||
void CSSFontFaceRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSFontFaceRulePrototype>(realm, "CSSFontFaceRule"));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
private:
|
||||
CSSFontFaceRule(JS::Realm&, FontFace&&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual DeprecatedString serialized() const override;
|
||||
|
||||
FontFace m_font_face;
|
||||
|
|
|
@ -18,11 +18,16 @@ CSSGroupingRule::CSSGroupingRule(JS::Realm& realm, CSSRuleList& rules)
|
|||
: CSSRule(realm)
|
||||
, m_rules(rules)
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSGroupingRulePrototype>(realm, "CSSGroupingRule"));
|
||||
for (auto& rule : m_rules)
|
||||
rule.set_parent_rule(this);
|
||||
}
|
||||
|
||||
void CSSGroupingRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSGroupingRulePrototype>(realm, "CSSGroupingRule"));
|
||||
}
|
||||
|
||||
void CSSGroupingRule::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
|
||||
protected:
|
||||
CSSGroupingRule(JS::Realm&, CSSRuleList&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -29,8 +29,6 @@ CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
|||
, m_url(move(url))
|
||||
, m_document(document)
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSImportRulePrototype>(document.realm(), "CSSImportRule"));
|
||||
|
||||
dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Loading import URL: {}", m_url);
|
||||
auto request = LoadRequest::create_for_url_on_page(m_url, document.page());
|
||||
|
||||
|
@ -41,6 +39,12 @@ CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
|||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||
}
|
||||
|
||||
void CSSImportRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSImportRulePrototype>(realm, "CSSImportRule"));
|
||||
}
|
||||
|
||||
void CSSImportRule::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
private:
|
||||
CSSImportRule(AK::URL, DOM::Document&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
virtual DeprecatedString serialized() const override;
|
||||
|
|
|
@ -21,6 +21,11 @@ CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rule
|
|||
: CSSConditionRule(realm, rules)
|
||||
, m_media(media)
|
||||
{
|
||||
}
|
||||
|
||||
void CSSMediaRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSMediaRulePrototype>(realm, "CSSMediaRule"));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
private:
|
||||
CSSMediaRule(JS::Realm&, MediaList&, CSSRuleList&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual DeprecatedString serialized() const override;
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@ CSSStyleRule::CSSStyleRule(JS::Realm& realm, NonnullRefPtrVector<Selector>&& sel
|
|||
, m_selectors(move(selectors))
|
||||
, m_declaration(declaration)
|
||||
{
|
||||
}
|
||||
|
||||
void CSSStyleRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleRulePrototype>(realm, "CSSStyleRule"));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
private:
|
||||
CSSStyleRule(JS::Realm&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual DeprecatedString serialized() const override;
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& me
|
|||
: StyleSheet(realm, media)
|
||||
, m_rules(&rules)
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleSheetPrototype>(realm, "CSSStyleSheet"));
|
||||
|
||||
if (location.has_value())
|
||||
set_location(location->to_deprecated_string());
|
||||
|
||||
|
@ -32,6 +30,12 @@ CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& me
|
|||
rule.set_parent_style_sheet(this);
|
||||
}
|
||||
|
||||
void CSSStyleSheet::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleSheetPrototype>(realm, "CSSStyleSheet"));
|
||||
}
|
||||
|
||||
void CSSStyleSheet::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
private:
|
||||
CSSStyleSheet(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
CSSRuleList* m_rules { nullptr };
|
||||
|
|
|
@ -20,6 +20,11 @@ CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr<Supports>&& sup
|
|||
: CSSConditionRule(realm, rules)
|
||||
, m_supports(move(supports))
|
||||
{
|
||||
}
|
||||
|
||||
void CSSSupportsRule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSSupportsRulePrototype>(realm, "CSSSupportsRule"));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
private:
|
||||
CSSSupportsRule(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual DeprecatedString serialized() const override;
|
||||
|
||||
NonnullRefPtr<Supports> m_supports;
|
||||
|
|
|
@ -25,10 +25,15 @@ MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<Medi
|
|||
, m_document(document)
|
||||
, m_media(move(media))
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListPrototype>(document.realm(), "MediaQueryList"));
|
||||
evaluate();
|
||||
}
|
||||
|
||||
void MediaQueryList::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListPrototype>(realm, "MediaQueryList"));
|
||||
}
|
||||
|
||||
void MediaQueryList::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
private:
|
||||
MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
|
|
|
@ -20,9 +20,14 @@ MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, DeprecatedFlyString c
|
|||
, m_media(event_init.media)
|
||||
, m_matches(event_init.matches)
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListEventPrototype>(realm, "MediaQueryListEvent"));
|
||||
}
|
||||
|
||||
MediaQueryListEvent::~MediaQueryListEvent() = default;
|
||||
|
||||
void MediaQueryListEvent::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListEventPrototype>(realm, "MediaQueryListEvent"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
private:
|
||||
MediaQueryListEvent(JS::Realm&, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
DeprecatedString m_media;
|
||||
bool m_matches;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,12 @@ Screen::Screen(HTML::Window& window)
|
|||
: PlatformObject(window.realm())
|
||||
, m_window(window)
|
||||
{
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::ScreenPrototype>(window.realm(), "Screen"));
|
||||
}
|
||||
|
||||
void Screen::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::ScreenPrototype>(realm, "Screen"));
|
||||
}
|
||||
|
||||
void Screen::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
private:
|
||||
explicit Screen(HTML::Window&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
HTML::Window const& window() const { return *m_window; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue