Commit graph

93 commits

Author SHA1 Message Date
Andreas Kling
b81269e78b Libraries: Clean up UTF-16 source text paths
Store parser errors, source range filenames, source code filenames,
module source, and Rust parser errors as UTF-16 where they flow back
into JavaScript-visible strings. Keep byte-oriented source buffers
byte-backed.

Remove temporary PrimitiveString, ByteString, and UTF-8 detours from
JSON, RegExp, module debug logging, print formatting, and tests.
2026-06-22 19:51:25 +02:00
Andreas Kling
b6bef6b688 Libraries: Use UTF-16 for JS-visible runtime strings
Produce JS-visible string results as UTF-16 at their source, including
numeric formatting, BigInt and BigFraction formatting, URI encoding,
console formatting, parser errors, regular expression errors, Intl and
Temporal records, LibUnicode locale boundaries, and LibWeb bindings.

Handle fractional radix formatting through the UTF-16 builder view.
2026-06-22 19:51:25 +02:00
Andreas Kling
ee37bb5a9c LibJS: Remove primitive string UTF-8 paths
Move the remaining LibJS primitive string users to UTF-16 views and
strings. Remove the primitive string UTF-8 accessors and byte-string
coercion paths so new callers cannot rely on the old storage model.
2026-06-22 19:51:25 +02:00
Tim Ledbetter
2f84f89874 LibWeb: Drop non-typesetting properties from pseudo element allowlist 2026-06-22 09:43:07 +02:00
Tim Ledbetter
cd29e3013d LibWeb: Remove block properties from inline typesetting allow list 2026-06-22 09:43:07 +02:00
Tim Ledbetter
9b06a79b81 LibWeb: Add missing properties to pseudo element allow list 2026-06-22 09:43:07 +02:00
Shannon Booth
7b0dd6ab30 LibTextCodec: Use encoding_rs for legacy codecs
Replace the generated C++ legacy codec implementations with a
small Rust wrapper around encoding_rs.

This keeps the existing LibTextCodec API while moving label lookup,
legacy decode/encode, validation, and streaming decoder state to Rust.
The generated index data and generator are no longer needed.

It also fixes several TextDecoder EOF cases due to a more correct
implementation. encoding_rs finalizes decoders according to the
Encoding Standard, so incomplete UTF-8/Big5 tails and malformed
UTF-16 surrogate tails produce the required single replacement at
end-of-queue instead of being dropped, buffered, or double-counted
by our old hand-written decoders.
2026-06-20 21:56:43 +02:00
Ali Mohammad Pur
530c95fde5 LibWasm: Remove all gc, function-refs and EH test exceptions 2026-06-19 17:01:47 +02:00
Ali Mohammad Pur
16d1486cc9 LibWasm: Implement the wasm-gc instruction set in the BC interpreter 2026-06-19 17:01:47 +02:00
Callum Law
fdca036ff3 LibWeb: Implement CSS progress() math function
`no-clamp` tests are added in-tree since there aren't any in WPT yet.
2026-06-19 09:33:06 +01:00
Aliaksandr Kalenik
54a07a08b4 LibWeb+Compositor: Move OpenGLContext in Compositor namespace 2026-06-17 19:07:32 +02:00
Aliaksandr Kalenik
7efdb8a900 LibWeb+Compositor: Move OpenGLContext in Compositor 2026-06-17 19:07:32 +02:00
Aliaksandr Kalenik
5f0e95de13 Meta+LibWeb+Compositor: Add remote canvas transports
The display list can now refer to canvas ids, but WebContent still had
no channel for creating or updating those canvas resources in the
Compositor. Both 2D and WebGL canvases would have had to grow the IPC
plumbing in the same commit that changes the rendering contexts.

This adds the Compositor-side CanvasHost, WebContent transport objects,
and the IPC/CMake pieces needed to allocate, update, read back, and
destroy remote canvas contexts. The rendering contexts are not switched
over yet, keeping this as plumbing for later commits.
2026-06-17 19:07:32 +02:00
Aliaksandr Kalenik
9a8a7798ec Meta+LibWeb: Generate WebGL command proxy scaffolding
Moving WebGL execution into the Compositor needs a serializable command
stream and a client-side proxy that can queue commands before sending
them over IPC. The existing generator metadata only described direct GL
wrappers, so generated code could not distinguish async commands from
sync calls or object factory methods.

This teaches the WebGL metadata and generators about command streams and
adds the unused LibWeb proxy/list types. No rendering behavior changes
yet; the later host wiring can build on these generated interfaces
without mixing the metadata churn into that commit.
2026-06-17 19:07:32 +02:00
Andreas Kling
e5bcffc3d5 LibJS: Move bytecode block counting to Rust
Use the Rust bytecode dumper's basic block collection logic for the
metadata block count. This removes the last C++ bytecode label walk and
lets us delete the generated C++ label and operand visitor helpers.
2026-06-15 02:41:57 +02:00
Andreas Kling
7a6af95db3 LibJS: Move bytecode instruction dumping to Rust
Generate Rust bytecode dump helpers from Bytecode.def and route
Executable::dump() through them for instruction stream formatting.

