Commit graph

183 commits

Author SHA1 Message Date
Andreas Kling
c0d7f748ed LibWeb: Avoid FlyString lookups when setting IDL interface prototypes
This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
2024-03-16 16:35:54 +01:00
Sam Atkins
4bdb7dba8c LibWeb: Add and use a helper to reject a promise with an exception 2024-03-08 14:14:57 -05:00
Timothy Flynn
6656f70387 LibWeb: Use TypedArray as a forward-declaration where appropriate
This reduces the number of files needed to be recompiled when TypedArray
changes from ~1000 to ~600. The remaining ~600 are almost all generated
constructors and prototypes.
2024-02-27 20:02:07 +01:00
Timothy Flynn
5a99a6afb4 LibWeb: Implement ReadableStreamBYOBRequest.respondWithNewView
The AO behind this prototype was added in commit ed1076d9ca,
so we can now trivially expose the prototype as well.
2024-01-29 17:10:56 -05:00
Timothy Flynn
3c11a1551d LibWeb: Add missing spec link to ReadableStreamBYOBRequest::respond 2024-01-29 17:10:56 -05:00
Timothy Flynn
6981ddfe13 LibWeb: Implement the ReadableByteStreamTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn
d7612969e0 LibWeb: Invoke the correct Streams BYOB AOs when in a closed state 2024-01-29 07:21:59 +01:00
Timothy Flynn
ed1076d9ca LibWeb: Implement the ReadableByteStreamControllerRespondWithNewView AO 2024-01-29 07:21:59 +01:00
Timothy Flynn
5e5b42730c LibWeb: Implement the CloneAsUint8Array AO 2024-01-29 07:21:59 +01:00
Timothy Flynn
debfe996d7 LibWeb: Implement the ReadableStreamDefaultTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn
d8413774df LibWeb: Expose the ReadableStream tee IDL interface
This just sets up the plumbing to the underlying ReadableStreamTee AO,
which as of this commit, will just throw a NotImplemented exception.
2024-01-29 07:21:59 +01:00
Timothy Flynn
5ccd1ff1bf LibWeb: Implement the StructuredClone AO 2024-01-29 07:21:59 +01:00
Shannon Booth
eaf9a56c10 LibWeb: Actually clear stream controller algorithms when needed
Now that these algorithms are a HeapFunction as opposed to SafeFunction,
the problem mentioned in the FIXME is no longer applicable as these
functions are GC-allocated like everything else.
2024-01-27 21:40:25 -05:00
Shannon Booth
5f484d200a LibWeb: Port Stream algorithms from JS::SafeFunction to JS::HeapFunction 2024-01-27 21:40:25 -05:00
Timothy Flynn
c8c3866101 LibWeb: Implement the CreateReadableByteStream AO 2024-01-27 16:01:56 +01:00
Shannon Booth
7067c5c972 LibWeb: Port TypeError in UnderlyingSource from ByteString 2024-01-02 10:01:26 +01:00
Shannon Booth
6b88fc2e05 LibWeb: Properly convert UnderlyingSource's autoAllocateChunkSize to u64
The JS::Value being passed through is not a bigint, and needs to be
converted using ConvertToInt, as per:

https://webidl.spec.whatwg.org/#es-unsigned-long-long

Furthermore, the IDL definition also specifies that this is associated
with the [EnforceRange] extended attribute.

This makes it actually possible to pass through an autoAllocateChunkSize
to the ReadableStream constructor without it throwing a TypeError.
2024-01-02 10:01:26 +01:00
Shannon Booth
99bf986889 LibWeb: Use unsigned long long for ReadableStreamBYOBRequest.respond
Now that the IDL generator supports this :^)
2024-01-02 10:01:26 +01:00
Timothy Flynn
9258d7b98a LibJS+LibWeb: Implement resizable ArrayBuffer support for TypedArray
This is (part of) a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/a9ae96e
2023-12-26 11:16:10 +01:00
Andrew Kaster
d361221657 LibJS+LibWeb: Add JS::Value constructor for `JS::Handle<T>`
Similar to the constructors for ``JS::{Nonnull}GCPtr<T>``, this helper
avoids unnecessary .ptr() clutter when we want to construct Values.
2023-12-19 09:21:55 -07:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Aliaksandr Kalenik
6ac43274b2 LibWeb+LibJS: Use JS::GCPtr for pointers to GC-allocated objects
Fixes warnings found by LibJSGCVerifier
2023-12-11 16:55:25 +01:00
Shannon Booth
48aa9fbe07 LibWeb: Implement ReadableByteStreamController.enqueue 2023-12-03 20:26:14 +01:00
Shannon Booth
feb7fbb95d LibWeb: Implement ReadableStreamBYOBRequest.respond
The parameter in IDL is left as an unsigned long instead of an unsigned
long long as the IDL generator does not currently support that.
2023-12-03 20:26:14 +01:00
Shannon Booth
08be5deb3f LibWeb: Implement AO ReadableByteStreamControllerRespond 2023-12-03 20:26:14 +01:00
Shannon Booth
2ab933e534 LibWeb: Implement AO ReadableByteStreamControllerRespondInternal 2023-12-03 20:26:14 +01:00
Shannon Booth
426cbd8ed3 LibWeb: Implement AO ReadableByteStreamControllerRespondInClosedState 2023-12-03 20:26:14 +01:00
Shannon Booth
be2195cb8c LibWeb: Implement AO ReadableByteStreamControllerRespondInReadableState 2023-12-03 20:26:14 +01:00
Shannon Booth
0245be70d8 LibWeb: Implement Streams AO CanTransferArrayBuffer 2023-12-03 20:26:14 +01:00
Shannon Booth
9d0700e770 LibWeb: Fix IDL getter for ReadableByteStreamController byobRequest
We were previously only returning the controllers current
[[byobRequest]] instead of taking into account pending pull intos.

