Commit Graph

564 Commits

Author SHA1 Message Date
Shannon Booth
e8c221bed4 LibWeb/Bindings: Resolve inherited interfaces via IDL context
When creating an inheritance stack, look up parent interfaces from the
parsed IDL context instead of the current interface's imported modules.
This removes a dependency on explicit #import directives during bindings
generation.
2026-04-23 22:12:13 +02:00
Shannon Booth
5a97dba495 LibWeb: Model Function as a callback type
Import WebIDL/Function.idl where TimerHandler uses Function, and let the
bindings generator handle it through the normal callback-function path.

This removes the special C++ mapping for Function and makes TimerHandler
use GC::Root<CallbackType>, matching the generated binding type when IDL
files are parsed together.
2026-04-23 07:07:49 +02:00
Shannon Booth
04b3537b8f LibWeb/Bindings: Use qualified namespace for WindowProxy in code gen
Rather than relying on the hacky using namespace defintions.
2026-04-23 07:07:49 +02:00
Shannon Booth
f25bfd747a LibIDL: Make parser return modules instead of interfaces
Change the IDL parser entry point to a static factory returning an
IDL::Module. Modules now own the parsed file identity and import graph,
with an optional reference to the file's real interface when one exists.

This is a step towards running the IDL generator on files without
an interface defined.
2026-04-23 07:07:49 +02:00
Shannon Booth
25254d5a20 LibWeb/Bindings: Move parsed IDL entities into Context
Start making IDL::Context represent the shared IDL world used during
code generation.

Move globally visible parsed IDL such as dictionaries, enums,
typedefs, callbacks, mixins, and partial declarations out of individual
Interface objects and into Context.

The main goal of this change is a step towards invoking the IDL
generator on every IDL file at once, rather than per interface.

In the meantime as standalone improvements, this lets code generation
resolve imported IDL types through the shared Context without copying
imported declarations onto each Interface. It also makes duplicate
local declarations unnecessary for imported shared types, since an
interface can reference an enum or dictionary owned by another
parsed IDL module without re-emitting it itself.
2026-04-22 13:26:01 +02:00
Shannon Booth
442a0e2e64 LibIDL+LibWeb: Move IDL interface dump into LibIDL 2026-04-22 13:26:01 +02:00
Shannon Booth
db41fde06a LibWeb/Bindings: Factor write_if_changed into standalone function 2026-04-22 13:26:01 +02:00
Shannon Booth
31a4093c86 LibWeb/Bindings: Factor out function for generating depfiles 2026-04-22 13:26:01 +02:00
Shannon Booth
0ec82fac38 LibWeb/Bindings: Convert file paths over to ByteString 2026-04-22 13:26:01 +02:00
Jonathan Gamble
baefb51902 LibWeb: Add Media Capture and Stream APIs 2026-04-21 16:40:46 -05:00
Shannon Booth
fd44da6829 LibWeb/Bindings: Emit one bindings header and cpp per IDL
Previously, the LibWeb bindings generator would output multiple per
interface files like Prototype/Constructor/Namespace/GlobalMixin
depending on the contents of that IDL file.

This complicates the build system as it means that it does not know
what files will be generated without knowledge of the contents of that
IDL file.

Instead, for each IDL file only generate a single Bindings/<IDLFile>.h
and Bindings/<IDLFile>.cpp.
2026-04-21 07:36:13 +02:00
Shannon Booth
f8288a14cc LibWeb/BindingsGenerator: Simplify weird dictionary member assignment
Remove the special case assignment path for string dictionary members.
The old logic was using the outer dictionary conversion’s optional and
optional_default_value state to decide how to assign an individual
member, which was very confusing and not correct.

