Title: [237106] trunk
Revision
237106
Author
commit-qu...@webkit.org
Date
2018-10-15 07:56:03 -0700 (Mon, 15 Oct 2018)

Log Message

Implement error handler of MediaRecorder
https://bugs.webkit.org/show_bug.cgi?id=190438

Patch by YUHAN WU <yuhan...@apple.com> on 2018-10-15
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/mediacapture-record/MediaRecorder-error-expected.txt: Added.
* web-platform-tests/mediacapture-record/MediaRecorder-error.html: Added.

Source/WebCore:

Test: imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error.html

Implement error event handler (onerror) for MediaRecorder and basic architecture of start() function.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/mediarecorder/MediaRecorder.cpp:
(WebCore::MediaRecorder::MediaRecorder):
(WebCore::MediaRecorder::~MediaRecorder):
(WebCore::MediaRecorder::stop):
(WebCore::MediaRecorder::start):
(WebCore::MediaRecorder::setNewRecordingState):
(WebCore::MediaRecorder::scheduleDeferredTask):
(WebCore::MediaRecorder::didAddOrRemoveTrack):
* Modules/mediarecorder/MediaRecorder.h:
* Modules/mediarecorder/MediaRecorder.idl:
* Modules/mediarecorder/MediaRecorderErrorEvent.cpp: Added.
(WebCore::MediaRecorderErrorEvent::create):
(WebCore::MediaRecorderErrorEvent::MediaRecorderErrorEvent):
(WebCore::MediaRecorderErrorEvent::eventInterface const):
* Modules/mediarecorder/MediaRecorderErrorEvent.h: Added.
* Modules/mediarecorder/MediaRecorderErrorEvent.idl: Added.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* dom/EventNames.in:
* dom/EventTargetFactory.in:

LayoutTests:

Since dataavailable event has not been implemented, skip three MediaRecorder-related tests now.
We will need to reenable those tests once implementing the dataavailable event for MediaRecorder.

* TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237105 => 237106)


--- trunk/LayoutTests/ChangeLog	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/LayoutTests/ChangeLog	2018-10-15 14:56:03 UTC (rev 237106)
@@ -1,3 +1,15 @@
+2018-10-15  YUHAN WU  <yuhan...@apple.com>
+
+        Implement error handler of MediaRecorder
+        https://bugs.webkit.org/show_bug.cgi?id=190438
+
+        Reviewed by Youenn Fablet.
+
+        Since dataavailable event has not been implemented, skip three MediaRecorder-related tests now.
+        We will need to reenable those tests once implementing the dataavailable event for MediaRecorder.
+
+        * TestExpectations:
+
 2018-10-15  Chris Dumez  <cdu...@apple.com>
 
         Window's properties such as 'location' should not become null when it loses its browsing context

Modified: trunk/LayoutTests/TestExpectations (237105 => 237106)


--- trunk/LayoutTests/TestExpectations	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/LayoutTests/TestExpectations	2018-10-15 14:56:03 UTC (rev 237106)
@@ -2897,3 +2897,8 @@
 webkit.org/b/190032 imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context.html [ Failure ]
 webkit.org/b/190032 imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/animate.html [ Failure ]
 webkit.org/b/190032 imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html [ Failure ]
