Chromium Code Reviews| Index: Source/core/html/track/TextTrack.cpp |
| diff --git a/Source/core/html/track/TextTrack.cpp b/Source/core/html/track/TextTrack.cpp |
| index 54f2cbdec176b2a2c6a4aefe59f6fb5adc5abd34..52a78446a156ade1fb3174e68ccc056a1252d6e0 100644 |
| --- a/Source/core/html/track/TextTrack.cpp |
| +++ b/Source/core/html/track/TextTrack.cpp |
| @@ -234,17 +234,18 @@ void TextTrack::addCue(PassRefPtrWillBeRawPtr<TextTrackCue> prpCue) |
| if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->startTime() < 0 || cue->endTime() < 0) |
| return; |
| - // 4.8.10.12.5 Text track API |
| + // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrack-addcue |
| // The addCue(cue) method of TextTrack objects, when invoked, must run the following steps: |
| - // 1. If the given cue is in a text track list of cues, then remove cue from that text track |
| - // list of cues. |
| - TextTrack* cueTrack = cue->track(); |
| - if (cueTrack && cueTrack != this) |
| + // (Steps 1 and 2 - pertaining to association of rendering rules - are not implemented.) |
| + |
| + // 3. If the given cue is in a text track list of cues, then remove cue |
| + // from that text track list of cues. |
| + if (TextTrack* cueTrack = cue->track()) |
| cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION); |
| - // 2. Add cue to the method's TextTrack object's text track's text track list of cues. |
| + // 4. Add cue to the method's TextTrack object's text track's text track list of cues. |
| cue->setTrack(this); |
| ensureTextTrackCueList()->add(cue); |
| @@ -257,20 +258,15 @@ void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) |
| if (!cue) |
| return; |
| - // 4.8.10.12.5 Text track API |
| + // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrack-removecue |
| // The removeCue(cue) method of TextTrack objects, when invoked, must run the following steps: |
| // 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. |
| - if (cue->track() != this) { |
| - exceptionState.throwDOMException(NotFoundError, "The specified cue is not listed in the TextTrack's list of cues."); |
| - return; |
| - } |
| - |
| // 2. Remove cue from the method's TextTrack object's text track's text track list of cues. |
| - if (!m_cues || !m_cues->remove(cue)) { |
|
philipj_slow
2015/02/23 13:32:13
If this shouldn't be possible, can we assert it in
fs
2015/02/23 14:04:49
Yes. There're a few of these invariants - in this
|
| - exceptionState.throwDOMException(InvalidStateError, "Failed to remove the specified cue."); |
| + if (cue->track() != this || !m_cues || !m_cues->remove(cue)) { |
| + exceptionState.throwDOMException(NotFoundError, "The specified cue is not listed in the TextTrack's list of cues."); |
| return; |
| } |