Update MediaStream events to stop using legacy [ConstructorTemplate=Event]
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 23:11:49 +0000 (23:11 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 23:11:49 +0000 (23:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163289

Reviewed by Sam Weinig.

Source/WebCore:

Update MediaStream events to stop using legacy [ConstructorTemplate=Event]
and use regular constructors instead.

* Modules/mediastream/MediaStreamEvent.cpp:
(WebCore::MediaStreamEvent::create):
(WebCore::MediaStreamEvent::MediaStreamEvent):
* Modules/mediastream/MediaStreamEvent.h:
* Modules/mediastream/MediaStreamEvent.idl:
* Modules/mediastream/MediaStreamTrackEvent.cpp:
(WebCore::MediaStreamTrackEvent::create):
(WebCore::MediaStreamTrackEvent::MediaStreamTrackEvent):
* Modules/mediastream/MediaStreamTrackEvent.h:
* Modules/mediastream/MediaStreamTrackEvent.idl:
* Modules/mediastream/OverconstrainedErrorEvent.h:
(WebCore::OverconstrainedErrorEvent::create):
(WebCore::OverconstrainedErrorEvent::OverconstrainedErrorEvent):
(WebCore::OverconstrainedErrorEvent::~OverconstrainedErrorEvent): Deleted.
* Modules/mediastream/OverconstrainedErrorEvent.idl:
* Modules/mediastream/RTCDTMFToneChangeEvent.cpp:
(WebCore::RTCDTMFToneChangeEvent::create):
(WebCore::RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent):
* Modules/mediastream/RTCDTMFToneChangeEvent.h:
* Modules/mediastream/RTCDTMFToneChangeEvent.idl:
* Modules/mediastream/RTCTrackEvent.cpp:
(WebCore::RTCTrackEvent::create):
(WebCore::RTCTrackEvent::RTCTrackEvent):
* Modules/mediastream/RTCTrackEvent.h:
* Modules/mediastream/RTCTrackEvent.idl:

LayoutTests:

Update existing test cases now that we throw more exceptions on bad input.

* fast/events/constructors/overconstrained-error-event-constructor-expected.txt:
* fast/events/constructors/overconstrained-error-event-constructor.html:
* fast/mediastream/MediaStreamTrackEvent-constructor-expected.txt:
* fast/mediastream/MediaStreamTrackEvent-constructor.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207175 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/constructors/overconstrained-error-event-constructor-expected.txt
LayoutTests/fast/events/constructors/overconstrained-error-event-constructor.html
LayoutTests/fast/mediastream/MediaStreamTrackEvent-constructor-expected.txt
LayoutTests/fast/mediastream/MediaStreamTrackEvent-constructor.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStreamEvent.cpp
Source/WebCore/Modules/mediastream/MediaStreamEvent.h
Source/WebCore/Modules/mediastream/MediaStreamEvent.idl
Source/WebCore/Modules/mediastream/MediaStreamTrackEvent.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrackEvent.h
Source/WebCore/Modules/mediastream/MediaStreamTrackEvent.idl
Source/WebCore/Modules/mediastream/OverconstrainedErrorEvent.h
Source/WebCore/Modules/mediastream/OverconstrainedErrorEvent.idl
Source/WebCore/Modules/mediastream/RTCDTMFToneChangeEvent.cpp
Source/WebCore/Modules/mediastream/RTCDTMFToneChangeEvent.h
Source/WebCore/Modules/mediastream/RTCDTMFToneChangeEvent.idl
Source/WebCore/Modules/mediastream/RTCTrackEvent.cpp
Source/WebCore/Modules/mediastream/RTCTrackEvent.h
Source/WebCore/Modules/mediastream/RTCTrackEvent.idl

index fe3ac46..4d33d4e 100644 (file)
@@ -1,3 +1,17 @@
+2016-10-11  Chris Dumez  <cdumez@apple.com>
+
+        Update MediaStream events to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163289
+
+        Reviewed by Sam Weinig.
+
+        Update existing test cases now that we throw more exceptions on bad input.
+
+        * fast/events/constructors/overconstrained-error-event-constructor-expected.txt:
+        * fast/events/constructors/overconstrained-error-event-constructor.html:
+        * fast/mediastream/MediaStreamTrackEvent-constructor-expected.txt:
+        * fast/mediastream/MediaStreamTrackEvent-constructor.html:
+
 2016-10-11  Dean Jackson  <dino@apple.com>
 
         Implement prefers-reduced-motion media query
index 1658bad..7311d84 100644 (file)
@@ -15,8 +15,8 @@ PASS new OverconstrainedErrorEvent('eventType', { error: new OverconstrainedErro
 PASS new OverconstrainedErrorEvent('eventType', { error: new OverconstrainedError('width') }).error.constraint is "width"
 PASS new OverconstrainedErrorEvent('eventType', { error: new OverconstrainedError('fred', 'unsupported constraint') }).error.message is "unsupported constraint"
 PASS new OverconstrainedErrorEvent('eventType', { error: null }).reason is undefined.
-PASS new OverconstrainedErrorEvent('eventType', { error: 'fake error' }).error is null
-PASS new OverconstrainedErrorEvent('eventType', { error: [] }).error is null
+PASS new OverconstrainedErrorEvent('eventType', { error: 'fake error' }) threw exception TypeError: Type error.
+PASS new OverconstrainedErrorEvent('eventType', { error: [] }) threw exception TypeError: Type error.
 PASS new OverconstrainedErrorEvent('eventType', { bubbles: true, cancelable: true, error: new OverconstrainedError() }).bubbles is true
 PASS new OverconstrainedErrorEvent('eventType', { bubbles: true, cancelable: true, error: new OverconstrainedError() }).cancelable is true
 PASS new OverconstrainedErrorEvent('eventType', { bubbles: true, cancelable: true, error: new OverconstrainedError('bogus') }).error.constraint is "bogus"
index 03798ce..7a980af 100644 (file)
@@ -35,8 +35,8 @@
         shouldBeEqualToString("new OverconstrainedErrorEvent('eventType', { error: new OverconstrainedError('fred', 'unsupported constraint') }).error.message", "unsupported constraint");
 
         shouldBeUndefined("new OverconstrainedErrorEvent('eventType', { error: null }).reason");
-        shouldBeNull("new OverconstrainedErrorEvent('eventType', { error: 'fake error' }).error", null);
-        shouldBeNull("new OverconstrainedErrorEvent('eventType', { error: [] }).error", null);
+        shouldThrowErrorName("new OverconstrainedErrorEvent('eventType', { error: 'fake error' })", "TypeError");
+        shouldThrowErrorName("new OverconstrainedErrorEvent('eventType', { error: [] })", "TypeError");
 
         // All initializers are passed.
         shouldBe("new OverconstrainedErrorEvent('eventType', { bubbles: true, cancelable: true, error: new OverconstrainedError() }).bubbles", "true");
index bbfb4a4..1e56737 100644 (file)
@@ -19,15 +19,13 @@ PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancela
 PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true }).track is null
 
 *** Bubbles and cancelable true, invalid track ***
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }).bubbles is true
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }).cancelable is true
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }).track is null
+PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }) threw exception TypeError: Type error.
 
 *** Initialize 'track' with a invalid values ***
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: 10 }).track is null
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: 'string' }).track is null
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: emptyObject }).track is null
-PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: document }).track is null
+PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: 10 }) threw exception TypeError: Type error.
+PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: 'string' }) threw exception TypeError: Type error.
+PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: emptyObject }) threw exception TypeError: Type error.
+PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: document }) threw exception TypeError: Type error.
 
 *** Bubbles and cancelable true, valid track ***
 PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: mediaStreamTrack }).bubbles is true
