浏览代码

LibWeb: Allow TrackEvent track to be a TextTrack

Fixes two FIXMEs :^)
Jamie Mansfield 1 年之前
父节点
当前提交
ab91a616b8

+ 1 - 1
Userland/Libraries/LibWeb/HTML/TrackEvent.cpp

@@ -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

+ 2 - 2
Userland/Libraries/LibWeb/HTML/TrackEvent.h

@@ -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);

+ 3 - 4
Userland/Libraries/LibWeb/HTML/TrackEvent.idl

@@ -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;
 };