Exemplo n.º 1
0
void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue)
{
    if (!prpCue)
        return;

    RefPtr<TextTrackCue> cue = prpCue;

    // TODO(93143): Add spec-compliant behavior for negative time values.
    if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->startTime() < 0 || cue->endTime() < 0)
        return;

    // 4.8.10.12.5 Text track API

    // 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)
        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.
    cue->setTrack(this);
    ensureTextTrackCueList()->add(cue);
    
    if (m_client)
        m_client->textTrackAddCue(this, cue.get());
}
Exemplo n.º 2
0
void TextTrack::addCue(TextTrackCue* cue)
{
    ASSERT(cue);

    // TODO(93143): Add spec-compliant behavior for negative time values.
    if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->startTime() < 0 || cue->endTime() < 0)
        return;

    // 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:

    // (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, ASSERT_NO_EXCEPTION);

    // 4. Add cue to the method's TextTrack object's text track's text track list of cues.
    cue->setTrack(this);
    ensureTextTrackCueList()->add(cue);

    if (cueTimeline() && m_mode != disabledKeyword())
        cueTimeline()->addCue(this, cue);
}
Exemplo n.º 3
0
void TextTrack::cueDidChange(TextTrackCue* cue)
{
    if (!m_client)
        return;

    // Make sure the TextTrackCueList order is up-to-date.
    ensureTextTrackCueList()->updateCueIndex(cue);

    // ... and add it back again.
    m_client->textTrackAddCue(this, cue);
}
Exemplo n.º 4
0
TextTrackCueList* TextTrack::cues()
{
    // 4.8.10.12.5 If the text track mode ... is not the text track disabled mode,
    // then the cues attribute must return a live TextTrackCueList object ...
    // Otherwise, it must return null. When an object is returned, the
    // same object must be returned each time.
    // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-cues
    if (m_mode != disabledKeyword())
        return ensureTextTrackCueList();
    return nullptr;
}
Exemplo n.º 5
0
void TextTrack::addListOfCues(HeapVector<Member<TextTrackCue>>& listOfNewCues)
{
    TextTrackCueList* cues = ensureTextTrackCueList();

    for (auto& newCue : listOfNewCues) {
        newCue->setTrack(this);
        cues->add(newCue);
    }

    if (cueTimeline() && mode() != disabledKeyword())
        cueTimeline()->addCues(this, cues);
}
Exemplo n.º 6
0
void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec)
{
    if (!prpCue)
        return;

    RefPtr<TextTrackCue> cue = prpCue;

    // 4.7.10.12.6 Text tracks exposing in-band metadata
    // The UA will use DataCue to expose only text track cue objects that belong to a text track that has a text
    // track kind of metadata.
    // If a DataCue is added to a TextTrack via the addCue() method but the text track does not have its text
    // track kind set to metadata, throw a InvalidNodeTypeError exception and don't add the cue to the TextTrackList
    // of the TextTrack.
    if (cue->cueType() == TextTrackCue::Data && kind() != metadataKeyword()) {
        ec = INVALID_NODE_TYPE_ERR;
        return;
    }

    // TODO(93143): Add spec-compliant behavior for negative time values.
    if (!cue->startMediaTime().isValid() || !cue->endMediaTime().isValid() || cue->startMediaTime() < MediaTime::zeroTime() || cue->endMediaTime() < MediaTime::zeroTime())
        return;

    // 4.8.10.12.5 Text track API

    // 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)
        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.
    cue->setTrack(this);
    ensureTextTrackCueList()->add(cue);
    
    if (m_client)
        m_client->textTrackAddCue(this, cue.get());
}
Exemplo n.º 7
0
void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec)
{
    if (!prpCue)
        return;

    RefPtr<TextTrackCue> cue = prpCue;

    // TODO(93143): Add spec-compliant behavior for negative time values.
    if (isnan(cue->startTime()) || isnan(cue->endTime()) || cue->startTime() < 0 || cue->endTime() < 0)
        return;

    // 4.8.10.12.4 Text track API

    // The addCue(cue) method of TextTrack objects, when invoked, must run the following steps:

    // 1. If the given cue is already associated with a text track other than 
    // the method's TextTrack object's text track, then throw an InvalidStateError
    // exception and abort these steps.
    TextTrack* cueTrack = cue->track();
    if (cueTrack && cueTrack != this) {
        ec = INVALID_STATE_ERR;
        return;
    }

    // 2. Associate cue with the method's TextTrack object's text track, if it is 
    // not currently associated with a text track.
    cue->setTrack(this);

    // 3. If the given cue is already listed in the method's TextTrack object's text
    // track's text track list of cues, then throw an InvalidStateError exception.
    // 4. Add cue to the method's TextTrack object's text track's text track list of cues.
    if (!ensureTextTrackCueList()->add(cue)) {
        ec = INVALID_STATE_ERR;
        return;
    }
    
    if (m_client)
        m_client->textTrackAddCue(this, cue.get());
}