Commit graph

19 commits

Author SHA1 Message Date
Linus Groh
b345a0acca LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm()
- Prefer VM::heap() over GlobalObject::heap()
- Prefer Cell::vm() over Cell::global_object()
- Prefer Wrapper::vm() over Wrapper::global_object()
- Inline Realm::global_object() calls used to access intrinsics as they
  will later perform a direct lookup without going through the global
  object
2022-08-23 13:58:30 +01:00
Linus Groh
40a70461a0 LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to
warrant passing a Realm directly instead of relying on the current realm
from the VM, as a wrapper may need to be allocated while no JS is being
executed.
2022-08-23 13:58:30 +01:00
Linus Groh
b99cc7d050 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.
2022-08-23 13:58:30 +01:00
Kenneth Myhra
1e5d107649 LibWeb: Declare variable with the auto keyword
Use the auto keyword instead of the full type name like we do elsewhere
in the codebase.
2022-08-02 08:20:40 +01:00
Kenneth Myhra
c8c5f05de5 LibWeb: Make sure Blob type is not outside range 0x0020-0x007E
This makes sure that type is set to an empty string if
BlobPropertyBag::type is outside the range 0x0020 to 0x007E.
2022-08-02 08:20:40 +01:00
Kenneth Myhra
73aec263b1 LibWeb: Move is_basic_latin() to Blob.{cpp,h}
This method needs to be accessible from both Blob and File.
2022-08-02 08:20:40 +01:00
Kenneth Myhra
bbd9490683 LibWeb: Handle endings member of options being "native"
This patch passes the options argument to process_blob_parts() and makes
use of the "convert line endings to native" algorithm when the endings
member of options (BlobPropertyBag) is set to "native".
2022-07-30 10:59:46 +01:00
Kenneth Myhra
516ea4d758 LibWeb: Implement "convert line endings to native" algorithm
This adds the "convert line endings to native" algorithm from the
FileAPI spec.
2022-07-30 10:59:46 +01:00
Kenneth Myhra
890514a057 LibWeb: Introduce the File interface from the FileAPI spec 2022-07-26 20:54:30 +01:00
Kenneth Myhra
df91dbfbb6 LibWeb: Add missing spec links to the Blob interface 2022-07-26 20:54:30 +01:00
Kenneth Myhra
6305ef197f LibWeb: Fix const issue on type() accessor for the Blob interface 2022-07-26 20:54:30 +01:00
Kenneth Myhra
c038a8c9c9 LibWeb: Make process_blob_parts() publicly accessible
This pulls process_blob_parts() out of the Blob class and makes it
publicly accessible.
2022-07-26 20:54:30 +01:00
Kenneth Myhra
622a4f29a7 LibWeb: Add public get accessor function for Blob's internal ByteBuffer
Blob::bytes() returns the ReadonlyBytes representation of our internal
ByteBuffer.

This change requires us to ByteBuffer::copy() Blob's ReadonlyBytes to a
ByteBuffer in XHR::send() and corresponding error handling of the copy
operation.

This removes the need for Blob to declare XMLHttpRequest as a friend
class.
2022-07-26 20:54:30 +01:00
Kenneth Myhra
9fe12c1851 LibWeb: Let get_buffer_source_copy() return ErrorOr instead of Optional
This is a minor refactor of IDL::get_buffer_source_copy() letting it
return ErrorOr<ByteBuffer> instead of Optional<ByteBuffer>.

This also updates all places that use IDL::get_buffer_source_copy().
2022-07-22 23:08:28 +01:00
Kenneth Myhra
9b3da5a142 LibWeb: Move extract_body() towards spec compliance 2022-07-18 14:57:58 +01:00
Linus Groh
bc68539e26 LibWeb: Add & use TRY_OR_RETURN_OOM macro
This is a convenient way to return a DOM exception for operations that
return ErrorOr and only have an OOM failure path.
2022-07-17 21:08:10 +01:00
Linus Groh
ac36d272d3 LibWeb: Avoid needless copies during Blob construction 2022-07-17 00:34:25 +01:00
Kenneth Myhra
5806eeec08 LibWeb: Add support for XHR response type Blob 2022-07-17 00:23:19 +01:00
Kenneth Myhra
df8c49f6bf LibWeb: Introduce Blob 2022-07-17 00:23:19 +01:00