LibWeb: Unify WebIDL C++ type generation

Represent WebIDL C++ types with a single CppType model that tracks
nullability, optional presence, and contained storage.

GC-like values now use GC::Ref/GC::Ptr directly, while containers choose
"plain", "Root", or "Conservative" container types depending on what
they contain. For example, sequence<Element> becomes a RootVector of
GC::Ref values, while sequence<SomeDictionary> becomes a
ConservativeVector only when the dictionary contains GC-like values.
This moves the generated bindings away from wrapping GC values in
GC::Root by default.

This has broad fallout as the types passed to interfaces for GC
objects changes almost fully across the board.
This commit is contained in:
Shannon Booth 2026-05-20 20:58:46 +02:00 committed by Shannon Booth
parent aa0eb13a89
commit 637fd51595
Notes: github-actions[bot] 2026-05-23 16:27:03 +00:00
207 changed files with 1126 additions and 1255 deletions

View file

@ -35,7 +35,7 @@ void HTMLFormControlsCollection::initialize(JS::Realm& realm)
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmlformcontrolscollection-nameditem
Variant<Empty, DOM::Element*, GC::Root<RadioNodeList>> HTMLFormControlsCollection::named_item_or_radio_node_list(FlyString const& name) const
Variant<Empty, GC::Ref<DOM::Element>, GC::Ref<RadioNodeList>> HTMLFormControlsCollection::named_item_or_radio_node_list(FlyString const& name) const
{
// 1. If name is the empty string, return null and stop the algorithm.
if (name.is_empty())
@ -63,18 +63,18 @@ Variant<Empty, DOM::Element*, GC::Root<RadioNodeList>> HTMLFormControlsCollectio
return {};
if (!multiple_matching)
return matching_element;
return GC::Ref { *matching_element };
// 4. Otherwise, create a new RadioNodeList object representing a live view of the HTMLFormControlsCollection object, further filtered so that the only nodes in the
// RadioNodeList object are those that have either an id attribute or a name attribute equal to name. The nodes in the RadioNodeList object must be sorted in tree
// order. Return that RadioNodeList object.
return GC::make_root(RadioNodeList::create(realm(), root(), DOM::LiveNodeList::Scope::Descendants, [name](auto const& node) {
return RadioNodeList::create(realm(), root(), DOM::LiveNodeList::Scope::Descendants, [name](auto const& node) {
if (!is<DOM::Element>(node))
return false;
auto const& element = as<DOM::Element>(node);
return element.id() == name || element.name() == name;
}));
});
}
JS::Value HTMLFormControlsCollection::named_item_value(FlyString const& name) const