Add a small Rust runtime::value helper for decoding encoded LibJS
Values so immediate Value operands are formatted on the Rust side. C++
callbacks remain only for local names and GC-backed Value payloads that
still need LibJS object access.

Remove the generated C++ to_byte_string_impl() methods and the old
Instruction::to_byte_string() dispatch. The bytecode dump tests cover
output compatibility.
2026-06-15 02:41:57 +02:00
Andreas Kling
5ca52d2a77 LibJS: Remove generic bytecode interpreter
Remove the C++ bytecode interpreter dispatch loop now that AsmInt is the
only bytecode execution engine. Keep the existing AsmInt fallback path
for instructions that have not yet been moved into assembly or C++ slow
path handlers.
2026-06-14 20:27:59 +02:00
Shannon Booth
4efd7dcef8 LibWeb: Always treat [Replaceable] attributes as having setters
[Replaceable] readonly attributes still need JS accessor setters for
replacement and receiver checks. Remove the include_replaceable opt-in
so the binding generator handles them consistently.
2026-06-13 22:05:45 +02:00
Aliaksandr Kalenik
5b856595b3 Meta+LibWeb/WebGL: Route all GL calls through generated GLFunctions
LibWeb's WebGL implementation currently reaches ANGLE by calling glFoo()
throughout the WebGL context and extension code. That ties the WebGL
spec layer to the concrete GL executor. A future backend that records
operations, sends them to another process, or executes them from the
Compositor would otherwise need to duplicate the WebGL logic or edit
every call site again.

Introduce GLFunctions as an explicit boundary between WebGL semantics
and GL execution. GLFunctions.json lists the GL entry points used by the
implementation, and the generator emits one forwarding method per entry
point. OpenGLContext implements those methods today, so the current
in-process ANGLE path keeps the same behavior while all callers go
through a single replaceable interface.

That boundary is needed before canvas/WebGL rendering can move to the
Compositor: the WebGL context code can keep doing validation, state
tracking, and spec-visible error handling in LibWeb, while a later
implementation can record the same GL calls and replay them where the
canvas surface is produced. The JSON source also gives the recorder and
replayer one shared description of argument shapes, avoiding two
hand-written views of the GL API drifting apart.
2026-06-13 01:58:43 +02:00
Shannon Booth
6ea6ba3866 LibWeb/Bindings: Don't install inherited members on global objects
When generating global mixins, only define regular members from the
[Global] interface itself on the global object. Inherited members remain
available through the prototype chain.

This was found due to a timeout on:

https://wpt.live/html/dom/idlharness.any.worker.html

Installing inherited members created fresh own functions on worker
globals, so self.importScripts differed from
WorkerGlobalScope.prototype.importScripts. That confused idlharness into
taking its null-this check path for importScripts, which then attempted
to import "null" and timed out.
2026-06-11 21:35:56 +02:00
Shannon Booth
cc871620e6 LibWeb/Bindings: Preserve object EventHandler assignments
EventHandler attributes are nullable callback function attributes with
[LegacyTreatNonObjectAsNull]. Assigning a non-object value should
produce null, but assigning an object value should preserve that object
as the callback value, even when the object is not callable.

Previously, object values such as `{ handleEvent() {} }` could pass the
nullable conversion and then be converted to null by the inner callback
function conversion. This made MessagePort.onmessage in the fixed test
return null after such an assignment.

Handle the non-object-to-null rule in nullable conversion, and let the
legacy callback conversion wrap object values without rejecting them for
not being callable.

Fixes a regression in the python port of the IDL generator.
2026-06-11 21:33:58 +02:00
Ali Mohammad Pur
38f8f747ee Meta+Tests: Fix test generation for extern refs and module definition 2026-06-10 14:10:57 +02:00
Shannon Booth
5ef34ecb7a LibURL: Use libpsl for public suffix matching
Replace the generated public suffix table and custom matcher with a
direct LibURL PublicSuffixData implementation backed by libpsl. This
drops our PSL download/generator path and uses the same library already
used by libcurl.

Performance is comparable before and after, while LibURL binary size
is smaller.
2026-06-10 11:43:44 +02:00
Shannon Booth
6c2ad3af02 LibWeb/Bindings: Reuse @@iterator method for sequence union conversion
When converting an object to a union containing a sequence, Web IDL
first gets @@iterator to decide whether the sequence arm applies, then
creates the sequence from the iterable using that same method.

The generator instead called sequence_to_idl_value(), which repeated the
@@iterator lookup. Split out create_sequence_from_iterable() and use it
from union sequence/FrozenArray conversion so overridden Symbol.iterator
accessors are only observed once.
2026-06-09 21:24:18 +02:00
Andreas Kling
4522340416 LibWeb: Preserve implemented overloads with FIXME siblings
Do not emit an unimplemented prototype property for an operation name
when at least one overload with that name is implemented. The overload
resolver already filters FIXME overloads out of the native overload set,
so defining an unimplemented property afterwards replaces the working
function with undefined.