index 561c46c..1d1f08f 100644 (file)
                 shouldBeNull("new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true }).track");
     
                 debug("<br>*** Bubbles and cancelable true, invalid track ***");
-                shouldBe("new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }).bubbles", "true");
-                shouldBe("new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }).cancelable", "true");
-                shouldBeNull("new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack }).track");
+                shouldThrowErrorName("new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: MediaStreamTrack })", "TypeError");
     
                 debug("<br>*** Initialize 'track' with a invalid values ***");
-                shouldBeNull("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: 10 }).track");
-                shouldBeNull("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: \'string\' }).track");
+                shouldThrowErrorName("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: 10 })", "TypeError");
+                shouldThrowErrorName("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: \'string\' })", "TypeError");
                 emptyObject = { };
-                shouldBeNull("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: emptyObject }).track");
-                shouldBeNull("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: document }).track");
+                shouldThrowErrorName("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: emptyObject })", "TypeError");
+                shouldThrowErrorName("new MediaStreamTrackEvent('MediaStreamTrackEvent', { track: document })", "TypeError");
 
                 debug("<br>*** Bubbles and cancelable true, valid track ***");
                 shouldBe("new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true, track: mediaStreamTrack }).bubbles", "true");
index 0b6d172..31250d2 100644 (file)
@@ -1,5 +1,41 @@
 2016-10-11  Chris Dumez  <cdumez@apple.com>
 
