mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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.
64 lines
1.8 KiB
C++
64 lines
1.8 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, TrackEventInit 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, TrackEventInit 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, TrackEventInit 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 }; });
|
|
}
|
|
|
|
}
|