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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 331 |
335 if (m_mediaController) { | 332 if (m_mediaController) { |
336 m_mediaController->removeMediaElement(this); | 333 m_mediaController->removeMediaElement(this); |
337 m_mediaController = nullptr; | 334 m_mediaController = nullptr; |
338 } | 335 } |
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(); |
384 #endif | 364 #endif |
385 } | 365 } |
386 | 366 |
387 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 367 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
388 { | 368 { |
389 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); | 369 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); |
390 | 370 |
391 if (m_shouldDelayLoadEvent) { | 371 if (m_shouldDelayLoadEvent) { |
392 document().incrementLoadEventDelayCount(); | 372 document().incrementLoadEventDelayCount(); |
(...skipping 2738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3131 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient() | 3111 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient() |
3132 { | 3112 { |
3133 #if ENABLE(WEB_AUDIO) | 3113 #if ENABLE(WEB_AUDIO) |
3134 if (m_audioSourceNode) | 3114 if (m_audioSourceNode) |
3135 m_audioSourceNode->lock(); | 3115 m_audioSourceNode->lock(); |
3136 | 3116 |
3137 if (audioSourceProvider()) | 3117 if (audioSourceProvider()) |
3138 audioSourceProvider()->setClient(0); | 3118 audioSourceProvider()->setClient(0); |
3139 #endif | 3119 #endif |
3140 | 3120 |
| 3121 // With Oilpan, if the media player is explicitly cleared, the |
| 3122 // player is detach()ed first to notify dependent objects. |
| 3123 // If this media element (and the player's "client") is finalized |
| 3124 // at the same time as the media player, no need to explicitly |
| 3125 // detach and notify. All heap-residing objects will die at the |
| 3126 // same time, and the media player object will handle notification |
| 3127 // of the browser process WebMediaPlayer object when finalized. |
| 3128 // |
| 3129 // To keep code paths regular, we explicitly detach in a non-Oilpan |
| 3130 // setting also rather than do it as part of the player's destructor. |
| 3131 if (m_player) { |
| 3132 // Reset the web layer right away. |
| 3133 mediaPlayerSetWebLayer(0); |
| 3134 m_player->detach(); |
| 3135 } |
3141 m_player.clear(); | 3136 m_player.clear(); |
3142 | 3137 |
3143 #if ENABLE(WEB_AUDIO) | 3138 #if ENABLE(WEB_AUDIO) |
3144 if (m_audioSourceNode) | 3139 if (m_audioSourceNode) |
3145 m_audioSourceNode->unlock(); | 3140 m_audioSourceNode->unlock(); |
3146 #endif | 3141 #endif |
3147 } | 3142 } |
3148 | 3143 |
3149 void HTMLMediaElement::clearMediaPlayer(int flags) | 3144 void HTMLMediaElement::clearMediaPlayer(int flags) |
3150 { | 3145 { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3428 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3423 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
3429 { | 3424 { |
3430 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3425 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
3431 configureMediaControls(); | 3426 configureMediaControls(); |
3432 | 3427 |
3433 return 0; | 3428 return 0; |
3434 } | 3429 } |
3435 | 3430 |
3436 void HTMLMediaElement::createMediaPlayer() | 3431 void HTMLMediaElement::createMediaPlayer() |
3437 { | 3432 { |
| 3433 closeMediaSource(); |
| 3434 |
| 3435 clearMediaPlayerAndAudioSourceProviderClient(); |
| 3436 |
3438 #if ENABLE(WEB_AUDIO) | 3437 #if ENABLE(WEB_AUDIO) |
3439 if (m_audioSourceNode) | 3438 if (m_audioSourceNode) |
3440 m_audioSourceNode->lock(); | 3439 m_audioSourceNode->lock(); |
3441 #endif | 3440 #endif |
3442 | 3441 |
3443 closeMediaSource(); | |
3444 | |
3445 m_player = MediaPlayer::create(this); | 3442 m_player = MediaPlayer::create(this); |
3446 | 3443 |
3447 #if ENABLE(WEB_AUDIO) | 3444 #if ENABLE(WEB_AUDIO) |
3448 if (m_audioSourceNode) { | 3445 if (m_audioSourceNode) { |
3449 // When creating the player, make sure its AudioSourceProvider knows abo
ut the client. | 3446 // When creating the player, make sure its AudioSourceProvider knows abo
ut the client. |
3450 if (audioSourceProvider()) | 3447 if (audioSourceProvider()) |
3451 audioSourceProvider()->setClient(m_audioSourceNode); | 3448 audioSourceProvider()->setClient(m_audioSourceNode); |
3452 | 3449 |
3453 m_audioSourceNode->unlock(); | 3450 m_audioSourceNode->unlock(); |
3454 } | 3451 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3627 if (webLayer == m_webLayer) | 3624 if (webLayer == m_webLayer) |
3628 return; | 3625 return; |
3629 | 3626 |
3630 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. | 3627 // 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) | 3628 if (!m_webLayer || !webLayer) |
3632 setNeedsCompositingUpdate(); | 3629 setNeedsCompositingUpdate(); |
3633 | 3630 |
3634 if (m_webLayer) | 3631 if (m_webLayer) |
3635 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 3632 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
3636 m_webLayer = webLayer; | 3633 m_webLayer = webLayer; |
3637 if (m_webLayer) { | 3634 if (m_webLayer) |
3638 GraphicsLayer::registerContentsLayer(m_webLayer); | 3635 GraphicsLayer::registerContentsLayer(m_webLayer); |
3639 } | |
3640 } | 3636 } |
3641 | 3637 |
3642 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe
diaSource) | 3638 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe
diaSource) |
3643 { | 3639 { |
3644 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3640 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3645 } | 3641 } |
3646 | 3642 |
3647 bool HTMLMediaElement::isInteractiveContent() const | 3643 bool HTMLMediaElement::isInteractiveContent() const |
3648 { | 3644 { |
3649 return fastHasAttribute(controlsAttr); | 3645 return fastHasAttribute(controlsAttr); |
3650 } | 3646 } |
3651 | 3647 |
3652 void HTMLMediaElement::defaultEventHandler(Event* event) | 3648 void HTMLMediaElement::defaultEventHandler(Event* event) |
3653 { | 3649 { |
3654 if (event->type() == EventTypeNames::focusin) { | 3650 if (event->type() == EventTypeNames::focusin) { |
3655 if (hasMediaControls()) | 3651 if (hasMediaControls()) |
3656 mediaControls()->mediaElementFocused(); | 3652 mediaControls()->mediaElementFocused(); |
3657 } | 3653 } |
3658 HTMLElement::defaultEventHandler(event); | 3654 HTMLElement::defaultEventHandler(event); |
3659 } | 3655 } |
3660 | 3656 |
3661 void HTMLMediaElement::trace(Visitor* visitor) | 3657 void HTMLMediaElement::trace(Visitor* visitor) |
3662 { | 3658 { |
3663 visitor->trace(m_error); | 3659 visitor->trace(m_error); |
3664 visitor->trace(m_currentSourceNode); | 3660 visitor->trace(m_currentSourceNode); |
3665 visitor->trace(m_nextChildNodeToConsider); | 3661 visitor->trace(m_nextChildNodeToConsider); |
| 3662 visitor->trace(m_player); |
3666 visitor->trace(m_textTracks); | 3663 visitor->trace(m_textTracks); |
3667 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3664 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3668 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3665 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
| 3666 MediaPlayerClient::trace(visitor); |
3669 HTMLElement::trace(visitor); | 3667 HTMLElement::trace(visitor); |
3670 } | 3668 } |
3671 | 3669 |
3672 } | 3670 } |
OLD | NEW |