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