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

Side by Side Diff: Source/core/html/track/CueTimeline.cpp

Issue 939193002: Remove TextTrackCue::notifyRegionWhenRemovingDisplayTree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Hoist removeDisplayTree-call from setIsActive. Created 5 years, 10 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 | « no previous file | Source/core/html/track/TextTrackCue.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/html/track/CueTimeline.h" 6 #include "core/html/track/CueTimeline.h"
7 7
8 #include "core/events/Event.h" 8 #include "core/events/Event.h"
9 #include "core/html/HTMLMediaElement.h" 9 #include "core/html/HTMLMediaElement.h"
10 #include "core/html/HTMLTrackElement.h" 10 #include "core/html/HTMLTrackElement.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 void CueTimeline::removeCue(TextTrack*, PassRefPtrWillBeRawPtr<TextTrackCue> cue ) 56 void CueTimeline::removeCue(TextTrack*, PassRefPtrWillBeRawPtr<TextTrackCue> cue )
57 { 57 {
58 // Negative duration cues need to be treated in the interval tree as 58 // Negative duration cues need to be treated in the interval tree as
59 // zero-length cues. 59 // zero-length cues.
60 double endTime = std::max(cue->startTime(), cue->endTime()); 60 double endTime = std::max(cue->startTime(), cue->endTime());
61 61
62 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c ue.get()); 62 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c ue.get());
63 m_cueTree.remove(interval); 63 m_cueTree.remove(interval);
64 64
65 // Since the cue will be removed from the media element and likely the
66 // TextTrack might also be destructed, notifying the region of the cue
67 // removal shouldn't be done.
68 cue->notifyRegionWhenRemovingDisplayTree(false);
69
70 size_t index = m_currentlyActiveCues.find(interval); 65 size_t index = m_currentlyActiveCues.find(interval);
71 if (index != kNotFound) { 66 if (index != kNotFound) {
72 m_currentlyActiveCues.remove(index); 67 m_currentlyActiveCues.remove(index);
73 cue->setIsActive(false); 68 cue->setIsActive(false);
69 // Since the cue will be removed from the media element and likely the
70 // TextTrack might also be destructed, notifying the region of the cue
71 // removal shouldn't be done.
72 cue->removeDisplayTree(TextTrackCue::DontNotifyRegion);
74 } 73 }
75 cue->removeDisplayTree();
76 updateActiveCues(mediaElement().currentTime()); 74 updateActiveCues(mediaElement().currentTime());
77
78 cue->notifyRegionWhenRemovingDisplayTree(true);
79 } 75 }
80 76
81 static bool trackIndexCompare(TextTrack* a, TextTrack* b) 77 static bool trackIndexCompare(TextTrack* a, TextTrack* b)
82 { 78 {
83 return a->trackIndex() - b->trackIndex() < 0; 79 return a->trackIndex() - b->trackIndex() < 0;
84 } 80 }
85 81
86 static bool eventTimeCueCompare(const std::pair<double, TextTrackCue*>& a, const std::pair<double, TextTrackCue*>& b) 82 static bool eventTimeCueCompare(const std::pair<double, TextTrackCue*>& a, const std::pair<double, TextTrackCue*>& b)
87 { 83 {
88 // 12 - Sort the tasks in events in ascending time order (tasks with earlier 84 // 12 - Sort the tasks in events in ascending time order (tasks with earlier
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 308 }
313 } 309 }
314 310
315 // 16 - Set the text track cue active flag of all the cues in the current 311 // 16 - Set the text track cue active flag of all the cues in the current
316 // cues, and unset the text track cue active flag of all the cues in the 312 // cues, and unset the text track cue active flag of all the cues in the
317 // other cues. 313 // other cues.
318 for (size_t i = 0; i < currentCuesSize; ++i) 314 for (size_t i = 0; i < currentCuesSize; ++i)
319 currentCues[i].data()->setIsActive(true); 315 currentCues[i].data()->setIsActive(true);
320 316
321 for (size_t i = 0; i < previousCuesSize; ++i) { 317 for (size_t i = 0; i < previousCuesSize; ++i) {
322 if (!currentCues.contains(previousCues[i])) 318 if (!currentCues.contains(previousCues[i])) {
323 previousCues[i].data()->setIsActive(false); 319 TextTrackCue* cue = previousCues[i].data();
320 cue->setIsActive(false);
321 cue->removeDisplayTree();
322 }
324 } 323 }
325 324
326 // Update the current active cues. 325 // Update the current active cues.
327 m_currentlyActiveCues = currentCues; 326 m_currentlyActiveCues = currentCues;
328 327
329 if (activeSetChanged) 328 if (activeSetChanged)
330 mediaElement.updateTextTrackDisplay(); 329 mediaElement.updateTextTrackDisplay();
331 } 330 }
332 331
333 void CueTimeline::beginIgnoringUpdateRequests() 332 void CueTimeline::beginIgnoringUpdateRequests()
334 { 333 {
335 ++m_ignoreUpdate; 334 ++m_ignoreUpdate;
336 } 335 }
337 336
338 void CueTimeline::endIgnoringUpdateRequests() 337 void CueTimeline::endIgnoringUpdateRequests()
339 { 338 {
340 ASSERT(m_ignoreUpdate); 339 ASSERT(m_ignoreUpdate);
341 --m_ignoreUpdate; 340 --m_ignoreUpdate;
342 if (!m_ignoreUpdate && mediaElement().inActiveDocument()) 341 if (!m_ignoreUpdate && mediaElement().inActiveDocument())
343 updateActiveCues(mediaElement().currentTime()); 342 updateActiveCues(mediaElement().currentTime());
344 } 343 }
345 344
346 DEFINE_TRACE(CueTimeline) 345 DEFINE_TRACE(CueTimeline)
347 { 346 {
348 visitor->trace(m_mediaElement); 347 visitor->trace(m_mediaElement);
349 } 348 }
350 349
351 } // namespace blink 350 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/track/TextTrackCue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698