bool TextTrackCueList::add(PassRefPtrWillBeRawPtr<TextTrackCue> cue) { ASSERT(cue->startTime() >= 0); ASSERT(cue->endTime() >= 0); return add(cue, 0, m_list.size()); }
static bool cueIsBefore(const TextTrackCue* cue, PassRefPtrWillBeRawPtr<TextTrackCue> otherCue) { if (cue->startTime() < otherCue->startTime()) return true; return cue->startTime() == otherCue->startTime() && cue->endTime() > otherCue->endTime(); }
void CueTimeline::addCueInternal(PassRefPtrWillBeRawPtr<TextTrackCue> cue) { // Negative duration cues need be treated in the interval tree as // zero-length cues. double endTime = std::max(cue->startTime(), cue->endTime()); CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get()); if (!m_cueTree.contains(interval)) m_cueTree.add(interval); }
bool TextTrackCueList::add(PassRefPtrWillBeRawPtr<TextTrackCue> cue) { ASSERT(cue->startTime() >= 0); ASSERT(cue->endTime() >= 0); // Maintain text track cue order: // https://html.spec.whatwg.org/#text-track-cue-order size_t index = findInsertionIndex(cue.get()); // FIXME: The cue should not exist in the list in the first place. if (!m_list.isEmpty() && (index > 0) && (m_list[index - 1].get() == cue.get())) return false; m_list.insert(index, cue); invalidateCueIndex(index); return true; }
void CueTimeline::removeCueInternal(PassRefPtrWillBeRawPtr<TextTrackCue> cue) { // Negative duration cues need to be treated in the interval tree as // zero-length cues. double endTime = std::max(cue->startTime(), cue->endTime()); CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get()); m_cueTree.remove(interval); size_t index = m_currentlyActiveCues.find(interval); if (index != kNotFound) { ASSERT(cue->isActive()); m_currentlyActiveCues.remove(index); cue->setIsActive(false); // Since the cue will be removed from the media element and likely the // TextTrack might also be destructed, notifying the region of the cue // removal shouldn't be done. cue->removeDisplayTree(TextTrackCue::DontNotifyRegion); } }