+        Update MediaStream events to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163289
+
+        Reviewed by Sam Weinig.
+
+        Update MediaStream events to stop using legacy [ConstructorTemplate=Event]
+        and use regular constructors instead.
+
+        * Modules/mediastream/MediaStreamEvent.cpp:
+        (WebCore::MediaStreamEvent::create):
+        (WebCore::MediaStreamEvent::MediaStreamEvent):
+        * Modules/mediastream/MediaStreamEvent.h:
+        * Modules/mediastream/MediaStreamEvent.idl:
+        * Modules/mediastream/MediaStreamTrackEvent.cpp:
+        (WebCore::MediaStreamTrackEvent::create):
+        (WebCore::MediaStreamTrackEvent::MediaStreamTrackEvent):
+        * Modules/mediastream/MediaStreamTrackEvent.h:
+        * Modules/mediastream/MediaStreamTrackEvent.idl:
+        * Modules/mediastream/OverconstrainedErrorEvent.h:
+        (WebCore::OverconstrainedErrorEvent::create):
+        (WebCore::OverconstrainedErrorEvent::OverconstrainedErrorEvent):
+        (WebCore::OverconstrainedErrorEvent::~OverconstrainedErrorEvent): Deleted.
+        * Modules/mediastream/OverconstrainedErrorEvent.idl:
+        * Modules/mediastream/RTCDTMFToneChangeEvent.cpp:
+        (WebCore::RTCDTMFToneChangeEvent::create):
+        (WebCore::RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent):
+        * Modules/mediastream/RTCDTMFToneChangeEvent.h:
+        * Modules/mediastream/RTCDTMFToneChangeEvent.idl:
+        * Modules/mediastream/RTCTrackEvent.cpp:
+        (WebCore::RTCTrackEvent::create):
+        (WebCore::RTCTrackEvent::RTCTrackEvent):
+        * Modules/mediastream/RTCTrackEvent.h:
+        * Modules/mediastream/RTCTrackEvent.idl:
+
+2016-10-11  Chris Dumez  <cdumez@apple.com>
+
         Update UIRequestEvent to stop using legacy [ConstructorTemplate=Event]
         https://bugs.webkit.org/show_bug.cgi?id=163288
 
index 3072e10..4bceadd 100644 (file)
@@ -37,9 +37,9 @@ Ref<MediaStreamEvent> MediaStreamEvent::create(const AtomicString& type, bool ca
     return adoptRef(*new MediaStreamEvent(type, canBubble, cancelable, WTFMove(stream)));
 }
 
