Commit graph

79055 commits

Author SHA1 Message Date
Andreas Kling
72720bc229 LibWeb: Preserve JS bytecode in memory cache
Store JavaScript bytecode side data in the WebContent HTTP memory
cache and replay it when serving cached responses. Also update an
already-complete memory-cache entry when asynchronous bytecode cache
generation finishes, so the first source-only response does not keep
shadowing the disk-cache sidecar during same-process navigations.

Keep the HTTP memory-cache backfill keyed with the request headers that
populated the memory-cache entry, so Vary responses still receive their
generated bytecode sidecar.

Add LibHTTP coverage for round-tripping bytecode side data through a
memory-cache entry, attaching it after the response body has already
been cached, and matching Vary headers during updates. Add LibWeb
coverage for preserving the memory-cache request headers when cloning
responses.
2026-06-06 09:15:09 +02:00
Aliaksandr Kalenik
221219e00c LibWeb: Track out-of-flow descendant visual contexts
Accumulated visual contexts only recorded the state used by normal
descendants. Fixed descendants started from the visual viewport, and
absolute descendants rebuilt their state from the containing block. That
could drop CSS clip and clip-path nodes from ancestors between the
positioned box and descendant, even though those clips still apply.

Carry separate transient AVC states for normal descendants,
absolute-position descendants, and fixed-position descendants while
building the AVC tree. The top-down paintable walk adds effects and CSS
clipping to positioned descendant contexts, and containing blocks switch
those contexts back to the normal context.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/9909
2026-06-05 23:27:21 +01:00
Andreas Kling
ec421d7fa4 LibWeb+LibJS: Validate bytecode cache blobs off-thread
Warm cache hits used to validate bytecode cache blobs on the main
thread. Route script and module sidecars through a worker step that
decodes and validates the cache blob, then returns the validated blob
for main-thread materialization.

Keep the source bytes mmap-backed and avoid decoding the full source on
cache hits. The main thread still computes the UTF-16 source length so
validation can reject stale blobs before materialization.

Remove the decoded source length getter now that sidecar validation uses
the explicit validation API instead.
2026-06-05 21:55:55 +02:00
Andreas Kling
bb20f15965 LibJS: Prepare bytecode cache validation off-thread
Add an explicit validation entry point for decoded bytecode cache blobs.
This lets callers validate a blob before materialization while keeping
the existing validated-before-use invariant in place.

Make validation idempotent so a prevalidated blob is not walked again
when materialization reaches the same check. Keep the existing decoded
source length query for callers that still validate synchronously.

Route decoded cache blob owner destruction through the origin event
loop. This lets a worker decode or reject mapped bytecode without
releasing non-atomically refcounted ImmutableBytes off-thread, while
lazy cached function materialization can still retain mmap-backed
bytecode.
2026-06-05 21:55:55 +02:00
Andreas Kling
bf81464904 LibWeb+LibJS: Remove rust_pipeline_available
The Rust pipeline is always available now, so the getter only wrapped
code that always ran. Remove it and make the JavaScript fetch paths use
the off-thread Rust pipeline directly.

This also removes the unreachable synchronous fallback branches from the
classic script and module fetch paths.
2026-06-05 21:55:55 +02:00
Andreas Kling
0d05c89778 LibJS: Merge bytecode cache validation walks
Cache materialization used to validate source ranges and bytecode in
separate passes. That made function and class tables decode the same
payloads repeatedly before materialization decoded them again.

Make the materialization validator check source ranges, index bounds,
and bytecode in the same recursive walk. Nested cached function
executables are now decoded once for validation instead of once for
ranges and once for bytecode.
2026-06-05 21:55:55 +02:00
Andreas Kling
9143ad4c96 LibJS: Avoid revalidating cached bytecode executables
Cache blobs already validate decoded bytecode before rebuilding C++
Bytecode::Executable objects. Keep that as the only cache validation
pass and mark the decoded cache state once it completes.

