Commit graph

4934 commits

Author SHA1 Message Date
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
Andreas Kling
164ed80244 Meta: Enable exit-time destructor warnings for libraries
Enable -Wexit-time-destructors for all in-tree library targets and
update process-lifetime library statics so they no longer register
exit-time destructors. Long-lived caches, lookup tables, singleton
registries, and generated constants now use NeverDestroyed or leaked
references where the data is intended to live until process exit.

Update LibWeb, LibLine, and the binding generators so regenerated
sources follow the same rule instead of reintroducing destructed
statics.
2026-06-04 19:20:49 +02:00
sideshowbarker
ad6f646d6d Meta: Rebuild Rust crates when the toolchain changes, not just sources
Problem: After a git pull of master, builds fail with an error message
about multiple/duplicate rust_eh_personality definitions/symbols.

Cause: LibWeb links two Rust staticlibs: libweb_content_blocker_rust and
libweb_rust. Both bundle Rust’s standard library (std). When we re-pin
rust-toolchain.toml, a git pull moves a rustup user’s compiler — but we
were only rebuilding the crate whose .rs also changed. So that left one
crate on the old std, and the other crate on the new std.

Fix: Make the cargo custom commands also depend on rust-toolchain.toml
and rustc — so a toolchain change re-triggers every Rust crate.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/9854
Fixes https://github.com/LadybirdBrowser/ladybird/issues/9643
2026-06-04 07:41:45 -04:00
Timothy Flynn
c5bb98bcf0 Meta: Revert to a stable rust compiler
Let's not depend on a nightly pre-release, especially not just for a
linting option. We can enable the linter option once it lands in the
stable release.
2026-06-02 20:12:41 +02:00
Aliaksandr Kalenik
0e6528f9da Meta+LibWeb: Generate accumulated visual context property metadata
Style invalidation kept the list of properties that require rebuilding
the accumulated visual context tree in StyleInvalidation.cpp. That made
the classification separate from the existing property metadata used for
layout and stacking-context invalidation.

Move that classification into Properties.json and teach the PropertyID
generator to emit property_affects_accumulated_visual_contexts(). Style
invalidation now uses the generated predicate, preserving the existing
property set and behavior while making future classification changes
data-driven.
2026-06-02 18:55:25 +01:00
Sam Atkins
693517daa0 LibWeb: Resolve container-relative length units
Add cqw/cqh/cqi/cqb/cqmin/cqmax to the unit tables and generated
helpers, then thread them through the shared length resolution path.

Length::ResolutionContext now carries the subject element and whether
its inline axis is horizontal. Container units need that extra context:
the nearest eligible query container is selected from the subject
element's flat-tree ancestors, and cqi/cqb/cqmin/cqmax map logical axes
through the subject's writing mode before resolving to a physical width
or height.

Teach Length to resolve each axis against the selected container's
content box, fall back to viewport lengths when no eligible container
exists, and mark size-container dependencies so post-layout
recomputation can happen when layout is not up to date.

Also expose the new units through Typed OM, reject them for
computationally independent `@property` initial values, and add focused
font-size coverage.
2026-06-01 08:27:17 +01:00
Andreas Kling
6f616ae9a9 LibGfx: Remove TinyVG image decoding
Remove the TinyVG decoder now that the Qt chrome no longer depends on
TVG resources. Drop the decoder registration, MIME and supported image
type entries, fuzzer target, decoder tests, and TinyVG test inputs.
2026-05-31 19:20:59 +02:00
Shannon Booth
5d9cbee20b LibWeb/Bindings: Follow WebIDL buffer source conversion steps
Handle ArrayBuffer, SharedArrayBuffer, DataView, and typed array
conversions according to the WebIDL buffer source algorithms.