-Ref<MediaStreamEvent> MediaStreamEvent::createForBindings(const AtomicString& type, const MediaStreamEventInit& initializer)
+Ref<MediaStreamEvent> MediaStreamEvent::create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
 {
-    return adoptRef(*new MediaStreamEvent(type, initializer));
+    return adoptRef(*new MediaStreamEvent(type, initializer, isTrusted));
 }
 
 MediaStreamEvent::MediaStreamEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<MediaStream>&& stream)
@@ -48,8 +48,8 @@ MediaStreamEvent::MediaStreamEvent(const AtomicString& type, bool canBubble, boo
 {
 }
 
-MediaStreamEvent::MediaStreamEvent(const AtomicString& type, const MediaStreamEventInit& initializer)
-    : Event(type, initializer)
+MediaStreamEvent::MediaStreamEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
     , m_stream(initializer.stream)
 {
 }
index 229e3cb..270b8cb 100644 (file)
 
 namespace WebCore {
 
-struct MediaStreamEventInit : public EventInit {
-    RefPtr<MediaStream> stream;
-};
-
 class MediaStreamEvent : public Event {
 public:
     virtual ~MediaStreamEvent();
 
     static Ref<MediaStreamEvent> create(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<MediaStream>&&);
-    static Ref<MediaStreamEvent> createForBindings(const AtomicString& type, const MediaStreamEventInit& initializer);
+
+    struct Init : EventInit {
+        RefPtr<MediaStream> stream;
+    };
+    static Ref<MediaStreamEvent> create(const AtomicString& type, const Init& initializer, IsTrusted = IsTrusted::No);
 
     MediaStream* stream() const;
 
@@ -50,7 +50,7 @@ public:
 
 private:
     MediaStreamEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<MediaStream>&&);
-    MediaStreamEvent(const AtomicString& type, const MediaStreamEventInit&);
+    MediaStreamEvent(const AtomicString& type, const Init&, IsTrusted);
 
     RefPtr<MediaStream> m_stream;
 };
index 620005f..431ede4 100644 (file)
 
 [
     Conditional=WEB_RTC,
-    ConstructorTemplate=Event
+    Constructor(DOMString type, MediaStreamEventInit eventInitDict),
 ] interface MediaStreamEvent : Event {
-   [InitializedByEventConstructor] readonly attribute MediaStream stream;
+    readonly attribute MediaStream? stream;
 };
 
+dictionary MediaStreamEventInit : EventInit {
+    MediaStream? stream = null;
+};
index 6ece61c..eea4564 100644 (file)
@@ -37,9 +37,9 @@ Ref<MediaStreamTrackEvent> MediaStreamTrackEvent::create(const AtomicString& typ
     return adoptRef(*new MediaStreamTrackEvent(type, canBubble, cancelable, WTFMove(track)));
 }
 
-Ref<MediaStreamTrackEvent> MediaStreamTrackEvent::createForBindings(const AtomicString& type, const MediaStreamTrackEventInit& initializer)
+Ref<MediaStreamTrackEvent> MediaStreamTrackEvent::create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
 {
-    return adoptRef(*new MediaStreamTrackEvent(type, initializer));
+    return adoptRef(*new MediaStreamTrackEvent(type, initializer, isTrusted));
 }
 
 MediaStreamTrackEvent::MediaStreamTrackEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<MediaStreamTrack>&& track)