Materialization now asserts that cache blobs and lazy cached function
records passed through validation before they can be installed or
decoded. This keeps the invariant without re-running the same validator
from rust_create_executable().
2026-06-05 21:55:55 +02:00
Aliaksandr Kalenik
ef58631dd5 LibWeb: Skip inline paint phase without inline content
The inline and replaced paint phase walks every descendant even for
block-only contexts. Track whether a stacking context has inline or
replaced descendants while the stacking-context tree is built, then
skip the phase when it cannot produce display-list commands. This adds
one bool to StackingContext.
2026-06-05 19:45:50 +01:00
Aliaksandr Kalenik
9327ab670e LibWeb: Skip float paint phase without floats
Stacking contexts already collect non-positioned floating descendants
while building the paint tree. Use that list to avoid walking the
whole context for the float paint phase when no float can be painted.
2026-06-05 19:45:50 +01:00
Aliaksandr Kalenik
bab8138236 LibWeb: Skip box hit-test records in irrelevant phases
PaintableBox::record_hit_test_items() is called for every paint phase,
but it only emits box hit-test entries during the background and
overlay passes. Return before touching the hit-test display list during
the other phases so cached paint replay stops repeating no-op work.
The hyperfine delta is within noise.
2026-06-05 19:45:50 +01:00
Aliaksandr Kalenik
760e82d299 LibWeb: Skip empty display-list command cache replay
DisplayListRecorder::replay_cached_commands() always entered the
display-list decoder to update save nesting, even when a paintable had
no cached commands. Empty command caches are common on the
ViewportPaintable benchmark, so return before decoding when the cache
is empty.
2026-06-05 19:45:50 +01:00
Shannon Booth
f41addcb02 LibWeb/WebAssembly: Use generated WASM dictionary definitions 2026-06-05 20:23:24 +02:00
Shannon Booth
13bae036d8 LibWeb: Do not refer to removed C++ DAFSA code generator 2026-06-05 20:23:24 +02:00
Shannon Booth
b52a7cdc6e LibWeb/DOM: Remove unnecessary LegacyNullToEmptyString usage
Perhaps this made a difference with an older version of the IDL
generator, but as far as I can tell, this no longer has any effect.
Remove the use of this attribute to match the specification IDL
definition.
2026-06-05 20:23:24 +02:00
Shannon Booth
2328c272e5 Documentation: Refer to correct directory for CSS code generators 2026-06-05 20:23:24 +02:00
Andreas Kling
3c0d0ecc28 LibThreading: Remove BackgroundAction
Remove BackgroundAction after ImageDecoder stopped using it. Drop its
dedicated test target and sources from LibThreading.

Replace the LibCore stream tests' remaining usage with explicit Thread
objects so the tree no longer depends on the removed API.
2026-06-05 20:00:12 +02:00
Andreas Kling
88dfee5528 ImageDecoder: Decode images on ThreadPool
Dispatch image decode work to ThreadPool workers instead of the old
BackgroundAction helper. BackgroundAction funneled all jobs through one
background thread, so image decodes were still serialized. The pool
lets independent decode jobs run in parallel while completions are
posted back to the origin event loop.

Keep pending decode state as a small cancel flag. Make animated
sessions ref-counted with a mutex so overlapping frame requests cannot
race shared decoders once jobs run in parallel.
2026-06-05 20:00:12 +02:00
Ali Mohammad Pur
540827040c Meta: Package the wasm cranelift compiler and restore it for benchmarks 2026-06-05 19:59:03 +02:00
Ali Mohammad Pur
6d2470dcad LibWasm: Refer to cranelift-compiler by relative path and env override 2026-06-05 19:59:03 +02:00
Callum Law
71e359831d DevTools: Update layout before inspecting DOM node
This avoids a crash which would occur when selecting a DOM node in the
inspector while layout was out of date.
2026-06-05 19:57:22 +02:00
sideshowbarker
bbfa1ca7ae Tests: De-flake abortsignal-timeout by dropping its wall-clock assertion
Problem: The abortsignal-timeout.html test was (still) intermittently
failing under CI — printing “…at least 10 milliseconds: false”.

Cause: The test asserts AbortSignal.timeout(10) fired >= 10ms later,
measured as a wall-clock time of performance.now() delta + 1ms fudge.
But that involves timings from two *different* clocks: performance.now()
uses CLOCK_MONOTONIC, while the timeout timer is armed and fired against
CLOCK_MONOTONIC_COARSE (the event-loop clock) — which is quantized to
the kernel tick, and which lags the precise clock by up to a tick. Thus,
a 10ms coarse-scheduled timeout can fall short of 10ms of precise time
by up to one tick. So what was likely happening is: When that shortfall
exceeds the 1ms fudge (coarse-tick kernels, or ticks delayed under CI
load), the delta landed under 10ms. The 1ms fudge added by 6fa32fbf69
narrowed but never closed the race — because the check gates on host
timer/clock precision, rather than on AbortSignal behavior.

Fix: Drop the wall-clock timing assertion. Keep the deterministic checks
that actually exercise AbortSignal.timeout: The abort fires, its
reason is TimeoutError, and the event is trusted. And add a synchronous
check that the signal isn’t aborted immediately after creation – which
confirms the abort is deferred, without racing the clock.
2026-06-05 15:35:34 +02:00
Callum Law
3e6cfb1ba6 LibWeb: Remove libweb-* colors
After `Native.css` was removed in the last commit only
`libweb-buttonfacedisabled` and `libweb-buttonfacehover` remain in use,
so the rest can be removed.