This rejects shared backing buffers unless [AllowShared] is present,
rejects resizable/growable backing buffers unless [AllowResizable] is
present.
2026-05-31 12:05:19 +02:00
Shannon Booth
c942084a16 LibWeb/Bindings: Remove unneeded Location special case
This should be handled by the platform object path.
2026-05-30 11:22:08 +02:00
Shannon Booth
97abc707c7 LibWeb/Bindings: Generate buffer typedefs as variants
Represent BufferSource and ArrayBufferView as ordinary IDL typedefs over
their underlying union types, instead of special casing in the IDL
generator. This allows the union conversion/return machinery handle
these types consistently with other typedefs, which removes buffer
specific paths from the IDL generator.

This necessitates changing the WebIDL::BufferSource and
WebIDL::ArrayBufferView classes as views over these variants. This
replaces the old GC backed BufferableObject wrapper structure and
provide convenience helpers to determine things such as the byte length,
byte offset, backing buffer, and typed-array APIs.
2026-05-30 11:22:08 +02:00
Luke Wilde
d4d9fc12f7 Meta: Generate HSTS preload data from Chromium's static list
Download transport_security_state_static.json on configure and
emit a sorted flat array of (name, include_subdomains) pairs.
The generator keeps only force-https entries, drops IP literals,
and validates names against [a-z0-9.-] so the emitted C++ string
literals need no escaping.

Matches Firefox's HSTS preload source:
https://searchfox.org/firefox-main/rev/ca47ec6bb1f3e46a384cd1ebb11c5996cceef90f/taskcluster/docker/periodic-updates/scripts/getHSTSPreloadList.js
2026-05-29 22:23:33 +02:00
Luke Wilde
85fd3bb7b0 LibGC: Introduce ConservativeHashTable 2026-05-28 21:16:23 +02:00
Sam Atkins
d3ad37e635 Meta: Define helper processes for Ladybird and test-web in one place
These both require the same helper processes, and maintaining the same
list in multiple places is error-prone. For example, I spent too long
debugging why test-web was crashing, when the issue was that Compositor
hadn't been rebuilt as test-web didn't depend on it. That problem can
no longer happen if we define the same dependency list for both.
2026-05-28 14:45:48 +01:00
Suraj Yadav
ec2b96f4bf Meta: Restore serenity_gdb.py
Restore serenity_gdb.py => Meta/gdb/PrettyPrinters/ak.py.
Remove VirtualAddress and AKFixedStringBuffer.
Fix Hashmap, IntrusiveList, Optional and Vector printers.
2026-05-28 14:33:25 +01:00
Suraj Yadav
a5b925fdec Meta: Add lldb pretty printers for AK types
fix string printer

Use lldb command to import printer

fix order and use nonsynthetic value

fix optional
2026-05-28 11:55:24 +01:00
Vanand Gasparyan
f3a3488cda Rust: Set import granularity to Item
By default, `rustfmt` persists the import granularity. In practice, most
Rust code has import granularity "Module" due to LSP's actions.

"Item" gets rid of import groupings and achieves cleaner diffs and
better conflict resolution. Better greppability is a positive side
effect.

Note: it's an unstable rustfmt feature. `cargo +nightly fmt` must be
used instead of `cargo fmt`.
2026-05-28 06:52:18 +02:00
Sam Atkins
ae2e01b77c Meta: Mark generated CSS enum to_string() methods as WEB_API
A couple of these are going to be needed by DevTools, running in the
WebContent process. It links to LibWeb, but couldn't link to these
previously.
2026-05-27 17:47:50 +01:00
Shannon Booth
59434095e6 LibWeb/Bindings: Avoid releasing nullable strings when wrapping
Generated wrapping code only needs to read the contained string value
when creating a JS::PrimitiveString. Use value() instead of
release_value() so nullable or optional string wrappers are not consumed
during wrapping, and remove the now-unneeded const_cast workaround.
2026-05-26 21:43:57 +02:00
Shannon Booth
9e68b5c3d8 LibWeb/Bindings: Use IteratorStepValue for sequence conversion 2026-05-26 21:43:57 +02:00
Shannon Booth
df6c3fcfaa LibWeb/Bindings: Remove GenerateAsRequired handling from IDL generator
This was used before we generated dictionary definitions using the IDL
generator, and no longer serves the purpose it used to.
2026-05-26 21:43:57 +02:00
aplefull
105098131b Tests+Meta: Reimport WebKit regexp tests
This commit updates Meta/import-webkit-regexp-tests.py and re-imports
WebKit tests.

