mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
This commit is contained in:
parent
7bd8fd000f
commit
834202aeb9
339 changed files with 1294 additions and 187 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
protected:
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder
|
||||
explicit TextEncoder(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue