Commit graph

33 commits

Author SHA1 Message Date
Timothy Flynn
6dd2a4c945 LibWeb: Do not create a RootVector to invoke IDL callbacks
These callbacks are evaluated synchronously via JS::Call. We do not need
to construct an expensive RootVector container just to immediately
invoke the callbacks.

Stylistically, this also helps indicate where the actual arguments start
at the call sites, by wrapping the arguments in braces.
2025-04-16 07:32:02 -04:00
Timothy Flynn
525343ba79 LibWeb: Add an alternative to WebIDL::invoke_callback to return promises
When we need the callback to return a promise, we can use this alternate
invoker to construct the WebIDL::Promise for us. Currently, the Streams
API will use WebIDL::invoke_callback to create a JS::Promise, and then
wrap that result in a resolved WebIDL::Promise. This results in rejected
JS::Promise instances not being propagated.
2025-04-15 20:33:30 -04:00
Timothy Flynn
c0ead1b01a LibIDL+LibWeb: Begin support for async iterator in IDL
This adds support for async iterators of the form:

    async iterable<value_type>;
    async iterable<value_type>(/* arguments... */);

It does not yet support the value pairs of the form:

    async iterable<key_type, value_type>;
    async iterable<key_type, value_type>(/* arguments... */);

Async iterators have an optional `return` data property. There's not a
particularly good way to know what interfaces implement this property.
So this adds a new extended attribute, DefinesAsyncIteratorReturn, which
interfaces can use to declare their support.
2025-04-14 17:43:11 -04:00
Timothy Flynn
eb0a51faf0 LibWeb: Implement ReadableStreamPipeTo according to spec
Our existing implementation of stream piping was extremely ad-hoc. It
did nothing to handle closed/errored streams, and did not read from or
write to streams in a way required by the spec.

This new implementation uses a custom JS::Cell to drive the read/write
loop.
2025-04-11 12:10:46 -04:00
Timothy Flynn
f7c095a318 LibWeb: Implement an AO to get a promise to wait for promises to settle 2025-04-11 12:10:46 -04:00
Andreas Kling
de424d6879 LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused.
This avoids a whole bunch of presence checks.
2025-04-05 11:20:26 +02:00
Andreas Kling
46a5710238 LibJS: Use FlyString in PropertyKey instead of DeprecatedFlyString
This required dealing with *substantial* fallout.
2025-03-24 22:27:17 +00:00
Andreas Kling
53da8893ac LibJS: Replace PropertyKey(char[]) with PropertyKey(FlyString)
...and deal with the fallout.
2025-03-24 22:27:17 +00:00
Andreas Kling
d7908dbff5 LibJS: Change PropertyKey(ByteString) to PropertyKey(String)
...and deal with the fallout.
2025-03-24 22:27:17 +00:00
devgianlu
cfeb916e61 LibWeb: Remove unused underlying_buffer_source function
This function is not used anywhere and will most likely end up causing
problems so just remove it.
2025-03-19 13:46:50 +01:00
stelar7
a0b252c0dd LibWeb/IDB: Update convert_a_value_to_a_key to latest changes 2025-03-13 11:23:15 +01:00
Tim Ledbetter
6d7b7e7822 LibWeb: Use as to cast global object to WindowOrWorkerGlobalScopeMixin
No functional changes.
2025-02-02 17:18:56 +01:00
Tim Ledbetter
15fe8e7906 LibWeb: Add formatters for WebIDL exception types
This adds formatters for `WebIDL::Exception`, `WebIDL::SimpleException`
and `WebIDL::DOMException`. These are useful for displaying the content
of errors when debugging.
2025-01-23 21:39:02 +01:00
Luke Wilde
3ab93667f5 LibWeb: Respect subarrays in TextEncoder::encode_into
This is the method that Figma uses to write strings into Wasm memory,
using subarrays to select a particular Wasm memory address to write to.
2025-01-21 21:36:05 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Aliaksandr Kalenik
cf57efd252 LibWeb: Unload fonts when adopted style sheet is removed
Add missing unloading step that we do for regular style sheets but
mistakenly missed for adopted style sheets.
2025-01-10 19:12:48 +03:00
Luke Wilde
b6bc5912d6 LibWeb/WebGL: Implement tex(Sub)Image2D with TexImageSource 2025-01-08 17:55:17 +03:00
Luke Wilde
18ea91715b LibWeb/WebGL2: Implement bufferData with offset and length 2025-01-08 17:55:17 +03:00
Shannon Booth
3d3c1d8bf7 LibWeb/WebIDL: Implement 'write' operation for ArrayBufferView 2024-12-27 06:56:38 -08:00
Andreas Kling
3bfb0534be LibGC: Rename MarkedVector => RootVector
Let's try to make it a bit more clear that this is a Vector of GC roots.
2024-12-26 19:10:44 +01:00
Tim Ledbetter
1f57df34f1 LibWeb: Update WebIDL::invoke_callback() to follow the latest spec
`WebIDL::invoke_callback()` now takes an `exception_behavior`
parameter, which can be set to `report` to report an exception before
returning. Setting `exception_behavior` to `rethrow` retains the
previous behavior.
2024-12-19 15:25:08 +00:00
Shannon Booth
99073c0561 LibWeb: Move ad hoc CallbackType helper method to CallbackType header
Abstract operations of a stream does not seem like the correct home for
this function.
2024-12-11 15:11:21 +01:00
Timothy Flynn
520bf6c9be LibWeb: Return a better error message for invalid byte strings
We are currently returning LibJS's invalid code point message, but not
formatting it with the bad value. So we get something like:

    Unhandled JavaScript exception: [TypeError] Invalid code point {},
    must be an integer no less than 0 and no greater than 0x10FFFF

So not only is the error unformatted, but it's inaccurate; in this case,
the byte cannot be larger than 255.
2024-12-10 10:30:14 -08:00
Jelle Raaijmakers
1514197e36 LibWeb: Remove dom_ from dom_exception_to_throw_completion
We're not converting `WebIDL::DOMException`, but `WebIDL::Exception`
instead.
2024-12-09 20:02:51 -07:00
Sam Atkins
0168ee22ad LibWeb: Redefine WebIDL types in terms of Infra spec
Corresponds to https://github.com/whatwg/webidl/pull/1452
2024-12-05 17:34:13 +01:00
Kenneth Myhra
4c5019f89c LibWeb: Add serialization and deserilization steps to DOMException
This makes DOMException a Serializable object.
2024-11-24 11:11:44 +01:00
Shannon Booth
3fffd1129c LibWeb: Implement overload resolution for sequence types
Fixes: #2508
2024-11-23 02:38:21 +00:00
Tim Ledbetter
19a5780f0c IDLGenerators: Throw TypeError if IDL ByteString contains element > 255 2024-11-21 15:49:48 -05:00
Shannon Booth
d6bcd3fb0b LibWeb: Make CallbackType take a realm instead of settings object
In line with the ShadowRealm proposal changes in the WebIDL spec:
webidl#1437 and supporting changes in HTML spec.

This is required for ShadowRealms as they have no relevant settings
object on the shadow realm, so fixes a crash in the QueueingStrategy
test in this commit.
2024-11-20 18:01:21 -07:00
Timothy Flynn
c0da3e356a LibWeb: Add a couple ad-hoc BufferSource AOs
These helpers will be used by CompressionStream/DecompressionStream.
2024-11-17 22:37:45 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Shannon Booth
9b79a686eb LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>
The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.

As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.
2024-11-13 16:51:44 -05:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00