Removed pcre-test-1 from SKIP_TESTS because we pass it.

Removed everything except slow.js from XFAIL_TESTS. We pass everything
except slow.js, which still hits the step limit.

Moved overflow.js to SKIP_FILES because it tests WebKit's behaviour of
rejecting regexps with huge quantifiers. Ladybird, Chrome, and Firefox
just clamp them.
2026-05-26 10:00:22 +02:00
aplefull
b3bd8884ae Tests+Meta: Reimport V8 regexp tests
This commit fixes assertEquals, assertThrows/assertDoesNotThrow in
compatibility shim - we were failing some tests purely because of a
bad shim.

Two test files are moved from XFAIL_TESTS to SKIP_FILES:
1. es6/regexp-tostring.js: checks for V8-specific error message wording
2. es6/unicode-regexp-ignore-case-noi18n.js: tests V8's non-i18n build
    behavior, it doesn't case-fold non-ASCII characters, but we do it
    correctly.

The regexp-unicode-sets.js test is now included and passes.

All files that were previously in XFAIL_TESTS and SKIP_TESTS are now
passing, so both lists are cleared.
2026-05-26 10:00:22 +02:00
Aliaksandr Kalenik
69a457a63b LibGC+Meta: Remove IGNORE_GC macro 2026-05-25 11:06:23 +02:00
Shannon Booth
a8a78100b3 LibWeb/Bindings: Add helpers for recursive IDL type traversal
Add a small type traversal helper for walking IDL type references, with
modes for type-structure-only traversal and expanded dictionary/callback
traversal.

Use it for generated include dependency collection, dictionary
dependency generation, and GC-aware storage detection. This removes
several bespoke recursive walkers while keeping each caller responsible
for the action taken for each referenced type.
2026-05-24 16:37:28 +02:00
Shannon Booth
63195c4830 LibWeb/Bindings: Track generated binding includes at use sites
Replace the bindings generator's up-front dependency include scan with a
GeneratedIncludes accumulator that is threaded through the
implementation, dictionary conversion, argument conversion, and wrapping
emitters.

Emitters now add the headers required by the code they produce, while
generated headers and implementations are built into temporary builders
so includes can be collected before the prologue is emitted. This also
folds module, bindings, and iterator include handling into the same
sorted/deduped header path mechanism.
2026-05-24 16:37:28 +02:00
Shannon Booth
6248296f86 LibWeb/Bindings: Normalize bindings generator include paths
Pass source/build Libraries roots via --header-include-path and
canonicalize them in BindingsGenerator so generated dependency includes
use LibWeb/... paths instead of local absolute paths.

For example:

`#include "/home/shannon/ladybird/Libraries/LibWeb/DOMURL/DOMURL.h"`

becomes:

`#include "LibWeb/DOMURL/DOMURL.h"`
2026-05-24 16:37:28 +02:00
Andreas Kling
bcdbdbb5b3 LibWeb: Add adblock-rust FFI hooks
Add adblock-rust to a dedicated LibWeb content blocker Rust crate
and expose FFI entry points for creating an engine, matching network
requests, and producing cosmetic CSS. Export a string result type for
returning generated CSS to C++ callers.

Regenerate the Flatpak cargo source list for the new Rust
dependencies.
2026-05-24 08:16:46 +02:00
Aliaksandr Kalenik
1201015ab8 Meta: Fix IPC generated try helper response unwrapping
Generated try_* proxy methods for synchronous messages with a single
output declared IPCErrorOr<T>, but returned the whole response object
instead of the output payload. That made helpers with named bool
responses unusable once callers started using the fallible path.

