Commit graph

72939 commits

Author SHA1 Message Date
Callum Law
408bbead31 LibWeb: Don't mangle inherited properties when updating animated style 2025-11-21 09:24:53 +01:00
stasoid
01f6f33236 Meta: Compile for the native architecture of the host system on Windows
when ENABLE_CI_BASELINE_CPU is OFF
2025-11-21 09:10:28 +01:00
Timothy Flynn
4470f94129 RequestServer: Store a couple of data hashes in disk cache entries
We currently have a FIXME to validate cached data with a crc32. But this
is sort of a non-starter, because we never actually have the cached data
in-memory - we transfer it to the WebContent process via system calls,
and it never reaches userspace in RequestServer.

Chrome makes a bit of an educated gamble here. They assume cosmic bit
blips are extremely unlikely, thus the cached data does not get verified
with a hash. Instead, they store non-cryptographic hashes of some select
fields, and they validate just those hashes.

Here, we store a hash of the cache key in the cache header, and a hash
of the cache header in the cache footer. With these validations, along
with other validations already in-place, we can be reasonably sure we
are not sending corrupt data to the WebContent process.
2025-11-21 08:48:42 +01:00
Timothy Flynn
3663e12585 RequestServer: Do not request partial content for failed cache reads
This effectively reverts 9b8f6b8108.

I misunderstood what Chrome was doing here - they will issue a range
request only for what they call "sparse" cache entries. These entries
are basically used to cache partial large file, e.g. a multi-gigabyte
video. If they hit a legitimate read error, they will fail the request
with a ERR_CACHE_READ_FAILURE status.

We will now (again) fail with a network error when a cache read fails.
2025-11-21 08:48:42 +01:00
Timothy Flynn
4fddd6a681 RequestServer: Do not log disk cache version mismatches on first-run
Particularly on test runs, this is just noise.
2025-11-21 08:48:42 +01:00
Aliaksandr Kalenik
2a18b6b802 LibWeb: Prevent default on pointerdown/mousedown should skip focus steps
Fixes a bug in the ChatGPT model dropdown where clicking it immediately
closes the menu because focus is being stolen.
2025-11-21 08:30:32 +01:00
Ali Mohammad Pur
d5d37abfa5 AK+LibRegex: Only set node metadata on Trie::ensure_child if missing
a290034a81 passed an empty vector to this,
which caused nodes that appeared multiple times to reset the trie
metadata...which broke the optimisation.

This patchset makes the function take a 'provide missing metadata'
function instead, and only invokes it when the node is missing rather
than unconditionally setting the metadata on all nodes.
2025-11-21 02:46:33 +01:00
Jelle Raaijmakers
2c5beeabe3 LibWeb: Improve support for SVG text positioning attributes
Previously, we only supported very basic numbers and a single level of
text positioning support in the `x`, `y`, `dx` and `dy` attributes in
`<text>` and `<tspan>` SVG elements.

This improves our support for them in the following ways:

  * Any `length-percentage` or `number` type value is accepted;
  * Nested `<text>` and `<tspan>` use the 'current text position'
    concept to determine where the next text run should go;
  * We expose the attributes' values through the API.

Though we still do not support:

  * Applying the `rotate` attribute;
  * Applying transformations on a per-character basis.
  * Proper horizontal and vertical glyph advancing (we just use the path
    bounding box for now).
2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
527a293047 LibWeb: Implement SVGAnimatedLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
797e6dd4eb LibWeb: Implement SVGLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
832e953c67 LibWeb: Use is_ascii_digit() in SVG attribute parsing 2025-11-20 23:15:24 +01:00
Hendiadyoin1
bcd01da91d AK: Use Deducing this for OptionalBase
This is taken from and akin to
https://github.com/SerenityOS/serenity/pull/25894
2025-11-20 16:27:07 +01:00
Sam Atkins
fd4888e800 LibWeb/Layout: Honor hanging and each-line in text-indent 2025-11-20 16:02:40 +01:00
Sam Atkins
c4b9e7eadf LibWeb: Parse and propagate extended text-indent property values
CSS Text 3 gives `text-indent` a couple of optional keywords to control
which lines are affected. This commit parses them, but doesn't yet do
anything with them.
2025-11-20 16:02:40 +01:00
Sam Atkins
eea1d4e1d2 test-web: Report which file has missing match/mismatch metadata
This makes it easier to figure out what's causing the assertion failure.
2025-11-20 16:02:40 +01:00
Sam Atkins
0e8f3a4648 Tests: Import ahem font for ref tests
A few tests were trying to use ahem.css but failed because the path was
invalid and the font wasn't imported.
2025-11-20 16:02:40 +01:00
R-Goc
b97892729f AK: Print backtrace with warnln
Printing the backtrace with our print function makes sure it is in one
piece when multiple threads are printing.
2025-11-20 15:44:25 +01:00
Timothy Flynn
54b9ddcc80 LibJS: Use relative date in NudgeToCalendarUnit when comparing durations
This is a normative change in the Temporal proposal. See:
17e12be

