Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 305 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
| 306 , m_webLayer(0) | 306 , m_webLayer(0) |
| 307 , m_preload(MediaPlayer::Auto) | 307 , m_preload(MediaPlayer::Auto) |
| 308 , m_displayMode(Unknown) | 308 , m_displayMode(Unknown) |
| 309 , m_cachedTime(MediaPlayer::invalidTime()) | 309 , m_cachedTime(MediaPlayer::invalidTime()) |
| 310 , m_cachedTimeWallClockUpdateTime(0) | 310 , m_cachedTimeWallClockUpdateTime(0) |
| 311 , m_minimumWallClockTimeToCacheMediaTime(0) | 311 , m_minimumWallClockTimeToCacheMediaTime(0) |
| 312 , m_fragmentStartTime(MediaPlayer::invalidTime()) | 312 , m_fragmentStartTime(MediaPlayer::invalidTime()) |
| 313 , m_fragmentEndTime(MediaPlayer::invalidTime()) | 313 , m_fragmentEndTime(MediaPlayer::invalidTime()) |
| 314 , m_pendingActionFlags(0) | 314 , m_pendingActionFlags(0) |
| 315 , m_userGestureRequiredForPlay(false) | |
| 316 , m_playing(false) | 315 , m_playing(false) |
| 317 , m_shouldDelayLoadEvent(false) | 316 , m_shouldDelayLoadEvent(false) |
| 318 , m_haveFiredLoadedData(false) | 317 , m_haveFiredLoadedData(false) |
| 319 , m_active(true) | 318 , m_active(true) |
| 320 , m_autoplaying(true) | 319 , m_autoplaying(true) |
| 321 , m_muted(false) | 320 , m_muted(false) |
| 322 , m_paused(true) | 321 , m_paused(true) |
| 323 , m_seeking(false) | 322 , m_seeking(false) |
| 324 , m_sentStalledEvent(false) | 323 , m_sentStalledEvent(false) |
| 325 , m_sentEndEvent(false) | 324 , m_sentEndEvent(false) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 341 , m_ignoreTrackDisplayUpdate(0) | 340 , m_ignoreTrackDisplayUpdate(0) |
| 342 #if ENABLE(WEB_AUDIO) | 341 #if ENABLE(WEB_AUDIO) |
| 343 , m_audioSourceNode(nullptr) | 342 , m_audioSourceNode(nullptr) |
| 344 #endif | 343 #endif |
| 345 { | 344 { |
| 346 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 345 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
| 347 | 346 |
| 348 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 347 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
| 349 ScriptWrappable::init(this); | 348 ScriptWrappable::init(this); |
| 350 | 349 |
| 351 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) | |
|
philipj_slow
2014/07/22 22:57:16
This was the last user of Settings, so the Setting
| |
| 352 m_userGestureRequiredForPlay = true; | |
| 353 | |
| 354 setHasCustomStyleCallbacks(); | 350 setHasCustomStyleCallbacks(); |
| 355 addElementToDocumentMap(this, &document); | 351 addElementToDocumentMap(this, &document); |
| 356 } | 352 } |
| 357 | 353 |
| 358 HTMLMediaElement::~HTMLMediaElement() | 354 HTMLMediaElement::~HTMLMediaElement() |
| 359 { | 355 { |
| 360 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); | 356 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); |
| 361 | 357 |
| 362 #if ENABLE(OILPAN) | 358 #if ENABLE(OILPAN) |
| 363 // If the HTMLMediaElement dies with the document we are not | 359 // If the HTMLMediaElement dies with the document we are not |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 | 686 |
| 691 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%s, %s) -> %s", mimeType.utf8( ).data(), keySystem.utf8().data(), canPlay.utf8().data()); | 687 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%s, %s) -> %s", mimeType.utf8( ).data(), keySystem.utf8().data(), canPlay.utf8().data()); |
| 692 | 688 |
| 693 return canPlay; | 689 return canPlay; |
| 694 } | 690 } |
| 695 | 691 |
| 696 void HTMLMediaElement::load() | 692 void HTMLMediaElement::load() |
| 697 { | 693 { |
| 698 WTF_LOG(Media, "HTMLMediaElement::load()"); | 694 WTF_LOG(Media, "HTMLMediaElement::load()"); |
| 699 | 695 |
| 700 if (UserGestureIndicator::processingUserGesture()) | |
| 701 m_userGestureRequiredForPlay = false; | |
| 702 | |
| 703 prepareForLoad(); | 696 prepareForLoad(); |
| 704 loadInternal(); | 697 loadInternal(); |
| 705 prepareToPlay(); | 698 prepareToPlay(); |
| 706 } | 699 } |
| 707 | 700 |
| 708 void HTMLMediaElement::prepareForLoad() | 701 void HTMLMediaElement::prepareForLoad() |
| 709 { | 702 { |
| 710 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); | 703 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); |
| 711 | 704 |
| 712 // Perform the cleanup required for the resource load algorithm to run. | 705 // Perform the cleanup required for the resource load algorithm to run. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 | 933 |
| 941 if (fastHasAttribute(mutedAttr)) | 934 if (fastHasAttribute(mutedAttr)) |
| 942 m_muted = true; | 935 m_muted = true; |
| 943 updateVolume(); | 936 updateVolume(); |
| 944 | 937 |
| 945 ASSERT(!m_mediaSource); | 938 ASSERT(!m_mediaSource); |
| 946 | 939 |
| 947 bool attemptLoad = true; | 940 bool attemptLoad = true; |
| 948 | 941 |
| 949 if (url.protocolIs(mediaSourceBlobProtocol)) { | 942 if (url.protocolIs(mediaSourceBlobProtocol)) { |
| 950 if (isMediaStreamURL(url.string())) { | 943 if (!isMediaStreamURL(url.string())) { |
| 951 m_userGestureRequiredForPlay = false; | |
| 952 } else { | |
| 953 m_mediaSource = HTMLMediaSource::lookup(url.string()); | 944 m_mediaSource = HTMLMediaSource::lookup(url.string()); |
| 954 | 945 |
| 955 if (m_mediaSource) { | 946 if (m_mediaSource) { |
| 956 if (!m_mediaSource->attachToElement(this)) { | 947 if (!m_mediaSource->attachToElement(this)) { |
| 957 // Forget our reference to the MediaSource, so we leave it a lone | 948 // Forget our reference to the MediaSource, so we leave it a lone |
| 958 // while processing remainder of load failure. | 949 // while processing remainder of load failure. |
| 959 m_mediaSource = nullptr; | 950 m_mediaSource = nullptr; |
| 960 attemptLoad = false; | 951 attemptLoad = false; |
| 961 } | 952 } |
| 962 } | 953 } |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1820 shouldUpdateDisplayState = true; | 1811 shouldUpdateDisplayState = true; |
| 1821 } | 1812 } |
| 1822 | 1813 |
| 1823 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1814 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
| 1824 if (oldState <= HAVE_CURRENT_DATA) { | 1815 if (oldState <= HAVE_CURRENT_DATA) { |
| 1825 scheduleEvent(EventTypeNames::canplay); | 1816 scheduleEvent(EventTypeNames::canplay); |
| 1826 if (isPotentiallyPlaying) | 1817 if (isPotentiallyPlaying) |
| 1827 scheduleEvent(EventTypeNames::playing); | 1818 scheduleEvent(EventTypeNames::playing); |
| 1828 } | 1819 } |
| 1829 | 1820 |
| 1830 if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(S andboxAutomaticFeatures) && !m_userGestureRequiredForPlay) { | 1821 if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(S andboxAutomaticFeatures)) { |
| 1831 m_paused = false; | 1822 m_paused = false; |
| 1832 invalidateCachedTime(); | 1823 invalidateCachedTime(); |
| 1833 scheduleEvent(EventTypeNames::play); | 1824 scheduleEvent(EventTypeNames::play); |
| 1834 scheduleEvent(EventTypeNames::playing); | 1825 scheduleEvent(EventTypeNames::playing); |
| 1835 } | 1826 } |
| 1836 | 1827 |
| 1837 scheduleEvent(EventTypeNames::canplaythrough); | 1828 scheduleEvent(EventTypeNames::canplaythrough); |
| 1838 | 1829 |
| 1839 shouldUpdateDisplayState = true; | 1830 shouldUpdateDisplayState = true; |
| 1840 } | 1831 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2191 void HTMLMediaElement::setPreload(const AtomicString& preload) | 2182 void HTMLMediaElement::setPreload(const AtomicString& preload) |
| 2192 { | 2183 { |
| 2193 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); | 2184 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); |
| 2194 setAttribute(preloadAttr, preload); | 2185 setAttribute(preloadAttr, preload); |
| 2195 } | 2186 } |
| 2196 | 2187 |
| 2197 void HTMLMediaElement::play() | 2188 void HTMLMediaElement::play() |
| 2198 { | 2189 { |
| 2199 WTF_LOG(Media, "HTMLMediaElement::play()"); | 2190 WTF_LOG(Media, "HTMLMediaElement::play()"); |
| 2200 | 2191 |
| 2201 if (m_userGestureRequiredForPlay && !UserGestureIndicator::processingUserGes ture()) | |
| 2202 return; | |
| 2203 if (UserGestureIndicator::processingUserGesture()) | |
| 2204 m_userGestureRequiredForPlay = false; | |
| 2205 | |
| 2206 playInternal(); | 2192 playInternal(); |
| 2207 } | 2193 } |
| 2208 | 2194 |
| 2209 void HTMLMediaElement::playInternal() | 2195 void HTMLMediaElement::playInternal() |
| 2210 { | 2196 { |
| 2211 WTF_LOG(Media, "HTMLMediaElement::playInternal"); | 2197 WTF_LOG(Media, "HTMLMediaElement::playInternal"); |
| 2212 | 2198 |
| 2213 // 4.8.10.9. Playing the media resource | 2199 // 4.8.10.9. Playing the media resource |
| 2214 if (!m_player || m_networkState == NETWORK_EMPTY) | 2200 if (!m_player || m_networkState == NETWORK_EMPTY) |
| 2215 scheduleDelayedAction(LoadMediaResource); | 2201 scheduleDelayedAction(LoadMediaResource); |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3978 | 3964 |
| 3979 #if ENABLE(WEB_AUDIO) | 3965 #if ENABLE(WEB_AUDIO) |
| 3980 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3966 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3981 { | 3967 { |
| 3982 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3968 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3983 audioSourceProvider()->setClient(0); | 3969 audioSourceProvider()->setClient(0); |
| 3984 } | 3970 } |
| 3985 #endif | 3971 #endif |
| 3986 | 3972 |
| 3987 } | 3973 } |
| OLD | NEW |