Diff
Modified: trunk/LayoutTests/ChangeLog (212310 => 212311)
--- trunk/LayoutTests/ChangeLog 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/LayoutTests/ChangeLog 2017-02-14 19:17:14 UTC (rev 212311)
@@ -1,3 +1,17 @@
+2017-02-14 Jer Noble <[email protected]>
+
+ Video elements with MediaSource objects set by srcObject are not cleared when srcObject is set to null
+ https://bugs.webkit.org/show_bug.cgi?id=168268
+
+ Reviewed by Eric Carlson.
+
+ * fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt: Added.
+ * fast/mediastream/MediaStream-MediaElement-setObject-null.html: Added.
+ * fast/mediastream/MediaStream-video-element-expected.txt:
+ * fast/mediastream/MediaStream-video-element-track-stop-expected.txt:
+ * fast/mediastream/MediaStream-video-element-track-stop.html:
+ * fast/mediastream/MediaStream-video-element.html:
+
2017-02-14 Antoine Quint <[email protected]>
[mac-wk1] LayoutTest media/modern-media-controls/forward-button/forward-button.html is a flaky timeout
Added: trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt (0 => 212311)
--- trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt 2017-02-14 19:17:14 UTC (rev 212311)
@@ -0,0 +1,8 @@
+PASS video.srcObject = stream did not throw exception.
+PASS video.duration is Number.POSITIVE_INFINITY
+PASS video.srcObject = null did not throw exception.
+PASS video.duration is Number.NaN
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null.html (0 => 212311)
--- trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null.html (rev 0)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null.html 2017-02-14 19:17:14 UTC (rev 212311)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+var video;
+var stream;
+
+function setStream(stream)
+{
+ window.stream = stream;
+ shouldNotThrow('video.srcObject = stream');
+ video.addEventListener('loadedmetadata', loadedMetadata);
+}
+
+function loadedMetadata(event)
+{
+ shouldBe('video.duration', 'Number.POSITIVE_INFINITY');
+ video.play().then(clearStream());
+}
+
+function clearStream()
+{
+ video.addEventListener('abort', abort);
+ shouldNotThrow('video.srcObject = null');
+}
+
+function abort()
+{
+ shouldBe('video.duration', 'Number.NaN');
+ finishJSTest();
+}
+
+function runTest()
+{
+ if (window.testRunner)
+ testRunner.setUserMediaPermission(true);
+
+ video = document.querySelector('#video');
+ navigator.mediaDevices.getUserMedia({ video: { }, audio: true })
+ .then(setStream)
+ .catch(defaultRejectOrCatch);
+}
+
+window.addEventListener('load', runTest);
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;
+</script>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<video id="video"></video>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/fast/mediastream/MediaStream-video-element-expected.txt (212310 => 212311)
--- trunk/LayoutTests/fast/mediastream/MediaStream-video-element-expected.txt 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-video-element-expected.txt 2017-02-14 19:17:14 UTC (rev 212311)
@@ -24,7 +24,6 @@
PASS video.videoWidth is mediaStream.getVideoTracks()[0].getSettings().width
PASS video.videoHeight is mediaStream.getVideoTracks()[0].getSettings().height
PASS video.src.indexOf("blob:") is 0
-PASS video.srcObject is mediaStream
**** check video tracks ****
PASS video.videoTracks.length is 1
Modified: trunk/LayoutTests/fast/mediastream/MediaStream-video-element-track-stop-expected.txt (212310 => 212311)
--- trunk/LayoutTests/fast/mediastream/MediaStream-video-element-track-stop-expected.txt 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-video-element-track-stop-expected.txt 2017-02-14 19:17:14 UTC (rev 212311)
@@ -25,7 +25,6 @@
PASS video.videoWidth is mediaStream.getVideoTracks()[0].getSettings().width
PASS video.videoHeight is mediaStream.getVideoTracks()[0].getSettings().height
PASS video.src.indexOf("blob:") is 0
-PASS video.srcObject is mediaStream
PASS video.videoTracks.length is 1
PASS video.videoTracks.selectedIndex is 0
Modified: trunk/LayoutTests/fast/mediastream/MediaStream-video-element-track-stop.html (212310 => 212311)
--- trunk/LayoutTests/fast/mediastream/MediaStream-video-element-track-stop.html 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-video-element-track-stop.html 2017-02-14 19:17:14 UTC (rev 212311)
@@ -63,7 +63,6 @@
shouldBe('video.videoWidth', 'mediaStream.getVideoTracks()[0].getSettings().width');
shouldBe('video.videoHeight', 'mediaStream.getVideoTracks()[0].getSettings().height');
shouldBe('video.src.indexOf("blob:")', '0');
- shouldBe('video.srcObject', 'mediaStream');
debug("");
shouldBe('video.videoTracks.length', '1');
Modified: trunk/LayoutTests/fast/mediastream/MediaStream-video-element.html (212310 => 212311)
--- trunk/LayoutTests/fast/mediastream/MediaStream-video-element.html 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-video-element.html 2017-02-14 19:17:14 UTC (rev 212311)
@@ -59,8 +59,7 @@
shouldBe('video.videoWidth', 'mediaStream.getVideoTracks()[0].getSettings().width');
shouldBe('video.videoHeight', 'mediaStream.getVideoTracks()[0].getSettings().height');
shouldBe('video.src.indexOf("blob:")', '0');
- shouldBe('video.srcObject', 'mediaStream');
-
+
debug("<br>**** check video tracks ****");
shouldBe('video.videoTracks.length', '1');
shouldBe('video.videoTracks[0].id', 'mediaStream.getVideoTracks()[0].id');
Modified: trunk/Source/WebCore/CMakeLists.txt (212310 => 212311)
--- trunk/Source/WebCore/CMakeLists.txt 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-02-14 19:17:14 UTC (rev 212311)
@@ -211,7 +211,6 @@
Modules/mediastream/DOMURLMediaStream.idl
Modules/mediastream/DoubleRange.idl
- Modules/mediastream/HTMLMediaElementMediaStream.idl
Modules/mediastream/LongRange.idl
Modules/mediastream/MediaDeviceInfo.idl
Modules/mediastream/MediaDevices.idl
@@ -896,7 +895,6 @@
Modules/mediasource/VideoPlaybackQuality.cpp
Modules/mediastream/DOMURLMediaStream.cpp
- Modules/mediastream/HTMLMediaElementMediaStream.cpp
Modules/mediastream/MediaConstraintsImpl.cpp
Modules/mediastream/MediaDeviceInfo.cpp
Modules/mediastream/MediaDevices.cpp
Modified: trunk/Source/WebCore/ChangeLog (212310 => 212311)
--- trunk/Source/WebCore/ChangeLog 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/ChangeLog 2017-02-14 19:17:14 UTC (rev 212311)
@@ -1,3 +1,56 @@
+2017-02-14 Jer Noble <[email protected]>
+
+ Video elements with MediaSource objects set by srcObject are not cleared when srcObject is set to null
+ https://bugs.webkit.org/show_bug.cgi?id=168268
+
+ Reviewed by Eric Carlson.
+
+ Test: fast/mediastream/MediaStream-MediaElement-setObject-null.html
+
+ Make the setSrcObject() operation compliant with the HTML spec. Since the specification defines
+ srcObject in terms of either a MediaSource, MediaStream, or Blob object, add the variant typedef
+ to HTMLMediaElement and move the definition out of the Modules/mediastream extension IDL and into
+ HTMLMediaElement.idl. Then bring the "media elements load" and "resource selection" algorithms up
+ to their most recent definitions in the HTML5 spec.
+
+ Drive-by fix: Allow the (admittedly weird) single-element-union type in IDL.
+
+ * CMakeLists.txt:
+ * DerivedSources.cpp:
+ * DerivedSources.make:
+ * Modules/mediastream/HTMLMediaElementMediaStream.cpp: Removed.
+ * Modules/mediastream/HTMLMediaElementMediaStream.h: Removed.
+ * Modules/mediastream/HTMLMediaElementMediaStream.idl: Removed.
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/scripts/IDLParser.pm:
+ (parseUnionType):
+ * html/HTMLAudioElement.cpp:
+ (WebCore::HTMLAudioElement::createForJSConstructor):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::actionName):
+ (WebCore::HTMLMediaElement::parseAttribute):
+ (WebCore::HTMLMediaElement::insertedInto):
+ (WebCore::HTMLMediaElement::scheduleDelayedAction):
+ (WebCore::HTMLMediaElement::scheduleNextSourceChild):
+ (WebCore::HTMLMediaElement::pendingActionTimerFired):
+ (WebCore::HTMLMediaElement::setSrcObject):
+ (WebCore::HTMLMediaElement::load):
+ (WebCore::HTMLMediaElement::prepareForLoad):
+ (WebCore::HTMLMediaElement::selectMediaResource):
+ (WebCore::HTMLMediaElement::loadResource):
+ (WebCore::HTMLMediaElement::playInternal):
+ (WebCore::HTMLMediaElement::pauseInternal):
+ (WebCore::HTMLMediaElement::sourceWasAdded):
+ (WebCore::HTMLMediaElement::clearMediaPlayer):
+ (WebCore::HTMLMediaElement::resume):
+ (WebCore::HTMLMediaElement::mediaCanStart):
+ (WebCore::HTMLMediaElement::createMediaPlayer):
+ (WebCore::HTMLMediaElement::loadInternal): Deleted.
+ * html/HTMLMediaElement.h:
+ (WebCore::HTMLMediaElement::srcObject):
+ * html/HTMLMediaElement.idl:
+ * platform/ContentType.h:
+
2017-02-14 Aakash Jain <[email protected]>
Remove unused WebThreadContextIsCurrent method from WebCoreThread.h
Modified: trunk/Source/WebCore/DerivedSources.cpp (212310 => 212311)
--- trunk/Source/WebCore/DerivedSources.cpp 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/DerivedSources.cpp 2017-02-14 19:17:14 UTC (rev 212311)
@@ -263,7 +263,6 @@
#include "JSHTMLMarqueeElement.cpp"
#include "JSHTMLMediaElement.cpp"
#include "JSHTMLMediaElementMediaSession.cpp"
-#include "JSHTMLMediaElementMediaStream.cpp"
#include "JSHTMLMenuElement.cpp"
#include "JSHTMLMetaElement.cpp"
#include "JSHTMLMeterElement.cpp"
Modified: trunk/Source/WebCore/DerivedSources.make (212310 => 212311)
--- trunk/Source/WebCore/DerivedSources.make 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/DerivedSources.make 2017-02-14 19:17:14 UTC (rev 212311)
@@ -152,7 +152,6 @@
$(WebCore)/Modules/mediasource/VideoTrackMediaSource.idl \
$(WebCore)/Modules/mediastream/DOMURLMediaStream.idl \
$(WebCore)/Modules/mediastream/DoubleRange.idl \
- $(WebCore)/Modules/mediastream/HTMLMediaElementMediaStream.idl \
$(WebCore)/Modules/mediastream/LongRange.idl \
$(WebCore)/Modules/mediastream/MediaDeviceInfo.idl \
$(WebCore)/Modules/mediastream/MediaDevices.idl \
Deleted: trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.cpp (212310 => 212311)
--- trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.cpp 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.cpp 2017-02-14 19:17:14 UTC (rev 212311)
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT HOLDERS OR
- * 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 "HTMLMediaElementMediaStream.h"
-
-#if ENABLE(MEDIA_STREAM) && ENABLE(VIDEO)
-
-#include "HTMLMediaElement.h"
-#include "MediaStream.h"
-
-namespace WebCore {
-
-MediaStream* HTMLMediaElementMediaStream::srcObject(HTMLMediaElement& mediaElement)
-{
- return mediaElement.srcObject();
-}
-
-void HTMLMediaElementMediaStream::setSrcObject(ScriptExecutionContext& context, HTMLMediaElement& mediaElement, MediaStream* mediaStream)
-{
- mediaElement.setSrcObject(context, mediaStream);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM) && ENABLE(VIDEO)
Deleted: trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.h (212310 => 212311)
--- trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.h 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.h 2017-02-14 19:17:14 UTC (rev 212311)
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT HOLDERS OR
- * 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) && ENABLE(VIDEO)
-
-namespace WebCore {
-
-class HTMLMediaElement;
-class MediaStream;
-class ScriptExecutionContext;
-
-class HTMLMediaElementMediaStream {
-public:
- static MediaStream* srcObject(HTMLMediaElement&);
- static void setSrcObject(ScriptExecutionContext&, HTMLMediaElement&, MediaStream*);
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM) && ENABLE(VIDEO)
Deleted: trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.idl (212310 => 212311)
--- trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.idl 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/Modules/mediastream/HTMLMediaElementMediaStream.idl 2017-02-14 19:17:14 UTC (rev 212311)
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT HOLDERS OR
- * 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.
- */
-
-[
- Conditional=VIDEO&MEDIA_STREAM,
-] partial interface HTMLMediaElement
-{
- [SetterCallWith=ScriptExecutionContext] attribute MediaStream? srcObject;
-};
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (212310 => 212311)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-02-14 19:17:14 UTC (rev 212311)
@@ -162,7 +162,6 @@
07707CB01E205EE300005BF7 /* AudioSourceObserverObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07707CAF1E205EC400005BF7 /* AudioSourceObserverObjC.h */; };
077664FC183E6B5C00133B92 /* JSQuickTimePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 077664FA183E6B5C00133B92 /* JSQuickTimePluginReplacement.cpp */; };
077664FD183E6B5C00133B92 /* JSQuickTimePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 077664FB183E6B5C00133B92 /* JSQuickTimePluginReplacement.h */; };
- 0779BF0D18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0779BF0A18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp */; };
0779BF0E18453168000B6AE7 /* HTMLMediaElementMediaStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0779BF0B18453168000B6AE7 /* HTMLMediaElementMediaStream.h */; };
077AF14018F4AE400001ED61 /* SerializedPlatformRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 077AF13E18F4AE400001ED61 /* SerializedPlatformRepresentation.h */; settings = {ATTRIBUTES = (Private, ); }; };
077AF14318F4B1BB0001ED61 /* SerializedPlatformRepresentationMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 077AF14118F4B1BB0001ED61 /* SerializedPlatformRepresentationMac.h */; };
@@ -7290,7 +7289,6 @@
07707CB11E20649C00005BF7 /* AudioCaptureSourceProviderObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioCaptureSourceProviderObjC.h; sourceTree = "<group>"; };
077664FA183E6B5C00133B92 /* JSQuickTimePluginReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSQuickTimePluginReplacement.cpp; sourceTree = "<group>"; };
077664FB183E6B5C00133B92 /* JSQuickTimePluginReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSQuickTimePluginReplacement.h; sourceTree = "<group>"; };
- 0779BF0A18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaElementMediaStream.cpp; sourceTree = "<group>"; };
0779BF0B18453168000B6AE7 /* HTMLMediaElementMediaStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLMediaElementMediaStream.h; sourceTree = "<group>"; };
0779BF0C18453168000B6AE7 /* HTMLMediaElementMediaStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLMediaElementMediaStream.idl; sourceTree = "<group>"; };
077AF13E18F4AE400001ED61 /* SerializedPlatformRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedPlatformRepresentation.h; sourceTree = "<group>"; };
@@ -15297,7 +15295,6 @@
073794EE19EE364200E5A045 /* DOMURLMediaStream.idl */,
93A806111E03B51C008A1F26 /* DoubleRange.h */,
93A806121E03B51C008A1F26 /* DoubleRange.idl */,
- 0779BF0A18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp */,
0779BF0B18453168000B6AE7 /* HTMLMediaElementMediaStream.h */,
0779BF0C18453168000B6AE7 /* HTMLMediaElementMediaStream.idl */,
93A806131E03B51C008A1F26 /* LongRange.h */,
@@ -30044,7 +30041,6 @@
A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */,
C968B2E81B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp in Sources */,
- 0779BF0D18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp in Sources */,
A8EA79F80A1916DF00A8EF5F /* HTMLMenuElement.cpp in Sources */,
2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */,
A871DC270A15205700B12A68 /* HTMLMetaElement.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (212310 => 212311)
--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm 2017-02-14 19:17:14 UTC (rev 212311)
@@ -2018,10 +2018,6 @@
$self->assertTokenValue($self->getToken(), "(", __LINE__);
push(@{$unionType->subtypes}, $self->parseUnionMemberType());
-
- $self->assertTokenValue($self->getToken(), "or", __LINE__);
-
- push(@{$unionType->subtypes}, $self->parseUnionMemberType());
push(@{$unionType->subtypes}, $self->parseUnionMemberTypes());
$self->assertTokenValue($self->getToken(), ")", __LINE__);
Modified: trunk/Source/WebCore/html/HTMLAudioElement.cpp (212310 => 212311)
--- trunk/Source/WebCore/html/HTMLAudioElement.cpp 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/html/HTMLAudioElement.cpp 2017-02-14 19:17:14 UTC (rev 212311)
@@ -50,10 +50,8 @@
{
Ref<HTMLAudioElement> audio = adoptRef(*new HTMLAudioElement(audioTag, document, false));
audio->setPreload("auto");
- if (!src.isNull()) {
+ if (!src.isNull())
audio->setSrc(src);
- audio->scheduleDelayedAction(HTMLMediaElement::LoadMediaResource);
- }
audio->suspendIfNeeded();
return audio;
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (212310 => 212311)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-02-14 19:17:14 UTC (rev 212311)
@@ -31,6 +31,7 @@
#include "ApplicationCacheHost.h"
#include "ApplicationCacheResource.h"
#include "Attribute.h"
+#include "Blob.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "ChromeClient.h"
@@ -203,7 +204,6 @@
actionBuilder.append(#_actionType); \
} \
- ACTION(LoadMediaResource);
ACTION(ConfigureTextTracks);
ACTION(TextTrackChangesNotification);
ACTION(ConfigureTextTrackDisplay);
@@ -742,18 +742,20 @@
void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == srcAttr) {
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#location-of-the-media-resource
+ // Location of the Media Resource
+ // 12 February 2017
+
+ // If a src attribute of a media element is set or changed, the user
+ // agent must invoke the media element's media element load algorithm.
#if PLATFORM(IOS)
// Note, unless the restriction on requiring user action has been removed,
// do not begin downloading data on iOS.
if (!value.isNull() && m_mediaSession->dataLoadingPermitted(*this))
#else
- // Trigger a reload, as long as the 'src' attribute is present.
if (!value.isNull())
#endif
- {
- clearMediaPlayer(LoadMediaResource);
- scheduleDelayedAction(LoadMediaResource);
- }
+ prepareForLoad();
} else if (name == controlsAttr)
configureMediaControls();
else if (name == loopAttr)
@@ -770,7 +772,7 @@
}
// The attribute must be ignored if the autoplay attribute is present
- if (!autoplay() && m_player)
+ if (!autoplay() && !m_havePreparedToPlay && m_player)
m_player->setPreload(m_mediaSession->effectivePreloadForElement(*this));
} else if (name == mediagroupAttr)
@@ -830,7 +832,7 @@
#else
if (m_networkState == NETWORK_EMPTY && !attributeWithoutSynchronization(srcAttr).isEmpty())
#endif
- scheduleDelayedAction(LoadMediaResource);
+ prepareForLoad();
}
if (!m_explicitlyMuted) {
@@ -930,11 +932,6 @@
{
LOG(Media, "HTMLMediaElement::scheduleDelayedAction(%p) - setting %s flag", this, actionName(actionType).utf8().data());
- if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaResource)) {
- prepareForLoad();
- setFlags(m_pendingActionFlags, LoadMediaResource);
- }
-
#if ENABLE(VIDEO_TRACK)
if (actionType & ConfigureTextTracks)
setFlags(m_pendingActionFlags, ConfigureTextTracks);
@@ -960,9 +957,9 @@
void HTMLMediaElement::scheduleNextSourceChild()
{
// Schedule the timer to try the next <source> element WITHOUT resetting state ala prepareForLoad.
- LOG(Media, "HTMLMediaElement::scheduleNextSourceChild(%p) - setting %s flag", this, actionName(LoadMediaResource).utf8().data());
- setFlags(m_pendingActionFlags, LoadMediaResource);
- m_pendingActionTimer.startOneShot(0);
+ m_resourceSelectionTaskQueue.enqueueTask([this] {
+ loadNextSourceChild();
+ });
}
void HTMLMediaElement::mediaPlayerActiveSourceBuffersChanged(const MediaPlayer*)
@@ -1036,13 +1033,6 @@
configureTextTracks();
#endif
- if (pendingActions & LoadMediaResource) {
- if (m_loadState == LoadingFromSourceElement)
- loadNextSourceChild();
- else
- loadInternal();
- }
-
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
if (pendingActions & CheckPlaybackTargetCompatablity && m_isPlayingToWirelessTarget && !m_player->canPlayToWirelessPlaybackTarget()) {
LOG(Media, "HTMLMediaElement::pendingActionTimerFired(%p) - calling setShouldPlayToPlaybackTarget(false)", this);
@@ -1071,8 +1061,7 @@
setAttributeWithoutSynchronization(srcAttr, url);
}
-#if ENABLE(MEDIA_STREAM)
-void HTMLMediaElement::setSrcObject(ScriptExecutionContext& context, MediaStream* mediaStream)
+void HTMLMediaElement::setSrcObject(MediaProvider&& mediaProvider)
{
// FIXME: Setting the srcObject attribute may cause other changes to the media element's internal state:
// Specifically, if srcObject is specified, the UA must use it as the source of media, even if the src
@@ -1081,14 +1070,14 @@
//
// https://bugs.webkit.org/show_bug.cgi?id=124896
- m_mediaStreamSrcObject = mediaStream;
- if (mediaStream) {
- m_settingMediaStreamSrcObject = true;
- setSrc(DOMURL::createPublicURL(context, *mediaStream));
- m_settingMediaStreamSrcObject = false;
- }
+
+ // https://www.w3.org/TR/html51/semantics-embedded-content.html#dom-htmlmediaelement-srcobject
+ // 4.7.14.2. Location of the media resource
+ // srcObject: On setting, it must set the element’s assigned media provider object to the new
+ // value, and then invoke the element’s media element load algorithm.
+ m_mediaProvider = WTFMove(mediaProvider);
+ prepareForLoad();
}
-#endif
void HTMLMediaElement::setCrossOrigin(const AtomicString& value)
{
@@ -1142,7 +1131,7 @@
void HTMLMediaElement::load()
{
- Ref<HTMLMediaElement> protectedThis(*this); // loadInternal may result in a 'beforeload' event, which can make arbitrary DOM mutations.
+ Ref<HTMLMediaElement> protectedThis(*this); // prepareForLoad may result in a 'beforeload' event, which can make arbitrary DOM mutations.
LOG(Media, "HTMLMediaElement::load(%p)", this);
@@ -1152,19 +1141,25 @@
removeBehaviorsRestrictionsAfterFirstUserGesture();
prepareForLoad();
- loadInternal();
- prepareToPlay();
+ m_resourceSelectionTaskQueue.enqueueTask([this] {
+ prepareToPlay();
+ });
}
void HTMLMediaElement::prepareForLoad()
{
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#media-element-load-algorithm
+ // The Media Element Load Algorithm
+ // 12 February 2017
+
LOG(Media, "HTMLMediaElement::prepareForLoad(%p)", this);
+ // 1 - Abort any already-running instance of the resource selection algorithm for this element.
// Perform the cleanup required for the resource load algorithm to run.
stopPeriodicTimers();
m_pendingActionTimer.stop();
+ m_resourceSelectionTaskQueue.cancelAllTasks();
// FIXME: Figure out appropriate place to reset LoadTextTrackResource if necessary and set m_pendingActionFlags to 0 here.
- m_pendingActionFlags &= ~LoadMediaResource;
m_sentEndEvent = false;
m_sentStalledEvent = false;
m_haveFiredLoadedData = false;
@@ -1177,52 +1172,55 @@
m_failedToPlayToWirelessTarget = false;
#endif
- // 1 - Abort any already-running instance of the resource selection algorithm for this element.
m_loadState = WaitingForSource;
m_currentSourceNode = nullptr;
- // 2 - If there are any tasks from the media element's media element event task source in
- // one of the task queues, then remove those tasks.
+ createMediaPlayer();
+
+ // 2 - Let pending tasks be a list of all tasks from the media element's media element event task source in one of the task queues.
+ // 3 - For each task in pending tasks that would resolve pending play promises or reject pending play promises, immediately resolve or reject those promises in the order the corresponding tasks were queued.
+ // 4 - Remove each task in pending tasks from its task queue
cancelPendingEventsAndCallbacks();
- // 3 - If the media element's networkState is set to NETWORK_LOADING or NETWORK_IDLE, queue
+ // 5 - If the media element's networkState is set to NETWORK_LOADING or NETWORK_IDLE, queue
// a task to fire a simple event named abort at the media element.
if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE)
scheduleEvent(eventNames().abortEvent);
-#if ENABLE(MEDIA_SOURCE)
- detachMediaSource();
-#endif
-
- createMediaPlayer();
-
- // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps
+ // 6 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps
if (m_networkState != NETWORK_EMPTY) {
- // 4.1 - Queue a task to fire a simple event named emptied at the media element.
+ // 6.1 - Queue a task to fire a simple event named emptied at the media element.
scheduleEvent(eventNames().emptiedEvent);
- // 4.2 - If a fetching process is in progress for the media element, the user agent should stop it.
+ // 6.2 - If a fetching process is in progress for the media element, the user agent should stop it.
m_networkState = NETWORK_EMPTY;
- // 4.3 - Forget the media element's media-resource-specific tracks.
+ // 6.3 - If the media element’s assigned media provider object is a MediaSource object, then detach it.
+#if ENABLE(MEDIA_SOURCE)
+ detachMediaSource();
+#endif
+
+ // 6.4 - Forget the media element's media-resource-specific tracks.
forgetResourceSpecificTracks();
- // 4.4 - If readyState is not set to HAVE_NOTHING, then set it to that state.
+ // 6.5 - If readyState is not set to HAVE_NOTHING, then set it to that state.
m_readyState = HAVE_NOTHING;
m_readyStateMaximum = HAVE_NOTHING;
- // 4.5 - If the paused attribute is false, then set it to true.
+ // 6.6 - If the paused attribute is false, then set it to true.
m_paused = true;
- // 4.6 - If seeking is true, set it to false.
+ // 6.7 - If seeking is true, set it to false.
clearSeeking();
- // 4.7 - Set the current playback position to 0.
+ // 6.8 - Set the current playback position to 0.
// Set the official playback position to 0.
// If this changed the official playback position, then queue a task to fire a simple event named timeupdate at the media element.
+ m_lastSeekTime = MediaTime::zeroTime();
+ m_playedTimeRanges = TimeRanges::create();
// FIXME: Add support for firing this event. e.g., scheduleEvent(eventNames().timeUpdateEvent);
- // 4.8 - Set the initial playback position to 0.
+ // 4.9 - Set the initial playback position to 0.
// FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call
// above.
refreshCachedTime();
@@ -1229,8 +1227,8 @@
invalidateCachedTime();
- // 4.9 - Set the timeline offset to Not-a-Number (NaN).
- // 4.10 - Update the duration attribute to Not-a-Number (NaN).
+ // 4.10 - Set the timeline offset to Not-a-Number (NaN).
+ // 4.11 - Update the duration attribute to Not-a-Number (NaN).
updateMediaController();
#if ENABLE(VIDEO_TRACK)
@@ -1238,57 +1236,42 @@
#endif
}
- // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRate attribute.
+ // 7 - Set the playbackRate attribute to the value of the defaultPlaybackRate attribute.
setPlaybackRate(defaultPlaybackRate());
- // 6 - Set the error attribute to null and the autoplaying flag to true.
+ // 8 - Set the error attribute to null and the autoplaying flag to true.
m_error = nullptr;
m_autoplaying = true;
mediaSession().clientWillBeginAutoplaying();
- // 7 - Invoke the media element's resource selection algorithm.
+ // 9 - Invoke the media element's resource selection algorithm.
+ selectMediaResource();
- // 8 - Note: Playback of any previously playing media resource for this element stops.
+ // 10 - Note: Playback of any previously playing media resource for this element stops.
- // The resource selection algorithm
- // 1 - Set the networkState to NETWORK_NO_SOURCE
- m_networkState = NETWORK_NO_SOURCE;
+ configureMediaControls();
+}
- // 2 - Asynchronously await a stable state.
+void HTMLMediaElement::selectMediaResource()
+{
+ // https://www.w3.org/TR/2016/REC-html51-20161101/semantics-embedded-content.html#resource-selection-algorithm
+ // The Resource Selection Algorithm
- m_playedTimeRanges = TimeRanges::create();
+ // 1. Set the element’s networkState attribute to the NETWORK_NO_SOURCE value.
+ m_networkState = NETWORK_NO_SOURCE;
- // FIXME: Investigate whether these can be moved into m_networkState != NETWORK_EMPTY block above
- // so they are closer to the relevant spec steps.
- m_lastSeekTime = MediaTime::zeroTime();
+ // 2. Set the element’s show poster flag to true.
+ setDisplayMode(Poster);
- // The spec doesn't say to block the load event until we actually run the asynchronous section
- // algorithm, but do it now because we won't start that until after the timer fires and the
- // event may have already fired by then.
- MediaPlayer::Preload effectivePreload = m_mediaSession->effectivePreloadForElement(*this);
- if (effectivePreload != MediaPlayer::None)
- setShouldDelayLoadEvent(true);
+ // 3. Set the media element’s delaying-the-load-event flag to true (this delays the load event).
+ setShouldDelayLoadEvent(true);
-#if PLATFORM(IOS)
- if (effectivePreload != MediaPlayer::None && m_mediaSession->allowsAutomaticMediaDataLoading(*this))
- prepareToPlay();
-#endif
+ // 4. in parallel await a stable state, allowing the task that invoked this algorithm to continue.
+ if (m_resourceSelectionTaskQueue.hasPendingTasks())
+ return;
- configureMediaControls();
-}
-
-void HTMLMediaElement::loadInternal()
-{
- LOG(Media, "HTMLMediaElement::loadInternal(%p)", this);
-
- // Some of the code paths below this function dispatch the BeforeLoad event. This ASSERT helps
- // us catch those bugs more quickly without needing all the branches to align to actually
- // trigger the event.
- ASSERT(NoEventDispatchAssertion::isEventAllowedInMainThread());
-
- // If we can't start a load right away, start it later.
if (!m_mediaSession->pageAllowsDataLoading(*this)) {
- LOG(Media, "HTMLMediaElement::loadInternal(%p) - not allowed to load in background, waiting", this);
+ LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - not allowed to load in background, waiting", this);
setShouldDelayLoadEvent(false);
if (m_isWaitingUntilMediaCanStart)
return;
@@ -1297,56 +1280,50 @@
return;
}
- clearFlags(m_pendingActionFlags, LoadMediaResource);
-
- // Once the page has allowed an element to load media, it is free to load at will. This allows a
- // playlist that starts in a foreground tab to continue automatically if the tab is subsequently
+ // Once the page has allowed an element to load media, it is free to load at will. This allows a
+ // playlist that starts in a foreground tab to continue automatically if the tab is subsequently
// put into the background.
m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePageConsentToLoadMedia);
+
+ m_resourceSelectionTaskQueue.enqueueTask([this] {
+ // 5. If the media element’s blocked-on-parser flag is false, then populate the list of pending text tracks.
#if ENABLE(VIDEO_TRACK)
- if (hasMediaControls())
- mediaControls()->changedClosedCaptionsVisibility();
+ if (hasMediaControls())
+ mediaControls()->changedClosedCaptionsVisibility();
- // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the
- // disabled state when the element's resource selection algorithm last started".
- m_textTracksWhenResourceSelectionBegan.clear();
- if (m_textTracks) {
- for (unsigned i = 0; i < m_textTracks->length(); ++i) {
- TextTrack* track = m_textTracks->item(i);
- if (track->mode() != TextTrack::Mode::Disabled)
- m_textTracksWhenResourceSelectionBegan.append(track);
+ // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the
+ // disabled state when the element's resource selection algorithm last started".
+ // FIXME: Update this to match "populate the list of pending text tracks" step.
+ m_textTracksWhenResourceSelectionBegan.clear();
+ if (m_textTracks) {
+ for (unsigned i = 0; i < m_textTracks->length(); ++i) {
+ TextTrack* track = m_textTracks->item(i);
+ if (track->mode() != TextTrack::Mode::Disabled)
+ m_textTracksWhenResourceSelectionBegan.append(track);
+ }
}
- }
#endif
- selectMediaResource();
-}
+ enum Mode { None, Object, Attribute, Children };
+ Mode mode = None;
-void HTMLMediaElement::selectMediaResource()
-{
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this);
-
- ASSERT(m_player);
- if (!m_player)
- return;
-
- enum Mode { attribute, children };
-
- // 3 - If the media element has a src attribute, then let mode be attribute.
- Mode mode = attribute;
- if (!hasAttributeWithoutSynchronization(srcAttr)) {
- // Otherwise, if the media element does not have a src attribute but has a source
- // element child, then let mode be children and let candidate be the first such
- // source element child in tree order.
- if (auto firstSource = childrenOfType<HTMLSourceElement>(*this).first()) {
- mode = children;
+ if (m_mediaProvider) {
+ // 6. If the media element has an assigned media provider object, then let mode be object.
+ mode = Object;
+ } else if (hasAttributeWithoutSynchronization(srcAttr)) {
+ // Otherwise, if the media element has no assigned media provider object but has a src attribute, then let mode be attribute.
+ mode = Attribute;
+ } else if (auto firstSource = childrenOfType<HTMLSourceElement>(*this).first()) {
+ // Otherwise, if the media element does not have an assigned media provider object and does not have a src attribute,
+ // but does have a source element child, then let mode be children and let candidate be the first such source element
+ // child in tree order.
+ mode = Children;
m_nextChildNodeToConsider = firstSource;
m_currentSourceNode = nullptr;
} else {
- // Otherwise the media element has neither a src attribute nor a source element
- // child: set the networkState to NETWORK_EMPTY, and abort these steps; the
- // synchronous section ends.
+ // Otherwise the media element has no assigned media provider object and has neither a src attribute nor a source
+ // element child: set the networkState to NETWORK_EMPTY, and abort these steps; the synchronous section ends.
m_loadState = WaitingForSource;
setShouldDelayLoadEvent(false);
m_networkState = NETWORK_EMPTY;
@@ -1354,49 +1331,95 @@
LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - nothing to load", this);
return;
}
- }
- // 4 - Set the media element's delaying-the-load-event flag to true (this delays the load event),
- // and set its networkState to NETWORK_LOADING.
- setShouldDelayLoadEvent(true);
- m_networkState = NETWORK_LOADING;
+ // 7. Set the media element’s networkState to NETWORK_LOADING.
+ m_networkState = NETWORK_LOADING;
- // 5 - Queue a task to fire a simple event named loadstart at the media element.
- scheduleEvent(eventNames().loadstartEvent);
+ // 8. Queue a task to fire a simple event named loadstart at the media element.
+ scheduleEvent(eventNames().loadstartEvent);
- // 6 - If mode is attribute, then run these substeps
- if (mode == attribute) {
- m_loadState = LoadingFromSrcAttr;
+ // 9. Run the appropriate steps from the following list:
+ // ↳ If mode is object
+ if (mode == Object) {
+ // 1. Set the currentSrc attribute to the empty string.
+ m_currentSrc = URL();
- // If the src attribute's value is the empty string ... jump down to the failed step below
- URL mediaURL = getNonEmptyURLAttribute(srcAttr);
- if (mediaURL.isEmpty()) {
- mediaLoadingFailed(MediaPlayer::FormatError);
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - empty 'src'", this);
+ // 2. End the synchronous section, continuing the remaining steps in parallel.
+ // 3. Run the resource fetch algorithm with the assigned media provider object.
+ WTF::visit(WTF::makeVisitor(
+#if ENABLE(MEDIA_STREAM)
+ [this](RefPtr<MediaStream> stream) { m_mediaStreamSrcObject = stream; },
+#endif
+#if ENABLE(MEDIA_SOURCE)
+ [this](RefPtr<MediaSource> source) { m_mediaSource = source; },
+#endif
+ [this](RefPtr<Blob> blob) { m_blob = blob; }
+ ), m_mediaProvider.value());
+
+ ContentType contentType;
+ loadResource(URL(), contentType, String());
+ LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - using 'srcObject' property", this);
+
+ // If that algorithm returns without aborting this one, then the load failed.
+ // 4. Failed with media provider: Reaching this step indicates that the media resource
+ // failed to load. Queue a task to run the dedicated media source failure steps.
+ // 5. Wait for the task queued by the previous step to have executed.
+ // 6. Abort these steps. The element won’t attempt to load another resource until this
+ // algorithm is triggered again.
return;
}
- if (!isSafeToLoadURL(mediaURL, Complain) || !dispatchBeforeLoadEvent(mediaURL.string())) {
- mediaLoadingFailed(MediaPlayer::FormatError);
+ // ↳ If mode is attribute
+ if (mode == Attribute) {
+ m_loadState = LoadingFromSrcAttr;
+
+ // 1. If the src attribute’s value is the empty string, then end the synchronous section,
+ // and jump down to the failed with attribute step below.
+ // 2. Let absolute URL be the absolute URL that would have resulted from parsing the URL
+ // specified by the src attribute’s value relative to the media element when the src
+ // attribute was last changed.
+ URL absoluteURL = getNonEmptyURLAttribute(srcAttr);
+ if (absoluteURL.isEmpty()) {
+ mediaLoadingFailed(MediaPlayer::FormatError);
+ LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - empty 'src'", this);
+ return;
+ }
+
+ if (!isSafeToLoadURL(absoluteURL, Complain) || !dispatchBeforeLoadEvent(absoluteURL.string())) {
+ mediaLoadingFailed(MediaPlayer::FormatError);
+ return;
+ }
+
+ // 3. If absolute URL was obtained successfully, set the currentSrc attribute to absolute URL.
+ m_currentSrc = absoluteURL;
+
+ // 4. End the synchronous section, continuing the remaining steps in parallel.
+ // 5. If absolute URL was obtained successfully, run the resource fetch algorithm with absolute
+ // URL. If that algorithm returns without aborting this one, then the load failed.
+
+ // No type or key system information is available when the url comes
+ // from the 'src' attribute so MediaPlayer
+ // will have to pick a media engine based on the file extension.
+ ContentType contentType;
+ loadResource(absoluteURL, contentType, String());
+ LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - using 'src' attribute url", this);
+
+ // 6. Failed with attribute: Reaching this step indicates that the media resource failed to load
+ // or that the given URL could not be resolved. Queue a task to run the dedicated media source failure steps.
+ // 7. Wait for the task queued by the previous step to have executed.
+ // 8. Abort these steps. The element won’t attempt to load another resource until this algorithm is triggered again.
return;
}
- // No type or key system information is available when the url comes
- // from the 'src' attribute so MediaPlayer
- // will have to pick a media engine based on the file extension.
- ContentType contentType((String()));
- loadResource(mediaURL, contentType, String());
- LOG(Media, "HTMLMediaElement::selectMediaResource(%p) - using 'src' attribute url", this);
- return;
- }
-
- // Otherwise, the source elements will be used
- loadNextSourceChild();
+ // ↳ Otherwise (mode is children)
+ // (Ctd. in loadNextSourceChild())
+ loadNextSourceChild();
+ });
}
void HTMLMediaElement::loadNextSourceChild()
{
- ContentType contentType((String()));
+ ContentType contentType;
String keySystem;
URL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain);
if (!mediaURL.isValid()) {
@@ -1413,7 +1436,7 @@
void HTMLMediaElement::loadResource(const URL& initialURL, ContentType& contentType, const String& keySystem)
{
- ASSERT(isSafeToLoadURL(initialURL, Complain));
+ ASSERT(initialURL.isEmpty() || isSafeToLoadURL(initialURL, Complain));
LOG(Media, "HTMLMediaElement::loadResource(%p) - %s, %s, %s", this, urlForLoggingMedia(initialURL).utf8().data(), contentType.raw().utf8().data(), keySystem.utf8().data());
@@ -1430,7 +1453,7 @@
}
URL url = ""
- if (!frame->loader().willLoadMediaElementURL(url)) {
+ if (!url.isEmpty() && !frame->loader().willLoadMediaElementURL(url)) {
mediaLoadingFailed(MediaPlayer::FormatError);
return;
}
@@ -1449,7 +1472,7 @@
// If the URL should be loaded from the application cache, pass the URL of the cached file to the media engine.
ApplicationCacheResource* resource = nullptr;
- if (frame->loader().documentLoader()->applicationCacheHost().shouldLoadResourceFromApplicationCache(ResourceRequest(url), resource)) {
+ if (!url.isEmpty() && frame->loader().documentLoader()->applicationCacheHost().shouldLoadResourceFromApplicationCache(ResourceRequest(url), resource)) {
// Resources that are not present in the manifest will always fail to load (at least, after the
// cache has been primed the first time), making the testing of offline applications simpler.
if (!resource || resource->path().isEmpty()) {
@@ -1483,7 +1506,7 @@
// Reset display mode to force a recalculation of what to show because we are resetting the player.
setDisplayMode(Unknown);
- if (!autoplay())
+ if (!autoplay() && !m_havePreparedToPlay)
m_player->setPreload(m_mediaSession->effectivePreloadForElement(*this));
m_player->setPreservesPitch(m_webkitPreservesPitch);
@@ -1497,21 +1520,17 @@
bool loadAttempted = false;
#if ENABLE(MEDIA_SOURCE)
- ASSERT(!m_mediaSource);
-
- if (url.protocolIs(mediaSourceBlobProtocol))
+ if (!m_mediaSource && url.protocolIs(mediaSourceBlobProtocol))
m_mediaSource = MediaSource::lookup(url.string());
if (m_mediaSource) {
- if (m_mediaSource->attachToElement(*this))
- m_player->load(url, contentType, m_mediaSource.get());
- else {
+ loadAttempted = true;
+ if (!m_mediaSource->attachToElement(*this) || !m_player->load(url, contentType, m_mediaSource.get())) {
// Forget our reference to the MediaSource, so we leave it alone
// while processing remainder of load failure.
m_mediaSource = nullptr;
mediaLoadingFailed(MediaPlayer::FormatError);
}
- loadAttempted = true;
}
#endif
@@ -1528,6 +1547,12 @@
}
#endif
+ if (!loadAttempted && m_blob) {
+ loadAttempted = true;
+ if (!m_player->load(m_blob->url(), contentType, keySystem))
+ mediaLoadingFailed(MediaPlayer::FormatError);
+ }
+
if (!loadAttempted && !m_player->load(url, contentType, keySystem))
mediaLoadingFailed(MediaPlayer::FormatError);
@@ -3121,7 +3146,7 @@
// 4.8.10.9. Playing the media resource
if (!m_player || m_networkState == NETWORK_EMPTY)
- scheduleDelayedAction(LoadMediaResource);
+ prepareForLoad();
if (endedPlayback())
seekInternal(MediaTime::zeroTime());
@@ -3209,7 +3234,7 @@
// don't trigger loading if a script calls pause().
if (!m_mediaSession->playbackPermitted(*this))
return;
- scheduleDelayedAction(LoadMediaResource);
+ prepareForLoad();
}
m_autoplaying = false;
@@ -4255,8 +4280,8 @@
// attribute and whose networkState has the value NETWORK_EMPTY, the user agent must invoke
// the media element's resource selection algorithm.
if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
- scheduleDelayedAction(LoadMediaResource);
m_nextChildNodeToConsider = source;
+ selectMediaResource();
return;
}
@@ -5041,6 +5066,8 @@
detachMediaSource();
#endif
+ m_blob = nullptr;
+
#if ENABLE(VIDEO_TRACK)
forgetResourceSpecificTracks();
#endif
@@ -5203,7 +5230,7 @@
// MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards).
// This behavior is not specified but it seems like a sensible thing to do.
// As it is not safe to immedately start loading now, let's schedule a load.
- scheduleDelayedAction(LoadMediaResource);
+ prepareForLoad();
}
updateRenderer();
@@ -5728,7 +5755,7 @@
ASSERT(m_isWaitingUntilMediaCanStart || m_pausedInternal);
if (m_isWaitingUntilMediaCanStart) {
m_isWaitingUntilMediaCanStart = false;
- loadInternal();
+ selectMediaResource();
}
if (m_pausedInternal)
setPausedInternal(false);
@@ -6002,8 +6029,7 @@
#endif
#if ENABLE(MEDIA_SOURCE)
- if (m_mediaSource)
- m_mediaSource->detachFromElement(*this);
+ detachMediaSource();
#endif
#if ENABLE(VIDEO_TRACK)
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (212310 => 212311)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2017-02-14 19:17:14 UTC (rev 212311)
@@ -57,6 +57,7 @@
class AudioSourceProvider;
class AudioTrackList;
class AudioTrackPrivate;
+class Blob;
class DOMError;
class DeferredPromise;
class DisplaySleepDisabler;
@@ -92,6 +93,15 @@
using CueList = Vector<CueInterval>;
#endif
+using MediaProvider = std::optional<Variant<
+#if ENABLE(MEDIA_STREAM)
+ RefPtr<MediaStream>,
+#endif
+#if ENABLE(MEDIA_SOURCE)
+ RefPtr<MediaSource>,
+#endif
+ RefPtr<Blob>>>;
+
class HTMLMediaElement
: public HTMLElement
, public ActiveDOMObject
@@ -164,10 +174,8 @@
void setSrc(const String&);
const URL& currentSrc() const { return m_currentSrc; }
-#if ENABLE(MEDIA_STREAM)
- MediaStream* srcObject() const { return m_mediaStreamSrcObject.get(); }
- void setSrcObject(ScriptExecutionContext&, MediaStream*);
-#endif
+ const MediaProvider& srcObject() const { return m_mediaProvider; }
+ void setSrcObject(MediaProvider&&);
WEBCORE_EXPORT void setCrossOrigin(const AtomicString&);
WEBCORE_EXPORT String crossOrigin() const;
@@ -698,7 +706,6 @@
#endif
// These "internal" functions do not check user gesture restrictions.
- void loadInternal();
bool playInternal();
void pauseInternal();
@@ -828,6 +835,7 @@
GenericTaskQueue<Timer> m_pauseAfterDetachedTaskQueue;
GenericTaskQueue<Timer> m_updatePlaybackControlsManagerQueue;
GenericTaskQueue<Timer> m_playbackControlsManagerBehaviorRestrictionsQueue;
+ GenericTaskQueue<Timer> m_resourceSelectionTaskQueue;
RefPtr<TimeRanges> m_playedTimeRanges;
GenericEventQueue m_asyncEventQueue;
@@ -1012,6 +1020,9 @@
friend class TrackDisplayUpdateScope;
+ RefPtr<Blob> m_blob;
+ MediaProvider m_mediaProvider;
+
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
RefPtr<WebKitMediaKeys> m_webKitMediaKeys;
#endif
Modified: trunk/Source/WebCore/html/HTMLMediaElement.idl (212310 => 212311)
--- trunk/Source/WebCore/html/HTMLMediaElement.idl 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/html/HTMLMediaElement.idl 2017-02-14 19:17:14 UTC (rev 212311)
@@ -23,6 +23,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+typedef (
+#if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM
+ MediaStream or
+#endif
+#if defined(ENABLE_MEDIA_SOURCE) && ENABLE_MEDIA_SOURCE
+ MediaSource or
+#endif
+ Blob) MediaProvider;
+
[
ActiveDOMObject,
Conditional=VIDEO,
@@ -35,6 +45,7 @@
// network state
[Reflect, URL] attribute USVString src;
+ attribute MediaProvider? srcObject;
[URL] readonly attribute USVString currentSrc;
attribute DOMString? crossOrigin;
Modified: trunk/Source/WebCore/platform/ContentType.h (212310 => 212311)
--- trunk/Source/WebCore/platform/ContentType.h 2017-02-14 19:13:04 UTC (rev 212310)
+++ trunk/Source/WebCore/platform/ContentType.h 2017-02-14 19:17:14 UTC (rev 212311)
@@ -34,6 +34,7 @@
class ContentType {
public:
explicit ContentType(const String& type);
+ ContentType() = default;
String parameter(const String& parameterName) const;
String type() const;