@@ -48,8 +48,8 @@ MediaStreamTrackEvent::MediaStreamTrackEvent(const AtomicString& type, bool canB
 {
 }
 
-MediaStreamTrackEvent::MediaStreamTrackEvent(const AtomicString& type, const MediaStreamTrackEventInit& initializer)
-    : Event(type, initializer)
+MediaStreamTrackEvent::MediaStreamTrackEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
     , m_track(initializer.track)
 {
 }
index 5ce3a1f..8915b0e 100644 (file)
@@ -34,16 +34,16 @@ namespace WebCore {
 
 class MediaStreamTrack;
 
-struct MediaStreamTrackEventInit : public EventInit {
-    RefPtr<MediaStreamTrack> track;
-};
-
 class MediaStreamTrackEvent : public Event {
 public:
     virtual ~MediaStreamTrackEvent();
 
     static Ref<MediaStreamTrackEvent> create(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<MediaStreamTrack>&&);
-    static Ref<MediaStreamTrackEvent> createForBindings(const AtomicString& type, const MediaStreamTrackEventInit& initializer);
+
+    struct Init : EventInit {
+        RefPtr<MediaStreamTrack> track;
+    };
+    static Ref<MediaStreamTrackEvent> create(const AtomicString& type, const Init&, IsTrusted = IsTrusted::No);
 
     MediaStreamTrack* track() const;
 
@@ -52,7 +52,7 @@ public:
 
 private:
     MediaStreamTrackEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<MediaStreamTrack>&&);
-    MediaStreamTrackEvent(const AtomicString& type, const MediaStreamTrackEventInit&);
+    MediaStreamTrackEvent(const AtomicString& type, const Init&, IsTrusted);
 
     RefPtr<MediaStreamTrack> m_track;
 };
index 10d5f33..bef0b26 100644 (file)
 
 [
     Conditional=MEDIA_STREAM,
-    ConstructorTemplate=Event
+    Constructor(DOMString type, optional MediaStreamTrackEventInit eventInitDict),
 ] interface MediaStreamTrackEvent : Event {
-   [InitializedByEventConstructor] readonly attribute MediaStreamTrack track;
+    readonly attribute MediaStreamTrack? track;
 };
 
+dictionary MediaStreamTrackEventInit : EventInit {
+    // FIXME: The specification says that this member should be required and non-nullable.
+    MediaStreamTrack? track = null;
+};
index d1b2fab..7e8fb1e 100644 (file)
 
 namespace WebCore {
 
-struct OverconstrainedErrorEventInit : public EventInit {
-    RefPtr<OverconstrainedError> error;
-};
-
 class OverconstrainedErrorEvent : public Event {
 public:
     virtual ~OverconstrainedErrorEvent() { }
@@ -49,9 +45,13 @@ public:
         return adoptRef(*new OverconstrainedErrorEvent(type, canBubble, cancelable, error));
     }
 
-    static Ref<OverconstrainedErrorEvent> createForBindings(const AtomicString& type, const OverconstrainedErrorEventInit& initializer)
+    struct Init : EventInit {
+        RefPtr<OverconstrainedError> error;
+    };
+
+    static Ref<OverconstrainedErrorEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
     {
-        return adoptRef(*new OverconstrainedErrorEvent(type, initializer));
+        return adoptRef(*new OverconstrainedErrorEvent(type, initializer, isTrusted));
     }
 
     OverconstrainedError* error() const { return m_error.get(); }
@@ -63,8 +63,8 @@ private:
         , m_error(error)
     {
     }
-    OverconstrainedErrorEvent(const AtomicString& type, const OverconstrainedErrorEventInit& initializer)
-        : Event(type, initializer)
+    OverconstrainedErrorEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+        : Event(type, initializer, isTrusted)
         , m_error(initializer.error)
     {
     }
index 538815a..ceddfa7 100644 (file)
 
 [
     Conditional=MEDIA_STREAM,
-    ConstructorTemplate=Event,
+    Constructor(DOMString type, optional OverconstrainedErrorEventInit eventInitDict),
 ] interface OverconstrainedErrorEvent : Event {
-   [InitializedByEventConstructor] readonly attribute OverconstrainedError? error;
+    readonly attribute OverconstrainedError? error;
 };
 
+dictionary OverconstrainedErrorEventInit : EventInit {
+    OverconstrainedError? error = null;
+};
index 13ab152..d6ff9fd 100644 (file)
@@ -37,10 +37,9 @@ Ref<RTCDTMFToneChangeEvent> RTCDTMFToneChangeEvent::create(const String& tone)
     return adoptRef(*new RTCDTMFToneChangeEvent(tone));
 }
 
-Ref<RTCDTMFToneChangeEvent> RTCDTMFToneChangeEvent::createForBindings(const AtomicString& type, const RTCDTMFToneChangeEventInit& initializer)
+Ref<RTCDTMFToneChangeEvent> RTCDTMFToneChangeEvent::create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
 {
-    ASSERT_UNUSED(type, type == eventNames().tonechangeEvent);
-    return adoptRef(*new RTCDTMFToneChangeEvent(initializer));
+    return adoptRef(*new RTCDTMFToneChangeEvent(type, initializer, isTrusted));
 }
 
 RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent(const String& tone)
@@ -49,8 +48,8 @@ RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent(const String& tone)
 {
 }
 
-RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent(const RTCDTMFToneChangeEventInit& initializer)
-    : Event(eventNames().tonechangeEvent, initializer)
+RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
     , m_tone(initializer.tone)
 {
 }
index 4a8cb81..0213c1e 100644 (file)
 
 namespace WebCore {
 
-struct RTCDTMFToneChangeEventInit : public EventInit {
-    String tone;
-};
-
 class RTCDTMFToneChangeEvent : public Event {
 public:
     virtual ~RTCDTMFToneChangeEvent();
 
     static Ref<RTCDTMFToneChangeEvent> create(const String& tone);
-    static Ref<RTCDTMFToneChangeEvent> createForBindings(const AtomicString& type, const RTCDTMFToneChangeEventInit& initializer);
+
+    struct Init : EventInit {
+        String tone;
+    };
+
+    static Ref<RTCDTMFToneChangeEvent> create(const AtomicString& type, const Init&, IsTrusted = IsTrusted::No);
 
     const String& tone() const;
 
@@ -50,7 +51,7 @@ public:
 
 private:
     explicit RTCDTMFToneChangeEvent(const String& tone);
-    explicit RTCDTMFToneChangeEvent(const RTCDTMFToneChangeEventInit&);
+    RTCDTMFToneChangeEvent(const AtomicString& type, const Init&, IsTrusted);
 
     String m_tone;
 };
index a75cc1e..dfd6da7 100644 (file)
  */
 
 [
-    NoInterfaceObject,
     Conditional=WEB_RTC,
-    ConstructorTemplate=Event
+    Constructor(DOMString type, optional RTCDTMFToneChangeEventInit eventInitDict),
 ] interface RTCDTMFToneChangeEvent : Event {
-    [InitializedByEventConstructor] readonly attribute DOMString tone;
+    readonly attribute DOMString tone;
+};
+
+dictionary RTCDTMFToneChangeEventInit : EventInit {
+    DOMString tone = "";
 };
index ad3eb9f..4018172 100644 (file)
@@ -45,9 +45,9 @@ Ref<RTCTrackEvent> RTCTrackEvent::create(const AtomicString& type, bool canBubbl
     return adoptRef(*new RTCTrackEvent(type, canBubble, cancelable, WTFMove(receiver), WTFMove(track), WTFMove(streams), WTFMove(transceiver)));
 }
 
-Ref<RTCTrackEvent> RTCTrackEvent::createForBindings(const AtomicString& type, const RTCTrackEventInit& initializer)
+Ref<RTCTrackEvent> RTCTrackEvent::create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
 {
-    return adoptRef(*new RTCTrackEvent(type, initializer));
+    return adoptRef(*new RTCTrackEvent(type, initializer, isTrusted));
 }
 
 RTCTrackEvent::RTCTrackEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<RTCRtpReceiver>&& receiver, RefPtr<MediaStreamTrack>&& track, Vector<RefPtr<MediaStream>>&& streams, RefPtr<RTCRtpTransceiver>&& transceiver)
@@ -59,8 +59,8 @@ RTCTrackEvent::RTCTrackEvent(const AtomicString& type, bool canBubble, bool canc
 {
 }
 
-RTCTrackEvent::RTCTrackEvent(const AtomicString& type, const RTCTrackEventInit& initializer)
-    : Event(type, initializer)
+RTCTrackEvent::RTCTrackEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
     , m_receiver(initializer.receiver)
     , m_track(initializer.track)
     , m_streams(initializer.streams)
index b80ae81..8f38851 100644 (file)
@@ -45,17 +45,17 @@ class RTCRtpTransceiver;
 
 typedef Vector<RefPtr<MediaStream>> MediaStreamArray;
 
-struct RTCTrackEventInit : public EventInit {
-    RefPtr<RTCRtpReceiver> receiver;
-    RefPtr<MediaStreamTrack> track;
-    MediaStreamArray streams;
-    RefPtr<RTCRtpTransceiver> transceiver;
-};
-
 class RTCTrackEvent : public Event {
 public:
     static Ref<RTCTrackEvent> create(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<RTCRtpReceiver>&&, RefPtr<MediaStreamTrack>&&, MediaStreamArray&&, RefPtr<RTCRtpTransceiver>&&);
-    static Ref<RTCTrackEvent> createForBindings(const AtomicString& type, const RTCTrackEventInit&);
+
+    struct Init : EventInit {
+        RefPtr<RTCRtpReceiver> receiver;
+        RefPtr<MediaStreamTrack> track;
+        MediaStreamArray streams;
+        RefPtr<RTCRtpTransceiver> transceiver;
+    };
+    static Ref<RTCTrackEvent> create(const AtomicString& type, const Init&, IsTrusted = IsTrusted::No);
 
     RTCRtpReceiver* receiver() const { return m_receiver.get(); }
     MediaStreamTrack* track() const  { return m_track.get(); }
@@ -66,7 +66,7 @@ public:
 
 private:
     RTCTrackEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<RTCRtpReceiver>&&, RefPtr<MediaStreamTrack>&&, MediaStreamArray&&, RefPtr<RTCRtpTransceiver>&&);
-    RTCTrackEvent(const AtomicString& type, const RTCTrackEventInit&);
+    RTCTrackEvent(const AtomicString& type, const Init&, IsTrusted);
 
     RefPtr<RTCRtpReceiver> m_receiver;
     RefPtr<MediaStreamTrack> m_track;
index 8e29d8e..ff9b885 100644 (file)
 
 [
     Conditional=WEB_RTC,
-    ConstructorTemplate=Event
+    Constructor(DOMString type, optional RTCTrackEventInit eventInitDict),
 ] interface RTCTrackEvent : Event {
-   [InitializedByEventConstructor] readonly attribute RTCRtpReceiver receiver;
-   [InitializedByEventConstructor] readonly attribute MediaStreamTrack track;
+   [InitializedByEventConstructor] readonly attribute RTCRtpReceiver? receiver;
+   [InitializedByEventConstructor] readonly attribute MediaStreamTrack? track;
    [InitializedByEventConstructor] readonly attribute sequence<MediaStream> streams;
-   [InitializedByEventConstructor] readonly attribute RTCRtpTransceiver transceiver;
+   [InitializedByEventConstructor] readonly attribute RTCRtpTransceiver? transceiver;
+};
+
+dictionary RTCTrackEventInit : EventInit {
+    sequence<MediaStream> streams = [];
+
+    // FIXME: The specification says that these members should be required and non-nullable.
+    RTCRtpReceiver? receiver = null;
+    MediaStreamTrack? track = null;
+    RTCRtpTransceiver? transceiver = null;
 };