mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
This commit is contained in:
@@ -15,6 +15,7 @@ namespace Web::Encoding {
|
||||
JS::Uint8Array* TextEncoder::encode(String const& input) const
|
||||
{
|
||||
auto& global_object = wrapper()->global_object();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
|
||||
// NOTE: The AK::String returned from PrimitiveString::string() is always UTF-8, regardless of the internal string type, so most of these steps are no-ops.
|
||||
|
||||
@@ -28,8 +29,8 @@ JS::Uint8Array* TextEncoder::encode(String const& input) const
|
||||
|
||||
auto byte_buffer = input.to_byte_buffer();
|
||||
auto array_length = byte_buffer.size();
|
||||
auto* array_buffer = JS::ArrayBuffer::create(global_object, move(byte_buffer));
|
||||
return JS::Uint8Array::create(global_object, array_length, *array_buffer);
|
||||
auto* array_buffer = JS::ArrayBuffer::create(realm, move(byte_buffer));
|
||||
return JS::Uint8Array::create(realm, array_length, *array_buffer);
|
||||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encoding
|
||||
|
||||
Reference in New Issue
Block a user