Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2199363002: Change play promises behaviour in the load algorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/media/media-play-promise.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index fcfb561150902d835e4b600fffe49f38e00c5a4f..21d7e5b5d0d2e4857aff6e5c947ebedf36a12b43 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -765,8 +765,6 @@ void HTMLMediaElement::invokeLoadAlgorithm()
// one of the task queues, then remove those tasks.
cancelPendingEventsAndCallbacks();
- rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request.");
-
// 3 - 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)
@@ -779,33 +777,36 @@ void HTMLMediaElement::invokeLoadAlgorithm()
// 4.1 - Queue a task to fire a simple event named emptied at the media element.
scheduleEvent(EventTypeNames::emptied);
- // 4.2 - If a fetching process is in progress for the media element, the user agent should stop it.
+ // 4.2 - Take pending play promises and reject pending play promises with the result and an "AbortError" DOMException.
+ rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request.");
+
+ // 4.3 - If a fetching process is in progress for the media element, the user agent should stop it.
setNetworkState(NETWORK_EMPTY);
- // 4.3 - Forget the media element's media-resource-specific tracks.
+ // 4.5 - 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.
+ // 4.6 - 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.
+ // 4.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.
+ // 4.7 - If seeking is true, set it to false.
m_seeking = false;
- // 4.7 - Set the current playback position to 0.
+ // 4.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.
// FIXME: Add support for firing this event.
- // 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 the ready state is HAVE_NOTHING.
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).
cueTimeline().updateActiveCues(0);
} else if (!m_paused) {
@@ -1401,10 +1402,15 @@ void HTMLMediaElement::cancelPendingEventsAndCallbacks()
for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*this); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
source->cancelPendingErrorEvent();
- m_playPromiseResolveTask->cancel();
- m_playPromiseResolveList.clear();
- m_playPromiseRejectTask->cancel();
- m_playPromiseRejectList.clear();
+ if (m_playPromiseResolveTask->isPending()) {
foolip 2016/08/03 14:32:56 Can you update the documentation of HTMLMediaEleme
mlamouri (slow - plz ping) 2016/08/03 15:57:56 Done.
+ m_playPromiseResolveTask->cancel();
+ resolveScheduledPlayPromises();
+ }
+
+ if (m_playPromiseRejectTask->isPending()) {
+ m_playPromiseRejectTask->cancel();
+ rejectScheduledPlayPromises();
+ }
}
void HTMLMediaElement::networkStateChanged()
« no previous file with comments | « third_party/WebKit/LayoutTests/media/media-play-promise.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698