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

Unified Diff: Source/core/html/track/TextTrack.cpp

Issue 979743003: Assert some invariants in TextTrack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/track/TextTrack.cpp
diff --git a/Source/core/html/track/TextTrack.cpp b/Source/core/html/track/TextTrack.cpp
index 08dca6f66b46981e8667e8c09367617caab2491b..777ba64eda2e7f112c74044ebce1f89bca3c1f8a 100644
--- a/Source/core/html/track/TextTrack.cpp
+++ b/Source/core/html/track/TextTrack.cpp
@@ -288,12 +288,20 @@ void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState)
// 1. If the given cue is not currently listed in the method's TextTrack
// object's text track's text track list of cues, then throw a NotFoundError exception.
- // 2. Remove cue from the method's TextTrack object's text track's text track list of cues.
- if (cue->track() != this || !m_cues || !m_cues->remove(cue)) {
+ if (cue->track() != this) {
exceptionState.throwDOMException(NotFoundError, "The specified cue is not listed in the TextTrack's list of cues.");
return;
}
+ // cue->track() == this implies that cue is in this track's list of cues,
+ // so this track should have a list of cues and the cue being removed
+ // should be in it.
+ ASSERT(m_cues);
+
+ // 2. Remove cue from the method's TextTrack object's text track's text track list of cues.
+ bool wasRemoved = m_cues->remove(cue);
+ ASSERT_UNUSED(wasRemoved, wasRemoved);
+
// If the cue is active, a timeline needs to be available.
ASSERT(!cue->isActive() || cueTimeline());
@@ -384,9 +392,13 @@ void TextTrack::cueWillChange(TextTrackCue* cue)
void TextTrack::cueDidChange(TextTrackCue* cue)
{
+ // This method is called through cue->track(), which should imply that this
+ // track has a list of cues.
+ ASSERT(m_cues && cue->track() == this);
+
// Make sure the TextTrackCueList order is up-to-date.
// FIXME: Only need to do this if the change was to any of the timestamps.
- ensureTextTrackCueList()->updateCueIndex(cue);
+ m_cues->updateCueIndex(cue);
// Since a call to cueDidChange is always preceded by a call to
// cueWillChange, the cue should no longer be active when we reach this
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698