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

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

Issue 22645014: Merge WebKit r153448 (Optimizes the number of updateTextTrackDisplay calls) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated tests Created 7 years, 2 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') | no next file » | 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 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 if (!currentCues.contains(previousCues[i]) && previousCues[i].data()->is Active()) 1034 if (!currentCues.contains(previousCues[i]) && previousCues[i].data()->is Active())
1035 activeSetChanged = true; 1035 activeSetChanged = true;
1036 1036
1037 for (size_t i = 0; i < currentCuesSize; ++i) { 1037 for (size_t i = 0; i < currentCuesSize; ++i) {
1038 currentCues[i].data()->updateDisplayTree(movieTime); 1038 currentCues[i].data()->updateDisplayTree(movieTime);
1039 1039
1040 if (!currentCues[i].data()->isActive()) 1040 if (!currentCues[i].data()->isActive())
1041 activeSetChanged = true; 1041 activeSetChanged = true;
1042 } 1042 }
1043 1043
1044 if (!activeSetChanged) { 1044 if (!activeSetChanged)
1045 // Even though the active set has not changed, it is possible that the
1046 // the mode of a track has changed from 'hidden' to 'showing' and the
1047 // cues have not yet been rendered.
1048 // Note: don't call updateTextTrackDisplay() unless we have controls bec ause it will
1049 // create them.
1050 if (hasMediaControls())
1051 updateTextTrackDisplay();
1052 return; 1045 return;
1053 }
1054 1046
1055 // 7 - If the time was reached through the usual monotonic increase of the 1047 // 7 - If the time was reached through the usual monotonic increase of the
1056 // current playback position during normal playback, and there are cues in 1048 // current playback position during normal playback, and there are cues in
1057 // other cues that have their text track cue pause-on-exi flag set and that 1049 // other cues that have their text track cue pause-on-exi flag set and that
1058 // either have their text track cue active flag set or are also in missed 1050 // either have their text track cue active flag set or are also in missed
1059 // cues, then immediately pause the media element. 1051 // cues, then immediately pause the media element.
1060 for (size_t i = 0; !m_paused && i < previousCuesSize; ++i) { 1052 for (size_t i = 0; !m_paused && i < previousCuesSize; ++i) {
1061 if (previousCues[i].data()->pauseOnExit() 1053 if (previousCues[i].data()->pauseOnExit()
1062 && previousCues[i].data()->isActive() 1054 && previousCues[i].data()->isActive()
1063 && !currentCues.contains(previousCues[i])) 1055 && !currentCues.contains(previousCues[i]))
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1236
1245 // If this is the first added track, create the list of text tra cks. 1237 // If this is the first added track, create the list of text tra cks.
1246 if (!m_textTracks) 1238 if (!m_textTracks)
1247 m_textTracks = TextTrackList::create(this, ActiveDOMObject::sc riptExecutionContext()); 1239 m_textTracks = TextTrackList::create(this, ActiveDOMObject::sc riptExecutionContext());
1248 } 1240 }
1249 break; 1241 break;
1250 } 1242 }
1251 } else if (track->trackType() == TextTrack::AddTrack && track->mode() != Tex tTrack::disabledKeyword()) 1243 } else if (track->trackType() == TextTrack::AddTrack && track->mode() != Tex tTrack::disabledKeyword())
1252 textTrackAddCues(track, track->cues()); 1244 textTrackAddCues(track, track->cues());
1253 1245
1254 configureTextTrackDisplay(); 1246 configureTextTrackDisplay(AssumeVisibleChange);
1255 updateActiveTextTrackCues(currentTime());
1256 } 1247 }
1257 1248
1258 void HTMLMediaElement::textTrackKindChanged(TextTrack* track) 1249 void HTMLMediaElement::textTrackKindChanged(TextTrack* track)
1259 { 1250 {
1260 if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTr ack::subtitlesKeyword() && track->mode() == TextTrack::showingKeyword()) 1251 if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTr ack::subtitlesKeyword() && track->mode() == TextTrack::showingKeyword())
1261 track->setMode(TextTrack::hiddenKeyword()); 1252 track->setMode(TextTrack::hiddenKeyword());
1262 } 1253 }
1263 1254
1264 void HTMLMediaElement::beginIgnoringTrackDisplayUpdateRequests() 1255 void HTMLMediaElement::beginIgnoringTrackDisplayUpdateRequests()
1265 { 1256 {
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 if (audioSourceProvider()) 3461 if (audioSourceProvider())
3471 audioSourceProvider()->setClient(0); 3462 audioSourceProvider()->setClient(0);
3472 #endif 3463 #endif
3473 stopPeriodicTimers(); 3464 stopPeriodicTimers();
3474 m_loadTimer.stop(); 3465 m_loadTimer.stop();
3475 3466
3476 m_pendingActionFlags &= ~flags; 3467 m_pendingActionFlags &= ~flags;
3477 m_loadState = WaitingForSource; 3468 m_loadState = WaitingForSource;
3478 3469
3479 if (m_textTracks) 3470 if (m_textTracks)
3480 configureTextTrackDisplay(); 3471 configureTextTrackDisplay(AssumeNoVisibleChange);
3481 } 3472 }
3482 3473
3483 bool HTMLMediaElement::canSuspend() const 3474 bool HTMLMediaElement::canSuspend() const
3484 { 3475 {
3485 return true; 3476 return true;
3486 } 3477 }
3487 3478
3488 void HTMLMediaElement::stop() 3479 void HTMLMediaElement::stop()
3489 { 3480 {
3490 LOG(Media, "HTMLMediaElement::stop"); 3481 LOG(Media, "HTMLMediaElement::stop");
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
3731 mediaControls()->hide(); 3722 mediaControls()->hide();
3732 return; 3723 return;
3733 } 3724 }
3734 3725
3735 if (!hasMediaControls() && !createMediaControls()) 3726 if (!hasMediaControls() && !createMediaControls())
3736 return; 3727 return;
3737 3728
3738 mediaControls()->show(); 3729 mediaControls()->show();
3739 } 3730 }
3740 3731
3741 void HTMLMediaElement::configureTextTrackDisplay() 3732 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption)
3742 { 3733 {
3743 ASSERT(m_textTracks); 3734 ASSERT(m_textTracks);
3744 LOG(Media, "HTMLMediaElement::configureTextTrackDisplay"); 3735 LOG(Media, "HTMLMediaElement::configureTextTrackDisplay");
3745 3736
3746 if (m_processingPreferenceChange) 3737 if (m_processingPreferenceChange)
3747 return; 3738 return;
3748 3739
3749 bool haveVisibleTextTrack = false; 3740 bool haveVisibleTextTrack = false;
3750 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 3741 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3751 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) { 3742 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
3752 haveVisibleTextTrack = true; 3743 haveVisibleTextTrack = true;
3753 break; 3744 break;
3754 } 3745 }
3755 } 3746 }
3756 3747
3757 if (m_haveVisibleTextTrack == haveVisibleTextTrack) 3748 if (assumption == AssumeNoVisibleChange
3749 && m_haveVisibleTextTrack == haveVisibleTextTrack) {
3750 updateActiveTextTrackCues(currentTime());
3758 return; 3751 return;
3752 }
3759 m_haveVisibleTextTrack = haveVisibleTextTrack; 3753 m_haveVisibleTextTrack = haveVisibleTextTrack;
3760 m_closedCaptionsVisible = m_haveVisibleTextTrack; 3754 m_closedCaptionsVisible = m_haveVisibleTextTrack;
3761 3755
3762 if (!m_haveVisibleTextTrack && !hasMediaControls()) 3756 if (!m_haveVisibleTextTrack && !hasMediaControls())
3763 return; 3757 return;
3764 if (!hasMediaControls() && !createMediaControls()) 3758 if (!hasMediaControls() && !createMediaControls())
3765 return; 3759 return;
3766 3760
3767 mediaControls()->changedClosedCaptionsVisibility(); 3761 mediaControls()->changedClosedCaptionsVisibility();
3768 3762
3769 if (RuntimeEnabledFeatures::videoTrackEnabled()) 3763 if (RuntimeEnabledFeatures::videoTrackEnabled()) {
3764 updateActiveTextTrackCues(currentTime());
3770 updateTextTrackDisplay(); 3765 updateTextTrackDisplay();
3766 }
3771 } 3767 }
3772 3768
3773 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 3769 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
3774 { 3770 {
3775 if (!m_textTracks) 3771 if (!m_textTracks)
3776 return; 3772 return;
3777 3773
3778 // Mark all tracks as not "configured" so that configureTextTracks() 3774 // Mark all tracks as not "configured" so that configureTextTracks()
3779 // will reconsider which tracks to display in light of new user preferences 3775 // will reconsider which tracks to display in light of new user preferences
3780 // (e.g. default tracks should not be displayed if the user has turned off 3776 // (e.g. default tracks should not be displayed if the user has turned off
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 { 3997 {
4002 m_restrictions = NoRestrictions; 3998 m_restrictions = NoRestrictions;
4003 } 3999 }
4004 4000
4005 void HTMLMediaElement::mediaPlayerScheduleLayerUpdate() 4001 void HTMLMediaElement::mediaPlayerScheduleLayerUpdate()
4006 { 4002 {
4007 scheduleLayerUpdate(); 4003 scheduleLayerUpdate();
4008 } 4004 }
4009 4005
4010 } 4006 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698