diff options
Diffstat (limited to 'Userland')
339 files changed, 1294 insertions, 187 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index ae44fe8c33..a9a65d4940 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -24,7 +24,6 @@ namespace Web::Bindings { LocationObject::LocationObject(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&cached_web_prototype(realm, "Location")); } LocationObject::~LocationObject() = default; @@ -41,6 +40,8 @@ void LocationObject::initialize(JS::Realm& realm) auto& vm = this->vm(); Object::initialize(realm); + set_prototype(&ensure_web_prototype<LocationPrototype>(realm, "Location")); + u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_accessor(realm, "href", href_getter, href_setter, attr); define_native_accessor(realm, "host", host_getter, {}, attr); diff --git a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp index b6d142d06c..d3d416fd2c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp @@ -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")); +} + } diff --git a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h index ca431328cf..34b8013d9b 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h @@ -26,6 +26,8 @@ public: protected: CSSConditionRule(JS::Realm&, CSSRuleList&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index b4a784d66b..11dba3358f 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -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")); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h index 6a7d7d3adf..03e9fcb92b 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp index 6977aa9ab4..01d9ef8643 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp @@ -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); diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h index 406a031037..3b77a75457 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h @@ -32,6 +32,8 @@ public: protected: CSSGroupingRule(JS::Realm&, CSSRuleList&); + + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index e4ec8b5883..965cc450d3 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -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); diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index 9d013690c7..68b87938fd 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp index c839371347..7f8ce6afc9 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp @@ -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")); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h index 3d32120661..75b4d66857 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp index bef547ead4..ec597f12d6 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -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")); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index fc67a33900..21b800f4ca 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 92ee1f3fcf..fd4eec4155 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -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); diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 58d8313839..747f2549f3 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -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 }; diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp index ee5eda4895..ffcbd1057e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp @@ -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")); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h index 13d6bdda11..fc91a0af16 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp index 91b2d64c70..be77857aab 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp @@ -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); diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h index 5ad1998993..12382afe51 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp index f33518add5..212790f537 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp @@ -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")); +} + } diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h index 8ab1863441..395f7bf099 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h @@ -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; }; diff --git a/Userland/Libraries/LibWeb/CSS/Screen.cpp b/Userland/Libraries/LibWeb/CSS/Screen.cpp index 15762d036b..f51e5d51e0 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.cpp +++ b/Userland/Libraries/LibWeb/CSS/Screen.cpp @@ -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) diff --git a/Userland/Libraries/LibWeb/CSS/Screen.h b/Userland/Libraries/LibWeb/CSS/Screen.h index d13600933e..c0ef644c41 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.h +++ b/Userland/Libraries/LibWeb/CSS/Screen.h @@ -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; } diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index 61dde15e80..453287a78e 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -22,7 +22,6 @@ JS::NonnullGCPtr<Crypto> Crypto::create(JS::Realm& realm) Crypto::Crypto(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "Crypto")); } Crypto::~Crypto() = default; @@ -30,6 +29,7 @@ Crypto::~Crypto() = default; void Crypto::initialize(JS::Realm& realm) { Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CryptoPrototype>(realm, "Crypto")); m_subtle = SubtleCrypto::create(realm); } diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.h b/Userland/Libraries/LibWeb/Crypto/Crypto.h index b1baabdd18..29a4e313e9 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.h +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.h @@ -26,11 +26,11 @@ public: DeprecatedString random_uuid() const; protected: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: explicit Crypto(JS::Realm&); - virtual void initialize(JS::Realm&) override; JS::GCPtr<SubtleCrypto> m_subtle; }; diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index 077e48ec83..a525d8200e 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -22,11 +22,16 @@ JS::NonnullGCPtr<SubtleCrypto> SubtleCrypto::create(JS::Realm& realm) SubtleCrypto::SubtleCrypto(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "SubtleCrypto")); } SubtleCrypto::~SubtleCrypto() = default; +void SubtleCrypto::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SubtleCryptoPrototype>(realm, "SubtleCrypto")); +} + // https://w3c.github.io/webcrypto/#dfn-SubtleCrypto-method-digest JS::Promise* SubtleCrypto::digest(DeprecatedString const& algorithm, JS::Handle<JS::Object> const& data) { diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h index 5fca39d5f8..23a07eb649 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h @@ -23,6 +23,7 @@ public: private: explicit SubtleCrypto(JS::Realm&); + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.cpp b/Userland/Libraries/LibWeb/DOM/AbortController.cpp index 9764c1586e..3152d92b72 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortController.cpp @@ -21,11 +21,16 @@ AbortController::AbortController(JS::Realm& realm, JS::NonnullGCPtr<AbortSignal> : PlatformObject(realm) , m_signal(move(signal)) { - set_prototype(&Bindings::cached_web_prototype(realm, "AbortController")); } AbortController::~AbortController() = default; +void AbortController::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::AbortControllerPrototype>(realm, "AbortController")); +} + void AbortController::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.h b/Userland/Libraries/LibWeb/DOM/AbortController.h index 040ed58a2e..b02bbca182 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.h +++ b/Userland/Libraries/LibWeb/DOM/AbortController.h @@ -28,6 +28,7 @@ public: private: AbortController(JS::Realm&, JS::NonnullGCPtr<AbortSignal>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://dom.spec.whatwg.org/#abortcontroller-signal diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp index 24e89a4275..d49254aa15 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -20,7 +20,12 @@ JS::NonnullGCPtr<AbortSignal> AbortSignal::construct_impl(JS::Realm& realm) AbortSignal::AbortSignal(JS::Realm& realm) : EventTarget(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "AbortSignal")); +} + +void AbortSignal::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::AbortSignalPrototype>(realm, "AbortSignal")); } // https://dom.spec.whatwg.org/#abortsignal-add diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.h b/Userland/Libraries/LibWeb/DOM/AbortSignal.h index 9020eeeb49..e25557e4df 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.h +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.h @@ -43,6 +43,7 @@ public: private: explicit AbortSignal(JS::Realm&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; // https://dom.spec.whatwg.org/#abortsignal-abort-reason diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index b1c81848e6..c09031cb08 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -29,7 +29,12 @@ Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString va , m_value(move(value)) , m_owner_element(owner_element) { - set_prototype(&Bindings::cached_web_prototype(document.realm(), "Attr")); +} + +void Attr::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::AttrPrototype>(realm, "Attr")); } void Attr::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Attr.h b/Userland/Libraries/LibWeb/DOM/Attr.h index 3c88b7457c..ddc8133614 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.h +++ b/Userland/Libraries/LibWeb/DOM/Attr.h @@ -45,6 +45,7 @@ public: private: Attr(Document&, QualifiedName, DeprecatedString value, Element const*); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; QualifiedName m_qualified_name; diff --git a/Userland/Libraries/LibWeb/DOM/CDATASection.cpp b/Userland/Libraries/LibWeb/DOM/CDATASection.cpp index 35f7dc14b7..d738f2fd4e 100644 --- a/Userland/Libraries/LibWeb/DOM/CDATASection.cpp +++ b/Userland/Libraries/LibWeb/DOM/CDATASection.cpp @@ -12,9 +12,14 @@ namespace Web::DOM { CDATASection::CDATASection(Document& document, DeprecatedString const& data) : Text(document, NodeType::CDATA_SECTION_NODE, data) { - set_prototype(&Bindings::cached_web_prototype(realm(), "CDATASection")); } CDATASection::~CDATASection() = default; +void CDATASection::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CDATASectionPrototype>(realm, "CDATASection")); +} + } diff --git a/Userland/Libraries/LibWeb/DOM/CDATASection.h b/Userland/Libraries/LibWeb/DOM/CDATASection.h index ad338e65ac..148dad1c8d 100644 --- a/Userland/Libraries/LibWeb/DOM/CDATASection.h +++ b/Userland/Libraries/LibWeb/DOM/CDATASection.h @@ -22,6 +22,8 @@ public: private: CDATASection(Document&, DeprecatedString const&); + + virtual void initialize(JS::Realm&) override; }; template<> diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp index fcd298bd0e..1a5a6712c7 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp @@ -17,7 +17,12 @@ CharacterData::CharacterData(Document& document, NodeType type, DeprecatedString : Node(document, type) , m_data(data) { - set_prototype(&Bindings::ensure_web_prototype<Bindings::CharacterDataPrototype>(document.realm(), "CharacterData")); +} + +void CharacterData::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CharacterDataPrototype>(realm, "CharacterData")); } // https://dom.spec.whatwg.org/#dom-characterdata-data diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.h b/Userland/Libraries/LibWeb/DOM/CharacterData.h index c5e62411ae..328a14a0db 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.h +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.h @@ -36,6 +36,8 @@ public: protected: CharacterData(Document&, NodeType, DeprecatedString const&); + virtual void initialize(JS::Realm&) override; + private: DeprecatedString m_data; }; diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp index 9bc3b4c466..be20d60880 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp @@ -25,11 +25,16 @@ CustomEvent::CustomEvent(JS::Realm& realm, DeprecatedFlyString const& event_name : Event(realm, event_name, event_init) , m_detail(event_init.detail) { - set_prototype(&Bindings::cached_web_prototype(realm, "CustomEvent")); } CustomEvent::~CustomEvent() = default; +void CustomEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CustomEventPrototype>(realm, "CustomEvent")); +} + void CustomEvent::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.h b/Userland/Libraries/LibWeb/DOM/CustomEvent.h index a42f917846..adab99322e 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.h +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.h @@ -28,6 +28,7 @@ public: // https://dom.spec.whatwg.org/#dom-customevent-detail JS::Value detail() const { return m_detail; } + virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; void init_custom_event(DeprecatedString const& type, bool bubbles, bool cancelable, JS::Value detail); diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 8c4d0abad8..ef391c340a 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -297,8 +297,6 @@ Document::Document(JS::Realm& realm, const AK::URL& url) , m_style_computer(make<CSS::StyleComputer>(*this)) , m_url(url) { - set_prototype(&Bindings::cached_web_prototype(realm, "Document")); - HTML::main_thread_event_loop().register_document({}, *this); m_style_update_timer = Platform::Timer::create_single_shot(0, [this] { @@ -315,6 +313,12 @@ Document::~Document() HTML::main_thread_event_loop().unregister_document({}, *this); } +void Document::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentPrototype>(realm, "Document")); +} + void Document::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 5757519dd4..67ce6c5ef6 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -450,6 +450,7 @@ public: DeprecatedString dump_accessibility_tree_as_json(); protected: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp index 2f9c183568..44bb492e8a 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -12,7 +12,12 @@ namespace Web::DOM { DocumentFragment::DocumentFragment(Document& document) : ParentNode(document, NodeType::DOCUMENT_FRAGMENT_NODE) { - set_prototype(&Bindings::cached_web_prototype(realm(), "DocumentFragment")); +} + +void DocumentFragment::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentFragmentPrototype>(realm, "DocumentFragment")); } void DocumentFragment::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.h b/Userland/Libraries/LibWeb/DOM/DocumentFragment.h index 47116712a8..0d5aa5e4c3 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.h @@ -33,6 +33,7 @@ public: protected: explicit DocumentFragment(Document& document); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp index cf2310c85d..567ff1eca0 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp @@ -17,7 +17,12 @@ JS::NonnullGCPtr<DocumentType> DocumentType::create(Document& document) DocumentType::DocumentType(Document& document) : Node(document, NodeType::DOCUMENT_TYPE_NODE) { - set_prototype(&Bindings::cached_web_prototype(realm(), "DocumentType")); +} + +void DocumentType::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentTypePrototype>(realm, "DocumentType")); } } diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.h b/Userland/Libraries/LibWeb/DOM/DocumentType.h index deb8b96a37..44e0f1d7f5 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.h @@ -36,6 +36,8 @@ public: private: explicit DocumentType(Document&); + virtual void initialize(JS::Realm&) override; + DeprecatedString m_name; DeprecatedString m_public_id; DeprecatedString m_system_id; diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 135e27f3c9..413a3faf5b 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -56,7 +56,6 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name) : ParentNode(document, NodeType::ELEMENT_NODE) , m_qualified_name(move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(document.realm(), "Element")); make_html_uppercased_qualified_name(); } @@ -65,6 +64,8 @@ Element::~Element() = default; void Element::initialize(JS::Realm& realm) { Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ElementPrototype>(realm, "Element")); + m_attributes = NamedNodeMap::create(*this); } diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp index 8d242f7227..7f01b98f76 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -21,7 +21,6 @@ MutationObserver::MutationObserver(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackT : PlatformObject(realm) , m_callback(move(callback)) { - set_prototype(&Bindings::cached_web_prototype(realm, "MutationObserver")); // 1. Set this’s callback to callback. @@ -32,6 +31,12 @@ MutationObserver::MutationObserver(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackT MutationObserver::~MutationObserver() = default; +void MutationObserver::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::MutationObserverPrototype>(realm, "MutationObserver")); +} + void MutationObserver::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.h b/Userland/Libraries/LibWeb/DOM/MutationObserver.h index 863839231c..edc5722394 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.h +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.h @@ -52,6 +52,7 @@ public: private: MutationObserver(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://dom.spec.whatwg.org/#concept-mo-callback @@ -81,6 +82,7 @@ public: protected: RegisteredObserver(MutationObserver& observer, MutationObserverInit const& options); + virtual void visit_edges(Cell::Visitor&) override; private: @@ -100,6 +102,7 @@ public: private: TransientRegisteredObserver(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source); + virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<RegisteredObserver> m_source; diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp index 9f29f539d6..8765e832ee 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -29,11 +29,16 @@ MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type , m_attribute_namespace(attribute_namespace) , m_old_value(old_value) { - set_prototype(&Bindings::cached_web_prototype(realm, "MutationRecord")); } MutationRecord::~MutationRecord() = default; +void MutationRecord::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::MutationRecordPrototype>(realm, "MutationRecord")); +} + void MutationRecord::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.h b/Userland/Libraries/LibWeb/DOM/MutationRecord.h index 5c5f296c01..76a5f747b9 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.h +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.h @@ -31,6 +31,8 @@ public: private: MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); + + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedFlyString m_type; diff --git a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp index 54e5126456..791d8eede7 100644 --- a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp +++ b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp @@ -15,7 +15,12 @@ ProcessingInstruction::ProcessingInstruction(Document& document, DeprecatedStrin : CharacterData(document, NodeType::PROCESSING_INSTRUCTION_NODE, data) , m_target(target) { - set_prototype(&Bindings::cached_web_prototype(document.realm(), "ProcessingInstruction")); +} + +void ProcessingInstruction::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ProcessingInstructionPrototype>(realm, "ProcessingInstruction")); } } diff --git a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h index f4f989b98b..ad5e448468 100644 --- a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h +++ b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h @@ -24,6 +24,8 @@ public: private: ProcessingInstruction(Document&, DeprecatedString const& data, DeprecatedString const& target); + virtual void initialize(JS::Realm&) override; + DeprecatedString m_target; }; diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index e7ffac96b0..75f723b201 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -52,13 +52,11 @@ JS::NonnullGCPtr<Range> Range::construct_impl(JS::Realm& realm) Range::Range(Document& document) : Range(document, 0, document, 0) { - set_prototype(&Bindings::cached_web_prototype(document.realm(), "Range")); } Range::Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) : AbstractRange(start_container, start_offset, end_container, end_offset) { - set_prototype(&Bindings::cached_web_prototype(start_container.realm(), "Range")); live_ranges().set(this); } @@ -67,6 +65,12 @@ Range::~Range() live_ranges().remove(this); } +void Range::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::RangePrototype>(realm, "Range")); +} + // https://dom.spec.whatwg.org/#concept-range-root Node& Range::root() { diff --git a/Userland/Libraries/LibWeb/DOM/Range.h b/Userland/Libraries/LibWeb/DOM/Range.h index 12b293f96e..697e281de8 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.h +++ b/Userland/Libraries/LibWeb/DOM/Range.h @@ -88,6 +88,8 @@ private: explicit Range(Document&); Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); + virtual void initialize(JS::Realm&) override; + Node& root(); Node const& root() const; diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp index 45140d78d2..f86bf5204d 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp @@ -17,7 +17,6 @@ namespace Web::DOM { StaticRange::StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) : AbstractRange(start_container, start_offset, end_container, end_offset) { - set_prototype(&Bindings::cached_web_prototype(start_container.realm(), "StaticRange")); } StaticRange::~StaticRange() = default; @@ -36,4 +35,10 @@ WebIDL::ExceptionOr<StaticRange*> StaticRange::construct_impl(JS::Realm& realm, return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).ptr(); } +void StaticRange::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::StaticRangePrototype>(realm, "StaticRange")); +} + } diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.h b/Userland/Libraries/LibWeb/DOM/StaticRange.h index f554d5fc5d..012714423d 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.h +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.h @@ -28,6 +28,8 @@ public: StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); virtual ~StaticRange() override; + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 9fb0967b52..33fe4b7d83 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -17,13 +17,17 @@ namespace Web::DOM { Text::Text(Document& document, DeprecatedString const& data) : CharacterData(document, NodeType::TEXT_NODE, data) { - set_prototype(&Bindings::cached_web_prototype(realm(), "Text")); } Text::Text(Document& document, NodeType type, DeprecatedString const& data) : CharacterData(document, type, data) { - set_prototype(&Bindings::cached_web_prototype(realm(), "Text")); +} + +void Text::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::TextPrototype>(realm, "Text")); } void Text::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Text.h b/Userland/Libraries/LibWeb/DOM/Text.h index 86663192e1..aed9f5f0fc 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.h +++ b/Userland/Libraries/LibWeb/DOM/Text.h @@ -38,6 +38,7 @@ protected: Text(Document&, DeprecatedString const&); Text(Document&, NodeType, DeprecatedString const&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index a06ff25f4a..262fa0dcb3 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -28,11 +28,16 @@ JS::NonnullGCPtr<XMLSerializer> XMLSerializer::construct_impl(JS::Realm& realm) XMLSerializer::XMLSerializer(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "XMLSerializer")); } XMLSerializer::~XMLSerializer() = default; +void XMLSerializer::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::XMLSerializerPrototype>(realm, "XMLSerializer")); +} + // https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring WebIDL::ExceptionOr<DeprecatedString> XMLSerializer::serialize_to_string(JS::NonnullGCPtr<DOM::Node> root) { diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h index 7f43c6d782..ee5e311d99 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h @@ -22,6 +22,8 @@ public: private: explicit XMLSerializer(JS::Realm&); + + virtual void initialize(JS::Realm&) override; }; enum class RequireWellFormed { diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp index 1979ef261c..0a300d6f42 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -29,11 +29,16 @@ TextDecoder::TextDecoder(JS::Realm& realm, TextCodec::Decoder& decoder, Deprecat , m_fatal(fatal) , m_ignore_bom(ignore_bom) { - set_prototype(&Bindings::cached_web_prototype(realm, "TextDecoder")); } TextDecoder::~TextDecoder() = default; +void TextDecoder::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::TextDecoderPrototype>(realm, "TextDecoder")); +} + // https://encoding.spec.whatwg.org/#dom-textdecoder-decode WebIDL::ExceptionOr<DeprecatedString> TextDecoder::decode(JS::Handle<JS::Object> const& input) const { diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h index 450ca2dbb5..c68447d078 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h @@ -35,6 +35,8 @@ private: // https://encoding.spec.whatwg.org/#dom-textdecoder TextDecoder(JS::Realm&, TextCodec::Decoder&, DeprecatedFlyString encoding, bool fatal, bool ignore_bom); + virtual void initialize(JS::Realm&) override; + TextCodec::Decoder& m_decoder; DeprecatedFlyString m_encoding; bool m_fatal { false }; diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp index c1a44767dc..78fbd0b131 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp @@ -19,11 +19,16 @@ JS::NonnullGCPtr<TextEncoder> TextEncoder::construct_impl(JS::Realm& realm) TextEncoder::TextEncoder(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "TextEncoder")); } TextEncoder::~TextEncoder() = default; +void TextEncoder::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::TextEncoderPrototype>(realm, "TextEncoder")); +} + // https://encoding.spec.whatwg.org/#dom-textencoder-encode JS::Uint8Array* TextEncoder::encode(DeprecatedString const& input) const { diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.h b/Userland/Libraries/LibWeb/Encoding/TextEncoder.h index 02eb55d736..2da540f5d5 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextEncoder.h +++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.h @@ -31,6 +31,8 @@ public: protected: // https://encoding.spec.whatwg.org/#dom-textencoder explicit TextEncoder(JS::Realm&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Headers.cpp index 759dac9596..7db1bb3691 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Headers.cpp @@ -33,11 +33,16 @@ Headers::Headers(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::HeaderList> : PlatformObject(realm) , m_header_list(header_list) { - set_prototype(&Bindings::cached_web_prototype(realm, "Headers")); } Headers::~Headers() = default; +void Headers::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersPrototype>(realm, "Headers")); +} + void Headers::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.h b/Userland/Libraries/LibWeb/Fetch/Headers.h index 5a905240ed..2a9b6b5474 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.h +++ b/Userland/Libraries/LibWeb/Fetch/Headers.h @@ -60,6 +60,7 @@ private: Headers(JS::Realm&, JS::NonnullGCPtr<Infrastructure::HeaderList>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; WebIDL::ExceptionOr<bool> validate(Infrastructure::Header const&) const; diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index 342f290c1e..9a1f682dfa 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -33,11 +33,16 @@ HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKin , m_headers(headers) , m_iteration_kind(iteration_kind) { - set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersIteratorPrototype>(headers.realm(), "HeadersIterator")); } HeadersIterator::~HeadersIterator() = default; +void HeadersIterator::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersIteratorPrototype>(realm, "HeadersIterator")); +} + void HeadersIterator::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h index a6a8c25ee1..68771b4134 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h @@ -22,6 +22,7 @@ public: JS::ThrowCompletionOr<JS::Object*> next(); private: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; HeadersIterator(Headers const&, JS::Object::PropertyKind iteration_kind); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index 47b7a0fc22..bb46a039c5 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -25,11 +25,16 @@ Request::Request(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::Request> req : PlatformObject(realm) , m_request(request) { - set_prototype(&Bindings::cached_web_prototype(realm, "Request")); } Request::~Request() = default; +void Request::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::RequestPrototype>(realm, "Request")); +} + void Request::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.h b/Userland/Libraries/LibWeb/Fetch/Request.h index c7d17f24e5..1a4ff6d914 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.h +++ b/Userland/Libraries/LibWeb/Fetch/Request.h @@ -98,6 +98,7 @@ public: private: Request(JS::Realm&, JS::NonnullGCPtr<Infrastructure::Request>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://fetch.spec.whatwg.org/#concept-request-request diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 7a3b53b9d4..92bf6188e4 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -22,11 +22,16 @@ Response::Response(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::Response> : PlatformObject(realm) , m_response(response) { - set_prototype(&Bindings::cached_web_prototype(realm, "Response")); } Response::~Response() = default; +void Response::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ResponsePrototype>(realm, "Response")); +} + void Response::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/Response.h b/Userland/Libraries/LibWeb/Fetch/Response.h index 4adb0afbda..7487911108 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.h +++ b/Userland/Libraries/LibWeb/Fetch/Response.h @@ -62,6 +62,7 @@ public: private: Response(JS::Realm&, JS::NonnullGCPtr<Infrastructure::Response>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::ExceptionOr<void> initialize_response(ResponseInit const&, Optional<Infrastructure::BodyWithType> const&); diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index d2d19a093d..6a76a7cbd4 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -115,7 +115,6 @@ bool is_basic_latin(StringView view) Blob::Blob(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "Blob")); } Blob::Blob(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type) @@ -123,18 +122,22 @@ Blob::Blob(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type) , m_byte_buffer(move(byte_buffer)) , m_type(move(type)) { - set_prototype(&Bindings::cached_web_prototype(realm, "Blob")); } Blob::Blob(JS::Realm& realm, ByteBuffer byte_buffer) : PlatformObject(realm) , m_byte_buffer(move(byte_buffer)) { - set_prototype(&Bindings::cached_web_prototype(realm, "Blob")); } Blob::~Blob() = default; +void Blob::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::BlobPrototype>(realm, "Blob")); +} + // https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(JS::Realm& realm, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options) { diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index 7a7150994b..f3d482eb0a 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -53,6 +53,8 @@ protected: Blob(JS::Realm&, ByteBuffer, DeprecatedString type); Blob(JS::Realm&, ByteBuffer); + virtual void initialize(JS::Realm&) override; + private: explicit Blob(JS::Realm&); diff --git a/Userland/Libraries/LibWeb/FileAPI/File.cpp b/Userland/Libraries/LibWeb/FileAPI/File.cpp index 5435b82abe..bd1c68ba9b 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/File.cpp @@ -16,7 +16,12 @@ File::File(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString file_name, , m_name(move(file_name)) , m_last_modified(last_modified) { - set_prototype(&Bindings::cached_web_prototype(realm, "File")); +} + +void File::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::FilePrototype>(realm, "File")); } File::~File() = default; diff --git a/Userland/Libraries/LibWeb/FileAPI/File.h b/Userland/Libraries/LibWeb/FileAPI/File.h index da43c79a7d..143f61ac3d 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.h +++ b/Userland/Libraries/LibWeb/FileAPI/File.h @@ -31,6 +31,8 @@ public: private: File(JS::Realm&, ByteBuffer, DeprecatedString file_name, DeprecatedString type, i64 last_modified); + virtual void initialize(JS::Realm&) override; + DeprecatedString m_name; i64 m_last_modified { 0 }; }; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index 93fc4bdd57..cd2a160629 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -18,7 +18,6 @@ JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) : DOMPointReadOnly(realm, x, y, z, w) { - set_prototype(&Bindings::cached_web_prototype(realm, "DOMPoint")); } // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint @@ -30,4 +29,10 @@ JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& DOMPoint::~DOMPoint() = default; +void DOMPoint::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointPrototype>(realm, "DOMPoint")); +} + } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h index c758d2784c..8d9bdc4c9e 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h @@ -34,6 +34,8 @@ public: private: DOMPoint(JS::Realm&, double x, double y, double z, double w); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index a24a192bd1..0b43b00f38 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -22,7 +22,6 @@ DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double , m_z(z) , m_w(w) { - set_prototype(&Bindings::cached_web_prototype(realm, "DOMPointReadOnly")); } // https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint @@ -34,4 +33,10 @@ JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMP DOMPointReadOnly::~DOMPointReadOnly() = default; +void DOMPointReadOnly::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointReadOnlyPrototype>(realm, "DOMPointReadOnly")); +} + } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h index aadc16f202..be5819b57f 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h @@ -39,6 +39,8 @@ public: protected: DOMPointReadOnly(JS::Realm&, double x, double y, double z, double w); + virtual void initialize(JS::Realm&) override; + double m_x; double m_y; double m_z; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp index b732bcf211..f74c4c74f3 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp @@ -22,9 +22,14 @@ JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const DOMRect::DOMRect(JS::Realm& realm, double x, double y, double width, double height) : DOMRectReadOnly(realm, x, y, width, height) { - set_prototype(&Bindings::cached_web_prototype(realm, "DOMRect")); } DOMRect::~DOMRect() = default; +void DOMRect::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectPrototype>(realm, "DOMRect")); +} + } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.h b/Userland/Libraries/LibWeb/Geometry/DOMRect.h index babc4897b3..b8398102d8 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.h @@ -32,6 +32,8 @@ public: private: DOMRect(JS::Realm&, double x, double y, double width, double height); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp index 82b778a930..c6a3286aef 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp @@ -18,9 +18,14 @@ DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double wi : PlatformObject(realm) , m_rect(x, y, width, height) { - set_prototype(&Bindings::cached_web_prototype(realm, "DOMRectReadOnly")); } DOMRectReadOnly::~DOMRectReadOnly() = default; +void DOMRectReadOnly::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectReadOnlyPrototype>(realm, "DOMRectReadOnly")); +} + } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h index e34665faa6..f0abdf72c5 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h @@ -34,6 +34,8 @@ public: protected: DOMRectReadOnly(JS::Realm&, double x, double y, double width, double height); + virtual void initialize(JS::Realm&) override; + Gfx::FloatRect m_rect; }; } diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index e1468820b6..e704ceebf2 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -43,11 +43,16 @@ CanvasGradient::CanvasGradient(JS::Realm& realm, Type type) : PlatformObject(realm) , m_type(type) { - set_prototype(&Bindings::cached_web_prototype(realm, "CanvasGradient")); } CanvasGradient::~CanvasGradient() = default; +void CanvasGradient::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CanvasGradientPrototype>(realm, "CanvasGradient")); +} + // https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop WebIDL::ExceptionOr<void> CanvasGradient::add_color_stop(double offset, DeprecatedString const& color) { diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h index 72aad2570d..92f2c1f551 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h @@ -32,6 +32,8 @@ public: private: CanvasGradient(JS::Realm&, Type); + virtual void initialize(JS::Realm&) override; + Type m_type {}; struct ColorStop { diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 39ac26198f..2b7a30705f 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -33,11 +33,16 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasE , CanvasPath(static_cast<Bindings::PlatformObject&>(*this)) , m_element(element) { - set_prototype(&Bindings::cached_web_prototype(realm, "CanvasRenderingContext2D")); } CanvasRenderingContext2D::~CanvasRenderingContext2D() = default; +void CanvasRenderingContext2D::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CanvasRenderingContext2DPrototype>(realm, "CanvasRenderingContext2D")); +} + void CanvasRenderingContext2D::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 995517eb9e..66fe651176 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -86,6 +86,7 @@ public: private: explicit CanvasRenderingContext2D(JS::Realm&, HTMLCanvasElement&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; struct PreparedTextGlyph { diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp index 1dbd77d1d1..d74105da24 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp @@ -25,9 +25,14 @@ CloseEvent::CloseEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, , m_code(event_init.code) , m_reason(event_init.reason) { - set_prototype(&Bindings::cached_web_prototype(realm, "CloseEvent")); } CloseEvent::~CloseEvent() = default; +void CloseEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::CloseEventPrototype>(realm, "CloseEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.h b/Userland/Libraries/LibWeb/HTML/CloseEvent.h index 6c94be526d..548f4d489d 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.h +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.h @@ -33,6 +33,8 @@ public: private: CloseEvent(JS::Realm&, DeprecatedFlyString const& event_name, CloseEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + bool m_was_clean { false }; u16 m_code { 0 }; DeprecatedString m_reason; diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp index 987447a034..bb40b3574c 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp @@ -21,11 +21,16 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> DOMParser::construct_impl(JS::R DOMParser::DOMParser(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "DOMParser")); } DOMParser::~DOMParser() = default; +void DOMParser::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMParserPrototype>(realm, "DOMParser")); +} + // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(DeprecatedString const& string, Bindings::DOMParserSupportedType type) { diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.h b/Userland/Libraries/LibWeb/HTML/DOMParser.h index 58ed38f0b8..85f696e46b 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.h +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.h @@ -27,6 +27,8 @@ public: private: explicit DOMParser(JS::Realm&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp index e557705fc7..2e83004d95 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp @@ -27,11 +27,16 @@ ErrorEvent::ErrorEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, , m_colno(event_init.colno) , m_error(event_init.error) { - set_prototype(&Bindings::cached_web_prototype(realm, "ErrorEvent")); } ErrorEvent::~ErrorEvent() = default; +void ErrorEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ErrorEventPrototype>(realm, "ErrorEvent")); +} + void ErrorEvent::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.h b/Userland/Libraries/LibWeb/HTML/ErrorEvent.h index e4ce4ba2fd..c34b6cf430 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.h +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.h @@ -47,6 +47,7 @@ public: private: ErrorEvent(JS::Realm&, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedString m_message { "" }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 6482ff09c0..8a6956f3c6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -13,8 +13,6 @@ namespace Web::HTML { HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLAnchorElement")); - activation_behavior = [this](auto const& event) { run_activation_behavior(event); }; @@ -22,6 +20,12 @@ HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, DOM::QualifiedName HTMLAnchorElement::~HTMLAnchorElement() = default; +void HTMLAnchorElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAnchorElementPrototype>(realm, "HTMLAnchorElement")); +} + void HTMLAnchorElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { HTMLElement::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 88cba8c554..3b0805a9ab 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -32,6 +32,8 @@ public: private: HTMLAnchorElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + void run_activation_behavior(Web::DOM::Event const&); // ^DOM::Element diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp index ab3efa3f34..dea9e96b16 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLAreaElement::HTMLAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLAreaElement")); } HTMLAreaElement::~HTMLAreaElement() = default; +void HTMLAreaElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAreaElementPrototype>(realm, "HTMLAreaElement")); +} + void HTMLAreaElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { HTMLElement::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h index 4140fdea31..f38a79f846 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h @@ -23,6 +23,8 @@ public: private: HTMLAreaElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + // ^DOM::Element virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; virtual i32 default_tab_index_value() const override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp index 86bd83230d..f480581aa2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLAudioElement::HTMLAudioElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLMediaElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLAudioElement")); } HTMLAudioElement::~HTMLAudioElement() = default; + +void HTMLAudioElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAudioElementPrototype>(realm, "HTMLAudioElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h index e2117f069e..4d32b7e9b3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h @@ -18,6 +18,8 @@ public: private: HTMLAudioElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp index 3dc799c88b..a13ae96957 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLBRElement::HTMLBRElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLBRElement")); } HTMLBRElement::~HTMLBRElement() = default; +void HTMLBRElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLBRElementPrototype>(realm, "HTMLBRElement")); +} + JS::GCPtr<Layout::Node> HTMLBRElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) { return heap().allocate_without_realm<Layout::BreakNode>(document(), *this, move(style)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h index d3c8af7440..f6b1cf2f7e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -20,6 +20,8 @@ public: private: HTMLBRElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp index 4bbbf5584c..7b515c87b1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLBaseElement::HTMLBaseElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLBaseElement")); } HTMLBaseElement::~HTMLBaseElement() = default; +void HTMLBaseElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLBaseElementPrototype>(realm, "HTMLBaseElement")); +} + void HTMLBaseElement::inserted() { HTMLElement::inserted(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h index 3634f847d9..2a69da35ef 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h @@ -28,6 +28,7 @@ public: private: HTMLBaseElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual bool is_html_base_element() const override { return true; } // https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index ea1f4015e2..4edc01ca4c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -15,11 +15,16 @@ namespace Web::HTML { HTMLBodyElement::HTMLBodyElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLBodyElement")); } HTMLBodyElement::~HTMLBodyElement() = default; +void HTMLBodyElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLBodyElementPrototype>(realm, "HTMLBodyElement")); +} + void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) const { for_each_attribute([&](auto& name, auto& value) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h index 1fb06052d5..fe5679114b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -29,6 +29,8 @@ public: private: HTMLBodyElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + // ^HTML::GlobalEventHandlers virtual EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const& event_name) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp index ad62b38fc6..6705b3e5fb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp @@ -13,8 +13,6 @@ namespace Web::HTML { HTMLButtonElement::HTMLButtonElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLButtonElement")); - // https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element:activation-behaviour activation_behavior = [this](auto&) { // 1. If element is disabled, then return. @@ -53,6 +51,12 @@ HTMLButtonElement::HTMLButtonElement(DOM::Document& document, DOM::QualifiedName HTMLButtonElement::~HTMLButtonElement() = default; +void HTMLButtonElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLButtonElementPrototype>(realm, "HTMLButtonElement")); +} + DeprecatedString HTMLButtonElement::type() const { auto value = attribute(HTML::AttributeNames::type); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h index 82f9646fdd..86d88e5e95 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h @@ -26,6 +26,8 @@ class HTMLButtonElement final public: virtual ~HTMLButtonElement() override; + virtual void initialize(JS::Realm&) override; + enum class TypeAttributeState { #define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(_, state) state, ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 3c4eb53e67..52090b55d5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -21,11 +21,16 @@ static constexpr auto max_canvas_area = 16384 * 16384; HTMLCanvasElement::HTMLCanvasElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLCanvasElement")); } HTMLCanvasElement::~HTMLCanvasElement() = default; +void HTMLCanvasElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLCanvasElementPrototype>(realm, "HTMLCanvasElement")); +} + void HTMLCanvasElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h index b9e88a7a53..51a0f11292 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -40,6 +40,7 @@ public: private: HTMLCanvasElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp index 384407b89c..eed2efc709 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDListElement::HTMLDListElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDListElement")); } HTMLDListElement::~HTMLDListElement() = default; + +void HTMLDListElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDListElementPrototype>(realm, "HTMLDListElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h index 020dc63caf..d0c1dbdd8e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h @@ -18,6 +18,8 @@ public: private: HTMLDListElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp index 982dfd649f..0ec6a42b80 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDataElement::HTMLDataElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDataElement")); } HTMLDataElement::~HTMLDataElement() = default; + +void HTMLDataElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDataElementPrototype>(realm, "HTMLDataElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h index 45b4e0aa34..6fd5497aa1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h @@ -22,6 +22,8 @@ public: private: HTMLDataElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp index 60bc4e31df..7c3f9619ca 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDataListElement::HTMLDataListElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDataListElement")); } HTMLDataListElement::~HTMLDataListElement() = default; + +void HTMLDataListElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDataListElementPrototype>(realm, "HTMLDataListElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h index 1decc6f6a0..df60c1b2c5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h @@ -21,6 +21,8 @@ public: private: HTMLDataListElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index 57a416647a..a6f6401ae3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDetailsElement::HTMLDetailsElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDetailsElement")); } HTMLDetailsElement::~HTMLDetailsElement() = default; + +void HTMLDetailsElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDetailsElementPrototype>(realm, "HTMLDetailsElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h index 11082c9ea4..46c2ce8236 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h @@ -22,6 +22,8 @@ public: private: HTMLDetailsElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp index b63e78faea..f283602cc6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDialogElement::HTMLDialogElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDialogElement")); } HTMLDialogElement::~HTMLDialogElement() = default; + +void HTMLDialogElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDialogElementPrototype>(realm, "HTMLDialogElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h index 4dbb6fc034..89e42c47c7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h @@ -22,6 +22,8 @@ public: private: HTMLDialogElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp index 3f44578d1f..7e76c9ee3c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDirectoryElement::HTMLDirectoryElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDirectoryElement")); } HTMLDirectoryElement::~HTMLDirectoryElement() = default; + +void HTMLDirectoryElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDirectoryElementPrototype>(realm, "HTMLDirectoryElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h index d0d8cb0cc9..fd53d1dc37 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h @@ -19,6 +19,8 @@ public: private: HTMLDirectoryElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp index 7ff717f1e0..050187c916 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLDivElement::HTMLDivElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLDivElement")); } HTMLDivElement::~HTMLDivElement() = default; + +void HTMLDivElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDivElementPrototype>(realm, "HTMLDivElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h index 064515fa9b..0d7c9172cd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h @@ -22,6 +22,8 @@ public: private: HTMLDivElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 35a146ac07..701699ddad 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -36,7 +36,6 @@ namespace Web::HTML { HTMLElement::HTMLElement(DOM::Document& document, DOM::QualifiedName qualified_name) : Element(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLElement")); } HTMLElement::~HTMLElement() = default; @@ -44,6 +43,8 @@ HTMLElement::~HTMLElement() = default; void HTMLElement::initialize(JS::Realm& realm) { Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLElementPrototype>(realm, "HTMLElement")); + m_dataset = DOMStringMap::create(*this); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp index 9e9b8c2211..7ba220f5c1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLEmbedElement::HTMLEmbedElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLEmbedElement")); } HTMLEmbedElement::~HTMLEmbedElement() = default; + +void HTMLEmbedElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLEmbedElementPrototype>(realm, "HTMLEmbedElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h index ff30ccab6c..311ad16d3a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h @@ -18,6 +18,8 @@ public: private: HTMLEmbedElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp index 9df7a9e9a4..59297ca6cc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLFieldSetElement::HTMLFieldSetElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLFieldSetElement")); } HTMLFieldSetElement::~HTMLFieldSetElement() = default; +void HTMLFieldSetElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFieldSetElementPrototype>(realm, "HTMLFieldSetElement")); +} + // https://html.spec.whatwg.org/multipage/form-elements.html#concept-fieldset-disabled bool HTMLFieldSetElement::is_disabled() const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h index 6b2e3ab1fa..bf1e54c4ec 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h @@ -40,6 +40,8 @@ public: private: HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp index 89032edfd0..75243d89c4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp @@ -14,11 +14,16 @@ namespace Web::HTML { HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLFontElement")); } HTMLFontElement::~HTMLFontElement() = default; +void HTMLFontElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFontElementPrototype>(realm, "HTMLFontElement")); +} + void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const { for_each_attribute([&](auto& name, auto& value) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h index 44be85a8a2..89a3b0783d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h @@ -20,6 +20,8 @@ public: private: HTMLFontElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 9149a10c77..54c13cbea7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -26,11 +26,16 @@ namespace Web::HTML { HTMLFormElement::HTMLFormElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLFormElement")); } HTMLFormElement::~HTMLFormElement() = default; +void HTMLFormElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFormElementPrototype>(realm, "HTMLFormElement")); +} + void HTMLFormElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h index 928c469d3b..df6bc49fe6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -43,6 +43,7 @@ public: private: HTMLFormElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; bool m_firing_submission_events { false }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp index 75597fed8d..3256104e30 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLFrameElement::HTMLFrameElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLFrameElement")); } HTMLFrameElement::~HTMLFrameElement() = default; +void HTMLFrameElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFrameElementPrototype>(realm, "HTMLFrameElement")); +} + // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex i32 HTMLFrameElement::default_tab_index_value() const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h index de3a5cc3a8..ab36507102 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h @@ -19,6 +19,9 @@ public: private: HTMLFrameElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; + // ^DOM::Element virtual i32 default_tab_index_value() const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp index 90af8cf910..b36b77f494 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLFrameSetElement::HTMLFrameSetElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLFrameSetElement")); } HTMLFrameSetElement::~HTMLFrameSetElement() = default; +void HTMLFrameSetElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFrameSetElementPrototype>(realm, "HTMLFrameSetElement")); +} + void HTMLFrameSetElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { HTMLElement::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h index 0a3ef76f58..24a4c295c9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h @@ -23,9 +23,9 @@ public: private: HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void parse_attribute(DeprecatedFlyString const&, DeprecatedString const&) override; -private: // ^HTML::GlobalEventHandlers virtual EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const& event_name) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp index 7312265757..f97a7814f8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLHRElement::HTMLHRElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLHRElement")); } HTMLHRElement::~HTMLHRElement() = default; + +void HTMLHRElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHRElementPrototype>(realm, "HTMLHRElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h index e1c4e9ef84..7176ba61b4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h @@ -22,6 +22,8 @@ public: private: HTMLHRElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp index e6bc7a4754..ff17191036 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLHeadElement::HTMLHeadElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLHeadElement")); } HTMLHeadElement::~HTMLHeadElement() = default; + +void HTMLHeadElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHeadElementPrototype>(realm, "HTMLHeadElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h index 921bdfd6db..6d88ab8034 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h @@ -18,6 +18,8 @@ public: private: HTMLHeadElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp index b1bc336ee9..e6fe3dddfc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLHeadingElement")); } HTMLHeadingElement::~HTMLHeadingElement() = default; +void HTMLHeadingElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHeadingElementPrototype>(realm, "HTMLHeadingElement")); +} + // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style) const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h index 892c1fcbe0..8289679077 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h @@ -29,6 +29,8 @@ public: private: HTMLHeadingElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp index d8d0eeff00..f2758c9c67 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLHtmlElement")); } HTMLHtmlElement::~HTMLHtmlElement() = default; +void HTMLHtmlElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHtmlElementPrototype>(realm, "HTMLHtmlElement")); +} + bool HTMLHtmlElement::should_use_body_background_properties() const { auto background_color = layout_node()->computed_values().background_color(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h index 88014cdaeb..6cc03a8f71 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h @@ -25,6 +25,7 @@ public: private: HTMLHtmlElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual bool is_html_html_element() const override { return true; } }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 92b760a7e2..98131a22a1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -17,11 +17,16 @@ namespace Web::HTML { HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, DOM::QualifiedName qualified_name) : BrowsingContextContainer(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLIFrameElement")); } HTMLIFrameElement::~HTMLIFrameElement() = default; +void HTMLIFrameElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLIFrameElementPrototype>(realm, "HTMLIFrameElement")); +} + JS::GCPtr<Layout::Node> HTMLIFrameElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) { return heap().allocate_without_realm<Layout::FrameBox>(document(), *this, move(style)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index d10dd68e30..e0a5f897e1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -28,6 +28,8 @@ public: private: HTMLIFrameElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + // ^DOM::Element virtual void inserted() override; virtual void removed_from(Node*) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 411717ee0b..13f6da07e2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -23,8 +23,6 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q : HTMLElement(document, move(qualified_name)) , m_image_loader(*this) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLImageElement")); - m_image_loader.on_load = [this] { set_needs_style_update(true); this->document().set_needs_layout(); @@ -50,6 +48,12 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q HTMLImageElement::~HTMLImageElement() = default; +void HTMLImageElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLImageElementPrototype>(realm, "HTMLImageElement")); +} + void HTMLImageElement::apply_presentational_hints(CSS::StyleProperties& style) const { for_each_attribute([&](auto& name, auto& value) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index 94b6d8a5c5..4119f3dad6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -48,6 +48,7 @@ public: private: HTMLImageElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; void animate(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 3c20012d63..ef6a08ef94 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -29,8 +29,6 @@ HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName q : HTMLElement(document, move(qualified_name)) , m_value(DeprecatedString::empty()) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLInputElement")); - activation_behavior = [this](auto&) { // The activation behavior for input elements are these steps: @@ -43,6 +41,12 @@ HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName q HTMLInputElement::~HTMLInputElement() = default; +void HTMLInputElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLInputElementPrototype>(realm, "HTMLInputElement")); +} + void HTMLInputElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index f9e0b369dc..3a6a863a14 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -134,6 +134,7 @@ private: // ^DOM::Element virtual i32 default_tab_index_value() const override; + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; static TypeAttributeState parse_type_attribute(StringView); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp index 307461215f..41cf0533e6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLLIElement::HTMLLIElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLLIElement")); } HTMLLIElement::~HTMLLIElement() = default; + +void HTMLLIElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLIElementPrototype>(realm, "HTMLLIElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h index 082670302a..2e4c0baeca 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h @@ -22,6 +22,8 @@ public: private: HTMLLIElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp index 940d880007..6d8372bf23 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLLabelElement::HTMLLabelElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLLabelElement")); } HTMLLabelElement::~HTMLLabelElement() = default; +void HTMLLabelElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLabelElementPrototype>(realm, "HTMLLabelElement")); +} + JS::GCPtr<Layout::Node> HTMLLabelElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) { return heap().allocate_without_realm<Layout::Label>(document(), this, move(style)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h index 7ebdd6e129..489ab4db4b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h @@ -22,6 +22,8 @@ public: private: HTMLLabelElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp index c1f5c4fb95..dd004bc08d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLLegendElement::HTMLLegendElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLLegendElement")); } HTMLLegendElement::~HTMLLegendElement() = default; + +void HTMLLegendElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLegendElementPrototype>(realm, "HTMLLegendElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h index 3e1d94e225..dc10820eda 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h @@ -18,6 +18,8 @@ public: private: HTMLLegendElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index e0f657d246..7787da4572 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -22,11 +22,16 @@ namespace Web::HTML { HTMLLinkElement::HTMLLinkElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLLinkElement")); } HTMLLinkElement::~HTMLLinkElement() = default; +void HTMLLinkElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLinkElementPrototype>(realm, "HTMLLinkElement")); +} + void HTMLLinkElement::inserted() { if (has_attribute(AttributeNames::disabled) && (m_relationship & Relationship::Stylesheet)) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h index 73edcfe137..bb8cdfbc34 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -33,6 +33,7 @@ public: private: HTMLLinkElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; void parse_attribute(DeprecatedFlyString const&, DeprecatedString const&) override; // ^ResourceClient diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp index 43c3dce152..ebcfa407b3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp @@ -12,8 +12,14 @@ namespace Web::HTML { HTMLMapElement::HTMLMapElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLMapElement")); } HTMLMapElement::~HTMLMapElement() = default; + +void HTMLMapElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMapElementPrototype>(realm, "HTMLMapElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h index c0afa994b1..c862ba7cc1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h @@ -18,6 +18,8 @@ public: private: HTMLMapElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp index ed5b523297..194f9e9cb7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLMarqueeElement::HTMLMarqueeElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLMarqueeElement")); } HTMLMarqueeElement::~HTMLMarqueeElement() = default; +void HTMLMarqueeElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMarqueeElementPrototype>(realm, "HTMLMarqueeElement")); +} + void HTMLMarqueeElement::apply_presentational_hints(CSS::StyleProperties& style) const { HTMLElement::apply_presentational_hints(style); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h index 996c447373..3c85d41bc2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h @@ -19,6 +19,8 @@ public: private: HTMLMarqueeElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 5273e680d0..a1325ce359 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLMediaElement::HTMLMediaElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLMediaElement")); } HTMLMediaElement::~HTMLMediaElement() = default; +void HTMLMediaElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMediaElementPrototype>(realm, "HTMLMediaElement")); +} + // https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype Bindings::CanPlayTypeResult HTMLMediaElement::can_play_type(DeprecatedString const& type) const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index a809226085..d1f3139bb6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -23,6 +23,8 @@ public: protected: HTMLMediaElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp index 1499835d44..b4b7575005 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLMenuElement::HTMLMenuElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLMenuElement")); } HTMLMenuElement::~HTMLMenuElement() = default; +void HTMLMenuElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMenuElementPrototype>(realm, "HTMLMenuElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h index 7517b6a927..1577bce29f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h @@ -22,6 +22,8 @@ public: private: HTMLMenuElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp index 425f077fb0..b40bb5507e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLMetaElement::HTMLMetaElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLMetaElement")); } HTMLMetaElement::~HTMLMetaElement() = default; +void HTMLMetaElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMetaElementPrototype>(realm, "HTMLMetaElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h index 743d0042e4..bd21f42c14 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h @@ -18,6 +18,8 @@ public: private: HTMLMetaElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp index f299750c9d..6f8ce5e8fa 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLMeterElement::HTMLMeterElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLMeterElement")); } HTMLMeterElement::~HTMLMeterElement() = default; +void HTMLMeterElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMeterElementPrototype>(realm, "HTMLMeterElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h index 9bb413df88..0c2907461b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h @@ -27,6 +27,8 @@ public: private: HTMLMeterElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp index b8326ea34a..bc5a40c4c7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLModElement::HTMLModElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLModElement")); } HTMLModElement::~HTMLModElement() = default; +void HTMLModElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLModElementPrototype>(realm, "HTMLModElement")); +} + DeprecatedFlyString HTMLModElement::default_role() const { // https://www.w3.org/TR/html-aria/#el-del diff --git a/Userland/Libraries/LibWeb/HTML/HTMLModElement.h b/Userland/Libraries/LibWeb/HTML/HTMLModElement.h index 908f56c12f..710cf9a471 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLModElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLModElement.h @@ -21,6 +21,8 @@ public: private: HTMLModElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp index 7f4b85e1c5..74de79aa2b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLOListElement::HTMLOListElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLOListElement")); } HTMLOListElement::~HTMLOListElement() = default; +void HTMLOListElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOListElementPrototype>(realm, "HTMLOListElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h index 81f63c1247..776fd1fb2b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h @@ -22,6 +22,8 @@ public: private: HTMLOListElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 68a1a1c87f..dbbfada928 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -19,8 +19,6 @@ namespace Web::HTML { HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name) : BrowsingContextContainer(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLObjectElement")); - // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element // Whenever one of the following conditions occur: // - the element is created, @@ -32,6 +30,12 @@ HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName HTMLObjectElement::~HTMLObjectElement() = default; +void HTMLObjectElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLObjectElementPrototype>(realm, "HTMLObjectElement")); +} + void HTMLObjectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { BrowsingContextContainer::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h index a83ecafc4d..46567c275e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -46,6 +46,8 @@ public: private: HTMLObjectElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp index 81cc1c0afe..77c433c961 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLOptGroupElement::HTMLOptGroupElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLOptGroupElement")); } HTMLOptGroupElement::~HTMLOptGroupElement() = default; +void HTMLOptGroupElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptGroupElementPrototype>(realm, "HTMLOptGroupElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h index d6875b1dc6..cef892b5c7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h @@ -22,6 +22,8 @@ public: private: HTMLOptGroupElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index 9c2cfc224d..17027c98b5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -21,11 +21,16 @@ namespace Web::HTML { HTMLOptionElement::HTMLOptionElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLOptionElement")); } HTMLOptionElement::~HTMLOptionElement() = default; +void HTMLOptionElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptionElementPrototype>(realm, "HTMLOptionElement")); +} + void HTMLOptionElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { HTMLElement::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h index 1f0c9546ea..9633a7c85b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h @@ -38,6 +38,8 @@ private: HTMLOptionElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; void did_remove_attribute(DeprecatedFlyString const& name) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index 4782523d10..61fd922053 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -21,11 +21,16 @@ JS::NonnullGCPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(DOM::Paren HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter) : DOM::HTMLCollection(root, move(filter)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLOptionsCollection")); } HTMLOptionsCollection::~HTMLOptionsCollection() = default; +void HTMLOptionsCollection::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptionsCollectionPrototype>(realm, "HTMLOptionsCollection")); +} + // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add WebIDL::ExceptionOr<void> HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h index 813b202ded..ee3d7ff5a0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h @@ -26,6 +26,8 @@ public: private: HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp index a50ac4232b..99a9d89ba9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLOutputElement::HTMLOutputElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLOutputElement")); } HTMLOutputElement::~HTMLOutputElement() = default; +void HTMLOutputElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOutputElementPrototype>(realm, "HTMLOutputElement")); +} + // https://html.spec.whatwg.org/multipage/form-elements.html#the-output-element:concept-form-reset-control void HTMLOutputElement::reset_algorithm() { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h index 9d46c7d8b6..bc4a574b9e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h @@ -49,6 +49,8 @@ public: private: HTMLOutputElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp index f6057fea88..72a77736ef 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLParagraphElement::HTMLParagraphElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLParagraphElement")); } HTMLParagraphElement::~HTMLParagraphElement() = default; +void HTMLParagraphElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLParagraphElementPrototype>(realm, "HTMLParagraphElement")); +} + // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& style) const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h index e0572366ec..d124674dec 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h @@ -24,6 +24,8 @@ public: private: HTMLParagraphElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp index aded0af35b..b71bdbaed9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLParamElement::HTMLParamElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLParamElement")); } HTMLParamElement::~HTMLParamElement() = default; +void HTMLParamElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLParamElementPrototype>(realm, "HTMLParamElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h index 17004cbdc0..8ae224061a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h @@ -18,6 +18,8 @@ public: private: HTMLParamElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp index 31986daad6..d9e4bb99a5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLPictureElement::HTMLPictureElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLPictureElement")); } HTMLPictureElement::~HTMLPictureElement() = default; +void HTMLPictureElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLPictureElementPrototype>(realm, "HTMLPictureElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h index 6aaa861419..c27e99ee34 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h @@ -18,6 +18,8 @@ public: private: HTMLPictureElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp index 70e641396a..684e4e49f1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLPreElement::HTMLPreElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLPreElement")); } HTMLPreElement::~HTMLPreElement() = default; +void HTMLPreElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLPreElementPrototype>(realm, "HTMLPreElement")); +} + void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) const { HTMLElement::apply_presentational_hints(style); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h index bfb623ab52..d2fc64fa2f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h @@ -22,6 +22,8 @@ public: private: HTMLPreElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index d31e5e8107..cde41d2594 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -17,11 +17,16 @@ namespace Web::HTML { HTMLProgressElement::HTMLProgressElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLProgressElement")); } HTMLProgressElement::~HTMLProgressElement() = default; +void HTMLProgressElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLProgressElementPrototype>(realm, "HTMLProgressElement")); +} + JS::GCPtr<Layout::Node> HTMLProgressElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) { if (style->appearance().value_or(CSS::Appearance::Auto) == CSS::Appearance::None) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h index 00689839f5..aa39a9f9db 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h @@ -39,6 +39,8 @@ public: private: HTMLProgressElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + void progress_position_updated(); bool is_determinate() const { return has_attribute(HTML::AttributeNames::value); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp index 116842758e..2547d64dd7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp @@ -14,11 +14,16 @@ namespace Web::HTML { HTMLQuoteElement::HTMLQuoteElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLQuoteElement")); } HTMLQuoteElement::~HTMLQuoteElement() = default; +void HTMLQuoteElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLQuoteElementPrototype>(realm, "HTMLQuoteElement")); +} + DeprecatedFlyString HTMLQuoteElement::default_role() const { // https://www.w3.org/TR/html-aria/#el-blockquote diff --git a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h index 79748de6f3..f12877b04c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h @@ -20,6 +20,8 @@ public: private: HTMLQuoteElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 4a39299a27..0af9dd888d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -26,11 +26,16 @@ namespace Web::HTML { HTMLScriptElement::HTMLScriptElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLScriptElement")); } HTMLScriptElement::~HTMLScriptElement() = default; +void HTMLScriptElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLScriptElementPrototype>(realm, "HTMLScriptElement")); +} + void HTMLScriptElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h index b4537d6880..049e5aa994 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -57,6 +57,7 @@ public: virtual void resource_did_load() override; virtual void resource_did_fail() override; + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 5ed7612b83..cc5ddb6906 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -16,11 +16,16 @@ namespace Web::HTML { HTMLSelectElement::HTMLSelectElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLSelectElement")); } HTMLSelectElement::~HTMLSelectElement() = default; +void HTMLSelectElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSelectElementPrototype>(realm, "HTMLSelectElement")); +} + void HTMLSelectElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h index 0e1c211bda..985edd49fc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h @@ -65,6 +65,7 @@ public: private: HTMLSelectElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // ^DOM::Element diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp index 49a434777a..7a43cb4ee1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLSlotElement")); } HTMLSlotElement::~HTMLSlotElement() = default; +void HTMLSlotElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSlotElementPrototype>(realm, "HTMLSlotElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h index 8924b5847f..9f7cc04950 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h @@ -18,6 +18,8 @@ public: private: HTMLSlotElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp index 40f6d0141a..5031b6b25b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLSourceElement::HTMLSourceElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLSourceElement")); } HTMLSourceElement::~HTMLSourceElement() = default; +void HTMLSourceElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSourceElementPrototype>(realm, "HTMLSourceElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h index 2fba7bb28d..98c98a4e05 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h @@ -18,6 +18,8 @@ public: private: HTMLSourceElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp index b7f41ee0c6..dd5559e20c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLSpanElement::HTMLSpanElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLSpanElement")); } HTMLSpanElement::~HTMLSpanElement() = default; +void HTMLSpanElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSpanElementPrototype>(realm, "HTMLSpanElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h index 75e165fcad..20d6a7d7bd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h @@ -22,6 +22,8 @@ public: private: HTMLSpanElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp index 7624f26152..cf42ecc56a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp @@ -14,11 +14,16 @@ namespace Web::HTML { HTMLStyleElement::HTMLStyleElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLStyleElement")); } HTMLStyleElement::~HTMLStyleElement() = default; +void HTMLStyleElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLStyleElementPrototype>(realm, "HTMLStyleElement")); +} + void HTMLStyleElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h index 413ceb04d5..522390128b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h @@ -29,6 +29,7 @@ public: private: HTMLStyleElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://www.w3.org/TR/cssom/#associated-css-style-sheet diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp index 82074e21ec..25354fdb42 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLTableCaptionElement::HTMLTableCaptionElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTableCaptionElement")); } HTMLTableCaptionElement::~HTMLTableCaptionElement() = default; +void HTMLTableCaptionElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableCaptionElementPrototype>(realm, "HTMLTableCaptionElement")); +} + // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& style) const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h index 259dbb101d..94f44b41a8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h @@ -24,6 +24,8 @@ public: private: HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index a97862b517..e554128132 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -14,11 +14,16 @@ namespace Web::HTML { HTMLTableCellElement::HTMLTableCellElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTableCellElement")); } HTMLTableCellElement::~HTMLTableCellElement() = default; +void HTMLTableCellElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableCellElementPrototype>(realm, "HTMLTableCellElement")); +} + void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& style) const { for_each_attribute([&](auto& name, auto& value) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h index c3e02ded3b..7eb0138762 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h @@ -26,6 +26,8 @@ public: private: HTMLTableCellElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp index 4055e3bddf..06e94dd8b6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLTableColElement::HTMLTableColElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTableColElement")); } HTMLTableColElement::~HTMLTableColElement() = default; +void HTMLTableColElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableColElementPrototype>(realm, "HTMLTableColElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h index c887819d2f..6b4a0f1da9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h @@ -18,6 +18,8 @@ public: private: HTMLTableColElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 9d78f4fd81..821d0e684f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -20,11 +20,16 @@ namespace Web::HTML { HTMLTableElement::HTMLTableElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTableElement")); } HTMLTableElement::~HTMLTableElement() = default; +void HTMLTableElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableElementPrototype>(realm, "HTMLTableElement")); +} + void HTMLTableElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h index 40b8eff682..5ed3f57edf 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -48,6 +48,7 @@ public: private: HTMLTableElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index aa44d76d9f..16be11e4b2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -18,11 +18,16 @@ namespace Web::HTML { HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTableRowElement")); } HTMLTableRowElement::~HTMLTableRowElement() = default; +void HTMLTableRowElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableRowElementPrototype>(realm, "HTMLTableRowElement")); +} + void HTMLTableRowElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h index ea80fe5bc2..9d404aed0e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h @@ -30,6 +30,7 @@ public: private: HTMLTableRowElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<DOM::HTMLCollection> mutable m_cells; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index 9c2a669692..146a0197b8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -17,11 +17,16 @@ namespace Web::HTML { HTMLTableSectionElement::HTMLTableSectionElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTableSectionElement")); } HTMLTableSectionElement::~HTMLTableSectionElement() = default; +void HTMLTableSectionElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableSectionElementPrototype>(realm, "HTMLTableSectionElement")); +} + void HTMLTableSectionElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h index 025ff5a874..83cfc5830e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h @@ -30,6 +30,7 @@ public: private: HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<DOM::HTMLCollection> mutable m_rows; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index 109417fd12..9712909d70 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -13,7 +13,6 @@ namespace Web::HTML { HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTemplateElement")); } HTMLTemplateElement::~HTMLTemplateElement() = default; @@ -21,6 +20,8 @@ HTMLTemplateElement::~HTMLTemplateElement() = default; void HTMLTemplateElement::initialize(JS::Realm& realm) { Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTemplateElementPrototype>(realm, "HTMLTemplateElement")); + m_content = heap().allocate<DOM::DocumentFragment>(realm, m_document->appropriate_template_contents_owner_document()); m_content->set_host(this); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index c2347f66c4..ac1443b100 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -12,11 +12,16 @@ namespace Web::HTML { HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTextAreaElement")); } HTMLTextAreaElement::~HTMLTextAreaElement() = default; +void HTMLTextAreaElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTextAreaElementPrototype>(realm, "HTMLTextAreaElement")); +} + // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex i32 HTMLTextAreaElement::default_tab_index_value() const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h index 7b5af5691f..86805985ab 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h @@ -57,6 +57,8 @@ public: private: HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + // ^DOM::Element virtual i32 default_tab_index_value() const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp index 27a06c1a6c..77692b083d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp @@ -12,7 +12,12 @@ namespace Web::HTML { HTMLTimeElement::HTMLTimeElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTimeElement")); +} + +void HTMLTimeElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTimeElementPrototype>(realm, "HTMLTimeElement")); } HTMLTimeElement::~HTMLTimeElement() = default; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h index f6962c6695..02655140f4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h @@ -22,6 +22,8 @@ public: private: HTMLTimeElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp index 27bcb0a15e..998a4b5b24 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp @@ -13,11 +13,16 @@ namespace Web::HTML { HTMLTitleElement::HTMLTitleElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTitleElement")); } HTMLTitleElement::~HTMLTitleElement() = default; +void HTMLTitleElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTitleElementPrototype>(realm, "HTMLTitleElement")); +} + void HTMLTitleElement::children_changed() { HTMLElement::children_changed(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h index ac6dc7f163..545b24b6f3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h @@ -19,6 +19,7 @@ public: private: HTMLTitleElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void children_changed() override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp index e02d866cd6..286d94b73a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLTrackElement::HTMLTrackElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLTrackElement")); } HTMLTrackElement::~HTMLTrackElement() = default; +void HTMLTrackElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTrackElementPrototype>(realm, "HTMLTrackElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h index 2c8172702d..17be218974 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h @@ -18,6 +18,8 @@ public: private: HTMLTrackElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp index adc74730ce..04e1fd451c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLUListElement::HTMLUListElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLUListElement")); } HTMLUListElement::~HTMLUListElement() = default; +void HTMLUListElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLUListElementPrototype>(realm, "HTMLUListElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h index 9c7b275f5c..45e4af2754 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h @@ -22,6 +22,8 @@ public: private: HTMLUListElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp index aca3da01ab..ae683a1b35 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLUnknownElement::HTMLUnknownElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLUnknownElement")); } HTMLUnknownElement::~HTMLUnknownElement() = default; +void HTMLUnknownElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLUnknownElementPrototype>(realm, "HTMLUnknownElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h index e0bf9c64a3..9e46892771 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h @@ -18,6 +18,8 @@ public: private: HTMLUnknownElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index 04810b30b5..eea5bfd1d5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -12,9 +12,14 @@ namespace Web::HTML { HTMLVideoElement::HTMLVideoElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLMediaElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLVideoElement")); } HTMLVideoElement::~HTMLVideoElement() = default; +void HTMLVideoElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLVideoElementPrototype>(realm, "HTMLVideoElement")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h index a83b90289b..0d4470a583 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h @@ -18,6 +18,8 @@ public: private: HTMLVideoElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 63deb9f798..7034c04ea5 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -19,11 +19,16 @@ History::History(JS::Realm& realm, DOM::Document& document) : PlatformObject(realm) , m_associated_document(document) { - set_prototype(&Bindings::cached_web_prototype(realm, "History")); } History::~History() = default; +void History::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HistoryPrototype>(realm, "History")); +} + void History::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/History.h b/Userland/Libraries/LibWeb/HTML/History.h index b873aabdff..c20902b1fe 100644 --- a/Userland/Libraries/LibWeb/HTML/History.h +++ b/Userland/Libraries/LibWeb/HTML/History.h @@ -30,6 +30,7 @@ public: private: History(JS::Realm&, DOM::Document&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; enum class IsPush { diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp index 8f16de3eac..426385033f 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp @@ -36,11 +36,16 @@ ImageData::ImageData(JS::Realm& realm, NonnullRefPtr<Gfx::Bitmap> bitmap, JS::No , m_bitmap(move(bitmap)) , m_data(move(data)) { - set_prototype(&Bindings::cached_web_prototype(realm, "ImageData")); } ImageData::~ImageData() = default; +void ImageData::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ImageDataPrototype>(realm, "ImageData")); +} + void ImageData::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.h b/Userland/Libraries/LibWeb/HTML/ImageData.h index e56f026c1b..86c25ce578 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.h +++ b/Userland/Libraries/LibWeb/HTML/ImageData.h @@ -31,6 +31,7 @@ public: private: ImageData(JS::Realm&, NonnullRefPtr<Gfx::Bitmap>, JS::NonnullGCPtr<JS::Uint8ClampedArray>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; NonnullRefPtr<Gfx::Bitmap> m_bitmap; diff --git a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp index b0c706a57a..069564c3e2 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp @@ -19,8 +19,6 @@ JS::NonnullGCPtr<MessageChannel> MessageChannel::construct_impl(JS::Realm& realm MessageChannel::MessageChannel(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "MessageChannel")); - // 1. Set this's port 1 to a new MessagePort in this's relevant Realm. m_port1 = MessagePort::create(realm); @@ -40,6 +38,12 @@ void MessageChannel::visit_edges(Cell::Visitor& visitor) visitor.visit(m_port2.ptr()); } +void MessageChannel::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::MessageChannelPrototype>(realm, "MessageChannel")); +} + MessagePort* MessageChannel::port1() { return m_port1; diff --git a/Userland/Libraries/LibWeb/HTML/MessageChannel.h b/Userland/Libraries/LibWeb/HTML/MessageChannel.h index 4fc9c2c2e4..1dfe15520c 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageChannel.h +++ b/Userland/Libraries/LibWeb/HTML/MessageChannel.h @@ -28,6 +28,7 @@ public: private: explicit MessageChannel(JS::Realm&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<MessagePort> m_port1; diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp index 907b869114..910a94b5ae 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -25,11 +25,16 @@ MessageEvent::MessageEvent(JS::Realm& realm, DeprecatedFlyString const& event_na , m_origin(event_init.origin) , m_last_event_id(event_init.last_event_id) { - set_prototype(&Bindings::cached_web_prototype(realm, "MessageEvent")); } MessageEvent::~MessageEvent() = default; +void MessageEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::MessageEventPrototype>(realm, "MessageEvent")); +} + void MessageEvent::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.h b/Userland/Libraries/LibWeb/HTML/MessageEvent.h index 675c1eeffe..73cd28d29c 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.h +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.h @@ -32,6 +32,7 @@ public: DeprecatedString const& last_event_id() const { return m_last_event_id; } private: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::Value m_data; diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 461ff967b6..52159660e0 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -22,11 +22,16 @@ JS::NonnullGCPtr<MessagePort> MessagePort::create(JS::Realm& realm) MessagePort::MessagePort(JS::Realm& realm) : DOM::EventTarget(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "MessagePort")); } MessagePort::~MessagePort() = default; +void MessagePort::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::MessagePortPrototype>(realm, "MessagePort")); +} + void MessagePort::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.h b/Userland/Libraries/LibWeb/HTML/MessagePort.h index 6dba0493ee..84de2b7288 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.h +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.h @@ -46,6 +46,7 @@ public: private: explicit MessagePort(JS::Realm&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; bool is_entangled() const { return m_remote_port; } diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.cpp b/Userland/Libraries/LibWeb/HTML/Navigator.cpp index ed25204e08..b53263418b 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigator.cpp @@ -23,11 +23,16 @@ JS::NonnullGCPtr<Navigator> Navigator::create(JS::Realm& realm) Navigator::Navigator(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "Navigator")); } Navigator::~Navigator() = default; +void Navigator::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::NavigatorPrototype>(realm, "Navigator")); +} + // https://w3c.github.io/webdriver/#dfn-webdriver bool Navigator::webdriver() const { diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.h b/Userland/Libraries/LibWeb/HTML/Navigator.h index 699bc6557a..a6447ed749 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.h +++ b/Userland/Libraries/LibWeb/HTML/Navigator.h @@ -45,6 +45,8 @@ public: private: explicit Navigator(JS::Realm&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp index 177277ffa4..33393346db 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp @@ -23,9 +23,14 @@ PageTransitionEvent::PageTransitionEvent(JS::Realm& realm, DeprecatedFlyString c : DOM::Event(realm, event_name, event_init) , m_persisted(event_init.persisted) { - set_prototype(&Bindings::cached_web_prototype(realm, "PageTransitionEvent")); } PageTransitionEvent::~PageTransitionEvent() = default; +void PageTransitionEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::PageTransitionEventPrototype>(realm, "PageTransitionEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h index e809bc9f59..6409d141c8 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h @@ -28,6 +28,8 @@ public: bool persisted() const { return m_persisted; } private: + virtual void initialize(JS::Realm&) override; + bool m_persisted { false }; }; diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.cpp b/Userland/Libraries/LibWeb/HTML/Path2D.cpp index 58d5383156..3803c7f019 100644 --- a/Userland/Libraries/LibWeb/HTML/Path2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/Path2D.cpp @@ -22,8 +22,6 @@ Path2D::Path2D(JS::Realm& realm, Optional<Variant<JS::Handle<Path2D>, Deprecated : PlatformObject(realm) , CanvasPath(static_cast<Bindings::PlatformObject&>(*this)) { - set_prototype(&Bindings::cached_web_prototype(realm, "Path2D")); - // 1. Let output be a new Path2D object. // 2. If path is not given, then return output. if (!path.has_value()) @@ -56,4 +54,10 @@ Path2D::Path2D(JS::Realm& realm, Optional<Variant<JS::Handle<Path2D>, Deprecated Path2D::~Path2D() = default; +void Path2D::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::Path2DPrototype>(realm, "Path2D")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.h b/Userland/Libraries/LibWeb/HTML/Path2D.h index 915717c8a6..db3d781d09 100644 --- a/Userland/Libraries/LibWeb/HTML/Path2D.h +++ b/Userland/Libraries/LibWeb/HTML/Path2D.h @@ -27,6 +27,8 @@ public: private: Path2D(JS::Realm&, Optional<Variant<JS::Handle<Path2D>, DeprecatedString>> const&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp index f16a98a2c6..b27adcc40d 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp @@ -24,7 +24,6 @@ PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, DeprecatedFlyStri , m_promise(const_cast<JS::Promise*>(event_init.promise.cell())) , m_reason(event_init.reason) { - set_prototype(&Bindings::cached_web_prototype(realm, "PromiseRejectionEvent")); } PromiseRejectionEvent::~PromiseRejectionEvent() = default; @@ -36,4 +35,10 @@ void PromiseRejectionEvent::visit_edges(Cell::Visitor& visitor) visitor.visit(m_reason); } +void PromiseRejectionEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::PromiseRejectionEventPrototype>(realm, "PromiseRejectionEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h index 0f79732f60..6b4f4e01ee 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h @@ -35,6 +35,7 @@ public: private: PromiseRejectionEvent(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::Promise* m_promise { nullptr }; diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index a21e2d89b8..e826eb44b7 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -18,11 +18,16 @@ JS::NonnullGCPtr<Storage> Storage::create(JS::Realm& realm) Storage::Storage(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "Storage")); } Storage::~Storage() = default; +void Storage::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::StoragePrototype>(realm, "Storage")); +} + // https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-length size_t Storage::length() const { diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index 0090431d45..6b3323bc81 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -35,6 +35,8 @@ public: private: explicit Storage(JS::Realm&); + virtual void initialize(JS::Realm&) override; + void reorder(); void broadcast(DeprecatedString const& key, DeprecatedString const& old_value, DeprecatedString const& new_value); diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp index 9d3cc07ff5..ee1a535447 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp @@ -23,11 +23,16 @@ SubmitEvent::SubmitEvent(JS::Realm& realm, DeprecatedFlyString const& event_name : DOM::Event(realm, event_name, event_init) , m_submitter(event_init.submitter) { - set_prototype(&Bindings::cached_web_prototype(realm, "SubmitEvent")); } SubmitEvent::~SubmitEvent() = default; +void SubmitEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SubmitEventPrototype>(realm, "SubmitEvent")); +} + void SubmitEvent::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.h b/Userland/Libraries/LibWeb/HTML/SubmitEvent.h index 56dc9b604b..51398d9a46 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.h +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.h @@ -29,6 +29,7 @@ public: private: SubmitEvent(JS::Realm&, DeprecatedFlyString const& event_name, SubmitEventInit const& event_init); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<HTMLElement> m_submitter; diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp index 5041db4006..fda88cba77 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp @@ -17,9 +17,14 @@ JS::NonnullGCPtr<TextMetrics> TextMetrics::create(JS::Realm& realm) TextMetrics::TextMetrics(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "TextMetrics")); } TextMetrics::~TextMetrics() = default; +void TextMetrics::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::TextMetricsPrototype>(realm, "TextMetrics")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.h b/Userland/Libraries/LibWeb/HTML/TextMetrics.h index 54bdfd29b1..8c969a2545 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.h +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.h @@ -47,6 +47,8 @@ public: private: explicit TextMetrics(JS::Realm&); + virtual void initialize(JS::Realm&) override; + double m_width { 0 }; double m_actual_bounding_box_left { 0 }; double m_actual_bounding_box_right { 0 }; diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 3aac30ea98..cf5179dc6a 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -28,7 +28,12 @@ Worker::Worker(DeprecatedFlyString const& script_url, WorkerOptions const option , m_interpreter_scope(*m_interpreter) , m_implicit_port(MessagePort::create(document.realm())) { - set_prototype(&Bindings::cached_web_prototype(document.realm(), "Worker")); +} + +void Worker::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::WorkerPrototype>(realm, "Worker")); } void Worker::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/Worker.h b/Userland/Libraries/LibWeb/HTML/Worker.h index 303ce77153..9650cd39ea 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.h +++ b/Userland/Libraries/LibWeb/HTML/Worker.h @@ -68,6 +68,7 @@ private: return static_cast<Bindings::WebEngineCustomData*>(target_vm.custom_data())->event_loop; } + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedFlyString m_script_url; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp index e86d942b56..2585f260b4 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp @@ -19,9 +19,14 @@ JS::NonnullGCPtr<WorkerNavigator> WorkerNavigator::create(WorkerGlobalScope& glo WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope) : PlatformObject(global_scope.realm()) { - set_prototype(&Bindings::cached_web_prototype(global_scope.realm(), "WorkerNavigator")); } WorkerNavigator::~WorkerNavigator() = default; +void WorkerNavigator::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::WorkerNavigatorPrototype>(realm, "WorkerNavigator")); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h index a9557aa3d3..54fdb2b263 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h @@ -28,6 +28,8 @@ public: private: explicit WorkerNavigator(WorkerGlobalScope&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 67ec50f83d..633ab366d8 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -17,12 +17,17 @@ Performance::Performance(HTML::Window& window) : DOM::EventTarget(window.realm()) , m_window(window) { - set_prototype(&Bindings::cached_web_prototype(realm(), "Performance")); m_timer.start(); } Performance::~Performance() = default; +void Performance::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::PerformancePrototype>(realm, "Performance")); +} + void Performance::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h index 2853b3c056..817b8087c1 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h @@ -25,6 +25,7 @@ public: private: explicit Performance(HTML::Window&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<HTML::Window> m_window; diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp index ec4522deeb..e14bf17609 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp @@ -23,11 +23,16 @@ JS::NonnullGCPtr<IntersectionObserver> IntersectionObserver::construct_impl(JS:: IntersectionObserver::IntersectionObserver(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "IntersectionObserver")); } IntersectionObserver::~IntersectionObserver() = default; +void IntersectionObserver::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::IntersectionObserverPrototype>(realm, "IntersectionObserver")); +} + // https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe void IntersectionObserver::observe(DOM::Element& target) { diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h index 82b73a443f..326385ed1e 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h @@ -32,6 +32,8 @@ public: private: explicit IntersectionObserver(JS::Realm&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp index cc5f507d00..a2d53b5ac9 100644 --- a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp +++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp @@ -12,11 +12,16 @@ PerformanceTiming::PerformanceTiming(HTML::Window& window) : PlatformObject(window.realm()) , m_window(window) { - set_prototype(&Bindings::cached_web_prototype(realm(), "PerformanceTiming")); } PerformanceTiming::~PerformanceTiming() = default; +void PerformanceTiming::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::PerformanceTimingPrototype>(realm, "PerformanceTiming")); +} + void PerformanceTiming::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h index 9bdadcb672..fa711fb634 100644 --- a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h +++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h @@ -43,6 +43,7 @@ public: private: explicit PerformanceTiming(HTML::Window&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<HTML::Window> m_window; diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp index 9fa2c62674..b0d6fb123d 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp @@ -21,7 +21,12 @@ IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout) : PlatformObject(realm) , m_did_timeout(did_timeout) { - set_prototype(&Bindings::cached_web_prototype(realm, "IdleDeadline")); +} + +void IdleDeadline::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::IdleDeadlinePrototype>(realm, "IdleDeadline")); } IdleDeadline::~IdleDeadline() = default; diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h index 23d546889b..d703a9c620 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h @@ -24,6 +24,8 @@ public: private: IdleDeadline(JS::Realm&, bool did_timeout); + virtual void initialize(JS::Realm&) override; + bool m_did_timeout { false }; }; diff --git a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp index 638ed78934..0112c34fd6 100644 --- a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp +++ b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp @@ -21,11 +21,16 @@ JS::NonnullGCPtr<ResizeObserver> ResizeObserver::construct_impl(JS::Realm& realm ResizeObserver::ResizeObserver(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "ResizeObserver")); } ResizeObserver::~ResizeObserver() = default; +void ResizeObserver::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ResizeObserverPrototype>(realm, "ResizeObserver")); +} + // https://drafts.csswg.org/resize-observer/#dom-resizeobserver-observe void ResizeObserver::observe(DOM::Element& target, ResizeObserverOptions options) { diff --git a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h index 591ed454cd..a9cd4aa3cf 100644 --- a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h +++ b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h @@ -29,6 +29,8 @@ public: private: explicit ResizeObserver(JS::Realm&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index cb0e635aad..124e2ed960 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -19,14 +19,18 @@ SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLengt , m_base_val(move(base_val)) , m_anim_val(move(anim_val)) { - set_prototype(&Bindings::cached_web_prototype(realm, "SVGAnimatedLength")); - // The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated. VERIFY(m_base_val.ptr() != m_anim_val.ptr()); } SVGAnimatedLength::~SVGAnimatedLength() = default; +void SVGAnimatedLength::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGAnimatedLengthPrototype>(realm, "SVGAnimatedLength")); +} + void SVGAnimatedLength::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h index 452d8b65e7..cb96977d03 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h @@ -25,6 +25,7 @@ public: private: SVGAnimatedLength(JS::Realm&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<SVGLength> m_base_val; diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index 886f8f2320..cb7ca7177b 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -14,7 +14,12 @@ namespace Web::SVG { SVGCircleElement::SVGCircleElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGCircleElement")); +} + +void SVGCircleElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGCircleElementPrototype>(realm, "SVGCircleElement")); } void SVGCircleElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h index d51459a202..376002299c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h @@ -28,6 +28,8 @@ public: private: SVGCircleElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Optional<Gfx::Path> m_path; Optional<float> m_center_x; diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index c7127dff91..4ded39d8c9 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -12,13 +12,18 @@ namespace Web::SVG { SVGClipPathElement::SVGClipPathElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGClipPathElement")); } SVGClipPathElement::~SVGClipPathElement() { } +void SVGClipPathElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGClipPathElementPrototype>(realm, "SVGClipPathElement")); +} + JS::GCPtr<Layout::Node> SVGClipPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>) { return nullptr; diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h index 36712c18b4..e5d562eba6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h @@ -20,6 +20,8 @@ public: private: SVGClipPathElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp index 86e7d87ff0..1403ed8380 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp @@ -12,13 +12,18 @@ namespace Web::SVG { SVGDefsElement::SVGDefsElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGraphicsElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGDefsElement")); } SVGDefsElement::~SVGDefsElement() { } +void SVGDefsElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGDefsElementPrototype>(realm, "SVGDefsElement")); +} + JS::GCPtr<Layout::Node> SVGDefsElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>) { return nullptr; diff --git a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h index ddb2eeb437..a875239cca 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h @@ -20,6 +20,8 @@ public: private: SVGDefsElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index 10c1a2e10c..6fd8c1c605 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -14,7 +14,12 @@ SVGElement::SVGElement(DOM::Document& document, DOM::QualifiedName qualified_nam : Element(document, move(qualified_name)) , m_dataset(HTML::DOMStringMap::create(*this)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGElement")); +} + +void SVGElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGElementPrototype>(realm, "SVGElement")); } void SVGElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGElement.h index 8752f71961..5cfca6517f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.h @@ -22,6 +22,7 @@ public: protected: SVGElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<HTML::DOMStringMap> m_dataset; diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index ae17c54d03..d062616c6a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -14,7 +14,12 @@ namespace Web::SVG { SVGEllipseElement::SVGEllipseElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGEllipseElement")); +} + +void SVGEllipseElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGEllipseElementPrototype>(realm, "SVGEllipseElement")); } void SVGEllipseElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h index 4ed5d584f5..72e179896e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h @@ -29,6 +29,8 @@ public: private: SVGEllipseElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Optional<Gfx::Path> m_path; Optional<float> m_center_x; diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index 75bd7a2c00..d2297e9730 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -17,7 +17,6 @@ namespace Web::SVG { SVGForeignObjectElement::SVGForeignObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGraphicsElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGForeignObjectElement")); } SVGForeignObjectElement::~SVGForeignObjectElement() = default; @@ -25,6 +24,7 @@ SVGForeignObjectElement::~SVGForeignObjectElement() = default; void SVGForeignObjectElement::initialize(JS::Realm& realm) { Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGForeignObjectElementPrototype>(realm, "SVGForeignObjectElement")); // FIXME: These never actually get updated! m_x = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 974f966797..6e3979d736 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -13,7 +13,12 @@ namespace Web::SVG { SVGGeometryElement::SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGraphicsElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGGeometryElement")); +} + +void SVGGeometryElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGeometryElementPrototype>(realm, "SVGGeometryElement")); } JS::GCPtr<Layout::Node> SVGGeometryElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h index bf01c92a93..3a32b82e1c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -25,6 +25,8 @@ public: protected: SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index 6479629eb2..9714587c71 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -16,7 +16,12 @@ namespace Web::SVG { SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGGraphicsElement")); +} + +void SVGGraphicsElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGraphicsElementPrototype>(realm, "SVGGraphicsElement")); } void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h index 2ce716ec3a..b62703ca94 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -26,6 +26,8 @@ public: protected: SVGGraphicsElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp index 2a268304ce..ae53ce61e0 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -19,7 +19,12 @@ SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value) , m_unit_type(unit_type) , m_value(value) { - set_prototype(&Bindings::cached_web_prototype(realm, "SVGLength")); +} + +void SVGLength::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLengthPrototype>(realm, "SVGLength")); } SVGLength::~SVGLength() = default; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.h b/Userland/Libraries/LibWeb/SVG/SVGLength.h index afd248ad11..02e129d748 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.h @@ -27,6 +27,8 @@ public: private: SVGLength(JS::Realm&, u8 unit_type, float value); + virtual void initialize(JS::Realm&) override; + u8 m_unit_type { 0 }; float m_value { 0 }; }; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp index 50731211ef..3e79cf16a9 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -14,7 +14,12 @@ namespace Web::SVG { SVGLineElement::SVGLineElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGLineElement")); +} + +void SVGLineElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLineElementPrototype>(realm, "SVGLineElement")); } void SVGLineElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.h b/Userland/Libraries/LibWeb/SVG/SVGLineElement.h index bf28fcc846..01ed6b136c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.h @@ -29,6 +29,8 @@ public: private: SVGLineElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Optional<Gfx::Path> m_path; Optional<float> m_x1; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp index 0616067969..2e30643663 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -87,7 +87,12 @@ namespace Web::SVG { SVGPathElement::SVGPathElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPathElement")); +} + +void SVGPathElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPathElementPrototype>(realm, "SVGPathElement")); } void SVGPathElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h index 7333bd5ad6..93b06bb340 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h @@ -26,6 +26,8 @@ public: private: SVGPathElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Vector<PathInstruction> m_instructions; Optional<Gfx::Path> m_path; }; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp index e4de039957..a17630bae6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp @@ -14,7 +14,12 @@ namespace Web::SVG { SVGPolygonElement::SVGPolygonElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPolygonElement")); +} + +void SVGPolygonElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolygonElementPrototype>(realm, "SVGPolygonElement")); } void SVGPolygonElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h index 017b57b10a..021392c743 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h @@ -23,6 +23,8 @@ public: private: SVGPolygonElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Optional<Gfx::Path> m_path; Vector<Gfx::FloatPoint> m_points; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp index e92d604b97..5275fcd606 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp @@ -14,7 +14,12 @@ namespace Web::SVG { SVGPolylineElement::SVGPolylineElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPolylineElement")); +} + +void SVGPolylineElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolylineElementPrototype>(realm, "SVGPolylineElement")); } void SVGPolylineElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h index 77015550cb..8ad2a9da82 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h @@ -23,6 +23,8 @@ public: private: SVGPolylineElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Optional<Gfx::Path> m_path; Vector<Gfx::FloatPoint> m_points; diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp index 1bd6ce469b..c14c1be515 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -16,7 +16,12 @@ namespace Web::SVG { SVGRectElement::SVGRectElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGeometryElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGRectElement")); +} + +void SVGRectElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRectElementPrototype>(realm, "SVGRectElement")); } void SVGRectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h index 6b079a3f05..eea648ae1d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h @@ -31,6 +31,8 @@ public: private: SVGRectElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + Gfx::FloatPoint calculate_used_corner_radius_values(); Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 256e3c0be8..cf1caff20a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -20,7 +20,12 @@ namespace Web::SVG { SVGSVGElement::SVGSVGElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGraphicsElement(document, qualified_name) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGSVGElement")); +} + +void SVGSVGElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGSVGElementPrototype>(realm, "SVGSVGElement")); } JS::GCPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h index 05fae1059e..7834df2154 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -28,6 +28,8 @@ public: private: SVGSVGElement(DOM::Document&, DOM::QualifiedName); + virtual void initialize(JS::Realm&) override; + virtual bool is_svg_svg_element() const override { return true; } virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp index 11086090b7..1cb956395f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp @@ -15,7 +15,12 @@ namespace Web::SVG { SVGTextContentElement::SVGTextContentElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGraphicsElement(document, move(qualified_name)) { - set_prototype(&Bindings::cached_web_prototype(realm(), "SVGTextContentElement")); +} + +void SVGTextContentElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTextContentElementPrototype>(realm, "SVGTextContentElement")); } // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h index 74ded56554..719ee102f3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h @@ -20,6 +20,8 @@ public: protected: SVGTextContentElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 34f225374e..f3ba361965 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -20,11 +20,16 @@ Selection::Selection(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Do : PlatformObject(realm) , m_document(document) { - set_prototype(&Bindings::cached_web_prototype(realm, "Selection")); } Selection::~Selection() = default; +void Selection::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::SelectionPrototype>(realm, "Selection")); +} + // https://w3c.github.io/selection-api/#dfn-empty bool Selection::is_empty() const { diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h index db75a876c9..81fb7dd16f 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.h +++ b/Userland/Libraries/LibWeb/Selection/Selection.h @@ -55,6 +55,7 @@ private: [[nodiscard]] bool is_empty() const; + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://w3c.github.io/selection-api/#dfn-empty diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp index 1b555abf71..ae898e4c5b 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -20,11 +20,16 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::construct_ ReadableStream::ReadableStream(JS::Realm& realm) : PlatformObject(realm) { - set_prototype(&Bindings::cached_web_prototype(realm, "ReadableStream")); } ReadableStream::~ReadableStream() = default; +void ReadableStream::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ReadableStreamPrototype>(realm, "ReadableStream")); +} + void ReadableStream::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.h b/Userland/Libraries/LibWeb/Streams/ReadableStream.h index 0d2bcde685..f8db6d1c56 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.h +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.h @@ -41,6 +41,7 @@ public: private: explicit ReadableStream(JS::Realm&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://streams.spec.whatwg.org/#readablestream-controller diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp index 30c1deeb50..3799d472eb 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp @@ -17,10 +17,15 @@ FocusEvent* FocusEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString con FocusEvent::FocusEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, FocusEventInit const& event_init) : UIEvent(realm, event_name) { - set_prototype(&Bindings::cached_web_prototype(realm, "FocusEvent")); set_related_target(const_cast<DOM::EventTarget*>(event_init.related_target.ptr())); } FocusEvent::~FocusEvent() = default; +void FocusEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::FocusEventPrototype>(realm, "FocusEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h index 255fba7c80..f11b84918b 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h @@ -24,6 +24,8 @@ public: private: FocusEvent(JS::Realm&, DeprecatedFlyString const& event_name, FocusEventInit const&); + + virtual void initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp index 32df18d397..7bc89ddbb6 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp @@ -128,9 +128,14 @@ KeyboardEvent::KeyboardEvent(JS::Realm& realm, DeprecatedFlyString const& event_ , m_key_code(event_init.key_code) , m_char_code(event_init.char_code) { - set_prototype(&Bindings::cached_web_prototype(realm, "KeyboardEvent")); } KeyboardEvent::~KeyboardEvent() = default; +void KeyboardEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::KeyboardEventPrototype>(realm, "KeyboardEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h index c63cd7e192..0ce603b9e5 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h @@ -56,6 +56,8 @@ public: private: KeyboardEvent(JS::Realm&, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + DeprecatedString m_key; DeprecatedString m_code; u32 m_location { 0 }; diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index d528c8dd68..2c4138f4fd 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -24,12 +24,17 @@ MouseEvent::MouseEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, , m_button(event_init.button) , m_buttons(event_init.buttons) { - set_prototype(&Bindings::cached_web_prototype(realm, "MouseEvent")); set_event_characteristics(); } MouseEvent::~MouseEvent() = default; +void MouseEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::MouseEventPrototype>(realm, "MouseEvent")); +} + // https://www.w3.org/TR/uievents/#dom-mouseevent-button static i16 determine_button(unsigned mouse_button) { diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 7cbce9c953..03d0f1b8bd 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -58,6 +58,8 @@ public: protected: MouseEvent(JS::Realm&, DeprecatedFlyString const& event_name, MouseEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + private: void set_event_characteristics(); diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp index f97f07fb16..e5781a8422 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp @@ -22,7 +22,6 @@ UIEvent* UIEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& ev UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name) : Event(realm, event_name) { - set_prototype(&Bindings::cached_web_prototype(realm, "UIEvent")); } UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEventInit const& event_init) @@ -30,11 +29,16 @@ UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEven , m_view(event_init.view) , m_detail(event_init.detail) { - set_prototype(&Bindings::cached_web_prototype(realm, "UIEvent")); } UIEvent::~UIEvent() = default; +void UIEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::UIEventPrototype>(realm, "UIEvent")); +} + void UIEvent::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h index 874a9d9399..97e7b1cd84 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h @@ -41,6 +41,7 @@ protected: UIEvent(JS::Realm&, DeprecatedFlyString const& event_name); UIEvent(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<HTML::Window> m_view; diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp index d8d92f503b..46152ce8dd 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp @@ -17,12 +17,17 @@ WheelEvent::WheelEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, , m_delta_y(event_init.delta_y) , m_delta_mode(event_init.delta_mode) { - set_prototype(&Bindings::cached_web_prototype(realm, "WheelEvent")); set_event_characteristics(); } WheelEvent::~WheelEvent() = default; +void WheelEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::WheelEventPrototype>(realm, "WheelEvent")); +} + WheelEvent* WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init) { return realm.heap().allocate<WheelEvent>(realm, realm, event_name, event_init); diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h index f3f65eae67..43a3c80f61 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h @@ -42,6 +42,8 @@ public: private: WheelEvent(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + void set_event_characteristics(); double m_delta_x { 0 }; diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index c52a3b4921..49cfc3f906 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -57,11 +57,16 @@ URL::URL(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query) , m_url(move(url)) , m_query(move(query)) { - set_prototype(&Bindings::cached_web_prototype(realm, "URL")); } URL::~URL() = default; +void URL::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::URLPrototype>(realm, "URL")); +} + void URL::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/URL/URL.h b/Userland/Libraries/LibWeb/URL/URL.h index 718ebf09ea..d691f0ec08 100644 --- a/Userland/Libraries/LibWeb/URL/URL.h +++ b/Userland/Libraries/LibWeb/URL/URL.h @@ -65,6 +65,7 @@ public: private: URL(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; AK::URL m_url; diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index f5766c6337..ddf08690a6 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -17,11 +17,16 @@ URLSearchParams::URLSearchParams(JS::Realm& realm, Vector<QueryParam> list) : PlatformObject(realm) , m_list(move(list)) { - set_prototype(&Bindings::cached_web_prototype(realm, "URLSearchParams")); } URLSearchParams::~URLSearchParams() = default; +void URLSearchParams::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::URLSearchParamsPrototype>(realm, "URLSearchParams")); +} + void URLSearchParams::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h index 02f5fb708e..9456c83030 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h @@ -48,6 +48,7 @@ private: URLSearchParams(JS::Realm&, Vector<QueryParam> list); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; void update(); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp index 6b289fe2c1..66ebc57ee9 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp @@ -33,11 +33,16 @@ URLSearchParamsIterator::URLSearchParamsIterator(URLSearchParams const& url_sear , m_url_search_params(url_search_params) , m_iteration_kind(iteration_kind) { - set_prototype(&Bindings::ensure_web_prototype<Bindings::URLSearchParamsIteratorPrototype>(url_search_params.realm(), "URLSearchParamsIterator")); } URLSearchParamsIterator::~URLSearchParamsIterator() = default; +void URLSearchParamsIterator::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::URLSearchParamsIteratorPrototype>(realm, "URLSearchParamsIterator")); +} + void URLSearchParamsIterator::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h index 84fc9373c7..7a2714d22a 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h @@ -24,6 +24,7 @@ public: private: URLSearchParamsIterator(URLSearchParams const&, JS::Object::PropertyKind iteration_kind); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; URLSearchParams const& m_url_search_params; diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp index 983899ad8b..54d850fc61 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp @@ -23,9 +23,14 @@ WebGLContextEvent::WebGLContextEvent(JS::Realm& realm, DeprecatedFlyString const : DOM::Event(realm, type, event_init) , m_status_message(event_init.status_message) { - set_prototype(&Bindings::cached_web_prototype(realm, "WebGLContextEvent")); } WebGLContextEvent::~WebGLContextEvent() = default; +void WebGLContextEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::WebGLContextEventPrototype>(realm, "WebGLContextEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h index 23cd69d0fd..a42fb8f224 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h @@ -29,6 +29,8 @@ public: private: WebGLContextEvent(JS::Realm&, DeprecatedFlyString const& type, WebGLContextEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + DeprecatedString m_status_message { DeprecatedString::empty() }; }; diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 54557345b8..44d7fb1bd3 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -52,9 +52,14 @@ JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> WebGLRenderingContext::c WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters) : WebGLRenderingContextBase(realm, canvas_element, move(context), move(context_creation_parameters), move(actual_context_parameters)) { - set_prototype(&Bindings::cached_web_prototype(realm, "WebGLRenderingContext")); } WebGLRenderingContext::~WebGLRenderingContext() = default; +void WebGLRenderingContext::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::WebGLRenderingContextPrototype>(realm, "WebGLRenderingContext")); +} + } diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h index d864e5dc00..b31a6742ee 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h @@ -21,6 +21,8 @@ public: virtual ~WebGLRenderingContext() override; private: + virtual void initialize(JS::Realm&) override; + WebGLRenderingContext(JS::Realm&, HTML::HTMLCanvasElement&, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters); }; diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp index 49709af9a5..baaeac3a3f 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp @@ -24,9 +24,14 @@ DOMException::DOMException(JS::Realm& realm, DeprecatedFlyString const& name, De , m_name(name) , m_message(message) { - set_prototype(&Bindings::cached_web_prototype(realm, "DOMException")); } DOMException::~DOMException() = default; +void DOMException::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMExceptionPrototype>(realm, "DOMException")); +} + } diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.h b/Userland/Libraries/LibWeb/WebIDL/DOMException.h index 38b86efc24..2e92283d94 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.h +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.h @@ -109,6 +109,8 @@ public: protected: DOMException(JS::Realm&, DeprecatedFlyString const& name, DeprecatedFlyString const& message); + virtual void initialize(JS::Realm&) override; + private: DeprecatedFlyString m_name; DeprecatedFlyString m_message; diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index e8abf405d6..c9f1284666 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -64,8 +64,6 @@ WebSocket::WebSocket(HTML::Window& window, AK::URL& url) : EventTarget(window.realm()) , m_window(window) { - set_prototype(&Bindings::cached_web_prototype(window.realm(), "WebSocket")); - // FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake auto origin_string = m_window->associated_document().origin().serialize(); m_websocket = WebSocketClientManager::the().connect(url, origin_string); @@ -97,6 +95,12 @@ WebSocket::WebSocket(HTML::Window& window, AK::URL& url) WebSocket::~WebSocket() = default; +void WebSocket::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::WebSocketPrototype>(realm, "WebSocket")); +} + void WebSocket::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h index d931c5a810..59e8738945 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h @@ -68,6 +68,7 @@ private: WebSocket(HTML::Window&, AK::URL&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<HTML::Window> m_window; diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp index d26f53cce2..f8332a2556 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp @@ -25,9 +25,14 @@ ProgressEvent::ProgressEvent(JS::Realm& realm, DeprecatedFlyString const& event_ , m_loaded(event_init.loaded) , m_total(event_init.total) { - set_prototype(&Bindings::cached_web_prototype(realm, "ProgressEvent")); } ProgressEvent::~ProgressEvent() = default; +void ProgressEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ProgressEventPrototype>(realm, "ProgressEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h index 3ef9daf643..abc7305fa9 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h @@ -35,6 +35,8 @@ public: private: ProgressEvent(JS::Realm&, DeprecatedFlyString const& event_name, ProgressEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + bool m_length_computable { false }; u64 m_loaded { 0 }; u64 m_total { 0 }; diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 888a61ac5a..eda2f78fbe 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -55,11 +55,16 @@ XMLHttpRequest::XMLHttpRequest(HTML::Window& window, Fetch::Infrastructure::Head , m_response_type(Bindings::XMLHttpRequestResponseType::Empty) { set_overrides_must_survive_garbage_collection(true); - set_prototype(&Bindings::cached_web_prototype(window.realm(), "XMLHttpRequest")); } XMLHttpRequest::~XMLHttpRequest() = default; +void XMLHttpRequest::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::XMLHttpRequestPrototype>(realm, "XMLHttpRequest")); +} + void XMLHttpRequest::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 8c5eb38fff..ca29cede33 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -72,6 +72,7 @@ public: void abort(); private: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual bool must_survive_garbage_collection() const override; |