Commit graph

33858 commits

Author SHA1 Message Date
Andreas Kling c8206fa070 LibWeb: Rename Element::shadow_root_internal() to shadow_root()
And let the old shadow_root(), which was only supposed to be used by
bindings, be called shadow_root_for_bindings() instead.

This makes it much easier to read DOM code, and we don't have to worry
about when to use shadow_root_internal() or why.

(cherry picked from commit f4bdf562127c12a7af18029777a88d4260af82d3)
2024-06-26 08:48:11 +02:00
Andreas Kling 1c5f0e8daf LibWeb: Update DOM cloning algorithm for declarative shadow DOM
(cherry picked from commit c7d9c1c0b21ad54894984dd73c775e225f82af09)
2024-06-26 08:48:11 +02:00
Andreas Kling 6217ebe33c LibWeb: Add HTMLTemplateElement IDL attrs for declarative shadow DOM
(cherry picked from commit a0e111220913ec1bf8d51dde37174120781b0a5f)
2024-06-26 08:48:11 +02:00
Andreas Kling 020764b204 LibWeb: Add ShadowRoot.clonable and ShadowRoot.serializable
(cherry picked from commit 8e68215d333963eeb63cccde171dba6ea77651d7)
2024-06-26 08:48:11 +02:00
Andreas Kling 88d9dc148c LibWeb: Update HTML fragment serialization for declarative shadow DOM
(cherry picked from commit e62db9c1181f5af49242656d3e065ceb0db800b9)
2024-06-26 08:48:11 +02:00
Andreas Kling a5189537e9 LibWeb: Parse declarative shadow DOM template elements
We now honor the shadowrootmode attribute on template elements while
parsing, and instantiate a shadow tree as required by the spec.

(cherry picked from commit 9eb4b91168145def5677cd41057d34ecf369372b)
2024-06-26 08:48:11 +02:00
Andreas Kling 34a4b28b89 LibWeb: Refactor Element.attachShadow() after spec changes
The bulk of this function is moved to a new "attach a shadow root"
helper, designed to be used both from here and the HTML parser.

