mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-12 01:46:46 +02:00
Previously we were inconsistent by generating code for enum definitions but not generating code for dictionaries. With future changes to the IDL generator to expose helpers to convert to and from IDL values this produced circular depdendencies. To solve this problem, also generate the dictionary definitions in bindings headers.
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
* Copyright (c) 2026, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/Bindings/TrackEvent.h>
|
|
#include <LibWeb/HTML/AudioTrack.h>
|
|
#include <LibWeb/HTML/TextTrack.h>
|
|
#include <LibWeb/HTML/TrackEvent.h>
|
|
#include <LibWeb/HTML/VideoTrack.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
GC_DEFINE_ALLOCATOR(TrackEvent);
|
|
|
|
GC::Ref<TrackEvent> TrackEvent::create(JS::Realm& realm, FlyString const& event_name, Bindings::TrackEventInit const& event_init)
|
|
{
|
|
return realm.create<TrackEvent>(realm, event_name, move(event_init));
|
|
}
|
|
|
|
WebIDL::ExceptionOr<GC::Ref<TrackEvent>> TrackEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::TrackEventInit const& event_init)
|
|
{
|
|
return create(realm, event_name, move(event_init));
|
|
}
|
|
|
|
TrackEvent::TrackTypeInternal TrackEvent::to_track_type_internal(NullableTrackType const& track_type)
|
|
{
|
|
return track_type.visit(
|
|
[](Empty) -> TrackTypeInternal { return Empty {}; },
|
|
[](auto const& root) -> TrackTypeInternal { return GC::Ref { *root }; });
|
|
}
|
|
|
|
TrackEvent::TrackEvent(JS::Realm& realm, FlyString const& event_name, Bindings::TrackEventInit const& event_init)
|
|
: DOM::Event(realm, event_name, event_init)
|
|
, m_track(to_track_type_internal(event_init.track))
|
|
{
|
|
}
|
|
|
|
void TrackEvent::initialize(JS::Realm& realm)
|
|
{
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(TrackEvent);
|
|
Base::initialize(realm);
|
|
}
|
|
|
|
void TrackEvent::visit_edges(Visitor& visitor)
|
|
{
|
|
Base::visit_edges(visitor);
|
|
m_track.visit(
|
|
[](Empty) {},
|
|
[&](auto const& ref) { visitor.visit(ref); });
|
|
}
|
|
|
|
NullableTrackType TrackEvent::track() const
|
|
{
|
|
return m_track.visit(
|
|
[](Empty) -> NullableTrackType { return Empty {}; },
|
|
[](auto const& ref) -> NullableTrackType { return GC::Root { *ref }; });
|
|
}
|
|
|
|
}
|