Commit graph

68626 commits

Author SHA1 Message Date
Aliaksandr Kalenik
466c793fdb LibIPC: Use AllocatingMemoryStream in TransportSocket send queue
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Memory stream is a more suitable container for the socket send queue,
as using it results in fewer allocations than trying to emulate a stream
using a Vector.
2025-04-15 18:48:53 +02:00
Aliaksandr Kalenik
247f7c5fcc AK: Add peek_some() to AllocatingMemoryStream
Same as read_some(), but doesn't move read position.
2025-04-15 18:48:53 +02:00
Jelle Raaijmakers
edaac0f2ee CI: Add missing event key to JS benchmarks workflow 2025-04-15 14:23:27 +02:00
Jelle Raaijmakers
1b4a4b0225 CI: Use workflow run's event commit SHA for JS benchmarks
Chaining workflows does not cause the subsequently spawned workflow runs
to use the same event, but rather it uses the latest head SHA based on
the branch it runs on. This would cause the JS benchmarks jobs to not be
able to find artifacts (if a new JS repl workflow was started before the
previous one could finish) and/or assign the wrong commit SHA to the
benchmark results.

Since `github.event` contains information about the original workflow
run that spawned the JS benchmarks jobs, we can take the commit SHA from
there and use it to download the correct artifact.
2025-04-15 13:53:07 +02:00
Sam Atkins
c00c0846c0 LibWeb: Don't double-dispatch click events on a label's child input
If the user clicked directly on the input inside a label, then it
already received a click event. Dispatching a second one via the label
is redundant, and means that if the input is a checkbox, it gets its
value toggled twice.
2025-04-15 12:34:24 +01:00
Andreas Kling
81d4ed27d8 LibJS: Add cache for the string "[object Object]"
This is very frequently returned by Object.prototype.toString(),
so we benefit from caching it instead of recreating it every time.

Takes Speedometer2.1/EmberJS-Debug-TodoMVC from ~4000ms to ~3700ms
on my M3 MacBook Pro.
2025-04-15 13:08:27 +02:00
Andreas Kling
e8c351505e LibJS: Use premade shape when creating unmapped arguments objects
Takes Speedometer2.1/EmberJS-Debug-TodoMVC from ~4500ms to ~4000ms
on my M3 MacBook Pro.
2025-04-15 13:08:27 +02:00
Jelle Raaijmakers
1f81f75add CI: Remove concurrency configuration for JS artifacts and benchmarks
We had concurrency set on the JS artifacts and JS benchmarks workflows
causing them to not run in parallel for the same combination of
(workflow, OS name). You'd expect that this causes a FIFO queue to exist
of the jobs to run sequentially, but in reality GitHub maintains a
single job to prioritize and cancels all others. We don't want that for
our artifacts and benchmarks: we want them to run on each push.

For example, a new push could have workflows getting cancelled because
someone restarted a previously failed workflow, resulting in the
following message:

  "Canceling since a higher priority waiting request for [..] exists"