(cherry picked from commit 043ad0eb7644a529c1ffbd4de9a4b89771808c84,
and amended to make `is_valid_shadow_host_name()` static.
2024-06-26 08:48:11 +02:00
Andreas Kling 3a2260b28b LibWeb: Add "allow declarative shadow roots" flag to Document
(cherry picked from commit f3070118b1fabda4a35f283a3bcf8086e32a25a9)
2024-06-26 08:48:11 +02:00
FujiBookPro 728f42f8f5 LibAudio: Replace DeprecatedFlyString with FlyString 2024-06-25 18:32:45 -06:00
Ali Mohammad Pur 3b05c81070 LibIPC: Allow sync messages to completely block the event loop
The expectation with these messages is that no other code is allowed to
run while we're waiting for the response to arrive.
Not meeting this requirement did not degrade any (observable)
functionality, however.
2024-06-25 18:30:03 -06:00
Daniel Bertalan 8d2a8dbb8b Everywhere: Write dtors for types with incomplete members out-of-line
These are rejected by Clang (19) trunk as a result of
https://github.com/llvm/llvm-project/pull/77753.

(cherry picked from commit bf1f631f257e90e91b0b45a6454d731b4b98914c)
2024-06-25 17:42:49 +02:00
Daniel Bertalan d1f1a6eef0 Everywhere: Remove usages of template keyword with no parameter list
These were made invalid with P1787, and Clang (19) trunk started warning
on them with https://github.com/llvm/llvm-project/pull/80801.

(cherry picked from commit 397774d42272fff8dbc6d8d53616d79667d6608a)
2024-06-25 17:42:49 +02:00
Timothy Flynn 46ce6decfe LibProtocol: Exit fatally if the connection to RequestServer disappears
The default implementation of die() causes the client process to simply
exit cleanly. This prevents any tests from recognizing that something
went wrong, as the process exits with a code of 0. With this patch, we
still just exit when the connection dies, but with a fatal signal. In
the future, we will want to launch a new RequestServer process and
re-establish client connections.

(cherry picked from commit d1ec32e28feee10c2c36f4cd0d496b8a95d375f8)
2024-06-25 17:42:49 +02:00
Nico Weber 7e2c8693b1 LibJS: Initialize fields of on-stack buf structure
We pass all fields of `buf` to `add_possible_value()`, and at least
on Linux `setjmp()` does not initialize all fields.

Fixes #24560.
2024-06-25 17:40:17 +02:00
Liav A. 393c886c24 Utilities: Introduce the sizefmt utility
This utility takes a human-readable size and converts it into a raw
integer that can be used on commandline utilities.
2024-06-25 09:24:55 +02:00
Andreas Kling 93253e3701 LibJS/Bytecode: Give TypeofBinding instructions a lookup cache
These can use an EnvironmentCoordinate for caching, just like normal
binding lookups. Saves a bunch of time for repeated typeof checks.

(cherry picked from commit 60a05ef414f804fe0c44d20fe13c795800826368)
2024-06-24 16:38:47 +02:00
Andreas Kling 3a7da923e6 LibJS/Bytecode: Rename TypeofVariable => TypeofBinding
(cherry picked from commit 4302e073463c403f8d7ab09c42e7644089fc33a2)
2024-06-24 16:38:47 +02:00
Andreas Kling cd7a151aef LibJS: Allow let and const to create locals in global code
This is actually safe everywhere but in the topmost program scope.
For web compatibility reasons, we have to flush all top-level bindings
to the environment, in case a subsequent separate <script> program
comes looking for them.

(cherry picked from commit 9d21d88374cf440ddf381e02a597a59ad329ed62)
2024-06-24 16:38:47 +02:00
Andreas Kling 776e5d38cd LibJS/Bytecode: Display local variable names in bytecode dumps
Instead of displaying locals as "locN", we now show them as "name~N".
This makes it a lot easier to follow bytecode dumps, especially in
longer functions.

Note that we keep displaying the local index, to avoid confusion in case
there are multiple separate locals with the same name in one executable.

(cherry picked from commit 0aa8cb7dac60c88eac3bb7674e3fe575cf1da60b)
2024-06-24 16:38:47 +02:00
Andreas Kling 63d8a1821e LibJS: Don't overwrite cached this value on async/generator reentry
When resuming execution of a suspended function, we must not overwrite
any cached `this` value with something from the ExecutionContext.

This was causing an empty JS::Value to leak into the VM when resuming
an async arrow function, since the "this mode" for such functions is
lexical and thus ExecutionContext will have an empty `this`.

It became a problem due to the bytecode optimization where we allow
ourselves to assume that `this` remains cached after we've executed a
ResolveThisBinding in this (or the first) basic block of the executable.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/138

(cherry picked from commit a91bb72dabe54849657720e36e19a3d3b737055f)
2024-06-24 16:38:47 +02:00
Tim Ledbetter 0b1adf784f SystemMonitor: Add an action to manually refresh process statistics 2024-06-23 21:20:37 +01:00
Tim Ledbetter 4091d7fc05 SystemMonitor: Add an action to pause updates 2024-06-23 21:20:37 +01:00
Liav A. 5cb1d2a63e Utilities/pkg: Move ports database handling from AvailablePort{.h,.cpp}
Instead, let's create a new class called AvailablePortDatabase that will
handle updating (from the Internet, by using our repository) of the list
and instantiating an object that could be used for querying.
2024-06-23 00:59:54 +02:00
Liav A. 1e13d758a2 Utilities/pkg: Move ports database handling from InstalledPort{.h,.cpp}
Instead, let's create a new class called InstalledPortDatabase that will
handle reading, and adding new entries as needed to such database.
2024-06-23 00:59:54 +02:00
Liav A. b201a91e72 Utilities/pkg: Rename ports_database => default_ports_database_path 2024-06-23 00:59:54 +02:00
Ali Mohammad Pur a711bb63b7 LibHTTP+LibCore+RequestServer: Use async streams for HTTP
We no longer use blocking reads and writes, yielding a nice performance
boost and a significantly cleaner (and more readable) implementation :^)
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur be2bf055dd LibCore: Fix some thread-related memory/object leaks 2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 1c31dbd110 LibJS: Make emsdk's clang happy 2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 9f4f319277 RequestServer+LibCore+LibTLS: Use coroutines for socket connection
This allows RS to start connections in parallel without actively waiting
for any possible handshakes.
Doing so gives us a nearly-3x speedup on the average connection latency.
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 30c41835e6 LibIPC: Actually yield to the event loop when EMSGSIZE or EAGAIN
Previously this just yielded the time slice, which blocked the event
loop until the other side read some data from the socket.
This "fixed" impl is still equally bad, but at least it doesn't block
the event loop.
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur ba54c9adb2 LibCore: Add a couple coroutine-related helper functions 2024-06-19 15:45:02 +02:00
Ali Mohammad Pur 8691d1b885 LibCrypto: Milk some more performance out of galois_multiply()
This simple change makes AES-GCM 5% faster :^)
2024-06-19 15:45:02 +02:00
Ali Mohammad Pur ea15ccdae3 LibCrypto: Remove select individual Vector/Span::at() calls
These were showing up on profiles as quite hot (>5%), we can avoid all
the unnecessary assertions by doing them once in advance and using
pointers for the rest of the function.
This makes AES-GCM about 6% faster.
2024-06-19 15:45:02 +02:00
Nico Weber 1cc4d29d20 LibGfx/WebPWriter: Use align_up_to()
No behavior change.
2024-06-16 14:50:32 -04:00
Nico Weber 8c7a0e6334 LibGfx/WebPWriter: Use count_required_bits()
This is slightly longer than doing it manually, but arguably easier
to read. (And we don't need to convert to float and back.)

No behavior to change.
2024-06-16 14:50:32 -04:00
Liav A. 5133c9d4cb Utilities/du: Add options to filter files with min and max sizes
These options supplements the original threshold option, because it's
now possible to specify a threshold and add either minimum/maximum size
for additional filtering.

It's also possible to not use the old threshold option (that Tim
Schumacher told me it was inherited from coreutils) and only specify the
2 new options to create a filtering.
2024-06-15 09:36:39 +02:00
circl ec7d44d635 Revert "LibWeb: Use memcpy() in CanvasRenderingContext2D.getImageData()"
This reverts commit 59cb7994c6.

