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 614c6ce029563ab390b6395af1f1e283eed2f81d..8177a4dee6d3f426a581de3a4dfe387a724fd673 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
@@ -314,7 +314,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum |
, m_deferredLoadState(NotDeferred) |
, m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
, m_webLayer(nullptr) |
- , m_displayMode(Unknown) |
, m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
, m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
, m_pendingActionFlags(0) |
@@ -737,7 +736,6 @@ void HTMLMediaElement::prepareForLoad() |
m_haveFiredLoadedData = false; |
m_completelyLoaded = false; |
m_havePreparedToPlay = false; |
- m_displayMode = Unknown; |
// 1 - Abort any already-running instance of the resource selection algorithm for this element. |
m_loadState = WaitingForSource; |
@@ -804,10 +802,11 @@ void HTMLMediaElement::prepareForLoad() |
// 8 - Note: Playback of any previously playing media resource for this element stops. |
// The resource selection algorithm |
- // 1 - Set the networkState to NETWORK_NO_SOURCE |
+ // 1 - Set the element's networkState attribute to the NETWORK_NO_SOURCE value. |
m_networkState = NETWORK_NO_SOURCE; |
- // 2 - Asynchronously await a stable state. |
+ // 2 - Set the element's show poster flag to true. |
+ setShowPoster(true); |
m_playedTimeRanges = TimeRanges::create(); |
@@ -816,12 +815,12 @@ void HTMLMediaElement::prepareForLoad() |
m_lastSeekTime = 0; |
m_duration = std::numeric_limits<double>::quiet_NaN(); |
- // 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. |
+ // 3 - Set the media element's delaying-the-load-event flag to true (this delays the load event). |
setShouldDelayLoadEvent(true); |
if (mediaControls()) |
mediaControls()->reset(); |
+ |
+ // 4 - Await a stable state, allowing the task that invoked this algorithm to continue. |
} |
void HTMLMediaElement::loadInternal() |
@@ -863,7 +862,6 @@ void HTMLMediaElement::selectMediaResource() |
m_loadState = WaitingForSource; |
setShouldDelayLoadEvent(false); |
m_networkState = NETWORK_EMPTY; |
- updateDisplayState(); |
WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing to load", this); |
return; |
@@ -954,9 +952,6 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c |
startProgressEventTimer(); |
- // Reset display mode to force a recalculation of what to show because we are resetting the player. |
- setDisplayMode(Unknown); |
- |
setPlayerPreload(); |
if (fastHasAttribute(mutedAttr)) |
@@ -997,10 +992,6 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c |
mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
} |
- // If there is no poster to display, allow the media engine to render video frames as soon as |
- // they are available. |
- updateDisplayState(); |
- |
if (layoutObject()) |
layoutObject()->updateFromElement(); |
} |
@@ -1248,10 +1239,11 @@ void HTMLMediaElement::waitForSourceChange() |
// 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_NO_SOURCE value |
m_networkState = NETWORK_NO_SOURCE; |
- // 6.18 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event. |
- setShouldDelayLoadEvent(false); |
+ // 6.18 - Set the element's show poster flag to true |
+ setShowPoster(true); |
- updateDisplayState(); |
+ // 6.19 - Queue a task to set the element's delaying-the-load-event flag to false. This stops delaying the load event. |
+ setShouldDelayLoadEvent(false); |
if (layoutObject()) |
layoutObject()->updateFromElement(); |
@@ -1265,32 +1257,35 @@ void HTMLMediaElement::noneSupported() |
m_loadState = WaitingForSource; |
m_currentSourceNode = nullptr; |
- // 4.8.10.5 |
+ // 4.8.13.5 |
// 6 - Reaching this step indicates that the media resource failed to load or that the given |
- // URL could not be resolved. In one atomic operation, run the following steps: |
+ // URL could not be resolved. Queue a task to run the dedicated media source failure steps. |
// 6.1 - Set the error attribute to a new MediaError object whose code attribute is set to |
// MEDIA_ERR_SRC_NOT_SUPPORTED. |
m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); |
- // 6.2 - Forget the media element's media-resource-specific text tracks. |
+ // 6.2 - Forget the media element's media-resource-specific tracks. |
forgetResourceSpecificTracks(); |
// 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE value. |
m_networkState = NETWORK_NO_SOURCE; |
- // 7 - Queue a task to fire a simple event named error at the media element. |
+ // 6.4 - Set the element's show poster flag to true. |
+ setShowPoster(true); |
+ |
+ // 6.5 - Fire a simple event named error at the media element. |
scheduleEvent(EventTypeNames::error); |
closeMediaSource(); |
- // 8 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event. |
+ // 6.6 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event. |
setShouldDelayLoadEvent(false); |
- // 9 - Abort these steps. Until the load() method is invoked or the src attribute is changed, |
- // the element won't attempt to load another resource. |
+ // 7 - Wait for the task queued by the previous step to have executed. |
- updateDisplayState(); |
+ // 8 - Abort these steps. The element won't attempt to load |
+ // another resource until this algorithm is triggered again. |
if (layoutObject()) |
layoutObject()->updateFromElement(); |
@@ -1376,7 +1371,6 @@ void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
&& m_loadState == LoadingFromSrcAttr) |
noneSupported(); |
- updateDisplayState(); |
if (mediaControls()) |
mediaControls()->reset(); |
} |
@@ -1568,6 +1562,7 @@ void HTMLMediaElement::setReadyState(ReadyState state) |
if (!m_userGestureRequiredForPlay) { |
m_paused = false; |
+ setShowPoster(false); |
invalidateCachedTime(); |
scheduleEvent(EventTypeNames::play); |
scheduleEvent(EventTypeNames::playing); |
@@ -1580,7 +1575,6 @@ void HTMLMediaElement::setReadyState(ReadyState state) |
} |
if (shouldUpdateDisplayState) { |
- updateDisplayState(); |
if (mediaControls()) |
mediaControls()->refreshClosedCaptionsButtonVisibility(); |
} |
@@ -1639,6 +1633,8 @@ void HTMLMediaElement::seek(double time) |
{ |
WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); |
+ // 1 - Set the media element's show poster flag to false. |
+ setShowPoster(false); |
// 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
if (m_readyState == HAVE_NOTHING) |
return; |
@@ -1721,8 +1717,6 @@ void HTMLMediaElement::finishSeek() |
// 17 - Queue a task to fire a simple event named seeked at the element. |
scheduleEvent(EventTypeNames::seeked); |
- |
- setDisplayMode(Video); |
} |
HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const |
@@ -2010,6 +2004,7 @@ void HTMLMediaElement::playInternal() |
if (m_paused) { |
m_paused = false; |
+ setShowPoster(false); |
invalidateCachedTime(); |
scheduleEvent(EventTypeNames::play); |
@@ -2875,7 +2870,6 @@ void HTMLMediaElement::repaint() |
if (m_webLayer) |
m_webLayer->invalidate(); |
- updateDisplayState(); |
if (layoutObject()) |
layoutObject()->setShouldDoFullPaintInvalidation(); |
} |
@@ -2988,7 +2982,6 @@ void HTMLMediaElement::updatePlayState() |
this, boolString(shouldBePlaying), boolString(isPlaying)); |
if (shouldBePlaying) { |
- setDisplayMode(Video); |
invalidateCachedTime(); |
if (!isPlaying) { |
@@ -3053,12 +3046,13 @@ void HTMLMediaElement::userCancelledLoad() |
// 3 - Queue a task to fire a simple event named error at the media element. |
scheduleEvent(EventTypeNames::abort); |
- // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the |
- // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a |
- // simple event named emptied at the element. Otherwise, set the element's networkState |
- // attribute to the NETWORK_IDLE value. |
+ // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, |
+ // set the element's networkState attribute to the NETWORK_EMPTY value set the element's |
+ // show poster flag to true, and fire a simple event named emptied at the element. |
+ // Otherwise, set the element's networkState attribute to the NETWORK_IDLE value. |
if (m_readyState == HAVE_NOTHING) { |
m_networkState = NETWORK_EMPTY; |
+ setShowPoster(true); |
scheduleEvent(EventTypeNames::emptied); |
} else { |
m_networkState = NETWORK_IDLE; |