| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 , m_readyStateMaximum(HAVE_NOTHING) | 243 , m_readyStateMaximum(HAVE_NOTHING) |
| 244 , m_volume(1.0f) | 244 , m_volume(1.0f) |
| 245 , m_lastSeekTime(0) | 245 , m_lastSeekTime(0) |
| 246 , m_previousProgressTime(numeric_limits<double>::max()) | 246 , m_previousProgressTime(numeric_limits<double>::max()) |
| 247 , m_duration(numeric_limits<double>::quiet_NaN()) | 247 , m_duration(numeric_limits<double>::quiet_NaN()) |
| 248 , m_lastTimeUpdateEventWallTime(0) | 248 , m_lastTimeUpdateEventWallTime(0) |
| 249 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max()) | 249 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max()) |
| 250 , m_loadState(WaitingForSource) | 250 , m_loadState(WaitingForSource) |
| 251 , m_webLayer(0) | 251 , m_webLayer(0) |
| 252 , m_opaque(false) | 252 , m_opaque(false) |
| 253 , m_restrictions(NoRestrictions) |
| 253 , m_preload(MediaPlayer::Auto) | 254 , m_preload(MediaPlayer::Auto) |
| 254 , m_displayMode(Unknown) | 255 , m_displayMode(Unknown) |
| 255 , m_cachedTime(MediaPlayer::invalidTime()) | 256 , m_cachedTime(MediaPlayer::invalidTime()) |
| 256 , m_cachedTimeWallClockUpdateTime(0) | 257 , m_cachedTimeWallClockUpdateTime(0) |
| 257 , m_minimumWallClockTimeToCacheMediaTime(0) | 258 , m_minimumWallClockTimeToCacheMediaTime(0) |
| 258 , m_fragmentStartTime(MediaPlayer::invalidTime()) | 259 , m_fragmentStartTime(MediaPlayer::invalidTime()) |
| 259 , m_fragmentEndTime(MediaPlayer::invalidTime()) | 260 , m_fragmentEndTime(MediaPlayer::invalidTime()) |
| 260 , m_pendingActionFlags(0) | 261 , m_pendingActionFlags(0) |
| 261 , m_userGestureRequiredForPlay(false) | |
| 262 , m_playing(false) | 262 , m_playing(false) |
| 263 , m_shouldDelayLoadEvent(false) | 263 , m_shouldDelayLoadEvent(false) |
| 264 , m_haveFiredLoadedData(false) | 264 , m_haveFiredLoadedData(false) |
| 265 , m_active(true) | 265 , m_active(true) |
| 266 , m_autoplaying(true) | 266 , m_autoplaying(true) |
| 267 , m_muted(false) | 267 , m_muted(false) |
| 268 , m_paused(true) | 268 , m_paused(true) |
| 269 , m_seeking(false) | 269 , m_seeking(false) |
| 270 , m_sentStalledEvent(false) | 270 , m_sentStalledEvent(false) |
| 271 , m_sentEndEvent(false) | 271 , m_sentEndEvent(false) |
| 272 , m_pausedInternal(false) | 272 , m_pausedInternal(false) |
| 273 , m_closedCaptionsVisible(false) | 273 , m_closedCaptionsVisible(false) |
| 274 , m_completelyLoaded(false) | 274 , m_completelyLoaded(false) |
| 275 , m_havePreparedToPlay(false) | 275 , m_havePreparedToPlay(false) |
| 276 , m_tracksAreReady(true) | 276 , m_tracksAreReady(true) |
| 277 , m_haveVisibleTextTrack(false) | 277 , m_haveVisibleTextTrack(false) |
| 278 , m_processingPreferenceChange(false) | 278 , m_processingPreferenceChange(false) |
| 279 , m_lastTextTrackUpdateTime(-1) | 279 , m_lastTextTrackUpdateTime(-1) |
| 280 , m_textTracks(nullptr) | 280 , m_textTracks(nullptr) |
| 281 , m_ignoreTrackDisplayUpdate(0) | 281 , m_ignoreTrackDisplayUpdate(0) |
| 282 #if ENABLE(WEB_AUDIO) | 282 #if ENABLE(WEB_AUDIO) |
| 283 , m_audioSourceNode(0) | 283 , m_audioSourceNode(0) |
| 284 #endif | 284 #endif |
| 285 { | 285 { |
| 286 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 286 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
| 287 | 287 |
| 288 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 288 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
| 289 ScriptWrappable::init(this); | 289 ScriptWrappable::init(this); |
| 290 | 290 |
| 291 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes
ture()) | 291 if (document.settings()) { |
| 292 m_userGestureRequiredForPlay = true; | 292 if (document.settings()->mediaPlaybackRequiresUserGesture()) |
| 293 addBehaviorRestriction(RequireUserGestureForPlayRestriction); |
| 294 if (document.settings()->mediaFullscreenRequiresUserGesture()) |
| 295 addBehaviorRestriction(RequireUserGestureForFullscreenRestriction); |
| 296 } |
| 293 | 297 |
| 294 // We must always have a ShadowRoot so children like <source> will not rende
r | 298 // We must always have a ShadowRoot so children like <source> will not rende
r |
| 295 // as they never have an insertion point. | 299 // as they never have an insertion point. |
| 296 ensureUserAgentShadowRoot(); | 300 ensureUserAgentShadowRoot(); |
| 297 setHasCustomStyleCallbacks(); | 301 setHasCustomStyleCallbacks(); |
| 298 addElementToDocumentMap(this, &document); | 302 addElementToDocumentMap(this, &document); |
| 299 } | 303 } |
| 300 | 304 |
| 301 HTMLMediaElement::~HTMLMediaElement() | 305 HTMLMediaElement::~HTMLMediaElement() |
| 302 { | 306 { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 return canPlay; | 591 return canPlay; |
| 588 } | 592 } |
| 589 | 593 |
| 590 void HTMLMediaElement::load() | 594 void HTMLMediaElement::load() |
| 591 { | 595 { |
| 592 RefPtr<HTMLMediaElement> protect(this); // loadInternal may result in a 'bef
oreload' event, which can make arbitrary DOM mutations. | 596 RefPtr<HTMLMediaElement> protect(this); // loadInternal may result in a 'bef
oreload' event, which can make arbitrary DOM mutations. |
| 593 | 597 |
| 594 WTF_LOG(Media, "HTMLMediaElement::load()"); | 598 WTF_LOG(Media, "HTMLMediaElement::load()"); |
| 595 | 599 |
| 596 if (UserGestureIndicator::processingUserGesture()) | 600 if (UserGestureIndicator::processingUserGesture()) |
| 597 m_userGestureRequiredForPlay = false; | 601 removeBehaviorsRestrictionsAfterFirstUserGesture(); |
| 598 | 602 |
| 599 prepareForLoad(); | 603 prepareForLoad(); |
| 600 loadInternal(); | 604 loadInternal(); |
| 601 prepareToPlay(); | 605 prepareToPlay(); |
| 602 } | 606 } |
| 603 | 607 |
| 604 void HTMLMediaElement::prepareForLoad() | 608 void HTMLMediaElement::prepareForLoad() |
| 605 { | 609 { |
| 606 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); | 610 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); |
| 607 | 611 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 m_muted = true; | 857 m_muted = true; |
| 854 updateVolume(); | 858 updateVolume(); |
| 855 | 859 |
| 856 ASSERT(!m_mediaSource); | 860 ASSERT(!m_mediaSource); |
| 857 | 861 |
| 858 bool attemptLoad = true; | 862 bool attemptLoad = true; |
| 859 | 863 |
| 860 if (url.protocolIs(mediaSourceBlobProtocol)) { | 864 if (url.protocolIs(mediaSourceBlobProtocol)) { |
| 861 if (isMediaStreamURL(url.string())) { | 865 if (isMediaStreamURL(url.string())) { |
| 862 loadType = blink::WebMediaPlayer::LoadTypeMediaStream; | 866 loadType = blink::WebMediaPlayer::LoadTypeMediaStream; |
| 863 m_userGestureRequiredForPlay = false; | 867 removeBehaviorRestriction(RequireUserGestureForPlayRestriction); |
| 864 } else { | 868 } else { |
| 865 m_mediaSource = HTMLMediaSource::lookup(url.string()); | 869 m_mediaSource = HTMLMediaSource::lookup(url.string()); |
| 866 | 870 |
| 867 if (m_mediaSource) { | 871 if (m_mediaSource) { |
| 868 loadType = blink::WebMediaPlayer::LoadTypeMediaSource; | 872 loadType = blink::WebMediaPlayer::LoadTypeMediaSource; |
| 869 | 873 |
| 870 if (!m_mediaSource->attachToElement(this)) { | 874 if (!m_mediaSource->attachToElement(this)) { |
| 871 // Forget our reference to the MediaSource, so we leave it a
lone | 875 // Forget our reference to the MediaSource, so we leave it a
lone |
| 872 // while processing remainder of load failure. | 876 // while processing remainder of load failure. |
| 873 m_mediaSource = nullptr; | 877 m_mediaSource = nullptr; |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 shouldUpdateDisplayState = true; | 1613 shouldUpdateDisplayState = true; |
| 1610 } | 1614 } |
| 1611 | 1615 |
| 1612 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track
sAreReady) { | 1616 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track
sAreReady) { |
| 1613 if (oldState <= HAVE_CURRENT_DATA) { | 1617 if (oldState <= HAVE_CURRENT_DATA) { |
| 1614 scheduleEvent(EventTypeNames::canplay); | 1618 scheduleEvent(EventTypeNames::canplay); |
| 1615 if (isPotentiallyPlaying) | 1619 if (isPotentiallyPlaying) |
| 1616 scheduleEvent(EventTypeNames::playing); | 1620 scheduleEvent(EventTypeNames::playing); |
| 1617 } | 1621 } |
| 1618 | 1622 |
| 1619 if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(S
andboxAutomaticFeatures) && !m_userGestureRequiredForPlay) { | 1623 if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(S
andboxAutomaticFeatures) && !userGestureRequiredForPlay()) { |
| 1620 m_paused = false; | 1624 m_paused = false; |
| 1621 invalidateCachedTime(); | 1625 invalidateCachedTime(); |
| 1622 scheduleEvent(EventTypeNames::play); | 1626 scheduleEvent(EventTypeNames::play); |
| 1623 scheduleEvent(EventTypeNames::playing); | 1627 scheduleEvent(EventTypeNames::playing); |
| 1624 } | 1628 } |
| 1625 | 1629 |
| 1626 scheduleEvent(EventTypeNames::canplaythrough); | 1630 scheduleEvent(EventTypeNames::canplaythrough); |
| 1627 | 1631 |
| 1628 shouldUpdateDisplayState = true; | 1632 shouldUpdateDisplayState = true; |
| 1629 } | 1633 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 void HTMLMediaElement::setPreload(const AtomicString& preload) | 1970 void HTMLMediaElement::setPreload(const AtomicString& preload) |
| 1967 { | 1971 { |
| 1968 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); | 1972 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); |
| 1969 setAttribute(preloadAttr, preload); | 1973 setAttribute(preloadAttr, preload); |
| 1970 } | 1974 } |
| 1971 | 1975 |
| 1972 void HTMLMediaElement::play() | 1976 void HTMLMediaElement::play() |
| 1973 { | 1977 { |
| 1974 WTF_LOG(Media, "HTMLMediaElement::play()"); | 1978 WTF_LOG(Media, "HTMLMediaElement::play()"); |
| 1975 | 1979 |
| 1976 if (m_userGestureRequiredForPlay && !UserGestureIndicator::processingUserGes
ture()) | 1980 if (userGestureRequiredForPlay() && !UserGestureIndicator::processingUserGes
ture()) |
| 1977 return; | 1981 return; |
| 1978 if (UserGestureIndicator::processingUserGesture()) | 1982 if (UserGestureIndicator::processingUserGesture()) |
| 1979 m_userGestureRequiredForPlay = false; | 1983 removeBehaviorsRestrictionsAfterFirstUserGesture(); |
| 1980 | 1984 |
| 1981 playInternal(); | 1985 playInternal(); |
| 1982 } | 1986 } |
| 1983 | 1987 |
| 1984 void HTMLMediaElement::playInternal() | 1988 void HTMLMediaElement::playInternal() |
| 1985 { | 1989 { |
| 1986 WTF_LOG(Media, "HTMLMediaElement::playInternal"); | 1990 WTF_LOG(Media, "HTMLMediaElement::playInternal"); |
| 1987 | 1991 |
| 1988 // 4.8.10.9. Playing the media resource | 1992 // 4.8.10.9. Playing the media resource |
| 1989 if (!m_player || m_networkState == NETWORK_EMPTY) | 1993 if (!m_player || m_networkState == NETWORK_EMPTY) |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3189 } | 3193 } |
| 3190 | 3194 |
| 3191 void HTMLMediaElement::enterFullscreen() | 3195 void HTMLMediaElement::enterFullscreen() |
| 3192 { | 3196 { |
| 3193 WTF_LOG(Media, "HTMLMediaElement::enterFullscreen"); | 3197 WTF_LOG(Media, "HTMLMediaElement::enterFullscreen"); |
| 3194 | 3198 |
| 3195 if (document().settings() && document().settings()->fullScreenEnabled()) | 3199 if (document().settings() && document().settings()->fullScreenEnabled()) |
| 3196 FullscreenElementStack::from(document()).requestFullScreenForElement(thi
s, 0, FullscreenElementStack::ExemptIFrameAllowFullScreenRequirement); | 3200 FullscreenElementStack::from(document()).requestFullScreenForElement(thi
s, 0, FullscreenElementStack::ExemptIFrameAllowFullScreenRequirement); |
| 3197 } | 3201 } |
| 3198 | 3202 |
| 3203 void HTMLMediaElement::exitFullscreen() |
| 3204 { |
| 3205 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen"); |
| 3206 |
| 3207 if (document().settings() && document().settings()->fullScreenEnabled() && i
sFullscreen()) |
| 3208 FullscreenElementStack::from(document()).webkitCancelFullScreen(); |
| 3209 } |
| 3210 |
| 3199 void HTMLMediaElement::didBecomeFullscreenElement() | 3211 void HTMLMediaElement::didBecomeFullscreenElement() |
| 3200 { | 3212 { |
| 3201 if (hasMediaControls()) | 3213 if (hasMediaControls()) |
| 3202 mediaControls()->enteredFullscreen(); | 3214 mediaControls()->enteredFullscreen(); |
| 3203 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isVideo()) | 3215 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isVideo()) |
| 3204 document().renderView()->compositor()->setCompositingLayersNeedRebuild()
; | 3216 document().renderView()->compositor()->setCompositingLayersNeedRebuild()
; |
| 3205 } | 3217 } |
| 3206 | 3218 |
| 3207 void HTMLMediaElement::willStopBeingFullscreenElement() | 3219 void HTMLMediaElement::willStopBeingFullscreenElement() |
| 3208 { | 3220 { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3605 MediaPlayerClient::CORSMode HTMLMediaElement::mediaPlayerCORSMode() const | 3617 MediaPlayerClient::CORSMode HTMLMediaElement::mediaPlayerCORSMode() const |
| 3606 { | 3618 { |
| 3607 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); | 3619 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); |
| 3608 if (crossOriginMode.isNull()) | 3620 if (crossOriginMode.isNull()) |
| 3609 return Unspecified; | 3621 return Unspecified; |
| 3610 if (equalIgnoringCase(crossOriginMode, "use-credentials")) | 3622 if (equalIgnoringCase(crossOriginMode, "use-credentials")) |
| 3611 return UseCredentials; | 3623 return UseCredentials; |
| 3612 return Anonymous; | 3624 return Anonymous; |
| 3613 } | 3625 } |
| 3614 | 3626 |
| 3627 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture() |
| 3628 { |
| 3629 m_restrictions = NoRestrictions; |
| 3630 } |
| 3631 |
| 3615 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) | 3632 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) |
| 3616 { | 3633 { |
| 3617 if (webLayer == m_webLayer) | 3634 if (webLayer == m_webLayer) |
| 3618 return; | 3635 return; |
| 3619 | 3636 |
| 3620 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. | 3637 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. |
| 3621 if (!m_webLayer || !webLayer) | 3638 if (!m_webLayer || !webLayer) |
| 3622 scheduleLayerUpdate(); | 3639 scheduleLayerUpdate(); |
| 3623 | 3640 |
| 3624 if (m_webLayer) | 3641 if (m_webLayer) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3641 { | 3658 { |
| 3642 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3659 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3643 } | 3660 } |
| 3644 | 3661 |
| 3645 bool HTMLMediaElement::isInteractiveContent() const | 3662 bool HTMLMediaElement::isInteractiveContent() const |
| 3646 { | 3663 { |
| 3647 return fastHasAttribute(controlsAttr); | 3664 return fastHasAttribute(controlsAttr); |
| 3648 } | 3665 } |
| 3649 | 3666 |
| 3650 } | 3667 } |
| OLD | NEW |