This lets WebGL2RenderingContext.texImage2D keep its implemented WebGL1
and typed-array overloads even though the PBO-offset overload remains
marked FIXME.
2026-06-09 16:08:44 +02:00
Andreas Kling
13a804dbf6 LibWeb: Compact generated CSSStyleProperties bindings
Stop emitting every generated CSS property accessor as an IDL attribute.
Instead, generate a compact CSSStyleProperties initializer that installs
all property aliases from a table and dispatches through one native
function class carrying the UTF-16 property name.

This keeps the generated binding file focused on cssFloat and moves the
large property list into a simple generated table.
2026-06-09 11:48:02 +02:00
Andreas Kling
aa01898299 LibWeb: Reuse generated attribute name IDs
Emit each generated attribute name once and reuse that UTF-16 id when
creating the getter, creating the setter, and defining the accessor.
This avoids repeating the same Utf16FlyString literal at every generated
attribute binding.
2026-06-09 11:48:02 +02:00
Andreas Kling
388ec003ca LibWeb: Take UTF-16 names in CSS property APIs
Move the remaining CSSStyleDeclaration property-name APIs to
Utf16FlyString. This lets CSSOM binding and generated accessor code
pass JS property names without first constructing FlyString values.

Keep internal custom-property and descriptor storage unchanged for now.
Those remaining FlyString conversions are at storage boundaries that
will be migrated in follow-up commits.
2026-06-09 11:48:02 +02:00
Andreas Kling
22a26babc5 LibWeb: Take UTF-16 names in get_property_value
Change get_property_value() to take a Utf16FlyString so generated CSS
property accessors can pass their JS property names through without
constructing FlyString instances first.

Keep the existing internal descriptor and custom-property storage shape
for now, and convert at those boundaries while the remaining CSS
property APIs are migrated separately.
2026-06-09 11:48:02 +02:00
Shannon Booth
20bfc49083 LibURL: Preserve trailing dots in public suffix matching
PublicSuffixData handled trailing-dot hosts incorrectly when a PSL rule
matched, causing returned public suffix and registrable-domain results
to drop the trailing dot.

Make PublicSuffixData skip leading dots for matching, ignore a single
trailing dot while running the PSL algorithm, and append that trailing
dot back to returned results.
2026-06-08 20:19:06 +02:00
Shannon Booth
d21044de15 LibURL: Fix public suffix matching for canonical hosts
Public suffix matching could fail when callers passed host text that
was not already in the same form as the generated PSL table. In
particular, uppercase ASCII hosts like EXAMPLE.COM and UTF-8 IDN hosts
could miss matches even though URL hosts are canonically represented as
lowercase ASCII/IDNA.

Make the PublicSuffixData API difficult to misuse by routing all
invocations through URL::Host overloads so that the canonical hostname
is always what is matched against.
2026-06-08 20:19:06 +02:00
Shannon Booth
9b80ac00be LibURL: Move registrable-domain PSL lookup to PublicSuffixData
Move the registrable-domain helper from URL into PublicSuffixData and
name it find_matching_registrable_domain().

This keeps it alongside find_matching_public_suffix(), making it clear
that both APIs only return results matched from the PSL data, while
Host::public_suffix() implements the URL Standard fallback to the
top-level domain.
2026-06-08 20:19:06 +02:00
Shannon Booth
ac344a5196 LibURL: Clarify PSL matching API names
Rename PublicSuffixData's raw lookup helpers to make it clear that they
only return public suffixes matched from the PSL data.

This distinguishes them from Host::public_suffix(), which implements the
URL Standard definition and falls back to the top-level domain when no
PSL rule matches.

We need both layers because address bar handling needs the raw lookup to
decide whether input should be treated as a URL or as a search.
2026-06-08 20:19:06 +02:00
Shannon Booth
4a681c9148 Libraries: Remove LibIDL
Move the overload-resolution metadata types into LibWeb::WebIDL and
update the Python generator and overload resolver to use them.

LibIDL no longer has any users after the C++ bindings generator removal,
so remove the library and unlink it from LibWeb.
2026-06-08 01:11:40 +02:00
Shannon Booth
dba62aefc0 LibWeb/Bindings: Port IDL bindings generator to Python
Replace the Lagom C++ bindings generator invocation with the new Python
generator under Meta/Generators/libweb_bindings.

Fold the exposed-interface generation into the same generator entry
point, and keep generated overload metadata using the existing LibIDL
types for now.
2026-06-08 01:11:40 +02:00
Tim Ledbetter
2a5f239d11 LibURL: Reverse host labels before searching the public suffix table
The generated public suffix table stores each entry with it's labels
reversed, but the lookup we were using didn't reverse its input before
searching. This led to multi-label public suffixes not matching when
they should have.
2026-06-07 14:00:48 +02:00
Shannon Booth
2e09af3116 Meta: Parse WebIDL declarations into structured objects
Teach the python WebIDL parser to retain typed declarations instead of
keeping or skipping raw text.
2026-06-06 19:16:52 +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
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
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
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
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
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
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
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
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
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
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