Resolving these colors was also the only use of `document` in
`ColorResolutionContex` so we can remove that too.
2026-06-05 12:59:00 +01:00
Callum Law
52db9e9e5d LibWebView: Remove Native.css
The last user (the built-in inspector) was removed in 810d04b.
2026-06-05 12:59:00 +01:00
Zaggy1024
0ce19a19ea LibWeb: Leave input elements' text node contents unchanged while typing
Replacing the text node's contents with the normalized value after each
keystroke made it impossible to type some inputs. For example, `1e`
would cause the text node to be emptied, making it impossible to type
`1e2`. Also, `time`, `date`, and other time-related input types had no
intermediate valid values, so it was genuinely impossible to type in
them.

Additionally, typed numbers weren't being parsed as floats before
normalization, so even just typing `1.` would clear the text node, so
it was impossible to type a fractional number.
2026-06-05 12:49:24 +02:00
Zaggy1024
e6664213ac LibWeb: Fall back to TextInputBox for unsupported input types
This isn't strictly correct as it stands currently, since the size
attribute isn't supposed to affect type="time" and others, but those
types currently end up with zero width instead.

Size could probably be applied through shadow DOM style, and the input
layout box would simply allow content sizing.
2026-06-05 12:49:24 +02:00
Zaggy1024
2b6ebe9738 Tests: Add a layout test for input[type="time"] without width
When width is unspecified, this input type has no actual width.
2026-06-05 12:49:24 +02:00
Zaggy1024
d84db0413c Tests: Add a test for typing a fraction in a number input 2026-06-05 12:49:24 +02:00
Sam Atkins
c7fa23b0c3 LibWeb/CSS: Update to latest @font-face serialization spec
The `font-family` descriptor may not be present, so handle that
gracefully. We already did so, but now it's an official part of the
spec.

Corresponds to:
75299e7be1
cfb59f593a
2026-06-05 22:44:55 +12:00
Sam Atkins
9cc6270bbc LibWeb/CSS: Clip image inputs
Corresponds to
7486cd721e
2026-06-05 22:44:55 +12:00
sideshowbarker
4df6ecd176 LibWeb: Ignore vertical-align on flex and grid items in box_baseline
Problem: Borked layout on (flex-styled) “D&D Beyond” site.

Cause: FormattingContext::box_baseline() was applying the box’s
vertical-align unconditionally. But vertical-align shouldn’t be
consulted for flex items or grid items.

Fix: Skip vertical-align handling in box_baseline() when the box is a
flex or grid item.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/9840
2026-06-05 10:11:06 +01:00
Callum Law
f28e7120ea LibWeb: Ensure that shadow roots have hosts before appending children
This change gives each shadow root its host before appending its
children, and asserts that a root has no children when it's assigned to
a host. This ensures the children inherit the correct connectedness.

Otherwise, without this change, the user-agent shadow trees for color
and file inputs append their children before the shadow root is given
a host which, if the input element has already been inserted, means the
children stay marked disconnected despite being present in the rendered
tree. Disconnected nodes then skip layout invalidations they should
trigger.

Fixes a crash when submitting a prompt on https://chatgpt.com
2026-06-05 18:08:21 +09:00
Jelle Raaijmakers
a9dbf75788 CI: Remove stalebot
PRs will now be fully owned by their respective author, so no need
automatically close them.
2026-06-05 10:20:15 +02:00
Jelle Raaijmakers
168ecb2e7d Everywhere: Update contribution guidelines
We've closed down the public PR route:

  https://ladybird.org/posts/changing-how-we-develop-ladybird/

Update our guidelines and documentation to reflect this.
2026-06-05 10:20:15 +02:00
dependabot[bot]
50892d7370 CI: Bump actions/checkout from 6.0.2 to 6.0.3
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.2 to 6.0.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6.0.2...v6.0.3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-05 09:21:33 +02:00
Andreas Kling
3f4f0f0c02 Utilities: Keep wasm event loop alive
Create the wasm utility event loop with
Core::EventLoop::initialize_for_current_thread() so it follows the same
process-lifetime model as other program main loops.
2026-06-05 09:18:39 +02:00
Andreas Kling
ab5709edfd LibCore: Tighten EventLoop current-loop checks
Make EventLoop::current() enforce the presence of a current event loop
directly, and make EventLoop::pump() verify that it is pumping the
current thread event loop. This keeps the one-loop-per-thread invariant
explicit across the public EventLoop entry points.
2026-06-05 09:18:39 +02:00
Andreas Kling
789d7cba48 LibWeb: Use direct references to main event loops
Post off-thread font, script, and DNS completion work back to direct
Core::EventLoop references. These callbacks target the process main
loop, which is intentionally kept alive for the lifetime of the
process.
2026-06-05 09:18:39 +02:00
Andreas Kling
aad293dacc LibMedia: Use direct references to main event loops
Pass direct Core::EventLoop references through media producer and
playback plumbing that posts work back to the main thread. The browser
process main loops stay alive for the process lifetime, so these paths
no longer need weak event loop references.

