Commit Graph

512 Commits

Author SHA1 Message Date
Shannon Booth
4b92e0f0c2 LibWeb/Bindings: Factor out attribute setter code generation
No functional impact.
2026-03-14 00:08:20 +01:00
Shannon Booth
dcce7e63c6 LibWeb/Bindings: Remove redundant HTML::Window check in impl_from
This is covered by the @fully_qualified_name@ type check just below,
WindowProxy is the only special case that we need to handle at the
IDL layer. Also split this into two separate functions while we
are at it, as this function as-is is performing a few different
specification steps all at once.
2026-03-14 00:08:20 +01:00
Jelle Raaijmakers
fb353a64c1 LibWeb: Detect promise-returning IDL callbacks correctly
The code generator checked is_object() to detect Promise return types,
but Promise<T> is a ParameterizedType, so the check always failed and
caused crashes in WebContent in throwing callback functions.
2026-03-12 10:38:43 +01:00
Shannon Booth
e555edd770 LibWeb/Bindings: Implement callback interface object bindings
Generate correct bindings for callback interfaces: only create an
interface object when the interface declares constants, and set up
the prototype correctly.

This also lets us tidy up some IDL for these callback interfaces.
2026-03-11 21:16:44 +01:00
Shannon Booth
6a2540213a LibWeb/Bindings: Use implemented names for imported IDL headers
The bindings generator derived imported interface headers from the IDL
file name. That only works when the IDL name, implemented C++ type, and
header basename all match.

Interfaces with [ImplementedAs] break that assumption, since the
generated bindings need to include the implementation header rather than
the header implied by the IDL file name.

This fixes a compile error in a future commit where EventListener
callback interface is split into its own IDL file with an
ImplementedAs of IDLEventListener.
2026-03-11 21:16:44 +01:00
Jonathan Gamble
938ca3dbad Meta: Fix optional dictionary wrapping in IDL generator
Handle Optional<T> and Optional<Variant<...>> correctly when wrapping
dictionary members, and make ComputedEffectTiming.localTime optional
to distinguish absence from null.
2026-03-10 22:49:19 +01:00
Jelle Raaijmakers
703bef336a Meta/IDLGenerators: Do not call resolve_overload() if possible
For overload sets of size 1, we don't need to call into
`resolve_overload()` preventing many heap allocations. This effectively
removed EffectiveOverloadSet / resolve_overload from profiles for me on
slither.io.
2026-02-27 11:42:38 -05:00
Jelle Raaijmakers
0d262ac558 Meta/IDLGenerators: Make use of as_if<T> for union type checks 2026-02-27 11:42:38 -05:00
Luke Wilde
09e00677eb IDLGenerators: Support Experimental extended attribute on IDL attributes 2026-02-24 17:08:48 +01:00
Luke Wilde
79de597f8a IDLGenerator: Implement LegacyLenientSetter 2026-02-23 18:44:26 +00:00
Ben Wiederhake
b765a3a261 LibWeb: Remove unused header in IDLGenerators 2026-02-23 12:15:23 +01:00
Ben Wiederhake
dab83d35d1 AK: Remove unused include from ByteString 2026-02-17 12:38:51 +00:00
Callum Law
3f8da74e63 LibIDL+Meta: Add support for WebIDL maplike declarations on interfaces
Currently we only support string keys and numeric sequence values.

This is heavily based on the implementation of `setlike`.
2026-02-17 12:25:27 +00:00
Shannon Booth
bc93ba4530 LibWeb/Bindings: Implement [SecureContext] extended attribute
Unfortunately this is a bit of a pain to test as it is surprisingly
difficult to create a non secure context in our test harness.
This is because both file scheme URLs and localhost are considered
secure contexts.

To test this, add a very specific internals setter to change the
top level origin of the environment for the current realm.
2026-02-14 20:22:40 +01:00
Niccolo Antonelli Dziri
94ca0dcbef IDLGenerators: Translate boolean? silent = null to Optional<bool>
It was prevously translating it to just `bool` instead of
`Optional<bool>`.

Required elements in dictionary (such as in Notification.idl
for the NotificationAction) were treated as Optional<T> like the other
non-required elements. Now it's just the type without the Optional.