Rename the getter function which would return the controllers
[[byobRequest]] slot to `raw_byob_request` to differentiate it from
the IDL getter.

This also leaves a FIXME for a spec step which we are also not currently
implementing correctly.
2023-12-03 20:26:14 +01:00
Shannon Booth
1e607f5775 LibWeb: Fix some missing initialize overrides for some Streams classes
This is some more motivation for me to get around to automatically
generate these initialize calls at some point.
2023-12-03 20:26:14 +01:00
Shannon Booth
b2a0a41503 LibWeb: Use TypedArrayBase::kind for pull into constructor lookup 2023-12-03 20:26:14 +01:00
Shannon Booth
a9a3dcd952 LibWeb: Use ArrayBufferView in ReadableStreamBYOBRequest 2023-12-03 20:26:14 +01:00
Shannon Booth
96af80acd1 LibWeb: Port Intrinsics from DeprecatedString 2023-11-28 17:15:27 -05:00
Shannon Booth
673329e1bd LibWeb: Use ArrayBufferView for ReadableStreamBYOBReader
Which means that we now have support for DataViews.

Using the ArrayBufferView class also seems to make this read a whole
bunch nicer as well.
2023-11-24 08:43:35 +01:00
Andreas Kling
bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00
Shannon Booth
1daded768d LibWeb: Implement ReadableStreamBYOBReader::read
Similiarly to the underlying AO's, currently only TypedArrays are
supported.
2023-11-19 18:53:17 +01:00
Shannon Booth
dcb7bb4a92 LibWeb: Support BYOB readers in ReadableByteStreamControllerEnqueue 2023-11-19 18:53:17 +01:00
Shannon Booth
9662872b20 LibWeb: Implement AO ReadableStreamByobReaderRead
We've finally implemented enough of the Streams AOs so that we are close
to actually performing read operations with BYOB readers.
2023-11-19 18:53:17 +01:00
Shannon Booth
3d37cb0753 LibWeb: Partially implement ReadableByteStreamControllerPullInto
This implementation does not handle DataViews at the moment, but should
handle all of the typed arrays.
2023-11-19 18:53:17 +01:00
Shannon Booth
1443715775 LibWeb: Add ReadableBSControllerProcessPullIntoDescriptorsUsingQueue 2023-11-19 18:53:17 +01:00
Shannon Booth
737dc6ce4e LibWeb: Add ReadableByteStreamControllerFillPullIntoDescriptorFromQueue 2023-11-19 18:53:17 +01:00
Shannon Booth
aca63fd947 LibWeb: Implement ReadableByteStreamControllerCommitPullIntoDescriptor 2023-11-19 18:53:17 +01:00
Shannon Booth
cdcc1ebbba LibWeb: Implement ReadableByteStreamControllerFillHeadPullIntoDescriptor 2023-11-19 18:53:17 +01:00
Shannon Booth
8d4095d00e LibWeb: Add some const overloads in ReadableByteStreamController 2023-11-19 18:53:17 +01:00
Shannon Booth
26e393fbbc LibWeb: Implement ReadableByteStreamControllerConvertPullIntoDescriptor 2023-11-19 18:53:17 +01:00
Shannon Booth
25f8b80eab LibWeb: Use move on ByteBuffer in TransferArrayBuffer 2023-11-19 18:53:17 +01:00
Shannon Booth
446a78f30e LibWeb: Implement Streams AO ReadableStreamAddReadIntoRequest
This is effectively identical to ReadableStreamAddReadRequest besides
from the fact that it takes a ReadIntoRequest instead of a ReadRequest,
and is instead intended to be used for BYOB readers.
2023-11-19 18:53:17 +01:00
Shannon Booth
f27e76b0b7 LibWeb: Make ReadableStreamAddReadRequest take a NonnullGCPtr
Make it more obvious in the function signature that this function will
be taking a GC ref to a ReadRequest by appending it to the
ReadableStreams pending read requests.
2023-11-19 18:53:17 +01:00
Shannon Booth
5ef41dca53 LibWeb: Implement Streams AO ReadableStreamFulfillReadIntoRequest 2023-11-19 18:53:17 +01:00