LibWeb: Allow TrackEvent track to be a TextTrack

Fixes two FIXMEs :^)
This commit is contained in:
Jamie Mansfield 2024-07-05 18:57:29 +01:00 committed by Andreas Kling
parent 13cd653d1c
commit ab91a616b8
Notes: sideshowbarker 2024-07-17 20:33:50 +09:00
3 changed files with 6 additions and 7 deletions

View File

@ -34,7 +34,7 @@ void TrackEvent::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(TrackEvent);
}
Variant<Empty, JS::Handle<VideoTrack>, JS::Handle<AudioTrack>> TrackEvent::track() const
Variant<Empty, JS::Handle<VideoTrack>, JS::Handle<AudioTrack>, JS::Handle<TextTrack>> TrackEvent::track() const
{
// FIXME: This is a bit awkward. When creating a nullable union, our IDL generator creates a type of
// Optional<Variant<...>>, using an empty Optional to represent null. But when retrieving the

View File

@ -15,7 +15,7 @@
namespace Web::HTML {
struct TrackEventInit : public DOM::EventInit {
using TrackType = Optional<Variant<JS::Handle<VideoTrack>, JS::Handle<AudioTrack>>>;
using TrackType = Optional<Variant<JS::Handle<VideoTrack>, JS::Handle<AudioTrack>, JS::Handle<TextTrack>>>;
TrackType track;
};
@ -28,7 +28,7 @@ public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TrackEvent>> construct_impl(JS::Realm&, FlyString const& event_name, TrackEventInit);
// https://html.spec.whatwg.org/multipage/media.html#dom-trackevent-track
Variant<Empty, JS::Handle<VideoTrack>, JS::Handle<AudioTrack>> track() const;
Variant<Empty, JS::Handle<VideoTrack>, JS::Handle<AudioTrack>, JS::Handle<TextTrack>> track() const;
private:
TrackEvent(JS::Realm&, FlyString const& event_name, TrackEventInit event_init);

View File

@ -1,5 +1,6 @@
#import <DOM/Event.idl>
#import <HTML/AudioTrack.idl>
#import <HTML/TextTrack.idl>
#import <HTML/VideoTrack.idl>
// https://html.spec.whatwg.org/multipage/media.html#trackevent
@ -7,11 +8,9 @@
interface TrackEvent : Event {
constructor(DOMString type, optional TrackEventInit eventInitDict = {});
// FIXME: Should be: (VideoTrack or AudioTrack or TextTrack)?
readonly attribute (VideoTrack or AudioTrack)? track;
readonly attribute (VideoTrack or AudioTrack or TextTrack)? track;
};
dictionary TrackEventInit : EventInit {
// FIXME: Should be: (VideoTrack or AudioTrack or TextTrack)?
(VideoTrack or AudioTrack)? track = null;
(VideoTrack or AudioTrack or TextTrack)? track = null;
};