+
+# FIXME: Need to implement MediaRecorder dataavailable event to support these testcases
+fast/mediacapturefromelement/CanvasCaptureMediaStream-imagebitmaprenderingcontext.html [ Skip ]
+fast/mediacapturefromelement/CanvasCaptureMediaStream-framerate-0.html [ Skip ]
+fast/mediacapturefromelement/CanvasCaptureMediaStream-capture-out-of-DOM-element.html [ Skip ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (237105 => 237106)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-10-15 14:56:03 UTC (rev 237106)
@@ -1,3 +1,13 @@
+2018-10-15  YUHAN WU  <yuhan...@apple.com>
+
+        Implement error handler of MediaRecorder
+        https://bugs.webkit.org/show_bug.cgi?id=190438
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/mediacapture-record/MediaRecorder-error-expected.txt: Added.
+        * web-platform-tests/mediacapture-record/MediaRecorder-error.html: Added.
+
 2018-10-15  Chris Dumez  <cdu...@apple.com>
 
         Window's properties such as 'location' should not become null when it loses its browsing context

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error-expected.txt (0 => 237106)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error-expected.txt	2018-10-15 14:56:03 UTC (rev 237106)
@@ -0,0 +1,5 @@
+
+PASS MediaRecorder will stop recording when any of track is added and error event will be fired 
+PASS MediaRecorder will stop recording when any of track is removed and error event will be fired 
+PASS MediaRecorder cannot start recording when MediaRecorder' state is not inactive and an InvalidStateError should be thrown 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error.html (0 => 237106)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error.html	2018-10-15 14:56:03 UTC (rev 237106)
@@ -0,0 +1,74 @@
+<!doctype html>
+<html>
+<head>
+    <title>MediaRecorder Error</title>
+    <link rel="help" href=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<canvas id="canvas">
+</canvas>
+<script>
+    function createAudioStream() {
+        let ac = new AudioContext();
+        let osc = ac.createOscillator();
+        let dest = ac.createMediaStreamDestination();
+        osc.connect(dest);
+        return dest.stream;
+    }
+
+    function createVideoStream() {
+        let canvas = document.getElementById("canvas");
+        return canvas.captureStream();
+    }
+
+    async_test(t => {
+        let video = createVideoStream();
+        let audio = createAudioStream();
+        let recorder = new MediaRecorder(video);
+        recorder._onerror_ = t.step_func(mediaRecorderErrorEvent => {
+            assert_true(mediaRecorderErrorEvent instanceof MediaRecorderErrorEvent, 'the type of event should be MediaRecorderErrorEvent');
+            assert_equals(mediaRecorderErrorEvent.error.name, 'UnknownError', 'the type of error should be UnknownError when track has been added or removed');
+            assert_true(mediaRecorderErrorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
+            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped after adding a track to stream");
+            t.done();
+        });
+        recorder.start();
+        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
+        video.addTrack(audio.getAudioTracks()[0]);
+        t.step_timeout(() => {
+            assert_unreached("error event is not fired after 2 seconds");
+        }, 2000);
+    }, "MediaRecorder will stop recording when any of track is added and error event will be fired", { timeout: 10000 });
+
+    async_test(t => {
+        let video = createVideoStream();
+        let recorder = new MediaRecorder(video);
+        recorder._onerror_ = t.step_func(mediaRecorderErrorEvent => {
+            assert_true(mediaRecorderErrorEvent instanceof MediaRecorderErrorEvent, 'the type of event should be MediaRecorderErrorEvent');
+            assert_equals(mediaRecorderErrorEvent.error.name, 'UnknownError', 'the type of error should be UnknownError when track has been added or removed');
+            assert_true(mediaRecorderErrorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
+            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped after removing a track from stream");
+            t.done();
+        });
+        recorder.start();
+        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
+        video.removeTrack(video.getVideoTracks()[0]);
+        t.step_timeout(() => {
+            assert_unreached("error event is not fired after 2 seconds");
+        }, 2000);
+    }, "MediaRecorder will stop recording when any of track is removed and error event will be fired", { timeout: 10000 });
+
+    test(t => {
+        let video = createVideoStream();
+        let recorder = new MediaRecorder(video);
+        recorder.start();
+        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
+        assert_throws("InvalidStateError", function() {
+            recorder.start();
+        });
+    }, "MediaRecorder cannot start recording when MediaRecorder' state is not inactive and an InvalidStateError should be thrown");
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/CMakeLists.txt (237105 => 237106)


--- trunk/Source/WebCore/CMakeLists.txt	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-10-15 14:56:03 UTC (rev 237106)
@@ -281,6 +281,7 @@
 
     Modules/mediarecorder/BlobEvent.idl
     Modules/mediarecorder/MediaRecorder.idl
+    Modules/mediarecorder/MediaRecorderErrorEvent.idl
 
     Modules/mediasession/HTMLMediaElementMediaSession.idl
     Modules/mediasession/MediaRemoteControls.idl

Modified: trunk/Source/WebCore/ChangeLog (237105 => 237106)


--- trunk/Source/WebCore/ChangeLog	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/ChangeLog	2018-10-15 14:56:03 UTC (rev 237106)
@@ -1,3 +1,38 @@
+2018-10-15  YUHAN WU  <yuhan...@apple.com>
+
+        Implement error handler of MediaRecorder
+        https://bugs.webkit.org/show_bug.cgi?id=190438
+
+        Reviewed by Youenn Fablet.
+
+        Test: imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-error.html
+
+        Implement error event handler (onerror) for MediaRecorder and basic architecture of start() function.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/mediarecorder/MediaRecorder.cpp:
+        (WebCore::MediaRecorder::MediaRecorder):
+        (WebCore::MediaRecorder::~MediaRecorder):
+        (WebCore::MediaRecorder::stop):
+        (WebCore::MediaRecorder::start):
+        (WebCore::MediaRecorder::setNewRecordingState):
+        (WebCore::MediaRecorder::scheduleDeferredTask):
+        (WebCore::MediaRecorder::didAddOrRemoveTrack):
+        * Modules/mediarecorder/MediaRecorder.h:
+        * Modules/mediarecorder/MediaRecorder.idl:
+        * Modules/mediarecorder/MediaRecorderErrorEvent.cpp: Added.
+        (WebCore::MediaRecorderErrorEvent::create):
+        (WebCore::MediaRecorderErrorEvent::MediaRecorderErrorEvent):
+        (WebCore::MediaRecorderErrorEvent::eventInterface const):
+        * Modules/mediarecorder/MediaRecorderErrorEvent.h: Added.
+        * Modules/mediarecorder/MediaRecorderErrorEvent.idl: Added.
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+        * dom/EventNames.in:
+        * dom/EventTargetFactory.in:
+
 2018-10-15  Chris Dumez  <cdu...@apple.com>
 
         Window's properties such as 'location' should not become null when it loses its browsing context

Modified: trunk/Source/WebCore/DerivedSources.make (237105 => 237106)


--- trunk/Source/WebCore/DerivedSources.make	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/DerivedSources.make	2018-10-15 14:56:03 UTC (rev 237106)
@@ -205,6 +205,7 @@
     $(WebCore)/Modules/mediacontrols/MediaControlsHost.idl \
 	$(WebCore)/Modules/mediarecorder/BlobEvent.idl \
 	$(WebCore)/Modules/mediarecorder/MediaRecorder.idl \
+	$(WebCore)/Modules/mediarecorder/MediaRecorderErrorEvent.idl \
     $(WebCore)/Modules/mediasession/HTMLMediaElementMediaSession.idl \
     $(WebCore)/Modules/mediasession/MediaRemoteControls.idl \
     $(WebCore)/Modules/mediasession/MediaSession.idl \

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp (237105 => 237106)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2018-10-15 14:56:03 UTC (rev 237106)
@@ -29,7 +29,8 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "Document.h"
-#include "MediaStream.h"
+#include "EventNames.h"
+#include "MediaRecorderErrorEvent.h"
 
 namespace WebCore {
 
@@ -45,8 +46,19 @@
     , m_options(WTFMove(option))
     , m_stream(WTFMove(stream))
 {
+    m_stream->addObserver(this);
 }
 
+MediaRecorder::~MediaRecorder()
+{
+    m_stream->removeObserver(this);
+}
+
+void MediaRecorder::stop()
+{
+    m_isActive = false;
+}
+
 const char* MediaRecorder::activeDOMObjectName() const
 {
     return "MediaRecorder";
@@ -57,6 +69,46 @@
     return false; // FIXME: We should do better here as this prevents entering PageCache.
 }
 
+ExceptionOr<void> MediaRecorder::start(std::optional<int> timeslice)
+{
+    UNUSED_PARAM(timeslice);
+    if (state() != RecordingState::Inactive)
+        return Exception { InvalidStateError, "The MediaRecorder's state must be inactive in order to start recording"_s };
+    
+    m_state = RecordingState::Recording;
+    return { };
+}
+
+void MediaRecorder::didAddOrRemoveTrack()
+{
+    scheduleDeferredTask([this] {
+        if (!m_isActive || state() == RecordingState::Inactive)
+            return;
+        auto event = MediaRecorderErrorEvent::create(eventNames().errorEvent, Exception { UnknownError, "Track cannot be added to or removed from the MediaStream while recording is happening"_s });
+        setNewRecordingState(RecordingState::Inactive, WTFMove(event));
+    });
+}
+
+void MediaRecorder::setNewRecordingState(RecordingState newState, Ref<Event>&& event)
+{
+    m_state = newState;
+    dispatchEvent(WTFMove(event));
+}
+
+void MediaRecorder::scheduleDeferredTask(Function<void()>&& function)
+{
+    ASSERT(function);
+    auto* scriptExecutionContext = this->scriptExecutionContext();
+    if (!scriptExecutionContext)
+        return;
+    scriptExecutionContext->postTask([weakThis = makeWeakPtr(*this), function = WTFMove(function)] (auto&) {
+        if (!weakThis)
+            return;
+
+        function();
+    });
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h (237105 => 237106)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2018-10-15 14:56:03 UTC (rev 237106)
@@ -27,13 +27,13 @@
 #if ENABLE(MEDIA_STREAM)
 #include "ActiveDOMObject.h"
 #include "EventTarget.h"
+#include "MediaStream.h"
 
 namespace WebCore {
 
 class Document;
-class MediaStream;
 
-class MediaRecorder final : public ActiveDOMObject, public RefCounted<MediaRecorder>, public EventTargetWithInlineData {
+class MediaRecorder final : public ActiveDOMObject, public RefCounted<MediaRecorder>, public EventTargetWithInlineData, public CanMakeWeakPtr<MediaRecorder>, private MediaStream::Observer {
 public:
     enum class RecordingState { Inactive, Recording, Paused };
     
@@ -44,6 +44,8 @@
         unsigned bitsPerSecond;
     };
     
+    ~MediaRecorder();
+    
     static Ref<MediaRecorder> create(Document&, Ref<MediaStream>&&, Options&& = { });
     
     RecordingState state() const { return m_state; }
@@ -51,6 +53,8 @@
     using RefCounted::ref;
     using RefCounted::deref;
     
+    ExceptionOr<void> start(std::optional<int>);
+    
 private:
     MediaRecorder(Document&, Ref<MediaStream>&&, Options&& = { });
     
@@ -57,16 +61,25 @@
     // EventTarget
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
-    EventTargetInterface eventTargetInterface() const final { return MediaStreamEventTargetInterfaceType; }
+    EventTargetInterface eventTargetInterface() const final { return MediaRecorderEventTargetInterfaceType; }
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
 
     // ActiveDOMObject API.
+    void stop() final;
     const char* activeDOMObjectName() const final;
     bool canSuspendForDocumentSuspension() const final;
     
+    // MediaStream::Observer
+    void didAddOrRemoveTrack() final;
+    
+    void scheduleDeferredTask(Function<void()>&&);
+    void setNewRecordingState(RecordingState, Ref<Event>&&);
+    
     Options m_options;
     Ref<MediaStream> m_stream;
     RecordingState m_state { RecordingState::Inactive };
+    
+    bool m_isActive { true };
 };
     
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl (237105 => 237106)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2018-10-15 14:56:03 UTC (rev 237106)
@@ -41,11 +41,11 @@
     // attribute EventHandler ondataavailable;
     // attribute EventHandler onpause;
     // attribute EventHandler onresume;
-    // attribute EventHandler onerror;
+    attribute EventHandler onerror;
     // readonly attribute unsigned long videoBitsPerSecond;
     // readonly attribute unsigned long audioBitsPerSecond;
 
-    // void start(optional long timeslice);
+    [MayThrowException] void start(optional long timeslice);
     // void stop();
     // void pause();
     // void resume();

Copied: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.cpp (from rev 237105, trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp) (0 => 237106)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.cpp	2018-10-15 14:56:03 UTC (rev 237106)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "MediaRecorderErrorEvent.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "DOMException.h"
+
+namespace WebCore {
+
+
+Ref<MediaRecorderErrorEvent> MediaRecorderErrorEvent::create(const AtomicString& type, Exception&& exception)
+{
+    return adoptRef(*new MediaRecorderErrorEvent(type, WTFMove(exception)));
+}
+
+Ref<MediaRecorderErrorEvent> MediaRecorderErrorEvent::create(const AtomicString& type, Init&& init, IsTrusted isTrusted)
+{
+    auto domError = init.error.releaseNonNull();
+    return adoptRef(*new MediaRecorderErrorEvent(type, WTFMove(init), WTFMove(domError), isTrusted));
+}
+
+MediaRecorderErrorEvent::MediaRecorderErrorEvent(const AtomicString& type, Init&& init, Ref<DOMException>&& exception, IsTrusted isTrusted)
+    : Event(type, WTFMove(init), isTrusted)
+    , m_domError(WTFMove(exception))
+{
+}
+
+MediaRecorderErrorEvent::MediaRecorderErrorEvent(const AtomicString& type, Exception&& exception)
+    : Event(type, Event::CanBubble::No, Event::IsCancelable::No)
+    , m_domError(DOMException::create(exception))
+{
+}
+
+EventInterface MediaRecorderErrorEvent::eventInterface() const
+{
+    return MediaRecorderErrorEventInterfaceType;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)

Copied: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.h (from rev 237105, trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp) (0 => 237106)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.h	2018-10-15 14:56:03 UTC (rev 237106)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(MEDIA_STREAM)
+#include "Event.h"
+
+namespace WebCore {
+
+class DOMException;
+
+class MediaRecorderErrorEvent final : public Event {
+public:
+    struct Init : EventInit {
+        RefPtr<DOMException> error;
+    };
+    
+    static Ref<MediaRecorderErrorEvent> create(const AtomicString&, Init&&, IsTrusted = IsTrusted::No);
+    static Ref<MediaRecorderErrorEvent> create(const AtomicString&, Exception&&);
+    
+    DOMException& error() const { return m_domError.get(); }
+
+private:
+    MediaRecorderErrorEvent(const AtomicString&, Init&&, Ref<DOMException>&&, IsTrusted);
+    MediaRecorderErrorEvent(const AtomicString&, Exception&&);
+    
+    // Event
+    EventInterface eventInterface() const override;
+
+    Ref<DOMException> m_domError;
+};
+    
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)

Copied: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.idl (from rev 237105, trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp) (0 => 237106)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorderErrorEvent.idl	2018-10-15 14:56:03 UTC (rev 237106)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary MediaRecorderErrorEventInit : EventInit {
+    required DOMException error;
+};
+
+[
+    Conditional=MEDIA_STREAM,
+    Constructor(DOMString type, MediaRecorderErrorEventInit eventInitDict),
+    Exposed=Window,
+    EnabledAtRuntime=MediaRecorder
+] interface MediaRecorderErrorEvent : Event {
+    [SameObject] readonly attribute DOMException error;
+};

Modified: trunk/Source/WebCore/Sources.txt (237105 => 237106)


--- trunk/Source/WebCore/Sources.txt	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/Sources.txt	2018-10-15 14:56:03 UTC (rev 237106)
@@ -141,6 +141,7 @@
 Modules/mediacontrols/MediaControlsHost.cpp
 
 Modules/mediarecorder/MediaRecorder.cpp
+Modules/mediarecorder/MediaRecorderErrorEvent.cpp
 
 Modules/mediasession/HTMLMediaElementMediaSession.cpp
 Modules/mediasession/MediaRemoteControls.cpp
@@ -2772,6 +2773,7 @@
 JSMediaQueryList.cpp
 JSMediaQueryListListener.cpp
 JSMediaRecorder.cpp
+JSMediaRecorderErrorEvent.cpp
 JSMediaRemoteControls.cpp
 JSMediaSession.cpp
 JSMediaSource.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (237105 => 237106)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-10-15 14:56:03 UTC (rev 237106)
@@ -1353,6 +1353,7 @@
 		4BDA40012151B6F500FD6604 /* CSSRegisteredCustomProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FFB2151B6F400FD6604 /* CSSRegisteredCustomProperty.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4D3B00AB215D69A70076B983 /* MediaRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D3B00A9215D69A70076B983 /* MediaRecorder.h */; };
 		4D3B00AF215D6A690076B983 /* BlobEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D3B00AD215D6A690076B983 /* BlobEvent.h */; };
+		4DB7130D216ECB4D0096A4DD /* MediaRecorderErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DB7130C216EC2BD0096A4DD /* MediaRecorderErrorEvent.h */; };
 		4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959240A39DACC00220FE5 /* MediaQuery.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7882,6 +7883,9 @@
 		4D3B00A8215D69A60076B983 /* MediaRecorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaRecorder.cpp; sourceTree = "<group>"; };
 		4D3B00A9215D69A70076B983 /* MediaRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaRecorder.h; sourceTree = "<group>"; };
 		4D3B00AD215D6A690076B983 /* BlobEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobEvent.h; sourceTree = "<group>"; };
+		4DB7130A216EC2BC0096A4DD /* MediaRecorderErrorEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaRecorderErrorEvent.idl; sourceTree = "<group>"; };
+		4DB7130C216EC2BD0096A4DD /* MediaRecorderErrorEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaRecorderErrorEvent.h; sourceTree = "<group>"; };
+		4DB7130E216EEBAE0096A4DD /* MediaRecorderErrorEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaRecorderErrorEvent.cpp; sourceTree = "<group>"; };
 		4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; };
 		4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; };
 		4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; };
@@ -17948,6 +17952,9 @@
 				4D3B00A8215D69A60076B983 /* MediaRecorder.cpp */,
 				4D3B00A9215D69A70076B983 /* MediaRecorder.h */,
 				4D3B00A4215D61040076B983 /* MediaRecorder.idl */,
+				4DB7130E216EEBAE0096A4DD /* MediaRecorderErrorEvent.cpp */,
+				4DB7130C216EC2BD0096A4DD /* MediaRecorderErrorEvent.h */,
+				4DB7130A216EC2BC0096A4DD /* MediaRecorderErrorEvent.idl */,
 			);
 			path = mediarecorder;
 			sourceTree = "<group>";
@@ -27583,7 +27590,6 @@
 				A15D75161E68F7C800A35FBC /* BlobCallback.h in Headers */,
 				2EDEF1F4121B0EFC00726DB2 /* BlobData.h in Headers */,
 				E1D31CDD19196020001005A3 /* BlobDataFileReference.h in Headers */,
-				E4E8B4F5216B956500B8834D /* FontCascadeDescription.h in Headers */,
 				4D3B00AF215D6A690076B983 /* BlobEvent.h in Headers */,
 				7C77C3D71DEF850A00A50BFA /* BlobLineEndings.h in Headers */,
 				E1C94AF9191303F000D5A893 /* BlobPart.h in Headers */,
@@ -27676,7 +27682,6 @@
 				57303BBB2006C6EE00355965 /* CBORBinary.h in Headers */,
 				57303BC12006E00C00355965 /* CBORReader.h in Headers */,
 				57303BB92006C6EE00355965 /* CBORValue.h in Headers */,
-				E4E8B4EC216B79E500B8834D /* SystemFontDatabaseCoreText.h in Headers */,
 				57303BBA2006C6EE00355965 /* CBORWriter.h in Headers */,
 				6550B69E099DF0270090D781 /* CDATASection.h in Headers */,
 				CDF4B7161E00B7E500E235A2 /* CDM.h in Headers */,
@@ -27768,7 +27773,6 @@
 				CE799F981C6A46BC0097B518 /* ContentSecurityPolicySourceList.h in Headers */,
 				CE799FAC1C6A50660097B518 /* ContentSecurityPolicySourceListDirective.h in Headers */,
 				41D015CA0F4B5C71004A662F /* ContentType.h in Headers */,
-				E4605FEC2166480900E53046 /* PrewarmInformation.h in Headers */,
 				97627B8E14FB3CEE002CDCA1 /* ContextDestructionObserver.h in Headers */,
 				93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */,
 				065AD4F50B0C2EDA005A2B1D /* ContextMenuClient.h in Headers */,
@@ -28321,6 +28325,7 @@
 				B2C3DA630D006CD600EF6F26 /* FontCache.h in Headers */,
 				C2458E631FE897B000594759 /* FontCacheCoreText.h in Headers */,
 				B2C3DA610D006CD600EF6F26 /* FontCascade.h in Headers */,
+				E4E8B4F5216B956500B8834D /* FontCascadeDescription.h in Headers */,
 				B2C3DA680D006CD600EF6F26 /* FontCascadeFonts.h in Headers */,
 				B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */,
 				B2C3DA660D006CD600EF6F26 /* FontDescription.h in Headers */,
@@ -29792,6 +29797,7 @@
 				9493B6C11D74B4120088E780 /* MediaQueryParser.h in Headers */,
 				4471710E205AF945000A116E /* MediaQueryParserContext.h in Headers */,
 				4D3B00AB215D69A70076B983 /* MediaRecorder.h in Headers */,
+				4DB7130D216ECB4D0096A4DD /* MediaRecorderErrorEvent.h in Headers */,
 				C90843D01B18E47D00B68564 /* MediaRemoteControls.h in Headers */,
 				CD8ACA8F1D23971900ECC59E /* MediaRemoteSoftLink.h in Headers */,
 				CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */,
@@ -30132,6 +30138,7 @@
 				A1C1507A1E3F2B3E0032C98C /* PreviewConverter.h in Headers */,
 				A185B42A1E8211A100DC9118 /* PreviewLoader.h in Headers */,
 				A10DBF4718F92317000D70C6 /* PreviewLoaderClient.h in Headers */,
+				E4605FEC2166480900E53046 /* PrewarmInformation.h in Headers */,
 				B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
 				51F645D51FECDBCE00B54DED /* Process.h in Headers */,
 				A8EA7EBC0A1945D000A8EF5F /* ProcessingInstruction.h in Headers */,
@@ -31012,6 +31019,7 @@
 				5185430B1FB6784500478F95 /* SWServerToContextConnection.h in Headers */,
 				517A53461F50C17F00DCDC0A /* SWServerWorker.h in Headers */,
 				E180811716FCF9CB00B80D07 /* SynchronousLoaderClient.h in Headers */,
+				E4E8B4EC216B79E500B8834D /* SystemFontDatabaseCoreText.h in Headers */,
 				0F03C0741884695E00A5F8CA /* SystemMemory.h in Headers */,
 				5D5975B319635F1100D00878 /* SystemVersion.h in Headers */,
 				A8CFF0510A154F09000A4234 /* TableLayout.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (237105 => 237106)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2018-10-15 14:56:03 UTC (rev 237106)
@@ -99,6 +99,7 @@
     macro(MediaKeySystemAccess) \
     macro(MediaKeys) \
     macro(MediaRecorder) \
+    macro(MediaRecorderErrorEvent) \
     macro(MediaSource) \
     macro(MediaStream) \
     macro(MediaStreamTrack) \

Modified: trunk/Source/WebCore/dom/EventNames.in (237105 => 237106)


--- trunk/Source/WebCore/dom/EventNames.in	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/dom/EventNames.in	2018-10-15 14:56:03 UTC (rev 237106)
@@ -48,6 +48,7 @@
 ApplePayValidateMerchantEvent conditional=APPLE_PAY
 AudioProcessingEvent conditional=WEB_AUDIO
 OfflineAudioCompletionEvent conditional=WEB_AUDIO
+MediaRecorderErrorEvent conditional=MEDIA_STREAM
 MediaStreamTrackEvent conditional=MEDIA_STREAM
 MerchantValidationEvent conditional=PAYMENT_REQUEST
 PaymentMethodChangeEvent conditional=PAYMENT_REQUEST

Modified: trunk/Source/WebCore/dom/EventTargetFactory.in (237105 => 237106)


--- trunk/Source/WebCore/dom/EventTargetFactory.in	2018-10-15 14:54:21 UTC (rev 237105)
+++ trunk/Source/WebCore/dom/EventTargetFactory.in	2018-10-15 14:56:03 UTC (rev 237106)
@@ -21,6 +21,7 @@
 MediaDevices conditional=MEDIA_STREAM
 MediaKeySession conditional=ENCRYPTED_MEDIA
 MediaRemoteControls conditional=MEDIA_SESSION
+MediaRecorder conditional=MEDIA_STREAM
 MediaSource conditional=MEDIA_SOURCE
 MediaStream conditional=MEDIA_STREAM
 MediaStreamTrack conditional=MEDIA_STREAM
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to