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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 | 464 |
| 465 removeElementFromDocumentMap(this, &oldDocument); | 465 removeElementFromDocumentMap(this, &oldDocument); |
| 466 addElementToDocumentMap(this, &document()); | 466 addElementToDocumentMap(this, &document()); |
| 467 | 467 |
| 468 // 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 |
| 469 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 469 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
| 470 // previous document. This restarts the load, as if the src attribute had be en set. | 470 // previous document. This restarts the load, as if the src attribute had be en set. |
| 471 // A proper fix would provide a mechanism to allow this object to refresh | 471 // A proper fix would provide a mechanism to allow this object to refresh |
| 472 // the MediaPlayer's LocalFrame and FrameLoader references on | 472 // the MediaPlayer's LocalFrame and FrameLoader references on |
| 473 // document changes so that playback can be resumed properly. | 473 // document changes so that playback can be resumed properly. |
| 474 clearMediaPlayer(LoadMediaResource); | 474 m_pendingActionFlags &= ~LoadMediaResource; |
|
philipj_slow
2015/12/11 15:01:51
This does much less than clearMediaPlayer, is the
Srirama
2015/12/11 15:05:47
resetMediaPlayerAndMediaSource is internally calle
philipj_slow
2015/12/14 14:30:40
OK, so assuming that this CL does not change any o
| |
| 475 forgetResourceSpecificTracks(); | |
| 475 scheduleDelayedAction(LoadMediaResource); | 476 scheduleDelayedAction(LoadMediaResource); |
| 476 | 477 |
| 477 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed | 478 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed |
| 478 // and there is no risk of dispatching a load event from within the destruct or. | 479 // and there is no risk of dispatching a load event from within the destruct or. |
| 479 oldDocument.decrementLoadEventDelayCount(); | 480 oldDocument.decrementLoadEventDelayCount(); |
| 480 | 481 |
| 481 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 482 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
| 482 HTMLElement::didMoveToNewDocument(oldDocument); | 483 HTMLElement::didMoveToNewDocument(oldDocument); |
| 483 } | 484 } |
| 484 | 485 |
| 485 bool HTMLMediaElement::supportsFocus() const | 486 bool HTMLMediaElement::supportsFocus() const |
| 486 { | 487 { |
| 487 if (ownerDocument()->isMediaDocument()) | 488 if (ownerDocument()->isMediaDocument()) |
| 488 return false; | 489 return false; |
| 489 | 490 |
| 490 // If no controls specified, we should still be able to focus the element if it has tabIndex. | 491 // If no controls specified, we should still be able to focus the element if it has tabIndex. |
| 491 return shouldShowControls() || HTMLElement::supportsFocus(); | 492 return shouldShowControls() || HTMLElement::supportsFocus(); |
| 492 } | 493 } |
| 493 | 494 |
| 494 bool HTMLMediaElement::isMouseFocusable() const | 495 bool HTMLMediaElement::isMouseFocusable() const |
| 495 { | 496 { |
| 496 return false; | 497 return false; |
| 497 } | 498 } |
| 498 | 499 |
| 499 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) | 500 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& oldValue, const AtomicString& value) |
| 500 { | 501 { |
| 501 if (name == srcAttr) { | 502 if (name == srcAttr) { |
| 502 // Trigger a reload, as long as the 'src' attribute is present. | 503 // Trigger a reload, as long as the 'src' attribute is present. |
| 503 if (!value.isNull()) { | 504 if (!value.isNull()) { |
| 504 clearMediaPlayer(LoadMediaResource); | 505 m_pendingActionFlags &= ~LoadMediaResource; |
| 506 forgetResourceSpecificTracks(); | |
| 505 scheduleDelayedAction(LoadMediaResource); | 507 scheduleDelayedAction(LoadMediaResource); |
| 506 } | 508 } |
| 507 } else if (name == controlsAttr) { | 509 } else if (name == controlsAttr) { |
| 508 configureMediaControls(); | 510 configureMediaControls(); |
| 509 } else if (name == preloadAttr) { | 511 } else if (name == preloadAttr) { |
| 510 setPlayerPreload(); | 512 setPlayerPreload(); |
| 511 } else { | 513 } else { |
| 512 HTMLElement::parseAttribute(name, oldValue, value); | 514 HTMLElement::parseAttribute(name, oldValue, value); |
| 513 } | 515 } |
| 514 } | 516 } |
| (...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2979 audioSourceProvider().setClient(nullptr); | 2981 audioSourceProvider().setClient(nullptr); |
| 2980 #endif | 2982 #endif |
| 2981 if (m_webMediaPlayer) { | 2983 if (m_webMediaPlayer) { |
| 2982 #if ENABLE(WEB_AUDIO) | 2984 #if ENABLE(WEB_AUDIO) |
| 2983 m_audioSourceProvider.wrap(nullptr); | 2985 m_audioSourceProvider.wrap(nullptr); |
| 2984 #endif | 2986 #endif |
| 2985 m_webMediaPlayer.clear(); | 2987 m_webMediaPlayer.clear(); |
| 2986 } | 2988 } |
| 2987 } | 2989 } |
| 2988 | 2990 |
| 2989 void HTMLMediaElement::clearMediaPlayer(int flags) | |
| 2990 { | |
| 2991 forgetResourceSpecificTracks(); | |
| 2992 | |
| 2993 closeMediaSource(); | |
| 2994 | |
| 2995 cancelDeferredLoad(); | |
| 2996 | |
| 2997 { | |
| 2998 AudioSourceProviderClientLockScope scope(*this); | |
| 2999 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | |
| 3000 } | |
| 3001 | |
| 3002 stopPeriodicTimers(); | |
| 3003 m_loadTimer.stop(); | |
| 3004 | |
| 3005 m_pendingActionFlags &= ~flags; | |
| 3006 m_loadState = WaitingForSource; | |
| 3007 | |
| 3008 // We can't cast if we don't have a media player. | |
| 3009 m_remoteRoutesAvailable = false; | |
| 3010 m_playingRemotely = false; | |
| 3011 if (mediaControls()) | |
| 3012 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | |
| 3013 | |
| 3014 if (layoutObject()) | |
| 3015 layoutObject()->setShouldDoFullPaintInvalidation(); | |
| 3016 } | |
| 3017 | |
| 3018 void HTMLMediaElement::stop() | 2991 void HTMLMediaElement::stop() |
| 3019 { | 2992 { |
| 3020 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 2993 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); |
| 3021 | 2994 |
| 3022 recordMetricsIfPausing(); | 2995 recordMetricsIfPausing(); |
| 3023 | 2996 |
| 3024 // Close the async event queue so that no events are enqueued. | 2997 // Close the async event queue so that no events are enqueued. |
| 3025 cancelPendingEventsAndCallbacks(); | 2998 cancelPendingEventsAndCallbacks(); |
| 3026 m_asyncEventQueue->close(); | 2999 m_asyncEventQueue->close(); |
| 3027 | 3000 |
| 3028 // Stop the playback without generating events | 3001 // Stop the playback without generating events |
| 3029 clearMediaPlayer(-1); | 3002 resetMediaPlayerAndMediaSource(); |
| 3003 forgetResourceSpecificTracks(); | |
| 3004 m_loadTimer.stop(); | |
| 3005 m_pendingActionFlags = 0; | |
| 3006 m_loadState = WaitingForSource; | |
| 3030 m_readyState = HAVE_NOTHING; | 3007 m_readyState = HAVE_NOTHING; |
| 3031 m_readyStateMaximum = HAVE_NOTHING; | 3008 m_readyStateMaximum = HAVE_NOTHING; |
| 3032 setNetworkState(NETWORK_EMPTY); | 3009 setNetworkState(NETWORK_EMPTY); |
| 3033 setShouldDelayLoadEvent(false); | 3010 setShouldDelayLoadEvent(false); |
| 3034 m_currentSourceNode = nullptr; | 3011 m_currentSourceNode = nullptr; |
| 3035 invalidateCachedTime(); | 3012 invalidateCachedTime(); |
| 3036 cueTimeline().updateActiveCues(0); | 3013 cueTimeline().updateActiveCues(0); |
| 3037 m_playing = false; | 3014 m_playing = false; |
| 3038 m_paused = true; | 3015 m_paused = true; |
| 3039 m_seeking = false; | 3016 m_seeking = false; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3384 } | 3361 } |
| 3385 | 3362 |
| 3386 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3363 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
| 3387 { | 3364 { |
| 3388 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3365 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
| 3389 configureMediaControls(); | 3366 configureMediaControls(); |
| 3390 | 3367 |
| 3391 return nullptr; | 3368 return nullptr; |
| 3392 } | 3369 } |
| 3393 | 3370 |
| 3394 // TODO(srirama.m): Refactor this and clearMediaPlayer to the extent possible. | |
| 3395 void HTMLMediaElement::resetMediaPlayerAndMediaSource() | 3371 void HTMLMediaElement::resetMediaPlayerAndMediaSource() |
| 3396 { | 3372 { |
| 3397 closeMediaSource(); | 3373 closeMediaSource(); |
| 3398 | 3374 |
| 3399 { | 3375 { |
| 3400 AudioSourceProviderClientLockScope scope(*this); | 3376 AudioSourceProviderClientLockScope scope(*this); |
| 3401 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3377 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3402 } | 3378 } |
| 3403 | 3379 |
| 3404 // We haven't yet found out if any remote routes are available. | 3380 // We haven't yet found out if any remote routes are available. |
| 3405 m_remoteRoutesAvailable = false; | 3381 m_remoteRoutesAvailable = false; |
| 3406 m_playingRemotely = false; | 3382 m_playingRemotely = false; |
| 3407 | 3383 |
| 3408 #if ENABLE(WEB_AUDIO) | 3384 #if ENABLE(WEB_AUDIO) |
| 3409 if (m_audioSourceNode) | 3385 if (m_audioSourceNode) |
| 3410 audioSourceProvider().setClient(m_audioSourceNode); | 3386 audioSourceProvider().setClient(m_audioSourceNode); |
| 3411 #endif | 3387 #endif |
| 3388 if (mediaControls()) | |
| 3389 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | |
| 3390 if (layoutObject()) | |
| 3391 layoutObject()->setShouldDoFullPaintInvalidation(); | |
| 3412 } | 3392 } |
| 3413 | 3393 |
| 3414 #if ENABLE(WEB_AUDIO) | 3394 #if ENABLE(WEB_AUDIO) |
| 3415 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) | 3395 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
| 3416 { | 3396 { |
| 3417 ASSERT(isMainThread()); | 3397 ASSERT(isMainThread()); |
| 3418 m_audioSourceNode = sourceNode; | 3398 m_audioSourceNode = sourceNode; |
| 3419 | 3399 |
| 3420 AudioSourceProviderClientLockScope scope(*this); | 3400 AudioSourceProviderClientLockScope scope(*this); |
| 3421 audioSourceProvider().setClient(m_audioSourceNode); | 3401 audioSourceProvider().setClient(m_audioSourceNode); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3632 visitor->trace(m_client); | 3612 visitor->trace(m_client); |
| 3633 } | 3613 } |
| 3634 | 3614 |
| 3635 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3615 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
| 3636 { | 3616 { |
| 3637 visitor->trace(m_client); | 3617 visitor->trace(m_client); |
| 3638 } | 3618 } |
| 3639 #endif | 3619 #endif |
| 3640 | 3620 |
| 3641 } | 3621 } |
| OLD | NEW |