Commit Graph

1234 Commits

Author SHA1 Message Date
Sam Atkins
f242bee7f3 Meta: Replace GenerateNamedCharacterReferences with a python generator
This is a direct conversion, and produces the same output.
2026-04-29 17:28:09 +01:00
Sam Atkins
7a7b838ed5 Meta: Replace GenerateAriaRoles with a python generator
This is a direct conversion, and produces the same output.
2026-04-29 17:28:09 +01:00
Shannon Booth
6cd7425a4b Meta: Port GenerateWindowOrWorkerInterfaces to Python
This replaces the C++ GenerateWindowOrWorkerInterfaces generator with a
python3 port.

The generator uses the new python WebIDL parser and writes directly to a
TextIO instance instead of porting SourceGenerator.

For validation, the python generator was diffed against the existing C++
generator over the full LibWeb IDL input set. The generated output is
behaviorally identical, and the only changes are whitespace changes
(all improvements).
2026-04-29 12:24:00 +01:00
Shannon Booth
7beac55210 LibWeb/Bindings: Pass exact typed array types through WebIDL bindings
Generate exact JS buffer types for exact IDL buffer arguments instead
of widening them to BufferSource or ArrayBufferView.

This fixes cases like TextEncoder.encodeInto(), whose IDL requires
a Uint8Array destination. Previously the generated binding accepted
any BufferSource, so DataView, other typed arrays, and
ArrayBuffer-backed values were let through. With exact conversion,
those are rejected at the binding layer as expected.
2026-04-26 17:50:58 +02:00
Sam Atkins
2ed3868012 Meta: Replace GenerateCSSPropertyID with a python generator
We don't match the C++ output byte-for-byte here, because the key
iteration order is different. So I've taken the opportunity to tidy up
some whitespace too.
2026-04-25 12:02:49 +02:00
Sam Atkins
3580e2506c Meta: Replace GenerateCSSStyleProperties with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
d3d124b1d8 Meta: Replace GenerateCSSNumericFactoryMethods with a python generator
Adds a new `invoke_py_idl_generator` CMake helper for python scripts
that also produce an IDL file.
2026-04-25 12:02:49 +02:00
Sam Atkins
399341c3de Meta: Replace GenerateCSSPseudoElement with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
353846fe79 Meta: Replace GenerateCSSMathFunctions with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
143f1bc34d Meta: Replace GenerateCSSDescriptors with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
5fbf6f6801 Meta: Replace GenerateCSSUnits with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f2ead8b520 Meta: Replace GenerateCSSMediaFeatureID with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
91022151d6 Meta: Replace GenerateCSSPseudoClass with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f7898d2c8b Meta: Replace GenerateCSSTransformFunctions with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f9dc467cae Meta: Replace GenerateCSSKeyword with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
f6a3ff388b Meta: Replace GenerateCSSEnvironmentVariable with a python generator 2026-04-25 12:02:49 +02:00
Sam Atkins
4de5f3056b Meta: Replace GenerateCSSEnums with a python generator 2026-04-25 12:02:49 +02:00
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
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
4178ec0af4 LibWeb/WebGL: Remove Extensions interface
No other third layer folder in LibWeb has its own namespace which
makes this a special case for the IDLGenerator when determining
namespaces. Instead of adding a special case, simply remove the
namespace.
2026-04-24 20:08:29 +02:00
Shannon Booth
83427086fa LibWeb/Bindings: Use IDL context to determine 'is platform object' 2026-04-24 20:08:29 +02:00
Shannon Booth
83f4e03045 LibWeb/Bindings: Batch BindingsGenerator over all IDL files
Teach BindingsGenerator to parse and generate bindings for the full
LibWeb IDL set in one invocation, and collapse the CMake bindings
rules from one custom command per IDL file to a single batched codegen
step.

This has the downsides of:
 * Any single IDL change now reruns the whole bindings generator
 * Per-IDL parallelism at the custom-command level is lost

However, I still feel that this is a worthy trade off as:
 * Generated files are written with write_if_changed(), so rebuilds
   of generated files should not be significantly impacted.
 * It is not a common task to be modifying IDL files
 * Most importantly, giving the IDL generator full knowledge of _all_
   IDL will allow for some simplifications of the bindings generator as
   it has knowledge of all types.
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
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
Callum Law
aa9f2ed83f LibWeb: Rename AcceptedTypeRange to NumericRange
This name wasn't very clear, also updates associated type and variable
names.
2026-04-22 14:24:12 +01:00
Callum Law
8a7332b7b9 LibWeb: Add OpacityValueStyleValue
This allows us to avoid the ugly hack in
`property_accepted_type_ranges()`.

This also updates the `ValueType` to be `opacity-value` rather than
`opacity` to match the spec.
2026-04-22 14:24:12 +01: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