diff options
author | Linus Groh <mail@linusgroh.de> | 2022-08-16 00:20:49 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-23 13:58:30 +0100 |
commit | b99cc7d05039b9386538a581244be5af782c8d05 (patch) | |
tree | 76e012c25d6ecda6dc56b37354dc833bd1a1b9ee /Userland/Libraries/LibWeb/FileAPI | |
parent | 5dd5896588b0e5a7bc7bdadeaa7dd4865f663b79 (diff) | |
download | serenity-b99cc7d05039b9386538a581244be5af782c8d05.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/FileAPI')
-rw-r--r-- | Userland/Libraries/LibWeb/FileAPI/Blob.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index 9487334ce9..4c5f9993c4 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -222,13 +222,14 @@ DOM::ExceptionOr<NonnullRefPtr<Blob>> Blob::slice(Optional<i64> start, Optional< JS::Promise* Blob::text() { auto& global_object = wrapper()->global_object(); + auto& realm = *global_object.associated_realm(); // FIXME: 1. Let stream be the result of calling get stream on this. // FIXME: 2. Let reader be the result of getting a reader from stream. If that threw an exception, return a new promise rejected with that exception. // FIXME: We still need to implement ReadableStream for this step to be fully valid. // 3. Let promise be the result of reading all bytes from stream with reader - auto* promise = JS::Promise::create(global_object); + auto* promise = JS::Promise::create(realm); auto* result = JS::js_string(global_object.heap(), String { m_byte_buffer.bytes() }); // 4. Return the result of transforming promise by a fulfillment handler that returns the result of running UTF-8 decode on its first argument. @@ -240,14 +241,15 @@ JS::Promise* Blob::text() JS::Promise* Blob::array_buffer() { auto& global_object = wrapper()->global_object(); + auto& realm = *global_object.associated_realm(); // FIXME: 1. Let stream be the result of calling get stream on this. // FIXME: 2. Let reader be the result of getting a reader from stream. If that threw an exception, return a new promise rejected with that exception. // FIXME: We still need to implement ReadableStream for this step to be fully valid. // 3. Let promise be the result of reading all bytes from stream with reader. - auto* promise = JS::Promise::create(global_object); - auto buffer_result = JS::ArrayBuffer::create(global_object, m_byte_buffer.size()); + auto* promise = JS::Promise::create(realm); + auto buffer_result = JS::ArrayBuffer::create(realm, m_byte_buffer.size()); if (buffer_result.is_error()) { promise->reject(buffer_result.release_error().value().release_value()); return promise; |