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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 , m_sentStalledEvent(false) | 275 , m_sentStalledEvent(false) |
276 , m_sentEndEvent(false) | 276 , m_sentEndEvent(false) |
277 , m_pausedInternal(false) | 277 , m_pausedInternal(false) |
278 , m_closedCaptionsVisible(false) | 278 , m_closedCaptionsVisible(false) |
279 , m_completelyLoaded(false) | 279 , m_completelyLoaded(false) |
280 , m_havePreparedToPlay(false) | 280 , m_havePreparedToPlay(false) |
281 , m_delayingLoadForPreloadNone(false) | 281 , m_delayingLoadForPreloadNone(false) |
282 , m_tracksAreReady(true) | 282 , m_tracksAreReady(true) |
283 , m_haveVisibleTextTrack(false) | 283 , m_haveVisibleTextTrack(false) |
284 , m_processingPreferenceChange(false) | 284 , m_processingPreferenceChange(false) |
285 #if ENABLE(OILPAN) | |
286 , m_isFinalizing(false) | |
287 #endif | |
288 , m_lastTextTrackUpdateTime(-1) | 285 , m_lastTextTrackUpdateTime(-1) |
289 , m_textTracks(nullptr) | 286 , m_textTracks(nullptr) |
290 , m_ignoreTrackDisplayUpdate(0) | 287 , m_ignoreTrackDisplayUpdate(0) |
291 #if ENABLE(WEB_AUDIO) | 288 #if ENABLE(WEB_AUDIO) |
292 , m_audioSourceNode(0) | 289 , m_audioSourceNode(0) |
293 #endif | 290 #endif |
294 { | 291 { |
295 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 292 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
296 | 293 |
297 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 294 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
(...skipping 25 matching lines...) Expand all Loading... | |
323 // removed from the map during weak processing. | 320 // removed from the map during weak processing. |
324 if (documentToElementSetMap().contains(&document())) | 321 if (documentToElementSetMap().contains(&document())) |
325 setShouldDelayLoadEvent(false); | 322 setShouldDelayLoadEvent(false); |
326 #else | 323 #else |
327 setShouldDelayLoadEvent(false); | 324 setShouldDelayLoadEvent(false); |
328 #endif | 325 #endif |
329 | 326 |
330 #if !ENABLE(OILPAN) | 327 #if !ENABLE(OILPAN) |
331 if (m_textTracks) | 328 if (m_textTracks) |
332 m_textTracks->clearOwner(); | 329 m_textTracks->clearOwner(); |
333 #endif | |
334 | 330 |
335 if (m_mediaController) { | 331 if (m_mediaController) { |
336 m_mediaController->removeMediaElement(this); | 332 m_mediaController->removeMediaElement(this); |
337 m_mediaController = nullptr; | 333 m_mediaController = nullptr; |
338 } | 334 } |
335 #endif | |
339 | 336 |
340 closeMediaSource(); | 337 closeMediaSource(); |
341 | 338 |
342 #if !ENABLE(OILPAN) | 339 #if !ENABLE(OILPAN) |
343 removeElementFromDocumentMap(this, &document()); | 340 removeElementFromDocumentMap(this, &document()); |
344 #endif | |
345 | 341 |
346 // Destroying the player may cause a resource load to be canceled, | 342 // Destroying the player may cause a resource load to be canceled, |
347 // which could result in userCancelledLoad() being called back. | 343 // which could result in userCancelledLoad() being called back. |
348 // Setting m_completelyLoaded ensures that such a call will not cause | 344 // Setting m_completelyLoaded ensures that such a call will not cause |
349 // us to dispatch an abort event, which would result in a crash. | 345 // us to dispatch an abort event, which would result in a crash. |
350 // See http://crbug.com/233654 for more details. | 346 // See http://crbug.com/233654 for more details. |
351 m_completelyLoaded = true; | 347 m_completelyLoaded = true; |
352 | 348 |
353 // With Oilpan load events on the Document are always delayed during | 349 // With Oilpan load events on the Document are always delayed during |
354 // sweeping so we don't need to explicitly increment and decrement | 350 // sweeping so we don't need to explicitly increment and decrement |
355 // load event delay counts. | 351 // load event delay counts. |
356 #if !ENABLE(OILPAN) | 352 |
357 // Destroying the player may cause a resource load to be canceled, | 353 // Destroying the player may cause a resource load to be canceled, |
358 // which could result in Document::dispatchWindowLoadEvent() being | 354 // which could result in Document::dispatchWindowLoadEvent() being |
359 // called via ResourceFetch::didLoadResource() then | 355 // called via ResourceFetch::didLoadResource() then |
360 // FrameLoader::loadDone(). To prevent load event dispatching during | 356 // FrameLoader::loadDone(). To prevent load event dispatching during |
361 // object destruction, we use Document::incrementLoadEventDelayCount(). | 357 // object destruction, we use Document::incrementLoadEventDelayCount(). |
362 // See http://crbug.com/275223 for more details. | 358 // See http://crbug.com/275223 for more details. |
363 document().incrementLoadEventDelayCount(); | 359 document().incrementLoadEventDelayCount(); |
364 #endif | |
365 | 360 |
366 #if ENABLE(OILPAN) | |
367 // Oilpan: the player must be released, but the player object | |
368 // cannot safely access this player client any longer as parts of | |
369 // it may have been finalized already (like the media element's | |
370 // supplementable table.) Handled for now by entering an | |
371 // is-finalizing state, which is explicitly checked for if the | |
372 // player tries to access the media element during shutdown. | |
373 // | |
374 // FIXME: Oilpan: move the media player to the heap instead and | |
375 // avoid having to finalize it from here; this whole #if block | |
376 // could then be removed (along with the state bit it depends on.) | |
377 // crbug.com/378229 | |
378 m_isFinalizing = true; | |
379 #endif | |
380 clearMediaPlayerAndAudioSourceProviderClient(); | 361 clearMediaPlayerAndAudioSourceProviderClient(); |
381 | 362 |
382 #if !ENABLE(OILPAN) | |
383 document().decrementLoadEventDelayCount(); | 363 document().decrementLoadEventDelayCount(); |
364 #else | |
365 // If the media element is finalized at the same time as | |
366 // the media player, the latter cannot be accessed and | |
367 // detached from the destructor. The web layer can be | |
368 // cleared out safely, however. | |
369 if (m_player) | |
370 mediaPlayerSetWebLayer(0); | |
384 #endif | 371 #endif |
385 } | 372 } |
386 | 373 |
387 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 374 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
388 { | 375 { |
389 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); | 376 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); |
390 | 377 |
391 if (m_shouldDelayLoadEvent) { | 378 if (m_shouldDelayLoadEvent) { |
392 document().incrementLoadEventDelayCount(); | 379 document().incrementLoadEventDelayCount(); |
393 // Note: Keeping the load event delay count increment on oldDocument tha t was added | 380 // Note: Keeping the load event delay count increment on oldDocument tha t was added |
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3131 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient() | 3118 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient() |
3132 { | 3119 { |
3133 #if ENABLE(WEB_AUDIO) | 3120 #if ENABLE(WEB_AUDIO) |
3134 if (m_audioSourceNode) | 3121 if (m_audioSourceNode) |
3135 m_audioSourceNode->lock(); | 3122 m_audioSourceNode->lock(); |
3136 | 3123 |
3137 if (audioSourceProvider()) | 3124 if (audioSourceProvider()) |
3138 audioSourceProvider()->setClient(0); | 3125 audioSourceProvider()->setClient(0); |
3139 #endif | 3126 #endif |
3140 | 3127 |
3128 // With Oilpan, if the media player is explicitly cleared, the | |
3129 // player is detach()ed first to notify dependent objects. | |
3130 // If this media element (and the player's "client") is finalized | |
3131 // at the same time as the media player, no need to explicitly | |
3132 // detach and notify. All heap-residing objects will die at the | |
3133 // same time, and the media player object will handle notification | |
3134 // of the browser process WebMediaPlayer object when finalized. | |
3135 // | |
3136 // To keep code paths regular, we explicitly detach in a non-Oilpan | |
3137 // setting also rather than do it as part of the player's destructor. | |
3138 if (m_player) { | |
3139 // Reset the web layer right away. | |
3140 mediaPlayerSetWebLayer(0); | |
3141 m_player->detach(); | |
3142 } | |
3141 m_player.clear(); | 3143 m_player.clear(); |
3142 | 3144 |
3143 #if ENABLE(WEB_AUDIO) | 3145 #if ENABLE(WEB_AUDIO) |
3144 if (m_audioSourceNode) | 3146 if (m_audioSourceNode) |
3145 m_audioSourceNode->unlock(); | 3147 m_audioSourceNode->unlock(); |
3146 #endif | 3148 #endif |
3147 } | 3149 } |
3148 | 3150 |
3149 void HTMLMediaElement::clearMediaPlayer(int flags) | 3151 void HTMLMediaElement::clearMediaPlayer(int flags) |
3150 { | 3152 { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3428 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3430 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
3429 { | 3431 { |
3430 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3432 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
3431 configureMediaControls(); | 3433 configureMediaControls(); |
3432 | 3434 |
3433 return 0; | 3435 return 0; |
3434 } | 3436 } |
3435 | 3437 |
3436 void HTMLMediaElement::createMediaPlayer() | 3438 void HTMLMediaElement::createMediaPlayer() |
3437 { | 3439 { |
3440 closeMediaSource(); | |
3441 | |
3442 clearMediaPlayerAndAudioSourceProviderClient(); | |
acolwell GONE FROM CHROMIUM
2014/06/03 19:23:08
Why is this done here? I believe this needs to occ
sof
2014/06/03 19:52:44
"this" == closeMediaSource() ? clearMediaPlayerAnd
| |
3443 | |
3438 #if ENABLE(WEB_AUDIO) | 3444 #if ENABLE(WEB_AUDIO) |
3439 if (m_audioSourceNode) | 3445 if (m_audioSourceNode) |
3440 m_audioSourceNode->lock(); | 3446 m_audioSourceNode->lock(); |
3441 #endif | 3447 #endif |
3442 | 3448 |
3443 closeMediaSource(); | |
3444 | |
3445 m_player = MediaPlayer::create(this); | 3449 m_player = MediaPlayer::create(this); |
3446 | 3450 |
3447 #if ENABLE(WEB_AUDIO) | 3451 #if ENABLE(WEB_AUDIO) |
3448 if (m_audioSourceNode) { | 3452 if (m_audioSourceNode) { |
3449 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. | 3453 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. |
3450 if (audioSourceProvider()) | 3454 if (audioSourceProvider()) |
3451 audioSourceProvider()->setClient(m_audioSourceNode); | 3455 audioSourceProvider()->setClient(m_audioSourceNode); |
3452 | 3456 |
3453 m_audioSourceNode->unlock(); | 3457 m_audioSourceNode->unlock(); |
3454 } | 3458 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3514 | 3518 |
3515 // Otherwise, let controller be a newly created MediaController. | 3519 // Otherwise, let controller be a newly created MediaController. |
3516 setControllerInternal(MediaController::create(Node::executionContext())); | 3520 setControllerInternal(MediaController::create(Node::executionContext())); |
3517 } | 3521 } |
3518 | 3522 |
3519 MediaController* HTMLMediaElement::controller() const | 3523 MediaController* HTMLMediaElement::controller() const |
3520 { | 3524 { |
3521 return m_mediaController.get(); | 3525 return m_mediaController.get(); |
3522 } | 3526 } |
3523 | 3527 |
3524 void HTMLMediaElement::setController(PassRefPtr<MediaController> controller) | 3528 void HTMLMediaElement::setController(PassRefPtrWillBeRawPtr<MediaController> con troller) |
3525 { | 3529 { |
3526 // 4.8.10.11.2 Media controllers: controller attribute. | 3530 // 4.8.10.11.2 Media controllers: controller attribute. |
3527 // On setting, it must first remove the element's mediagroup attribute, if a ny, | 3531 // On setting, it must first remove the element's mediagroup attribute, if a ny, |
3528 removeAttribute(mediagroupAttr); | 3532 removeAttribute(mediagroupAttr); |
3529 // and then set the current media controller to the given value. | 3533 // and then set the current media controller to the given value. |
3530 setControllerInternal(controller); | 3534 setControllerInternal(controller); |
3531 } | 3535 } |
3532 | 3536 |
3533 void HTMLMediaElement::setControllerInternal(PassRefPtr<MediaController> control ler) | 3537 void HTMLMediaElement::setControllerInternal(PassRefPtrWillBeRawPtr<MediaControl ler> controller) |
3534 { | 3538 { |
3535 if (m_mediaController) | 3539 if (m_mediaController) |
3536 m_mediaController->removeMediaElement(this); | 3540 m_mediaController->removeMediaElement(this); |
3537 | 3541 |
3538 m_mediaController = controller; | 3542 m_mediaController = controller; |
3539 | 3543 |
3540 if (m_mediaController) | 3544 if (m_mediaController) |
3541 m_mediaController->addMediaElement(this); | 3545 m_mediaController->addMediaElement(this); |
3542 } | 3546 } |
3543 | 3547 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3627 if (webLayer == m_webLayer) | 3631 if (webLayer == m_webLayer) |
3628 return; | 3632 return; |
3629 | 3633 |
3630 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. | 3634 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. |
3631 if (!m_webLayer || !webLayer) | 3635 if (!m_webLayer || !webLayer) |
3632 setNeedsCompositingUpdate(); | 3636 setNeedsCompositingUpdate(); |
3633 | 3637 |
3634 if (m_webLayer) | 3638 if (m_webLayer) |
3635 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 3639 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
3636 m_webLayer = webLayer; | 3640 m_webLayer = webLayer; |
3637 if (m_webLayer) { | 3641 if (m_webLayer) |
3638 GraphicsLayer::registerContentsLayer(m_webLayer); | 3642 GraphicsLayer::registerContentsLayer(m_webLayer); |
3639 } | |
3640 } | 3643 } |
3641 | 3644 |
3642 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) | 3645 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) |
3643 { | 3646 { |
3644 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3647 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3645 } | 3648 } |
3646 | 3649 |
3647 bool HTMLMediaElement::isInteractiveContent() const | 3650 bool HTMLMediaElement::isInteractiveContent() const |
3648 { | 3651 { |
3649 return fastHasAttribute(controlsAttr); | 3652 return fastHasAttribute(controlsAttr); |
3650 } | 3653 } |
3651 | 3654 |
3652 void HTMLMediaElement::defaultEventHandler(Event* event) | 3655 void HTMLMediaElement::defaultEventHandler(Event* event) |
3653 { | 3656 { |
3654 if (event->type() == EventTypeNames::focusin) { | 3657 if (event->type() == EventTypeNames::focusin) { |
3655 if (hasMediaControls()) | 3658 if (hasMediaControls()) |
3656 mediaControls()->mediaElementFocused(); | 3659 mediaControls()->mediaElementFocused(); |
3657 } | 3660 } |
3658 HTMLElement::defaultEventHandler(event); | 3661 HTMLElement::defaultEventHandler(event); |
3659 } | 3662 } |
3660 | 3663 |
3661 void HTMLMediaElement::trace(Visitor* visitor) | 3664 void HTMLMediaElement::trace(Visitor* visitor) |
3662 { | 3665 { |
3663 visitor->trace(m_error); | 3666 visitor->trace(m_error); |
3664 visitor->trace(m_currentSourceNode); | 3667 visitor->trace(m_currentSourceNode); |
3665 visitor->trace(m_nextChildNodeToConsider); | 3668 visitor->trace(m_nextChildNodeToConsider); |
3669 visitor->trace(m_player); | |
3666 visitor->trace(m_textTracks); | 3670 visitor->trace(m_textTracks); |
3667 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3671 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3672 visitor->trace(m_mediaController); | |
3668 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3673 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3674 MediaPlayerClient::trace(visitor); | |
3669 HTMLElement::trace(visitor); | 3675 HTMLElement::trace(visitor); |
3670 } | 3676 } |
3671 | 3677 |
3672 } | 3678 } |
OLD | NEW |