This change caused a bug where getImageData returned the image in
BGRA8888 format instead of RGBA8888.

(cherry picked from commit d2f9ba7db1d8dd1dd611e6a3f40b9125b5aa054d)
2024-06-14 18:18:40 -04:00
Diego cafc66f272 LibWasm: Tighten validation algorithm
The big improvement included in this commit is stack height mismatch
validation. There are other minor improvements included (related to the
validation algorithm). The method of supporting stack polymorphism has
changed to be more like the spec, which was necessary for confidently
handling stack height mismatches.

See:
https://webassembly.github.io/spec/core/appendix/algorithm.html
(cherry picked from commit 9b58271f8b6de2dbfff416780a54e0322f9c6799)
2024-06-13 23:14:39 +02:00
Diego cdf15887db LibWasm: Refactor validator to use one stack for frame information
Previously, the validator had a lot of extraneous information related to
frames. Now, there's just one stack with all the necessary information
derived from it.

(cherry picked from commit ad54b69de9df6ccd44178cbe49779e313f95f273)
2024-06-13 23:14:39 +02:00
Diego f6d7702411 LibWasm: Make loops work
This commit should hopefully allow for `loop.wast` to be run in CI.

(cherry picked from commit 6ca6fd248a14ab394f11131c3df029b486952d54)
2024-06-13 23:14:39 +02:00
Diego 1c86b8146a LibWasm: Make memory.fill fill with single bytes
Previously, `memory.fill` filled memory with 4-byte values, even though
`memory.fill` should fill with just one byte. Also fixes some other
issues with some of the bulk memory instructions, like `memory.init`.

(cherry picked from commit d8ee2e343df25d12637e08d54908b4fd86a22dc3)
2024-06-13 23:14:39 +02:00
Diego 510bfbbbc3 LibWasm: Validate imports
(cherry picked from commit a1ed3e5d8f4f7b9f44ec4d3e15432d60cba9f2ee)
2024-06-13 23:14:39 +02:00
Diego 15effbaf2a LibWasm: Validate that function and code sections match
(cherry picked from commit cda0d6d27746672058b26b0e61d0900dc73b1fb3)
2024-06-13 23:14:39 +02:00
Diego 985c4c590d LibWasm: Validate that data section exists for some instructions
(cherry picked from commit 5e5df136849c1d450a6e0dd4af3805f7e56f6e76)
2024-06-13 23:14:39 +02:00
Diego be3bc9bd7c LibWasm: Disallow multiple start sections
(cherry picked from commit 6b9977a265b8175cf4da68d601ded427cb49e44e)
2024-06-13 23:14:39 +02:00
Diego 96fb79bb98 LibWasm: Make sure no duplicate export names are possible
(cherry picked from commit c51c018fb13f4fb182da5b12e9e3fda69f6b72ef)
2024-06-13 23:14:39 +02:00
Diego 5502c1a1f8 LibWasm: Validate number of data sections
(cherry picked from commit f7d3ab8e160a61abddfe4db9c8d79260e890bb41)
2024-06-13 23:14:39 +02:00
Dan Klishch 7d1d0fe6ad LibHTTP: Support chunked transfer encoding in async HTTP client
This uses AK::{Generator,AsyncStreamTransform,AsyncStreamBuffer} added
in the previous commits.
2024-06-13 17:40:24 +02:00
Dan Klishch 77be5254e1 LibHTTP: Implement bare-bones HTTP/1.1 client using coroutines
We don't have asynchronous TCP socket implementation, so its usefulness
is a bit limited currently but we can still test it using memory
streams. Additionally, it serves as a temporary {show,test}case for the
asynchronous streams machinery.
2024-06-13 17:40:24 +02:00
Dan Klishch 205bfcc6c8 LibTest: Add Test::AsyncMemory{Input,Output}Stream
They are useful for unit testing other asynchronous streams. They have
to be tested themselves in the first place though.
2024-06-13 17:40:24 +02:00