The test added here would previously crash.
2025-11-20 08:28:51 -05:00
Aliaksandr Kalenik
0eb28a1a54 LibWeb: Delete unused BufferPolicy from fetch Request
This is no longer needed since all requests are unbuffered.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
16b0f1e6c2 LibWeb: Delete unused ResourceLoader::load()
...and rename `load_unbuffered()` to `load()`.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
3058274386 LibWeb: Use unbuffered network requests for all Fetch requests
Previously, unbuffered requests were only available as a special mode
for EventSource. With this change, they are enabled by default, which
means chunks can be read from the stream as soon as they arrive.

This unlocks some interesting possibilities, such as starting to parse
HTML documents before the entire response has been received (that, in
turn, allows us to initiate subresource fetches earlier or begin
executing scripts sooner), or start rendering videos before they are
fully downloaded.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
f942fef39b LibWeb: Allow microtasks to run if document has been destroyed
187f8c54 made `HTML::Task` runnable for destroyed documents, and this
change aligns microtask behavior with that. This is required for an
upcoming change that switches Fetch to be unbuffered by default. During
navigation, fetching the new document is initiated by the previous
document, which means we need to allow microtasks created in the
previous document's realm to run even after that document has been
destroyed.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
cce5197f90 LibWeb: Implement :resource support for load_unbuffered()
Preparation work before enabling unbuffered fetching by default.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
1f4b53d9fc LibWeb: Implement :about protocol support for load_unbuffered()
Preparation work before enabling unbuffered fetching by default.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
2fd7b70784 LibWeb: Implement file: protocol support for load_unbuffered()
Preparation work before enabling unbuffered fetching by default.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
fa46efae48 LibWeb: Exit process_stylesheet_resource if document isn't fully active
This change is required to fix crashing in `link-re-enable-crash.html`
that is going to be introduced by switching to unbuffered fetching.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
a79c995d8a Tests: Specify Content-Type header in tests that use HTTP server
Currently these tests work, because we are lucky to have fetched
response body available in `load_document()` to correctly sniff the MIME
type. This is a preparation for upcoming change that makes fetching
unbuffered, which will break these test unless we explicitly set the
`Content-Type` header.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
5bbf2ddc5b Tests: Make preload link load/error event test order-independent
This changes `link-element-rel-preload-load-event.html`, so the test no
longer depends on the relative ordering of load and error events.

This is required for the upcoming change that makes fetching unbuffered
by default, as the test would otherwise become flaky.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
f28611d84a Tests: Rewrite Window-postMessage.html to set up onload earlier
...for iframes with srcdoc, this ensures the test won't get stuck if the
load event fires between creating the iframe and adding the onload
handler in the `asyncTest()` callback.

Previously, this test would pass in Firefox and Safari, but get stuck in
Chrome. Now all browsers pass it.
2025-11-20 06:29:13 -05:00
Sam Atkins
29666e1d83 LibWeb/DOM: Invalidate children with relative font-weight/font-size
`font-weight` and `font-size` both can have keywords that are relative
to their inherited value, and so need recomputing when that changes.

Fixes all but one subtest in font-weight-computed.html, because that
remaining one uses container-query units. No font-size tests seem to be
affected: font-size-computed.html doesn't update the parent element's
`font-size` so this invalidation bug didn't apply.
2025-11-20 12:22:03 +01:00
Timothy Flynn
813986237e LibWeb: Add some tests that exercise the HTTP disk cache
Our HTTP disk cache is currently manually tested against various sites.
This patch adds some tests to cover various scenarios, including non-
cacheable responses, expired responses, and revalidation.

In order to ensure we hit the disk cache in RequestServer, we must
disable the in-memory cache in WebContent.
2025-11-20 09:33:49 +01:00
Timothy Flynn
a4c8e39b99 test-web: Add basic support for If-Mod-Since requests in our test server
This just lets the test decide on a per-request basis if it wants the
test server to respond with a 304.
2025-11-20 09:33:49 +01:00
Timothy Flynn
4de3f77d37 RequestServer: Add a hook to advance a request's clock time for testing
For example, we will want to be able to test that a cached object was
expired after N seconds. Rather than waiting that time during testing,
this adds a testing-only request header to internally advance the clock
for a single HTTP request.
2025-11-20 09:33:49 +01:00
Timothy Flynn
b2c112c41a LibWebView+RequestServer: Add a simple test mode for the HTTP disk cache
This mode allows us to test the HTTP disk cache with two mechanisms:

1. If RequestServer is launched with --http-disk-cache-mode=testing, it
   will cache requests with a X-Ladybird-Enable-Disk-Cache header.

2. In test mode, RS will include a X-Ladybird-Disk-Cache-Status response
   header indicating how the response was handled by the cache. There is
   no standard way for a web request to know what happened with respect
   to the disk cache, so this fills that hole for testing.