Co-authored-by: Zaggy1024 <gregory.bertilson@gmail.com>
2026-02-13 16:47:42 +00:00
Shannon Booth
39976bb4b8 LibWeb/Bindings: Use DefineDataPropertyOrThrow in Replaceable setter 2026-02-07 11:49:36 +01:00
Shannon Booth
1d3e48cce8 LibWeb/Bindings: Use JS Get for [PutForwards] attribute setter
Previously we were invoking the c++ getter, which is clearly not
correct.
2026-02-06 19:23:30 +01:00
Shannon Booth
c71d6d3b20 LibWeb/Bindings: Do not throw on [PutForwards] attribute setter 2026-02-06 19:23:30 +01:00
Shannon Booth
932a20423f LibWeb/Bindings: Treat missing attribute setter argument as undefined
Fold attribute setter handling into the shared [Replaceable] and
[PutForwards] paths, aligning the implementation more closely with the
WebIDL specification.

This change unfortunately introduces a regression in a WebAssembly
JS API test that expects attribute setters to throw when invoked
with no arguments (rather than treating the missing argument as
undefined). The exact specification text that mandates this
behavior for the WASM API is unclear to me.

The new behaviour seems like it would be more compatible in the
general case by not throwing an exception for all of the other
cases, so this commit accepts this as a regression until the
reasoning for needing to throw can be determined.
2026-02-06 19:23:30 +01:00
Shannon Booth
aa6b9ed318 LibWeb/Bindings: Treat no args as undefined for Replaceable/PutForwards 2026-02-06 19:23:30 +01:00
Shannon Booth
a5bbe4e44d LibWeb/Bindings: Add spec comments for PutForwards and Replaceable
No functional change intended, this is just intending to make it
obvious where the previous implementation was not following the
specification.
2026-02-06 19:23:30 +01:00
Andreas Kling
74a80b7bfc LibJS: Mark JS::Cell::initialize() as MUST_UPCALL
Intermediate classes in the initialize() chain set up prototypes and
define properties. Forgetting to call Base::initialize() in any
override would silently skip that setup.
2026-02-06 13:50:54 +01:00
Andreas Kling
706eb0018c LibGC+LibWeb: Mark two GC::Cell functions as MUST_UPCALL
Let's make sure that subclasses always call their base class when
overriding these virtuals:

- void finalize()
- void visit_edges(Visitor&)
2026-02-06 13:50:54 +01:00
Psychpsyo
617b8cb247 LibWeb: Implement the very basics of XRSession 2026-02-04 15:08:37 +01:00
Timothy Flynn
34466eeb2d IDLGenerators: Do not generate a plain type for default nullable values
Commit 1b8e81cd6f added a check to prevent
assigning a default value when the default value itself is null. But we
had previously generated an uninitialized type, expecting it to become
defaulted later on. So we would have generated code such as:

    bool value;

    if (!property.is_null() && !property.is_undefined())
        value = property.to_boolean();

    options.value = value;

This is undefined behavior.

We know use the same default value check to ensure we generate Optional
types instead. So the above `value` initializer becomes:

    Optional<bool> value;
2026-02-02 18:01:08 +01:00
Jonathan Gamble
4e48ba36bd LibWeb: Better handling of union types in IDL code generation
First check if a string is a member of the enum before attempting
numeric conversion. This generates correct code for fields like:

AudioContextOptions {
  latencyHint: AudioContextLatencyCategory | double;
}
2026-01-26 18:46:39 +01:00
Reimar
26181f2958 LibWeb: Implement External interface 2026-01-22 14:56:46 +01:00
Jelle Raaijmakers
e8cbddbeb8 Meta/IDLGenerators: Clean up is_platform_object()
Any type ending in "Event" or "Element" does not need to be added to the
manually curated list of platform objects in is_platform_object().
Additionally, "WindowProxy" was already part of that list, so no need to
check for it separately. No functional changes.
2026-01-20 07:28:32 -05:00
Jelle Raaijmakers
99923eac8d LibWeb: Add stubbed Speech API 2026-01-20 06:51:04 -05:00
Psychpsyo
52781cc2fd LibWeb: Add WebXR's XRSystem 2026-01-11 00:01:24 +01:00
Shannon Booth
f67c15b2ff LibWeb/Bindings: Ensure identity for [LegacyUnforgeable] attributes
The WebIDL spec requires that attributes marked [LegacyUnforgeable]
share the same getter and setter function objects across all instances
within the same Realm.

