ladybird/Libraries/LibWeb/HTML/TrackEvent.h
Shannon Booth 637fd51595 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.
2026-05-23 18:26:12 +02:00

41 lines
1.2 KiB
C++

/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
* Copyright (c) 2026, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <AK/Optional.h>
#include <AK/Variant.h>
#include <LibGC/Root.h>
#include <LibWeb/Bindings/TrackEvent.h>
#include <LibWeb/DOM/Event.h>
namespace Web::HTML {
using NullableTrackType = Variant<GC::Ref<VideoTrack>, GC::Ref<AudioTrack>, GC::Ref<TextTrack>, Empty>;
class TrackEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(TrackEvent, DOM::Event);
GC_DECLARE_ALLOCATOR(TrackEvent);
public:
[[nodiscard]] static GC::Ref<TrackEvent> create(JS::Realm&, FlyString const& event_name, Bindings::TrackEventInit const& = {});
static WebIDL::ExceptionOr<GC::Ref<TrackEvent>> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::TrackEventInit const&);
// https://html.spec.whatwg.org/multipage/media.html#dom-trackevent-track
NullableTrackType track() const;
private:
TrackEvent(JS::Realm&, FlyString const& event_name, Bindings::TrackEventInit const&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor&) override;
NullableTrackType m_track;
};
}