Share the same single-output accessor logic used by the infallible sync
helpers so fallible generated helpers return the declared payload type.
2026-05-24 03:35:07 +01:00
Shannon Booth
637fd51595 LibWeb: Unify WebIDL C++ type generation
Represent WebIDL C++ types with a single CppType model that tracks
nullability, optional presence, and contained storage.

GC-like values now use GC::Ref/GC::Ptr directly, while containers choose
"plain", "Root", or "Conservative" container types depending on what
they contain. For example, sequence<Element> becomes a RootVector of
GC::Ref values, while sequence<SomeDictionary> becomes a
ConservativeVector only when the dictionary contains GC-like values.
This moves the generated bindings away from wrapping GC values in
GC::Root by default.

This has broad fallout as the types passed to interfaces for GC
objects changes almost fully across the board.
2026-05-23 18:26:12 +02:00
Martin Chrástek
cd3c72dfda LibWeb: Implement chardetng-based encoding detection for HTML parsing 2026-05-23 11:57:33 +02:00
Martin Chrástek
d0334ca550 Meta: Handle legacy-encoded WPT files in import-wpt-test.py
Some WPT test files (e.g. encoding-detection tests) are intentionally
stored in a legacy encoding rather than UTF-8. Use
decode("utf-8", errors="replace") so undecodable bytes are replaced
with U+FFFD instead of raising a UnicodeDecodeError.
2026-05-23 11:57:33 +02:00
Darshanx256
e3cc5d1fe9 LibWeb: Support CSS transitions and animations on all pseudo-elements
Restricted pseudo-elements (like ::placeholder, ::first-letter,
::first-line, and ::selection) use property whitelists. These
whitelists did not include transition or animation properties.
As a result, pseudo_element_supports_property() rejected transition and
animation declarations during cascade filtering. This caused
transition-duration and transition-delay to resolve to their initial
values (0s), which triggered the zero-second optimization in
compute_transitioned_properties() and prevented transition
registration.

This change introduces a fast-path check in the generated function
pseudo_element_supports_property() to automatically accept all CSS
transition and animation properties on any styleable pseudo-element.
2026-05-22 10:07:29 +01:00
Luke Wilde
f955d4e8a4 LibGC: Introduce ConservativeHashMap 2026-05-21 18:29:41 +02:00
Callum Law
0c5d120d75 LibWeb: Mark pseudo-elements as either synthetic or element-reference
See new paragraph in `Documentation/CSSGeneratedFiles.md` for what this
signifies.
2026-05-21 14:26:22 +01:00
Shannon Booth
387cd6e2e2 LibGC: Default-construct RootVector from the global heap
Similar to GC::Root<T>, make GC::RootVector<T> constructible without
explicitly passing a Heap.

This is implemented by having RootVectorBase use GC::Heap::the() for
heap-free construction.
2026-05-20 20:37:55 +02:00
Sam Atkins
9996403e73 LibWeb/CSS: Extract base class from MediaFeature
`<media-feature>` and the upcoming `<size-feature>` from `@container`,
share the same syntax and almost all of their behaviour. To avoid a lot
of duplication, pull as much as possible into a FeatureQuery template
class that they will both inherit from.

MediaFeatureValue is renamed FeatureValue as it's also shared by both.

No behaviour change.
2026-05-20 13:00:50 +01:00
Luke Wilde
d911b79ec9 LibGC: Introduce RootHashTable 2026-05-19 19:24:08 +02:00
Andreas Kling
4ac744082b LibJS: Cache dynamic environment coordinates
Dynamic environment binding opcodes lost the old coordinate warmup.
They were split away from the static coordinate opcodes. Hot closures
and eval-sensitive functions then resolved the same binding by name on
every execution, which regressed JS benchmark throughput badly.

Give each dynamic environment opcode a per-executable coordinate cache
slot. The cache keeps the bytecode stream immutable while letting both
interpreters take a direct declarative environment fast path after the
first lookup. Keep the existing eval invalidation behavior and only warm
caches for declarative-only chains so with environments continue to
observe object shadowing.