Previously, we were creating new JS::NativeFunction wrappers during
every instance initialization, which caused identity checks to fail.
This change moves these functions into Bindings::Intrinsics so they
are created once per Realm and reused.
2026-01-08 12:57:17 +01:00
Andreas Kling
2ac363dcba LibGC: Only call finalize() on types that override finalize()
This dramatically cuts down on time spent in the GC's finalizer pass,
since most types don't override finalize().
2026-01-07 20:51:17 +01:00
Shannon Booth
f9a996650b LibWeb/HTML: Implement the Origin interface
See: https://github.com/whatwg/html/commit/68909b2
2025-12-30 12:40:27 +01:00
Sam Atkins
7418d262ed IDLGenerators: Convert reflected attribute names to ASCII lowercase 2025-12-15 14:08:24 +00:00
Callum Law
3089f12609 Meta: Avoid outputting stray closing bracket in IDL code generation 2025-12-12 10:49:18 +00:00
Andreas Kling
cb23d65625 LibJS: Pass JS::Value directly to string formatting functions
We don't need to call .to_string_without_side_effects() when passing
a JS::Value in for string formatting. The Formatter will do it for us.
2025-12-09 21:44:13 -06:00
mikiubo
de4e3ef63a LibWeb: Honor LegacyNullToEmptyString in union string conversion
The IDL generator was passing 'false' to generate_to_cpp when converting
a union containing a string type.
This broke WebIDL's LegacyNullToEmptyString behavior.

Pass the actual legacy_null_to_empty_string flag instead.
Fixes some WPTs:

domparsing/outerhtml-02
trusted-types/block-string-assignment-to-Element-outerHTML
trusted-types/block-string-assignment-to-HTMLElement-generic
trusted-types/block-string-assignment-to-ShadowRoot-innerHTML
2025-12-07 07:45:45 +00:00
Jelle Raaijmakers
797e6dd4eb LibWeb: Implement SVGLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
7e869c7816 LibWeb: Add SVGNumber 2025-11-09 01:22:48 +01:00
Luke Wilde
82bd3d3891 LibWeb: Avoid invoking Trusted Types where avoidable
Prevents observably calling Trusted Types, which can run arbitrary JS,
cause crashes due to use of MUST and allow arbitrary JS to modify
internal elements.
2025-11-06 11:43:06 -05:00
Tete17
676171bccd IDLGenerators: Allow set_attribute's to throw exceptions 2025-10-28 13:46:54 +00:00
Luke Wilde
4ebe43af58 LibWeb/WebGL2: Implement most of the transform feedback APIs 2025-10-21 23:29:50 +02:00
Luke Wilde
5c1bf5c3f6 LibWeb/WebGL2: Implement most of the query APIs 2025-10-21 23:29:50 +02:00
Andreas Kling
dfa796a4e4 LibJS+LibWeb: Use GC::Weak instead of AK::WeakPtr for GC-allocated types
This makes some common types like JS::Object smaller (by 8 bytes) and
yields a minor speed improvement on many benchmarks.
2025-10-17 17:22:16 +02:00
Johannes Gustafsson
f04b866cb0 LibWeb: Implement stubs for XPathEvaluator 2025-10-03 13:16:11 +02:00
Aliaksandr Kalenik
ffc05a9ca9 LibWeb/WebGL: Define Uint32List exactly like in the spec
Same fix as d54cab60 but applied for Uint32List.
2025-09-30 18:35:32 +02:00
Aliaksandr Kalenik
c75a8fab3b LibWeb/WebGL: Define Int32List exactly like in the spec
Same fix as d54cab60 but applied for Int32List.
2025-09-30 17:57:46 +02:00
Aliaksandr Kalenik
22075c08e4 BindingsGenerator: Return the exact typed array member type for unions
Allows definition of:
`typedef (Float32Array or sequence<GLfloat>) Float32List;`

which did fail to compile before, because `GC::Root<JS::Object>` fails
to implicitly cast into
`AK::Variant<GC::Root<JS::Float32Array>, AK::Vector<float>>`.
2025-09-30 16:47:16 +02:00
Sam Atkins
a1db5e7789 LibWeb/CSS: Implement CSSMatrixComponent
Equivalent to the matrix() and matrix3d() transform functions.

+19 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
8e86bf2dd0 LibWeb/CSS: Implement CSSTransformComponent
This is a base type for the various transform functions.

CSSMatrixComponent's to_string() can throw exceptions, so to_string() is
implemented that way. https://github.com/w3c/fxtf-drafts/issues/611

+9 WPT subtests.
2025-09-24 12:27:05 +01:00