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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 1377353002: Update poster code as per https://html.spec.whatwg.org/#show-poster-flag Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 , m_lastSeekTime(0) 307 , m_lastSeekTime(0)
308 , m_previousProgressTime(std::numeric_limits<double>::max()) 308 , m_previousProgressTime(std::numeric_limits<double>::max())
309 , m_duration(std::numeric_limits<double>::quiet_NaN()) 309 , m_duration(std::numeric_limits<double>::quiet_NaN())
310 , m_lastTimeUpdateEventWallTime(0) 310 , m_lastTimeUpdateEventWallTime(0)
311 , m_lastTimeUpdateEventMovieTime(0) 311 , m_lastTimeUpdateEventMovieTime(0)
312 , m_defaultPlaybackStartPosition(0) 312 , m_defaultPlaybackStartPosition(0)
313 , m_loadState(WaitingForSource) 313 , m_loadState(WaitingForSource)
314 , m_deferredLoadState(NotDeferred) 314 , m_deferredLoadState(NotDeferred)
315 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 315 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
316 , m_webLayer(nullptr) 316 , m_webLayer(nullptr)
317 , m_displayMode(Unknown)
318 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) 317 , m_cachedTime(std::numeric_limits<double>::quiet_NaN())
319 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) 318 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN())
320 , m_pendingActionFlags(0) 319 , m_pendingActionFlags(0)
321 , m_userGestureRequiredForPlay(false) 320 , m_userGestureRequiredForPlay(false)
322 , m_playing(false) 321 , m_playing(false)
323 , m_shouldDelayLoadEvent(false) 322 , m_shouldDelayLoadEvent(false)
324 , m_haveFiredLoadedData(false) 323 , m_haveFiredLoadedData(false)
325 , m_autoplaying(true) 324 , m_autoplaying(true)
326 , m_muted(false) 325 , m_muted(false)
327 , m_paused(true) 326 , m_paused(true)
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 stopPeriodicTimers(); 729 stopPeriodicTimers();
731 m_loadTimer.stop(); 730 m_loadTimer.stop();
732 cancelDeferredLoad(); 731 cancelDeferredLoad();
733 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. 732 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here.
734 m_pendingActionFlags &= ~LoadMediaResource; 733 m_pendingActionFlags &= ~LoadMediaResource;
735 m_sentEndEvent = false; 734 m_sentEndEvent = false;
736 m_sentStalledEvent = false; 735 m_sentStalledEvent = false;
737 m_haveFiredLoadedData = false; 736 m_haveFiredLoadedData = false;
738 m_completelyLoaded = false; 737 m_completelyLoaded = false;
739 m_havePreparedToPlay = false; 738 m_havePreparedToPlay = false;
740 m_displayMode = Unknown; 739 setShowPoster(true);
741 740
742 // 1 - Abort any already-running instance of the resource selection algorith m for this element. 741 // 1 - Abort any already-running instance of the resource selection algorith m for this element.
743 m_loadState = WaitingForSource; 742 m_loadState = WaitingForSource;
744 m_currentSourceNode = nullptr; 743 m_currentSourceNode = nullptr;
745 744
746 // 2 - If there are any tasks from the media element's media element event t ask source in 745 // 2 - If there are any tasks from the media element's media element event t ask source in
747 // one of the task queues, then remove those tasks. 746 // one of the task queues, then remove those tasks.
748 cancelPendingEventsAndCallbacks(); 747 cancelPendingEventsAndCallbacks();
749 748
750 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue 749 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 mode = children; 855 mode = children;
857 m_nextChildNodeToConsider = element; 856 m_nextChildNodeToConsider = element;
858 m_currentSourceNode = nullptr; 857 m_currentSourceNode = nullptr;
859 } else { 858 } else {
860 // Otherwise the media element has neither a src attribute nor a sou rce element 859 // Otherwise the media element has neither a src attribute nor a sou rce element
861 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the 860 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the
862 // synchronous section ends. 861 // synchronous section ends.
863 m_loadState = WaitingForSource; 862 m_loadState = WaitingForSource;
864 setShouldDelayLoadEvent(false); 863 setShouldDelayLoadEvent(false);
865 m_networkState = NETWORK_EMPTY; 864 m_networkState = NETWORK_EMPTY;
866 updateDisplayState(); 865 updateDisplayState(false);
867 866
868 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t o load", this); 867 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t o load", this);
869 return; 868 return;
870 } 869 }
871 } 870 }
872 871
873 // 4 - Set the media element's delaying-the-load-event flag to true (this de lays the load event), 872 // 4 - Set the media element's delaying-the-load-event flag to true (this de lays the load event),
874 // and set its networkState to NETWORK_LOADING. 873 // and set its networkState to NETWORK_LOADING.
875 setShouldDelayLoadEvent(true); 874 setShouldDelayLoadEvent(true);
876 m_networkState = NETWORK_LOADING; 875 m_networkState = NETWORK_LOADING;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 946
948 #if ENABLE(WEB_AUDIO) 947 #if ENABLE(WEB_AUDIO)
949 if (m_audioSourceNode) 948 if (m_audioSourceNode)
950 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); 949 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc);
951 #endif 950 #endif
952 951
953 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th is, urlForLoggingMedia(m_currentSrc).utf8().data()); 952 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th is, urlForLoggingMedia(m_currentSrc).utf8().data());
954 953
955 startProgressEventTimer(); 954 startProgressEventTimer();
956 955
957 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. 956 setShowPoster(true);
958 setDisplayMode(Unknown);
959 957
960 setPlayerPreload(); 958 setPlayerPreload();
961 959
962 if (fastHasAttribute(mutedAttr)) 960 if (fastHasAttribute(mutedAttr))
963 m_muted = true; 961 m_muted = true;
964 updateVolume(); 962 updateVolume();
965 963
966 ASSERT(!m_mediaSource); 964 ASSERT(!m_mediaSource);
967 965
968 bool attemptLoad = true; 966 bool attemptLoad = true;
(...skipping 23 matching lines...) Expand all
992 deferLoad(); 990 deferLoad();
993 } else { 991 } else {
994 startPlayerLoad(); 992 startPlayerLoad();
995 } 993 }
996 } else { 994 } else {
997 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 995 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
998 } 996 }
999 997
1000 // If there is no poster to display, allow the media engine to render video frames as soon as 998 // If there is no poster to display, allow the media engine to render video frames as soon as
1001 // they are available. 999 // they are available.
1002 updateDisplayState(); 1000 updateDisplayState(false);
1003 1001
1004 if (layoutObject()) 1002 if (layoutObject())
1005 layoutObject()->updateFromElement(); 1003 layoutObject()->updateFromElement();
1006 } 1004 }
1007 1005
1008 void HTMLMediaElement::startPlayerLoad() 1006 void HTMLMediaElement::startPlayerLoad()
1009 { 1007 {
1010 ASSERT(!m_webMediaPlayer); 1008 ASSERT(!m_webMediaPlayer);
1011 // Filter out user:pass as those two URL components aren't 1009 // Filter out user:pass as those two URL components aren't
1012 // considered for media resource fetches (including for the CORS 1010 // considered for media resource fetches (including for the CORS
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1242
1245 stopPeriodicTimers(); 1243 stopPeriodicTimers();
1246 m_loadState = WaitingForSource; 1244 m_loadState = WaitingForSource;
1247 1245
1248 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value 1246 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N O_SOURCE value
1249 m_networkState = NETWORK_NO_SOURCE; 1247 m_networkState = NETWORK_NO_SOURCE;
1250 1248
1251 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event. 1249 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop s delaying the load event.
1252 setShouldDelayLoadEvent(false); 1250 setShouldDelayLoadEvent(false);
1253 1251
1254 updateDisplayState(); 1252 updateDisplayState(false);
1255 1253
1256 if (layoutObject()) 1254 if (layoutObject())
1257 layoutObject()->updateFromElement(); 1255 layoutObject()->updateFromElement();
1258 } 1256 }
1259 1257
1260 void HTMLMediaElement::noneSupported() 1258 void HTMLMediaElement::noneSupported()
1261 { 1259 {
1262 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); 1260 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this);
1263 1261
1264 stopPeriodicTimers(); 1262 stopPeriodicTimers();
(...skipping 18 matching lines...) Expand all
1283 scheduleEvent(EventTypeNames::error); 1281 scheduleEvent(EventTypeNames::error);
1284 1282
1285 closeMediaSource(); 1283 closeMediaSource();
1286 1284
1287 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 1285 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
1288 setShouldDelayLoadEvent(false); 1286 setShouldDelayLoadEvent(false);
1289 1287
1290 // 9 - Abort these steps. Until the load() method is invoked or the src attr ibute is changed, 1288 // 9 - Abort these steps. Until the load() method is invoked or the src attr ibute is changed,
1291 // the element won't attempt to load another resource. 1289 // the element won't attempt to load another resource.
1292 1290
1293 updateDisplayState(); 1291 updateDisplayState(false);
1294 1292
1295 if (layoutObject()) 1293 if (layoutObject())
1296 layoutObject()->updateFromElement(); 1294 layoutObject()->updateFromElement();
1297 } 1295 }
1298 1296
1299 void HTMLMediaElement::mediaEngineError(MediaError* err) 1297 void HTMLMediaElement::mediaEngineError(MediaError* err)
1300 { 1298 {
1301 ASSERT(m_readyState >= HAVE_METADATA); 1299 ASSERT(m_readyState >= HAVE_METADATA);
1302 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code())); 1300 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code()));
1303 1301
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1367
1370 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) 1368 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA)
1371 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); 1369 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK));
1372 else if (error == WebMediaPlayer::NetworkStateDecodeError) 1370 else if (error == WebMediaPlayer::NetworkStateDecodeError)
1373 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); 1371 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE));
1374 else if ((error == WebMediaPlayer::NetworkStateFormatError 1372 else if ((error == WebMediaPlayer::NetworkStateFormatError
1375 || error == WebMediaPlayer::NetworkStateNetworkError) 1373 || error == WebMediaPlayer::NetworkStateNetworkError)
1376 && m_loadState == LoadingFromSrcAttr) 1374 && m_loadState == LoadingFromSrcAttr)
1377 noneSupported(); 1375 noneSupported();
1378 1376
1379 updateDisplayState(); 1377 updateDisplayState(false);
1380 if (mediaControls()) 1378 if (mediaControls())
1381 mediaControls()->reset(); 1379 mediaControls()->reset();
1382 } 1380 }
1383 1381
1384 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) 1382 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state)
1385 { 1383 {
1386 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is %d", this, static_cast<int>(state), static_cast<int>(m_networkState)); 1384 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is %d", this, static_cast<int>(state), static_cast<int>(m_networkState));
1387 1385
1388 if (state == WebMediaPlayer::NetworkStateEmpty) { 1386 if (state == WebMediaPlayer::NetworkStateEmpty) {
1389 // Just update the cached state and leave, we can't do anything. 1387 // Just update the cached state and leave, we can't do anything.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 scheduleEvent(EventTypeNames::playing); 1571 scheduleEvent(EventTypeNames::playing);
1574 } 1572 }
1575 } 1573 }
1576 1574
1577 scheduleEvent(EventTypeNames::canplaythrough); 1575 scheduleEvent(EventTypeNames::canplaythrough);
1578 1576
1579 shouldUpdateDisplayState = true; 1577 shouldUpdateDisplayState = true;
1580 } 1578 }
1581 1579
1582 if (shouldUpdateDisplayState) { 1580 if (shouldUpdateDisplayState) {
1583 updateDisplayState(); 1581 updateDisplayState(false);
1584 if (mediaControls()) 1582 if (mediaControls())
1585 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1583 mediaControls()->refreshClosedCaptionsButtonVisibility();
1586 } 1584 }
1587 1585
1588 updatePlayState(); 1586 updatePlayState();
1589 updateMediaController(); 1587 updateMediaController();
1590 cueTimeline().updateActiveCues(currentTime()); 1588 cueTimeline().updateActiveCues(currentTime());
1591 } 1589 }
1592 1590
1593 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1591 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 1713
1716 // 14 - Set the seeking IDL attribute to false. 1714 // 14 - Set the seeking IDL attribute to false.
1717 m_seeking = false; 1715 m_seeking = false;
1718 1716
1719 // 16 - Queue a task to fire a simple event named timeupdate at the element. 1717 // 16 - Queue a task to fire a simple event named timeupdate at the element.
1720 scheduleTimeupdateEvent(false); 1718 scheduleTimeupdateEvent(false);
1721 1719
1722 // 17 - Queue a task to fire a simple event named seeked at the element. 1720 // 17 - Queue a task to fire a simple event named seeked at the element.
1723 scheduleEvent(EventTypeNames::seeked); 1721 scheduleEvent(EventTypeNames::seeked);
1724 1722
1725 setDisplayMode(Video); 1723 setShowPoster(false);
1726 } 1724 }
1727 1725
1728 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const 1726 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const
1729 { 1727 {
1730 return m_readyState; 1728 return m_readyState;
1731 } 1729 }
1732 1730
1733 bool HTMLMediaElement::hasAudio() const 1731 bool HTMLMediaElement::hasAudio() const
1734 { 1732 {
1735 return webMediaPlayer() && webMediaPlayer()->hasAudio(); 1733 return webMediaPlayer() && webMediaPlayer()->hasAudio();
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 if (mediaControls()) 2866 if (mediaControls())
2869 mediaControls()->stoppedCasting(); 2867 mediaControls()->stoppedCasting();
2870 } 2868 }
2871 2869
2872 // MediaPlayerPresentation methods 2870 // MediaPlayerPresentation methods
2873 void HTMLMediaElement::repaint() 2871 void HTMLMediaElement::repaint()
2874 { 2872 {
2875 if (m_webLayer) 2873 if (m_webLayer)
2876 m_webLayer->invalidate(); 2874 m_webLayer->invalidate();
2877 2875
2878 updateDisplayState(); 2876 updateDisplayState(false);
2879 if (layoutObject()) 2877 if (layoutObject())
2880 layoutObject()->setShouldDoFullPaintInvalidation(); 2878 layoutObject()->setShouldDoFullPaintInvalidation();
2881 } 2879 }
2882 2880
2883 void HTMLMediaElement::sizeChanged() 2881 void HTMLMediaElement::sizeChanged()
2884 { 2882 {
2885 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); 2883 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
2886 2884
2887 ASSERT(hasVideo()); // "resize" makes no sense absent video. 2885 ASSERT(hasVideo()); // "resize" makes no sense absent video.
2888 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 2886 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2981 2979
2982 void HTMLMediaElement::updatePlayState() 2980 void HTMLMediaElement::updatePlayState()
2983 { 2981 {
2984 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); 2982 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
2985 bool shouldBePlaying = potentiallyPlaying(); 2983 bool shouldBePlaying = potentiallyPlaying();
2986 2984
2987 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", 2985 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s",
2988 this, boolString(shouldBePlaying), boolString(isPlaying)); 2986 this, boolString(shouldBePlaying), boolString(isPlaying));
2989 2987
2990 if (shouldBePlaying) { 2988 if (shouldBePlaying) {
2991 setDisplayMode(Video); 2989 setShowPoster(false);
2992 invalidateCachedTime(); 2990 invalidateCachedTime();
2993 2991
2994 if (!isPlaying) { 2992 if (!isPlaying) {
2995 // Set rate, muted before calling play in case they were set before the media engine was setup. 2993 // Set rate, muted before calling play in case they were set before the media engine was setup.
2996 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 2994 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
2997 webMediaPlayer()->setRate(effectivePlaybackRate()); 2995 webMediaPlayer()->setRate(effectivePlaybackRate());
2998 updateVolume(); 2996 updateVolume();
2999 webMediaPlayer()->play(); 2997 webMediaPlayer()->play();
3000 } 2998 }
3001 2999
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 visitor->trace(m_client); 3812 visitor->trace(m_client);
3815 } 3813 }
3816 3814
3817 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) 3815 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl)
3818 { 3816 {
3819 visitor->trace(m_client); 3817 visitor->trace(m_client);
3820 } 3818 }
3821 #endif 3819 #endif
3822 3820
3823 } 3821 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698