Reject cached bytecode that uses the no-cache sentinel for dynamic
environment coordinate cache operands, since execution indexes those
cache arrays unconditionally.

Rebaseline bytecode expectations for the instruction size changes. Add
coverage for with-object shadowing across repeated dynamic lookups and
for rejecting corrupt dynamic environment cache indices.
2026-05-19 15:54:23 +02:00
Shannon Booth
dc86cc1118 Meta: Remove unused GeneratorUtil.h 2026-05-19 15:33:18 +02:00
Andreas Kling
a5ba300186 LibJS: Split dynamic environment lookups from coordinates
Add separate bytecode instructions for environment lookups that must
stay dynamic, such as eval- and with-sensitive scopes. Keep the
coordinate variants for eagerly resolved declarative environments so
their operands can be treated as immutable at runtime.

This removes cached-coordinate mutation from the interpreter paths and
updates the bytecode expectations for the new dynamic lookup opcodes.
2026-05-18 20:35:14 +02:00
Andreas Kling
1ce4242b4b LibJS: Store bytecode cache indexes instead of pointers
Store compact cache indexes in bytecode instructions instead of raw
pointers to the executable cache vectors. This keeps the instruction
stream independent from heap addresses and removes pointer fixups when
materializing cached bytecode.

Resolve the mutable cache pointers at execution time from the current
Executable. Bytecode test expectations are updated for the smaller cache
operands and resulting instruction offsets.
2026-05-18 20:35:14 +02:00
Shannon Booth
c41629ec22 LibWeb/Bindings: Handle nullable conversions at the top level
Move nullable JS-to-C++ handling out of the per-type conversion helpers
and into the top-level conversion path. This lets us implement type
conversion much closer to the specification steps, and will allow for
making type representation more consistent.
2026-05-17 21:27:15 +02:00
Shannon Booth
e75f5255f2 Meta: Generate LibWeb Bindings/Forward.h from Python
Port Bindings/Forward.h generation into
generate_window_or_worker_interfaces.py and remove the old C++
generate_forward_header path from BindingsGenerator.
2026-05-15 17:52:52 +01:00
Shannon Booth
265559c5b5 Meta: Add limited parsing for WebIDL dictionaries
For now, this is limited as we do not parse the contents of the
dictionary and only extract the dictionary names.
2026-05-15 17:52:52 +01:00
Shannon Booth
c8a650ec1f LibWeb/Bindings: Handle variadic conversion at the top level
Move variadic JS-to-C++ handling out of the per-type conversion helpers
and into the top-level conversion path. This allows us to centrlize
the logic, and also adds support to variadic to more types.
2026-05-15 08:59:25 +02:00
Shannon Booth
3d35517734 LibWeb/Bindings: Handle optional conversion defaults at the top level
Move optional JS-to-C++ handling out of the per-type conversion helpers
and into the top-level conversion path. This allows us to centralize
handling and makes type conversion much closer to the specification
steps.
2026-05-15 08:59:25 +02:00
sideshowbarker
8121ff8278 CI: Bump base image to ubuntu:26.04; add AT-SPI2 deps
Required for Qt AT-SPI2 bridge tests. The 26.04 bump gets us Qt 6.10 (we
need ≥6.8) and Orca 50.1 (we need ≥47) directly from apt — so we don’t
need a separate Qt install or Orca overlay.

This also gets us both clang-21 and clang++-21 — because Ubuntu’s own
26.04 repo has those, and bundles both into the same package. So we no
longer need to add the apt.llvm.org repo to get those.
2026-05-13 16:23:47 +02:00
Zaggy1024
5aa0d13a99 Meta+CI: Add pyright type checking to lint_python.sh 2026-05-13 08:13:51 -05:00
Zaggy1024
935b185aaa Meta: Make static type checking happy in import-wpt-test.py 2026-05-13 08:13:51 -05:00
Zaggy1024
c0609f4ee1 Meta: Clarify that webidl_parser.py's raise_parse_error() cannot return
This allows functions to skip returning/asserting after calling it.
2026-05-13 08:13:51 -05:00