Commit Graph

28 Commits

Author SHA1 Message Date
Shannon Booth
cc6e048bd6 LibWeb+LibIDL: Remove support for #import directives during parsing
These no longer serve any purpose now that we run the IDLGenerator
on all of these files at once.
2026-04-24 20:08:29 +02:00
Shannon Booth
ba741994dd LibIDL: Resolve parsed interfaces post parsing
Move partial interface, partial namespace, mixin, typedef, and overload
finalization into a context-wide post-parse resolve step.

This lets BindingsGenerator parse all declared IDL files first and then
finalize the shared IDL context before generating bindings.
2026-04-24 20:08:29 +02:00
Shannon Booth
a153732a64 LibWeb: Parse support IDL files when generating bindings
Teach the bindings build to pass support IDL files alongside the regular
binding IDLs so BindingsGenerator parses the full declared IDL set into
a shared context.

Keep idl_files.cmake as the source of truth for parsed support IDLs, and
let Interface::will_generate_code() decide which parsed interfaces emit
generated bindings.
2026-04-24 20:08:29 +02:00
Shannon Booth
5f3812ecca LibIDL: Drop unused imported module state
Semantic IDL lookups no longer rely on imported modules, so stop storing
that state on Interface and Module.

import directives are still resolved during parsing for now, but the
parsed imported-module lists are no longer needed.
2026-04-24 20:08:29 +02:00
Shannon Booth
0e55b0f87e LibWeb/Bindings: Derive includes from IDL references
Stop using imported modules to decide which binding headers to include.
Instead, collect dependencies from referenced interfaces, dictionaries,
enumerations, callbacks, and nested IDL types in the parsed context.
2026-04-24 20:08:29 +02:00
Shannon Booth
535b8f5b9b LibWeb/Bindings: Qualify generated C++ type names
Derive C++ namespaces from each IDL module's location and use those
qualified names when generating binding code.

Also Teach dictionaries their owning IDL module path so dictionary C++
types can be qualified the same way as interfaces. This removes the need
for the generated `using namespace Web::*` hack and the hard-coded
namespace list.

Also fix DOMURL.idl to refer to the IDL interface name `URL`, not the
C++ implementation name `DOMURL`.
2026-04-24 20:08:29 +02:00
Shannon Booth
bd4ef4b95a LibIDL: Resolve JSON interface types via context
Use the shared IDL context when checking whether a type is a JSON type
instead of walking imported modules from the current interface. This
removes another dependency on explicit #import directives when resolving
interface inheritance for toJSON.
2026-04-23 22:12:13 +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
462d83fc4e LibIDL: Track referenced interfaces for an interface
This will allow the IDL generator to query a type name during
code generation and determine whether that type is an interface
or not and use properties of that interface for use in code
generation.

For example, in a future commit, this will be used to determine
whether a given type name is a callback interface.
2026-03-11 21:16:44 +01:00
Shannon Booth
308ac11231 LibIDL: Handle parsing 'callback interface' types 2026-03-11 21:16:44 +01:00
Ben Wiederhake
6d185ed54b LibIDL: Remove unused header in Types 2026-02-23 12:15:23 +01: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
Jelle Raaijmakers
d025e14cb4 LibIDL: Add support for partial interface mixin
This adds parsing support for `partial interface mixin` as specified
in WebIDL. Partial mixins are merged into their corresponding mixins
before the mixins are resolved into interfaces.
2026-01-13 10:09:22 +01:00
Sam Atkins
6e3cd7dd06 LibIDL: Support partial namespaces 2025-09-11 17:06:44 +01:00
Tim Ledbetter
fdbd25967b LibIDL: Allow iterable<T> to be defined before property getter
Previously, an error would occur if an `iterable<T>` was defined before
the required value iterator. An is now also reported if an`iterable<T>`
is defined before a pair iterator, previously this error would only be
reported if the iterable was defined after the pair iterator.
2025-09-02 10:41:33 +01:00
Jelle Raaijmakers
2e910dd6e1 LibIDL: Change overload sets to be ordered
We fill these overload sets from vectors, which means that by the time
we iterated over them, any semblance of their original ordering was
lost. Their ordering is important, because we invoke
define_native_function() for them which eventually stores ordered
properties.

This should not be an issue as long as iterating over a HashMap that was
filled in exactly the same way results in the same ordering. However,
HashTable utilizes kmalloc_good_size() to determine a good allocation
size - and the implementation for kmalloc_good_size() on Linux and macOS
differs, causing a different capacity and ordering on those platforms.

This was not caught by CI, because we run that with sanitizers enabled
which overrides malloc_good_size() on macOS, resulting in the same
behavior as on Linux.

Change the overload sets to be OrderedHashMaps instead and rebaseline
the failing test.
2025-08-26 10:14:22 +02:00
Idan Horowitz
dc1b7b1925 IDLGenerators: Support generating dictionary to value converter helpers
This is useful when returning dictionaries as a Promise.
2025-08-08 13:09:58 -04:00
Timothy Flynn
49467d0583 LibIDL+LibWeb: Support UTF-16 USVString 2025-07-26 00:40:06 +02:00
Timothy Flynn
cb85eac3d8 LibIDL+IDLGenerators: Begin supporting UTF-16 strings in IDL
This adds a new IDL type, Utf16DOMString. This is the same as DOMString,
except it is UTF-16. This type is temporary - we will want DOMString to
be UTF-16 by default once we've ported enough of LibWeb.

To make this support easier, some string IDL generator handling is moved
directly into `generate_to_string` from the call sites.
2025-07-24 19:00:20 +02:00
Jelle Raaijmakers
1da304f7b7 LibIDL: Support partial interfaces
Partial interfaces have the same name as the interface they extend, and
can appear in any order. In practice, we import the partial interfaces
into the main interface's IDL.
2025-07-22 13:07:06 +01:00
Bastiaan van der Plaat
41a6ebfba2 LibIDL: Save parsed stringifier_extended_attributes 2025-06-30 11:39:16 -06:00
Timothy Flynn
c0ead1b01a LibIDL+LibWeb: Begin support for async iterator in IDL
This adds support for async iterators of the form:

    async iterable<value_type>;
    async iterable<value_type>(/* arguments... */);

It does not yet support the value pairs of the form:

    async iterable<key_type, value_type>;
    async iterable<key_type, value_type>(/* arguments... */);

Async iterators have an optional `return` data property. There's not a
particularly good way to know what interfaces implement this property.
So this adds a new extended attribute, DefinesAsyncIteratorReturn, which
interfaces can use to declare their support.
2025-04-14 17:43:11 -04:00
Luke Wilde
c7d25301d3 LibWeb: Implement the LegacyUnforgeable attribute
This fixes the frame-ancestors WPT tests from crashing when an iframe
is blocked from loading. This is because it would get an undefined
location.href from the cross-origin iframe, which causes a crash as it
expects it to be there.
2025-03-27 23:50:35 +00:00
devgianlu
348db1c445 LibIDL+IDLGenerators: Support generation of IDL partial dictionaries 2025-02-05 13:18:47 -07:00
Andreas Kling
3bfb0534be LibGC: Rename MarkedVector => RootVector
Let's try to make it a bit more clear that this is a Vector of GC roots.
2024-12-26 19:10:44 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00