Commit graph

12 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
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
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
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
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