Commit graph

72926 commits

Author SHA1 Message Date
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
Sam Atkins
7d2f631d4c LibWeb/CSS: Handle whitespace better in font-language-override strings
The rules for strings here are:
- 4 ASCII characters long
- Shorter ones are right-padded with spaces before use
- Trailing whitespace is always removed when serializing

We previously always padded them during parsing, which was incorrect.
This commit flips it around so we trim trailing whitespace when parsing.

We don't yet actually use this property's value for anything. Once we do
so, maybe we'll care more about them being stored as 4 characters
always, but for now this avoids us needing a special step during
computation.
2025-11-18 17:22:03 +01:00
Jelle Raaijmakers
61f9b324c7 LibWeb: Always serialize CSSScale with at least two values 2025-11-18 14:44:49 +00:00
Jelle Raaijmakers
3083b19b09 LibWeb: Show bounding_rect in PushStackingContext dump 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
740629a3a8 LibWeb: Pass reference to bounding rect for Skia paint style 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
ba40da5e5f LibWeb: Rename DisplayList's apply_filters to apply_filter 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
d7ebc4eef4 LibWeb: Remove PaintableBox const_casts from ViewportPaintable
They're not necessary here - no functional changes.
2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
9547889a6b LibWeb: Remove unused include from StackingContext 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
871f121c75 Everywhere: Validate // NOTE: ... and // NB: ... comments 2025-11-18 09:07:37 -05:00
Jelle Raaijmakers
8a02161481 Documentation: Standardize our spec note comment prefixes 2025-11-18 09:07:37 -05:00
Jelle Raaijmakers
41eb7251e4 LibWeb: Convert Ladybird notes in spec steps to // NB: ...
We have a couple of ways to designate spec notes and (our) developer
notes in comments, but we never really settled on a single approach. As
a result, we have a bit of a mixed bag of note comments on our hands.

To the extent that I could find them, I changed developer notes to
`// NB: ...` and changed spec notes to `// NOTE: ...`. The rationale for
this is that in most web specs, notes are prefixed by `NOTE: ...` so
this makes it easier to copy paste verbatim. The choice for `NB: ...` is
pretty arbitrary, but it makes it stand out from the regular spec notes
and it was already in wide use in our codebase.
2025-11-18 09:07:37 -05:00
Jelle Raaijmakers
9394c9a10b LibWeb: Deduplicate transformation creation logic
We had two code blocks responsible for turning a
TransformationStyleValue into a Transformation; get rid of one.
2025-11-18 14:36:26 +01:00
Jelle Raaijmakers
15fa6676b0 LibWeb: Simplify generation of perspective() matrix transform
A value of `perspective(none)` should result in the identity matrix. But
instead of creating that identity matrix explicitly, just break and
default to the identity matrix at the bottom of this method.
2025-11-18 14:36:26 +01:00
Jelle Raaijmakers
e4dc2663ba LibWeb: Reimplement transform interpolation according to spec
We had a partial implementation of transformation function interpolation
that did not support numerical interpolation of simple functions (e.g.
`scale(0)` -> `scale(1)`). This refactors the interpolation to follow
the spec more closely.

Gains us 267 WPT subtest passes in `css/css-transforms`.

Fixes #6774.
2025-11-18 14:36:26 +01:00