By removing the concurrency setting from these workflows, we make use of
all available runners to execute the jobs and potentially run some of
them in parallel. For the benchmarks however, we currently only have one
matching self-hosted runner per job, and as such they are still not run
in parallel.
2025-04-15 12:47:45 +02:00
Jelle Raaijmakers
d616ab0d95 CI: Remove EOL escapes from single quoted string in js-benchmarks
Some checks are pending
Lint Code / lint (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Don't need these, they mess up the JSON payload.
2025-04-15 10:55:05 +02:00
Jelle Raaijmakers
612b0cdddd CI: Add architecture to js-benchmarks webhook callback 2025-04-15 10:55:05 +02:00
Sam Atkins
c224644bed LibWeb/CSS: Fetch ImageStyleValue images closer to spec
We now don't absolutize the URL during parsing, keeping it as a CSS::URL
object which we then pass to the "fetch an external image for a
stylesheet" algorithm. Our version of this algorithm is a bit ad-hoc,
in order to make use of SharedResourceRequest. To try and reduce
duplication, I've pulled all of fetch_a_style_resource() into a static
function, apart from the "actually do the fetch" step.
2025-04-15 09:54:35 +01:00
Sam Atkins
9f00425dad LibWeb/CSS: Let CSSStyleValue know its CSSStyleSheet
The CSS `fetch_foo()` functions resolve the URL relative to the
CSSStyleSheet if one is provided. So, style values that do so need to
know what CSSStyleSheet they are part of so that, for example, `url
(foo.png)` is loaded relative to the style sheet's URL instead of the
document's one.

That all works without this change because we currently absolutize URLs
during parsing, but we're in the process of stopping that.

This commit adds the infrastructure for telling style values what their
CSSStyleSheet is.
2025-04-15 09:54:35 +01:00
Sam Atkins
bf873a2d5b Tests: Add tests for loading images from an imported style sheet
We previously had no coverage for the situation of "relative-linking to
an image in a style sheet which isn't in the same directory as the
document".
2025-04-15 09:54:35 +01:00
Sam Atkins
aebbb008c1 LibWeb/CSS: Expose owning document of CSSStyleSheet
This will be needed for fetching images from CSS.
2025-04-15 09:54:35 +01:00
Sam Atkins
f1af4bcc58 LibWeb: Include SharedResourceRequest.h where it's used
ImageStyleValue.h can rely on the forward-declaration.
2025-04-15 09:54:35 +01:00
Sam Atkins
3ed59f2bd2 LibWeb/CSS: Make fetch_a_style_resource() fall back to sheet's location
See linked spec issue.
2025-04-15 09:54:35 +01:00
Sam Atkins
43950c7342 LibWeb/CSS: Make fetch_a_style_resource() work with no CSSStyleSheet
See the spec issue in the comments for details. There are situations
where we will need to call this but don't have a CSSStyleSheet to pass
in, but we always have a Document, so use that where possible.
2025-04-15 09:54:35 +01:00
Sam Atkins
f4cfdd704b LibWeb/CSS: Make fetch_a_style_resource() take URLs not strings
The spec has this parameter as "a url or `<url>`", so let's match that.
2025-04-15 09:54:35 +01:00
Sam Atkins
3fe978c8a0 LibWeb/CSS: Set request's referrer in fetch_a_style_resource()
THe `location` is now a URL so we can pass it directly.
2025-04-15 09:54:35 +01:00
Sam Atkins
9284530a9f LibWeb/CSS: Return GC::Ref from style sheet parsing methods
These actually always return a value, despite the `CSSStyleSheet*`
return type. So, make that clearer by returning `GC::Ref<CSSStyleSheet>`
instead. This also means we can remove some ad-hoc error-checking code.
2025-04-15 09:40:38 +01:00
Sam Atkins
2a96a81e68 LibWeb: Move style sheet parsing into create_a_css_style_sheet()
The spec is unclear about when exactly we should parse the style sheet.
Previously we'd do so before calling this algorithm, which was
error-prone, as seen by the bug fixed by the previous commit. The spec
for step 1 of "create a CSS style sheet" says:

1. Create a new CSS style sheet object and set its properties as
   specified.

The definitions linked are UA-defined enough that it seems reasonable to
put the parsing here. That simplifies the user code a little and makes
it harder to mess up. It does raise the question of what to do if
parsing fails. I've matched our previous behaviour by just logging and
returning in that case.

While I'm modifying this method, I've also converted the bool params to
enums so they're a little clearer to read.
2025-04-15 09:40:38 +01:00
Sam Atkins
f29a95e2fe LibWeb: Assign linked style sheet location when parsing it
Before this change, we assigned the style sheet's location *after* its
content rules were parsed and added to it. This meant any `@import`s
would try to fetch their style sheet before they knew the URL they
should fetch it relative to.
2025-04-15 09:40:38 +01:00
Sam Atkins
336ccdb5f1 LibWeb/XML: Treat declared namespaces as valid for attributes
Previously if we encountered any attributes with a namespace other than
`xml` or `xmlns`, we treated it as a parse error. Now, allow it as long
as it's been declared in the current context.

We also handle errors more gracefully - instead of exploding if setting
the namespace fails, treat it as an error and carry on.
2025-04-15 09:39:19 +01:00
Sam Atkins
c99aac4bf0 LibWeb/XML: Make namespace getter reject invalid qualified names
Names like ":hi", "wow:", or "a🅱️c" are invalid, so early-out instead
of searching our namespace stack for matching prefixes.

And also rename the function because it's relevant to attributes too.
2025-04-15 09:39:19 +01:00
Andrew Kaster
7d797b2c32 CMake: Remove warning suppression for unknown attributes
We should take care of these with macros or other means instead of
suppressing them.
2025-04-15 02:19:06 -06:00
Andrew Kaster
5e7e6475c6 AK: Annotate [[no_unique_address]] members with NO_UNIQUE_ADDRESS macro 2025-04-15 02:19:06 -06:00
Andrew Kaster
b133c27305 CMake: Disable [[no_unique_address]] when Swift is enabled
There's an upstream bug on this already.
2025-04-15 02:19:06 -06:00
Andrew Kaster
864ddfb55d AK: Add macro to switch between no_unique_address attribute forms
Also add an escape hatch for completely disabling the annotation.
2025-04-15 02:19:06 -06:00
Aliaksandr Kalenik
a4cc0703d1 LibGfx: Make Skia surface construction/destruction thread-safe
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
With this change we ensure that Skia surfaces are allowed to be created
or destroyed only by one thread at a time. Not enforcing this before
resulted in "Single owner failure." assertion crashes in debug mode on
pages with canvas elements.
2025-04-15 02:33:32 +02:00
Timothy Flynn
cef7821f53 LibWeb: Unindent looping over a BYOB reader's pull-into requests
This was causing us to hang on some BYOB tests.
2025-04-14 19:56:58 -04:00
Timothy Flynn
f22fa827ec LibWeb: Align some BYOB stream AOs with spec text/reality
A couple of minor things I came across while debugging BYOB streams.
Adjust some spec text to match the latest spec, and use GC::Ref instead
of a raw pointer where applicable.
2025-04-14 19:56:58 -04:00
Timothy Flynn
9d33b3632f LibWeb: Update imported WPT utility file
This changed upstream and affects our ability to import BYOB tests. See:
bc9dcbbf1a
2025-04-14 19:56:58 -04:00
Andrew Kaster
2a15b85658 Documentation: Add instructions for how to enable the Swift build 2025-04-14 16:04:08 -06:00
Timothy Flynn
d5d9d999ae LibWeb: Implement ReadableStream's async iterator 2025-04-14 17:43:11 -04:00
Timothy Flynn
e6463e4ecc LibWeb: Import ReadableStream async iterator tests 2025-04-14 17:43:11 -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
398f1ce2a0 LibIDL: Fix typos in IDL error messages 2025-04-14 17:43:11 -04:00
Timothy Flynn
296a81c4b8 LibWeb: Add Streams to the list of IDL interface namespaces
Otherwise, we are not able to generate a fully qualified name for
Streams objects.
2025-04-14 17:43:11 -04:00
Timothy Flynn
16559002bf LibJS: Fully qualify use of js_undefined in TRY_OR_REJECT macro
This allows this macro to be used in LibWeb.
2025-04-14 17:43:11 -04:00
Timothy Flynn
988df9cc8c LibWeb: Perform writes during ReadableStreamPipeTo asynchronously
I don't quite see what spec text requires this, but it is explicitly
checked by WPT. We used to pass this test, but that regressed after
commit 3c6010c663.
2025-04-14 16:56:15 -04:00
Timothy Flynn
6f6b39ecec LibWeb: Import ReadableStreamPipeTo synchronous writing tests 2025-04-14 16:56:15 -04:00
Timothy Flynn
8599917188 LibWeb: Do not throw exceptions from Promise-type attributes
If an attribute's getter were to throw an exception, we must instead
return a rejected promise. We already supported this behavior for
functions.
2025-04-14 15:50:21 -04:00
Timothy Flynn
40fa5887cc LibWeb: Import the streams IDL harness test
This required a bit of manual manipulation. These tests dynamically
fetch generated IDL files, e.g.:

https://github.com/web-platform-tests/wpt/blob/master/interfaces/streams.idl

Our WPT importer is not able to detect the IDL files that need to be
imported, so dom.idl and streams.idl was copied over manually. Further,
idlharness.js would create URLs of the form "file://interfaces/dom.idl".
So idlharness.js was adapted to create a URL relative to the test file.
2025-04-14 15:50:21 -04:00
Timothy Flynn
500fbcb5b8 Meta: Do not lint IDL files imported from WPT 2025-04-14 15:50:21 -04:00
rmg-x
555c8139d8 LibTLS: Call close() when we receive SSL_ERROR_ZERO_RETURN
If we don't do this, then we endlessly spin trying to read data which
ends up in a deadlock.

The description for SSL_ERROR_ZERO_RETURN states:
> The TLS/SSL connection has been closed. If the protocol version is SSL
> 3.0 or TLS 1.0, this result code is returned only if a closure alert
> has occurred in the protocol, i.e., if the connection has been closed
> cleanly. Note that in this case SSL_ERROR_ZERO_RETURN does not
> necessarily indicate that the underlying transport has been closed.
2025-04-14 21:07:42 +02:00
Kenneth Myhra
b285202951 LibWeb: Widen assertion to avoid accidentally writing to a closed stream
This widens the assertion from only checking if the WritableStream's
state is Errored or Erroring to asserting that the WritableStream is not
in a Writable state.
2025-04-14 14:50:54 -04:00
Mehran Kamal
6ba60188b4 LibWeb+LibGfx: Paint dash array and offset for SVG and Canvas 2025-04-14 18:00:38 +01:00
Mehran Kamal
a64902ba25 LibWeb+LibGfx: Paint miter_limit for SVG and Canvas 2025-04-14 18:00:38 +01:00
Andreas Kling
87ec5b32b0 LibRegex: Use ReadonlySpan to peek into OpCode_Compare LUTs
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
By the time we're executing bytecode, we know the the bytecode will be
flattened. This means we can use ReadonlySpan to look into it instead of
DisjointChunks::spans(), which allocates.
2025-04-14 17:40:13 +02:00
Andreas Kling
c1c3b01a6c LibRegex: Allow Vector<Match> to use trivial memcpy
Now that Match has no more members that need destruction, we can allow
Vector to memcpy them around.
2025-04-14 17:40:13 +02:00