Update LibMedia tests to pass their stack event loop directly to the
producer helpers.
2026-06-05 09:18:39 +02:00
Andreas Kling
b51fde39a2 Services: Use direct references to main event loops
Store direct Core::EventLoop references in WebDriver and the
Compositor when callbacks post back to the process main loop. The
main event loop is intentionally kept alive for the lifetime of these
services, so these paths no longer need WeakEventLoopReference guards.
2026-06-05 09:18:39 +02:00
Andreas Kling
83b293e4f2 LibCore: Keep main event loops alive
Add an explicit initializer for process-lifetime event loops and use it
for browser, helper service, and utility main loops. This preserves weak
event loop references for cross-thread users while making main thread
loop lifetime independent of normal program teardown.
2026-06-05 09:18:39 +02:00
Andreas Kling
02b205361d LibCore: Remove nested EventLoop support
Replace the per-thread EventLoop stack with a single thread-local
pointer. Constructing an EventLoop now requires that the current thread
does not already have one, and exec() and spin_until() operate only on
that current loop instead of pushing a temporary nested loop.

LibLine was the last user that needed nested Core event loops, so the
stack allocation and pthread cleanup machinery can go away.
2026-06-05 00:09:37 +02:00
Andreas Kling
dfb2656d9c Utilities: Replace LibLine with libedit
Use libedit's readline-compatible interface for the JavaScript REPL so
line editing, history, and tab completion no longer depend on LibLine.
The REPL keeps its existing multiline input and completion behavior,
but no longer provides LibLine's live syntax highlighting.

Remove the unused LibLine dependency from the wasm utility and delete
the LibLine library from the build now that it has no remaining
consumers.
2026-06-05 00:09:37 +02:00
Ali Mohammad Pur
08221aebab LibWasm: Start execution immediately after validation
This adds a tier-up mechanism at loop edges, making it so we can
seamlessly (ish) transition between interpreted and native code so we
can start running wasm code immediately after validation while
compilation happens in the background, and switching to native code
eventually once we hit a big enough function that would benefit from
being compiled to begin with.
2026-06-05 00:08:11 +02:00
Ali Mohammad Pur
3c89c36158 LibWasm+LibWeb: Restore disk cache for compiled wasm modules
Also untangle the confusing validation layering on async compilation.
2026-06-05 00:08:11 +02:00
Timothy Flynn
85c7620805 UI/Qt: Collapse hover-expanded vertical tabs after leaving window
When collapsed vertical tabs are expanded on hover, the collapse check
used QCursor::pos() against the vertical tabs rect. On some platforms,
after the cursor leaves the browser window entirely, that position can
remain at the last in-window coordinate, so the tabs stay expanded.
2026-06-04 22:16:16 +01:00
Sam Atkins
879fc69f89 LibWeb/CSS: Link DevTools rules to UA stylesheets
UA and user stylesheets do not have owner nodes or owner rules, so their
matched rules cannot be mapped through the generic stylesheet identifier
helper. Share the built-in UA stylesheet enumeration and map UA rules by
the matched CSSStyleSheet object, so that they stay in sync with any
future changes.
2026-06-04 20:54:33 +01:00
Sam Atkins
64e0aa8c26 LibWeb+LibDevTools: Link style rules to CSS sources
Resolve applied-rule stylesheet identities through StyleSheetsActor and
include Firefox parentStyleSheet, line, and column fields on rule forms.
Firefox can then show matched rules as stylesheet rules and open the
corresponding CSS source location from the Rules panel.
2026-06-04 20:54:33 +01:00
Sam Atkins
b2b164ebd7 LibWeb+WebContent: Report CSS rule source data
Include parser rule locations and stylesheet identities in the applied
style rule data sent to DevTools. This gives the protocol layer enough
information to map matched rules to existing stylesheet resources
without guessing from displayed rule text.
2026-06-04 20:54:33 +01:00
Sam Atkins
52e1d30404 LibWeb+LibDevTools: Report applied style rules to Firefox
Collect the style rules that apply to an inspected element and expose
them through the existing DOM node inspection path. This gives Firefox's
Rules panel real rule forms instead of the previous empty getApplied
response.
2026-06-04 20:54:33 +01:00
Sam Atkins
121105eb83 LibWebView+WebContent: Pass DOM inspection options
Extend the existing DOM node inspection request with an options payload
and carry it through the browser process, WebView, IPC, and WebContent.
This lets later DevTools requests forward Firefox's top-level flags
without changing any inspected-node behavior yet.
2026-06-04 20:54:33 +01:00