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