Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 177243018: Prevent 'removetrack' events from firing when all inband text tracks are removed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove console messages Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/track/InbandTextTrack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 // a task to fire a simple event named abort at the media element. 650 // a task to fire a simple event named abort at the media element.
651 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) 651 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE)
652 scheduleEvent(EventTypeNames::abort); 652 scheduleEvent(EventTypeNames::abort);
653 653
654 closeMediaSource(); 654 closeMediaSource();
655 655
656 createMediaPlayer(); 656 createMediaPlayer();
657 657
658 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps 658 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps
659 if (m_networkState != NETWORK_EMPTY) { 659 if (m_networkState != NETWORK_EMPTY) {
660 // 4.1 - Queue a task to fire a simple event named emptied at the media element.
661 scheduleEvent(EventTypeNames::emptied);
662
663 // 4.2 - If a fetching process is in progress for the media element, the user agent should stop it.
660 m_networkState = NETWORK_EMPTY; 664 m_networkState = NETWORK_EMPTY;
665
666 // 4.3 - Forget the media element's media-resource-specific tracks.
667 forgetResourceSpecificTracks();
668
669 // 4.4 - If readyState is not set to HAVE_NOTHING, then set it to that s tate.
661 m_readyState = HAVE_NOTHING; 670 m_readyState = HAVE_NOTHING;
662 m_readyStateMaximum = HAVE_NOTHING; 671 m_readyStateMaximum = HAVE_NOTHING;
672
673 // 4.5 - If the paused attribute is false, then set it to true.
674 m_paused = true;
675
676 // 4.6 - If seeking is true, set it to false.
677 m_seeking = false;
678
679 // 4.7 - Set the current playback position to 0.
680 // Set the official playback position to 0.
681 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element.
682 // FIXME: Add support for firing this event.
683
684 // 4.8 - Set the initial playback position to 0.
685 // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call
686 // above.
663 refreshCachedTime(); 687 refreshCachedTime();
664 m_paused = true;
665 m_seeking = false;
666 invalidateCachedTime(); 688 invalidateCachedTime();
667 scheduleEvent(EventTypeNames::emptied); 689
690 // 4.9 - Set the timeline offset to Not-a-Number (NaN).
691 // 4.10 - Update the duration attribute to Not-a-Number (NaN).
692
693
668 updateMediaController(); 694 updateMediaController();
669 if (RuntimeEnabledFeatures::videoTrackEnabled()) 695 if (RuntimeEnabledFeatures::videoTrackEnabled())
670 updateActiveTextTrackCues(0); 696 updateActiveTextTrackCues(0);
671 } 697 }
672 698
673 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. 699 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute.
674 setPlaybackRate(defaultPlaybackRate()); 700 setPlaybackRate(defaultPlaybackRate());
675 701
676 // 6 - Set the error attribute to null and the autoplaying flag to true. 702 // 6 - Set the error attribute to null and the autoplaying flag to true.
677 m_error = nullptr; 703 m_error = nullptr;
678 m_autoplaying = true; 704 m_autoplaying = true;
679 705
680 // 7 - Invoke the media element's resource selection algorithm. 706 // 7 - Invoke the media element's resource selection algorithm.
681 707
682 // 8 - Note: Playback of any previously playing media resource for this elem ent stops. 708 // 8 - Note: Playback of any previously playing media resource for this elem ent stops.
683 709
684 // The resource selection algorithm 710 // The resource selection algorithm
685 // 1 - Set the networkState to NETWORK_NO_SOURCE 711 // 1 - Set the networkState to NETWORK_NO_SOURCE
686 m_networkState = NETWORK_NO_SOURCE; 712 m_networkState = NETWORK_NO_SOURCE;
687 713
688 // 2 - Asynchronously await a stable state. 714 // 2 - Asynchronously await a stable state.
689 715
690 m_playedTimeRanges = TimeRanges::create(); 716 m_playedTimeRanges = TimeRanges::create();
717
718 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above
719 // so they are closer to the relevant spec steps.
691 m_lastSeekTime = 0; 720 m_lastSeekTime = 0;
692 m_duration = numeric_limits<double>::quiet_NaN(); 721 m_duration = numeric_limits<double>::quiet_NaN();
693 722
694 // The spec doesn't say to block the load event until we actually run the as ynchronous section 723 // The spec doesn't say to block the load event until we actually run the as ynchronous section
695 // algorithm, but do it now because we won't start that until after the time r fires and the 724 // algorithm, but do it now because we won't start that until after the time r fires and the
696 // event may have already fired by then. 725 // event may have already fired by then.
697 setShouldDelayLoadEvent(true); 726 setShouldDelayLoadEvent(true);
698 727
699 configureMediaControls(); 728 configureMediaControls();
700 } 729 }
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 1380
1352 // 4.8.10.5 1381 // 4.8.10.5
1353 // 6 - Reaching this step indicates that the media resource failed to load o r that the given 1382 // 6 - Reaching this step indicates that the media resource failed to load o r that the given
1354 // URL could not be resolved. In one atomic operation, run the following ste ps: 1383 // URL could not be resolved. In one atomic operation, run the following ste ps:
1355 1384
1356 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to 1385 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to
1357 // MEDIA_ERR_SRC_NOT_SUPPORTED. 1386 // MEDIA_ERR_SRC_NOT_SUPPORTED.
1358 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); 1387 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
1359 1388
1360 // 6.2 - Forget the media element's media-resource-specific text tracks. 1389 // 6.2 - Forget the media element's media-resource-specific text tracks.
1390 forgetResourceSpecificTracks();
1361 1391
1362 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v alue. 1392 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v alue.
1363 m_networkState = NETWORK_NO_SOURCE; 1393 m_networkState = NETWORK_NO_SOURCE;
1364 1394
1365 // 7 - Queue a task to fire a simple event named error at the media element. 1395 // 7 - Queue a task to fire a simple event named error at the media element.
1366 scheduleEvent(EventTypeNames::error); 1396 scheduleEvent(EventTypeNames::error);
1367 1397
1368 closeMediaSource(); 1398 closeMediaSource();
1369 1399
1370 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 1400 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } 1455 }
1426 1456
1427 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) 1457 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error)
1428 { 1458 {
1429 stopPeriodicTimers(); 1459 stopPeriodicTimers();
1430 1460
1431 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1461 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more
1432 // <source> children, schedule the next one 1462 // <source> children, schedule the next one
1433 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { 1463 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) {
1434 1464
1465 // resource selection algorithm
1466 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO M manipulation task source, to fire a simple event named error at the candidate element.
1435 if (m_currentSourceNode) 1467 if (m_currentSourceNode)
1436 m_currentSourceNode->scheduleErrorEvent(); 1468 m_currentSourceNode->scheduleErrorEvent();
1437 else 1469 else
1438 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - error event not sent, <source> was removed"); 1470 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - error event not sent, <source> was removed");
1439 1471
1472 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorit hm says the synchronous section has ended.
1473
1474 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks.
1475 forgetResourceSpecificTracks();
1476
1440 if (havePotentialSourceChild()) { 1477 if (havePotentialSourceChild()) {
1441 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next <source>"); 1478 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next <source>");
1442 scheduleNextSourceChild(); 1479 scheduleNextSourceChild();
1443 } else { 1480 } else {
1444 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - no more <source> elements, waiting"); 1481 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - no more <source> elements, waiting");
1445 waitForSourceChange(); 1482 waitForSourceChange();
1446 } 1483 }
1447 1484
1448 return; 1485 return;
1449 } 1486 }
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 void HTMLMediaElement::addTextTrack(TextTrack* track) 2544 void HTMLMediaElement::addTextTrack(TextTrack* track)
2508 { 2545 {
2509 textTracks()->append(track); 2546 textTracks()->append(track);
2510 2547
2511 closeCaptionTracksChanged(); 2548 closeCaptionTracksChanged();
2512 } 2549 }
2513 2550
2514 void HTMLMediaElement::removeTextTrack(TextTrack* track) 2551 void HTMLMediaElement::removeTextTrack(TextTrack* track)
2515 { 2552 {
2516 TrackDisplayUpdateScope scope(this); 2553 TrackDisplayUpdateScope scope(this);
2517 TextTrackCueList* cues = track->cues();
2518 if (cues)
2519 textTrackRemoveCues(track, cues);
2520 m_textTracks->remove(track); 2554 m_textTracks->remove(track);
2521 2555
2522 closeCaptionTracksChanged(); 2556 closeCaptionTracksChanged();
2523 } 2557 }
2524 2558
2525 void HTMLMediaElement::removeAllInbandTracks() 2559 void HTMLMediaElement::forgetResourceSpecificTracks()
2526 { 2560 {
2527 if (!m_textTracks) 2561 if (m_textTracks) {
2528 return; 2562 TrackDisplayUpdateScope scope(this);
2529 2563 m_textTracks->removeAllInbandTracks();
2530 TrackDisplayUpdateScope scope(this); 2564 closeCaptionTracksChanged();
2531 for (int i = m_textTracks->length() - 1; i >= 0; --i) {
2532 TextTrack* track = m_textTracks->item(i);
2533
2534 if (track->trackType() == TextTrack::InBand)
2535 removeTextTrack(track);
2536 } 2565 }
2537 } 2566 }
2538 2567
2539 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) 2568 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState)
2540 { 2569 {
2541 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); 2570 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2542 2571
2543 // 4.8.10.12.4 Text track API 2572 // 4.8.10.12.4 Text track API
2544 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: 2573 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps:
2545 2574
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 m_player.clear(); 3410 m_player.clear();
3382 3411
3383 #if ENABLE(WEB_AUDIO) 3412 #if ENABLE(WEB_AUDIO)
3384 if (m_audioSourceNode) 3413 if (m_audioSourceNode)
3385 m_audioSourceNode->unlock(); 3414 m_audioSourceNode->unlock();
3386 #endif 3415 #endif
3387 } 3416 }
3388 3417
3389 void HTMLMediaElement::clearMediaPlayer(int flags) 3418 void HTMLMediaElement::clearMediaPlayer(int flags)
3390 { 3419 {
3391 removeAllInbandTracks(); 3420 forgetResourceSpecificTracks();
3392 3421
3393 closeMediaSource(); 3422 closeMediaSource();
3394 3423
3395 setMediaKeysInternal(0); 3424 setMediaKeysInternal(0);
3396 3425
3397 clearMediaPlayerAndAudioSourceProviderClient(); 3426 clearMediaPlayerAndAudioSourceProviderClient();
3398 3427
3399 stopPeriodicTimers(); 3428 stopPeriodicTimers();
3400 m_loadTimer.stop(); 3429 m_loadTimer.stop();
3401 3430
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
3898 { 3927 {
3899 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3928 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3900 } 3929 }
3901 3930
3902 bool HTMLMediaElement::isInteractiveContent() const 3931 bool HTMLMediaElement::isInteractiveContent() const
3903 { 3932 {
3904 return fastHasAttribute(controlsAttr); 3933 return fastHasAttribute(controlsAttr);
3905 } 3934 }
3906 3935
3907 } 3936 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/track/InbandTextTrack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698