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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (m_textTracks) | 377 if (m_textTracks) |
378 m_textTracks->clearOwner(); | 378 m_textTracks->clearOwner(); |
379 m_audioTracks->shutdown(); | 379 m_audioTracks->shutdown(); |
380 m_videoTracks->shutdown(); | 380 m_videoTracks->shutdown(); |
381 | 381 |
382 closeMediaSource(); | 382 closeMediaSource(); |
383 | 383 |
384 removeElementFromDocumentMap(this, &document()); | 384 removeElementFromDocumentMap(this, &document()); |
385 | 385 |
386 // Destroying the player may cause a resource load to be canceled, | 386 // Destroying the player may cause a resource load to be canceled, |
387 // which could result in userCancelledLoad() being called back. | |
388 // Setting m_isFinalizing ensures that such a call will not cause | |
389 // us to dispatch an abort event, which would result in a crash. | |
390 // See http://crbug.com/233654 for more details. | |
391 m_isFinalizing = true; | |
392 | |
393 // Destroying the player may cause a resource load to be canceled, | |
394 // which could result in Document::dispatchWindowLoadEvent() being | 387 // which could result in Document::dispatchWindowLoadEvent() being |
395 // called via ResourceFetch::didLoadResource() then | 388 // called via ResourceFetch::didLoadResource() then |
396 // FrameLoader::checkCompleted(). To prevent load event dispatching during | 389 // FrameLoader::checkCompleted(). To prevent load event dispatching during |
397 // object destruction, we use Document::incrementLoadEventDelayCount(). | 390 // object destruction, we use Document::incrementLoadEventDelayCount(). |
398 // See http://crbug.com/275223 for more details. | 391 // See http://crbug.com/275223 for more details. |
399 document().incrementLoadEventDelayCount(); | 392 document().incrementLoadEventDelayCount(); |
400 | 393 |
401 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 394 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
402 | 395 |
403 document().decrementLoadEventDelayCount(); | 396 document().decrementLoadEventDelayCount(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // Incrementing the load event delay count so that destruction of m_webM
ediaPlayer can not | 460 // Incrementing the load event delay count so that destruction of m_webM
ediaPlayer can not |
468 // cause load event dispatching in oldDocument. | 461 // cause load event dispatching in oldDocument. |
469 oldDocument.incrementLoadEventDelayCount(); | 462 oldDocument.incrementLoadEventDelayCount(); |
470 } | 463 } |
471 | 464 |
472 removeElementFromDocumentMap(this, &oldDocument); | 465 removeElementFromDocumentMap(this, &oldDocument); |
473 addElementToDocumentMap(this, &document()); | 466 addElementToDocumentMap(this, &document()); |
474 | 467 |
475 // FIXME: This is a temporary fix to prevent this object from causing the | 468 // FIXME: This is a temporary fix to prevent this object from causing the |
476 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 469 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
477 // previous document. A proper fix would provide a mechanism to allow this | 470 // previous document. This restarts the load, as if the src attribute had be
en set. |
478 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references
on | 471 // A proper fix would provide a mechanism to allow this object to refresh |
| 472 // the MediaPlayer's LocalFrame and FrameLoader references on |
479 // document changes so that playback can be resumed properly. | 473 // document changes so that playback can be resumed properly. |
480 userCancelledLoad(); | 474 clearMediaPlayer(LoadMediaResource); |
| 475 scheduleDelayedAction(LoadMediaResource); |
481 | 476 |
482 // Decrement the load event delay count on oldDocument now that m_webMediaPl
ayer has been destroyed | 477 // Decrement the load event delay count on oldDocument now that m_webMediaPl
ayer has been destroyed |
483 // and there is no risk of dispatching a load event from within the destruct
or. | 478 // and there is no risk of dispatching a load event from within the destruct
or. |
484 oldDocument.decrementLoadEventDelayCount(); | 479 oldDocument.decrementLoadEventDelayCount(); |
485 | 480 |
486 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 481 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
487 HTMLElement::didMoveToNewDocument(oldDocument); | 482 HTMLElement::didMoveToNewDocument(oldDocument); |
488 } | 483 } |
489 | 484 |
490 bool HTMLMediaElement::supportsFocus() const | 485 bool HTMLMediaElement::supportsFocus() const |
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2968 if (layoutObject()) | 2963 if (layoutObject()) |
2969 layoutObject()->updateFromElement(); | 2964 layoutObject()->updateFromElement(); |
2970 } | 2965 } |
2971 | 2966 |
2972 void HTMLMediaElement::stopPeriodicTimers() | 2967 void HTMLMediaElement::stopPeriodicTimers() |
2973 { | 2968 { |
2974 m_progressEventTimer.stop(); | 2969 m_progressEventTimer.stop(); |
2975 m_playbackProgressTimer.stop(); | 2970 m_playbackProgressTimer.stop(); |
2976 } | 2971 } |
2977 | 2972 |
2978 void HTMLMediaElement::userCancelledLoad() | |
2979 { | |
2980 WTF_LOG(Media, "HTMLMediaElement::userCancelledLoad(%p)", this); | |
2981 | |
2982 // If the media data fetching process is aborted by the user: | |
2983 | |
2984 // 1 - The user agent should cancel the fetching process. | |
2985 clearMediaPlayer(-1); | |
2986 // Reset m_readyState and m_readyStateMaximum since m_webMediaPlayer is gone
. | |
2987 ReadyState readyState = m_readyState; | |
2988 m_readyState = HAVE_NOTHING; | |
2989 m_readyStateMaximum = HAVE_NOTHING; | |
2990 | |
2991 // TODO(srirama.m): Investigate if this condition can be dropped entirely wi
thout any issues. | |
2992 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded || m_isFinalizing) | |
2993 return; | |
2994 | |
2995 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is set to MEDIA_ERR_ABORTED. | |
2996 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); | |
2997 | |
2998 // 3 - Queue a task to fire a simple event named error at the media element. | |
2999 scheduleEvent(EventTypeNames::abort); | |
3000 | |
3001 // 4 - If the media element's readyState attribute has a value equal to HAVE
_NOTHING, set the | |
3002 // element's networkState attribute to the NETWORK_EMPTY value and queue a t
ask to fire a | |
3003 // simple event named emptied at the element. Otherwise, set the element's n
etworkState | |
3004 // attribute to the NETWORK_IDLE value. | |
3005 if (readyState == HAVE_NOTHING) { | |
3006 setNetworkState(NETWORK_EMPTY); | |
3007 scheduleEvent(EventTypeNames::emptied); | |
3008 } else { | |
3009 setNetworkState(NETWORK_IDLE); | |
3010 } | |
3011 | |
3012 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | |
3013 setShouldDelayLoadEvent(false); | |
3014 | |
3015 // 6 - Abort the overall resource selection algorithm. | |
3016 m_currentSourceNode = nullptr; | |
3017 | |
3018 invalidateCachedTime(); | |
3019 cueTimeline().updateActiveCues(0); | |
3020 } | |
3021 | |
3022 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin
g() | 2973 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin
g() |
3023 { | 2974 { |
3024 #if ENABLE(WEB_AUDIO) | 2975 #if ENABLE(WEB_AUDIO) |
3025 audioSourceProvider().setClient(nullptr); | 2976 audioSourceProvider().setClient(nullptr); |
3026 #endif | 2977 #endif |
3027 if (m_webMediaPlayer) { | 2978 if (m_webMediaPlayer) { |
3028 #if ENABLE(WEB_AUDIO) | 2979 #if ENABLE(WEB_AUDIO) |
3029 m_audioSourceProvider.wrap(nullptr); | 2980 m_audioSourceProvider.wrap(nullptr); |
3030 #endif | 2981 #endif |
3031 m_webMediaPlayer.clear(); | 2982 m_webMediaPlayer.clear(); |
(...skipping 28 matching lines...) Expand all Loading... |
3060 if (layoutObject()) | 3011 if (layoutObject()) |
3061 layoutObject()->setShouldDoFullPaintInvalidation(); | 3012 layoutObject()->setShouldDoFullPaintInvalidation(); |
3062 } | 3013 } |
3063 | 3014 |
3064 void HTMLMediaElement::stop() | 3015 void HTMLMediaElement::stop() |
3065 { | 3016 { |
3066 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3017 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); |
3067 | 3018 |
3068 recordMetricsIfPausing(); | 3019 recordMetricsIfPausing(); |
3069 | 3020 |
3070 // Close the async event queue so that no events are enqueued by userCancell
edLoad. | 3021 // Close the async event queue so that no events are enqueued. |
3071 cancelPendingEventsAndCallbacks(); | 3022 cancelPendingEventsAndCallbacks(); |
3072 m_asyncEventQueue->close(); | 3023 m_asyncEventQueue->close(); |
3073 | 3024 |
3074 userCancelledLoad(); | |
3075 | |
3076 // Stop the playback without generating events | 3025 // Stop the playback without generating events |
| 3026 clearMediaPlayer(-1); |
| 3027 m_readyState = HAVE_NOTHING; |
| 3028 m_readyStateMaximum = HAVE_NOTHING; |
| 3029 setNetworkState(NETWORK_EMPTY); |
| 3030 setShouldDelayLoadEvent(false); |
| 3031 m_currentSourceNode = nullptr; |
| 3032 invalidateCachedTime(); |
| 3033 cueTimeline().updateActiveCues(0); |
3077 m_playing = false; | 3034 m_playing = false; |
3078 m_paused = true; | 3035 m_paused = true; |
3079 m_seeking = false; | 3036 m_seeking = false; |
3080 | 3037 |
3081 if (layoutObject()) | 3038 if (layoutObject()) |
3082 layoutObject()->updateFromElement(); | 3039 layoutObject()->updateFromElement(); |
3083 | 3040 |
3084 stopPeriodicTimers(); | 3041 stopPeriodicTimers(); |
3085 | 3042 |
3086 // Ensure that hasPendingActivity() is not preventing garbage collection, si
nce otherwise this | 3043 // Ensure that hasPendingActivity() is not preventing garbage collection, si
nce otherwise this |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3682 visitor->trace(m_client); | 3639 visitor->trace(m_client); |
3683 } | 3640 } |
3684 | 3641 |
3685 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3642 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
3686 { | 3643 { |
3687 visitor->trace(m_client); | 3644 visitor->trace(m_client); |
3688 } | 3645 } |
3689 #endif | 3646 #endif |
3690 | 3647 |
3691 } | 3648 } |
OLD | NEW |