LibWeb/HTML: Store TrackEvent track as Ref not Root

This commit is contained in:
Sam Atkins
2026-02-16 14:26:27 +00:00
committed by Tim Flynn
parent cf8249b2f8
commit 0656f2f334
Notes: github-actions[bot] 2026-02-17 14:20:40 +00:00
2 changed files with 35 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
* Copyright (c) 2026, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -28,14 +29,19 @@ public:
static WebIDL::ExceptionOr<GC::Ref<TrackEvent>> construct_impl(JS::Realm&, FlyString const& event_name, TrackEventInit);
// https://html.spec.whatwg.org/multipage/media.html#dom-trackevent-track
Variant<Empty, GC::Root<VideoTrack>, GC::Root<AudioTrack>, GC::Root<TextTrack>> track() const;
using TrackReturnType = Variant<Empty, GC::Root<VideoTrack>, GC::Root<AudioTrack>, GC::Root<TextTrack>>;
TrackReturnType track() const;
private:
TrackEvent(JS::Realm&, FlyString const& event_name, TrackEventInit event_init);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor&) override;
TrackEventInit::TrackType m_track;
using TrackTypeInternal = Variant<Empty, GC::Ref<VideoTrack>, GC::Ref<AudioTrack>, GC::Ref<TextTrack>>;
static TrackTypeInternal to_track_type_internal(TrackEventInit::TrackType const&);
TrackTypeInternal m_track;
};
}