This mode is not exposed to users.
2025-11-20 09:33:49 +01:00
Timothy Flynn
a853bb43ef LibWebView+UI: Pass RequestServerOptions to Application implementations
This will be needed by test-web.
2025-11-20 09:33:49 +01:00
Timothy Flynn
0020af37cd RequestServer: Do not pack the disk cache header and footer structures
This is causing misaligned reads with Address Sanitizer enabled. We
could maintain the packed attribute, and deal with alignment - but we
ended up not actually needing these to be packed anyways. The only thing
we need to know is the serialized size of the header, which we can just
determine differently.
2025-11-20 09:33:49 +01:00
Timothy Flynn
71f9c77ee1 RequestServer: Remove headers exempted from storage from in-memory cache
We previously excluded headers exempted from storage when we serialized
the headers into the database. However, we stored the original headers
in-memory. So when a subsequent request hit CacheIndex::find_entry, we
would return an entry with response headers that should have been
excluded.
2025-11-20 09:33:49 +01:00
Timothy Flynn
a580392109 RequestServer: Compute response ages without truncating sub-fractions
We can use Duration as-is without coercing values to seconds. This
probably doesn't make much difference in real-world scenarios, but when
we hammer the cache during tests, this truncation will cause flakey
behavior.
2025-11-20 09:33:49 +01:00
Sam Atkins
44326c4d7f LibWeb/CSS: Define value ranges for grid properties
Grid track sizes cannot be negative.
2025-11-19 23:45:52 +00:00
Sam Atkins
7de17dce9d LibWeb/CSS: Absolutize grid-related StyleValues 2025-11-19 23:45:52 +00:00
Aliaksandr Kalenik
597fe8288c LibWeb: Apply own clip rect for background phase only when clip used
Fixes a bug where we would clip `box-shadow` when `overflow: hidden`
was set, which is not supposed to happen since `overflow` only affects
clipping of an element's content.
2025-11-19 18:17:42 +01:00
Aliaksandr Kalenik
e816a92dfe LibWeb: Move clip_frames from public to private in ViewportPaintable 2025-11-19 18:17:42 +01:00
Luke Wilde
47b512ec56 LibWeb/WebAudio: Fire complete event with OfflineAudioCompletionEvent 2025-11-19 17:26:09 +01:00
Psychpsyo
556699d601 LibWeb: Prevent view transition crashes due to lack of execution context 2025-11-19 10:58:29 -05:00
Jelle Raaijmakers
674e1a5c47 LibWeb: Support transitions between 3D and non-derivative 2D functions
If either of the two transform functions during interpolation is a 3D
function, both of them get coerced to a 3D function before deciding what
to do next. However, we only supported converting 2D functions to 3D if
they had a 2D primitive they could be converted to first.

Change our behavior to default to converting to matrix3d() if there is
no explicit conversion path. Fixes a crash in
`css/css-transforms/animation/transform-interpolation-004.html`.
2025-11-19 10:08:11 +01:00
ayeteadoe
8348c55570 RequestServer: Support HTTP response write retries on Windows
The Windows RequestPipe implementation uses a non blocking local socket
pair, which means the non-fatal "resource is temporarily unavailable"
error that can occur in the non-blocking HTTP Response data writes can
be retried. This was seen often when loading https://ladybird.org.

While the EAGAIN errno is defined on Windows, WSAEWOULDBLOCK is the
error code returned in this scenario, so we were not detecting that we
could retry and treated the failed write attempt as a proper error.

We now detect WSAEWOULDBLOCK and convert it into the errno equivalent
EWOULDBLOCK. There is precedent for doing a similar conversion in the
Windows PosixSocketHelper::read() implementation.

Finally, we retry when we receive either EAGAIN or EWOULDBLOCK error
codes on all platforms. While POSIX allows these 2 error codes to have
the same value, which they do on Linux according to
https://www.man7.org/linux/man-pages/man3/errno.3.html, it is not
guarenteed. So we now ensure platforms that return EWOULDBLOCK with a
value different than EAGAIN also perform write retries.
2025-11-19 09:17:18 +01:00
ayeteadoe
fa262d2db5 LibCore: Add VERIFY checks for all wait completion packet nt.dll calls 2025-11-18 18:49:37 +01:00
ayeteadoe
d5e5dbdf3d LibCore: Signal an event to queue a wake completion packet on Windows
The initial IOCP event loop implementation adjusted wake() to manually
queue a completion packet onto the current threads IOCP. This caused
us to now be dependent on the current threads IOCP, when the previous
behaviour did not depend on any data from the thread that was waking
the event loop.

Restoring that old behaviour allows https://hardwaretester.com/gamepad
to be loaded again.
2025-11-18 18:49:37 +01:00
ayeteadoe
540bbae480 LibCore: Restore single-shot timer objects manual reset on Windows
The initial IOCP event loop implementation removed the single shot
timer fix added in 0005207 was removed.

Adding this back allowed simple web pages like https://ladybird.org/ to
be loaded again.
2025-11-18 18:49:37 +01:00
ayeteadoe
11b8bbeadf LibCore: Use correct fd for NotifierActivationEvent on Windows
The initial IOCP event loop implementation had a fd() method for the
EventLoopNotifier packet that did not actually return the fd for the
notifier, but a to_fd() call on an object HANDLE that was always NULL.
This meant we were always posting NotifierActivationEvents with a fd of
0.

This rendered all of our WinSock2 I/O invalid, meaning no IPC messages
would ever be successfully sent or received.
2025-11-18 18:49:37 +01:00