This was probably needed on earlier buggier versions of the IDL
generator working around the wrong problem.
2026-04-17 20:48:30 +01:00
Shannon Booth
e9f8b6b035 LibWeb/Bindings: Add all integral types to idl_type_name_to_cpp_type
Which would be required if we added, for example, IDL which had
the missing types as part of a sequence. Also arange them in
terms of size while we are here.
2026-04-17 20:48:30 +01:00
Shannon Booth
6321f09296 LibWeb/Bindings: Remove some stray return statements 2026-04-17 20:48:30 +01:00
Shannon Booth
3cd2835232 LibWeb/Bindings: Use more any_of in generate_union_to_cpp 2026-04-17 20:48:30 +01:00
Shannon Booth
d5727168f2 LibWeb/Bindings: Remove dead else in branch in generate_to_string
This was appending just an empty line.
2026-04-17 20:48:30 +01:00
Shannon Booth
f172bf6818 LibWeb/Bindings: Simplify LegacyNullToEmptyString handling
Stop passing LegacyNullToEmptyString as a separate boolean and derive
it from parameter.extended_attributes instead.
2026-04-17 20:48:30 +01:00
Shannon Booth
33725b494b LibWeb/Bindings: Factor generate_union_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
20b1fe22d1 LibWeb/Bindings: Factor generate_sequence_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
1532ac1551 LibWeb/Bindings: Factor generate_callback_function_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
6e5db85fac LibWeb/Bindings: Factor generate_enum_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
de472d3454 LibWeb/Bindings: Factor generate_record_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
6e21df0138 LibWeb/Bindings: Factor out generate_any_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
3b2df8eefb LibWeb/Bindings: Factor generate_array_buffer_view_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
d0e07d05f7 LibWeb/Bindings: Factor generate_callback_interface_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
2f184f00ec LibWeb/Bindings: Factor generate_buffer_source_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
241c5e182f LibWeb/Bindings: Name is_javascript_builtin in terms of BufferSource
While this does add some extra cases into the function, this is
effectively a rename to better match how we were effectively already
doing this. Rename the function and link it to the right location in
the specification. Doing this also allows us to drop the FIXME as it
makes it clear what this hardcoded list is meant to achieve.
2026-04-17 15:50:07 +01:00
Shannon Booth
3a6d4ec77a LibWeb/Bindings: Factor generate_floating_point_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
ca524a0a0c LibWeb/Bindings: Factor generate_platform_object_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
536052c3c8 LibWeb/Bindings: Factor generate_promise_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
69fb476e76 LibWeb/Bindings: Factor generate_object_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
431e8a7b81 LibWeb/Bindings: Remove uneeded File/MediaSource special cases
These are already covered by nature of being considered a platform
object.
2026-04-17 15:50:07 +01:00
Andreas Kling
9694134f32 LibWeb: Stop emitting custom element reactions in attribute getters
In other engines, the [CEReactions] extended attribute on an attribute
only applies to the setter steps. Attribute getters never fire custom
element reactions, yet our bindings generator was still pushing a new
element queue onto the custom element reactions stack on entry and
popping + invoking it on return for every single getter call on a
[CEReactions] attribute.
2026-04-17 01:31:32 +02:00
Shannon Booth
649b7fa32d LibWeb/Bindings: Remove support for [ExplicitNull] extended attribute
This is no longer used, and only adds complexity.
2026-04-13 23:30:54 +02:00
Shannon Booth
bb0f244667 LibWeb: Remove ShadowRealm HTML integration 2026-04-05 13:57:58 +02:00
Shannon Booth
85765ccb5c LibWeb: Factor newTarget prototype setup into WebIDL helper 2026-04-05 02:09:39 +02:00
Shannon Booth
b05c56cbb6 LibWeb/Bindings: Fix LegacyUnenumerableNamedProperties enumerability
The boolean was mistakenly reversed.
2026-04-03 18:33:45 +02:00
Shannon Booth
379461e047 LibWeb: Make global prototype chains immutable
Per https://webidl.spec.whatwg.org/#interface-prototype-object any
global platform object should reject prototype changes (besides
from ShadowRealmGlobalScope), and interface prototype objects on
global prototype chains must be immutable.

We already handled parts of this on the globals themselves, but not
the full chain.

Also align some spec comments to the latest WebIDL spec.
2026-04-03 18:33:45 +02:00
Psychpsyo
f4a86c8466 LibWeb: Implement enough of WebXR for xrSession_end test to pass 2026-04-03 13:14:33 +02:00
Timothy Flynn
2e2a99a379 LibWeb: Add a stub for the Cache interface
The Cache and CacheStorage interfaces are quite intertwined. A Cache
object can only be created through CacheStorage, so the Cache interface
cannot be tested on its own. So adding just this stub will allow
implementing the CacheStorage interfaces that create Cache objects. We
can then implement the Cache interface piecemeal.
2026-04-03 11:04:12 +02:00
Zaggy1024
a54a86c024 Meta: Treat MediaSource as a platform object
This allows URL.createObjectURL(new MediaSource()) to succeed.
2026-04-01 02:54:22 -05:00
Sam Atkins
ed6a5f25a0 LibWeb: Implement scoped custom element registries 2026-03-27 19:49:55 +00:00
Sam Atkins
ecbd846272 LibWeb/DOM: Implement DocumentOrShadowRoot.customElementRegistry
Step towards scoped custom element registries.
2026-03-27 19:49:55 +00:00
Jonathan Gamble
793a4eeb8e Meta: Support nullable BufferSource as Optional in IDL generator
This IDL change is needed for webaudio's WaveShaperNode, where a
null BufferSource for a curve attribute results in a zero-length buffer.

WebGL also has a nullable BufferSource arg in bufferData(...). But
there, a null data/srcData value returns GL_INVALID_VALUE.
2026-03-27 00:03:39 +01:00
Luke Wilde
cfd795f907 LibWeb+IDLGenerators: Support nullable union types 2026-03-25 13:18:15 +00:00
Shannon Booth
3a95df60f9 LibWeb/Bindings: Deduplicate cpp type name normalization
This was copy and pasted twice.
2026-03-19 22:14:26 +01:00
Shannon Booth
0803ace948 LibWeb/Bindings: Factor out function for generating dictionary to cpp 2026-03-19 22:14:26 +01:00
Shannon Booth
f04e7d88d5 LibWeb/Bindings: Add a forward declaration of generate_to_cpp
generate_to_cpp is called recursively, such as when generating
dictionary values. To support factoring this (massive) function
into functions, add a forward declaration.
2026-03-19 22:14:26 +01:00
Shannon Booth
92f4fc2cb9 LibWeb/Bindings: Don't use parameter type in may_be_null checks
Whether a converted value may be null should only depend on the presence
and value of an optional default, not the nullability of the type being
passed in.
2026-03-19 22:14:26 +01:00
Shannon Booth
71ba774083 LibWeb/Bindings: Don’t set @@unscopables in unforgeable attribute setup
[Unscopable] members should only affect the interface prototype’s
@@unscopables object. The bindings generator was also creating an empty
@@unscopables object in define_unforgeable_attributes(), installing it
as an own property on instances.
2026-03-19 20:44:36 +01:00