LibWeb+IDLGenerators: Support nullable union types

This commit is contained in:
Luke Wilde
2026-02-17 14:57:03 +00:00
committed by Sam Atkins
parent 500ca417ce
commit cfd795f907
Notes: github-actions[bot] 2026-03-25 13:21:41 +00:00
39 changed files with 146 additions and 128 deletions

View File

@@ -14,8 +14,10 @@
namespace Web::IntersectionObserver {
using NullableIntersectionObserverRoot = Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>, Empty>;
struct IntersectionObserverInit {
Optional<Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>>> root;
NullableIntersectionObserverRoot root { Empty {} };
String root_margin { "0px"_string };
String scroll_margin { "0px"_string };
Variant<double, Vector<double>> threshold { 0 };
@@ -42,7 +44,7 @@ public:
Vector<GC::Ref<DOM::Element>> const& observation_targets() const { return m_observation_targets; }
Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>, Empty> root() const;
NullableIntersectionObserverRoot root() const;
String root_margin() const;
String scroll_margin() const;
Vector<CSS::LengthPercentage> const& scroll_margin_values() const { return m_scroll_margin; }
@@ -60,7 +62,7 @@ public:
WebIDL::CallbackType& callback() { return *m_callback; }
private:
explicit IntersectionObserver(JS::Realm&, GC::Ptr<WebIDL::CallbackType> callback, Optional<Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>>> const& root, Vector<CSS::LengthPercentage> root_margin, Vector<CSS::LengthPercentage> scroll_margin, Vector<double>&& thresholds, double debug, bool track_visibility);
explicit IntersectionObserver(JS::Realm&, GC::Ptr<WebIDL::CallbackType> callback, NullableIntersectionObserverRoot const& root, Vector<CSS::LengthPercentage> root_margin, Vector<CSS::LengthPercentage> scroll_margin, Vector<double>&& thresholds, double debug, bool track_visibility);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(JS::Cell::Visitor&) override;