Changeset 207907 in webkit


Ignore:
Timestamp:
Oct 26, 2016 12:27:20 PM (7 years ago)
Author:
Chris Dumez
Message:

First parameter to TextTrack.addCue() / removeCue() should not be nullable
https://bugs.webkit.org/show_bug.cgi?id=164020

Reviewed by Eric Carlson.

Source/WebCore:

First parameter to TextTrack.addCue() / removeCue() should not be nullable:

Firefox and Chrome agree with the specification.

Test: media/track/texttrack-addCue-null.html

  • html/track/InbandDataTextTrack.cpp:

(WebCore::InbandDataTextTrack::removeDataCue):
(WebCore::InbandDataTextTrack::removeCue):

  • html/track/InbandDataTextTrack.h:
  • html/track/InbandGenericTextTrack.cpp:

(WebCore::InbandGenericTextTrack::addGenericCue):
(WebCore::InbandGenericTextTrack::removeGenericCue):
(WebCore::InbandGenericTextTrack::removeCue):

  • html/track/InbandGenericTextTrack.h:
  • html/track/TextTrack.cpp:

(WebCore::TextTrack::addCue):
(WebCore::TextTrack::removeCue):

  • html/track/TextTrack.h:
  • html/track/TextTrack.idl:

LayoutTests:

Add layout test coverage.

  • media/track/texttrack-addCue-null-expected.txt: Added.
  • media/track/texttrack-addCue-null.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207905 r207907  
     12016-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        First parameter to TextTrack.addCue() / removeCue() should not be nullable
     4        https://bugs.webkit.org/show_bug.cgi?id=164020
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add layout test coverage.
     9
     10        * media/track/texttrack-addCue-null-expected.txt: Added.
     11        * media/track/texttrack-addCue-null.html: Added.
     12
    1132016-10-26  Antoine Quint  <graouts@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r207905 r207907  
     12016-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        First parameter to TextTrack.addCue() / removeCue() should not be nullable
     4        https://bugs.webkit.org/show_bug.cgi?id=164020
     5
     6        Reviewed by Eric Carlson.
     7
     8        First parameter to TextTrack.addCue() / removeCue() should not be nullable:
     9        - https://html.spec.whatwg.org/#texttrack
     10
     11        Firefox and Chrome agree with the specification.
     12
     13        Test: media/track/texttrack-addCue-null.html
     14
     15        * html/track/InbandDataTextTrack.cpp:
     16        (WebCore::InbandDataTextTrack::removeDataCue):
     17        (WebCore::InbandDataTextTrack::removeCue):
     18        * html/track/InbandDataTextTrack.h:
     19        * html/track/InbandGenericTextTrack.cpp:
     20        (WebCore::InbandGenericTextTrack::addGenericCue):
     21        (WebCore::InbandGenericTextTrack::removeGenericCue):
     22        (WebCore::InbandGenericTextTrack::removeCue):
     23        * html/track/InbandGenericTextTrack.h:
     24        * html/track/TextTrack.cpp:
     25        (WebCore::TextTrack::addCue):
     26        (WebCore::TextTrack::removeCue):
     27        * html/track/TextTrack.h:
     28        * html/track/TextTrack.idl:
     29
    1302016-10-26  Antoine Quint  <graouts@apple.com>
    231
  • trunk/Source/WebCore/html/track/InbandDataTextTrack.cpp

    r207720 r207907  
    115115        return;
    116116
    117     RefPtr<DataCue> cue = iter->value;
    118     if (cue) {
     117    if (RefPtr<DataCue> cue = iter->value) {
    119118        LOG(Media, "InbandDataTextTrack::removeDataCue removing cue: start=%s, end=%s\n", toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data());
    120         removeCue(cue.get());
     119        removeCue(*cue);
    121120    }
    122121}
    123122
    124 ExceptionOr<void> InbandDataTextTrack::removeCue(TextTrackCue* cue)
     123ExceptionOr<void> InbandDataTextTrack::removeCue(TextTrackCue& cue)
    125124{
    126     ASSERT(cue->cueType() == TextTrackCue::Data);
     125    ASSERT(cue.cueType() == TextTrackCue::Data);
    127126
    128     m_incompleteCueMap.remove(const_cast<SerializedPlatformRepresentation*>(toDataCue(cue)->platformValue()));
     127    m_incompleteCueMap.remove(const_cast<SerializedPlatformRepresentation*>(toDataCue(&cue)->platformValue()));
    129128
    130129    return InbandTextTrack::removeCue(cue);
  • trunk/Source/WebCore/html/track/InbandDataTextTrack.h

    r207720 r207907  
    5151    void updateDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>) final;
    5252    void removeDataCue(InbandTextTrackPrivate*, const MediaTime& start, const MediaTime& end, PassRefPtr<SerializedPlatformRepresentation>) final;
    53     ExceptionOr<void> removeCue(TextTrackCue*) final;
     53    ExceptionOr<void> removeCue(TextTrackCue&) final;
    5454
    5555    HashMap<RefPtr<SerializedPlatformRepresentation>, RefPtr<DataCue>> m_incompleteCueMap;
  • trunk/Source/WebCore/html/track/InbandGenericTextTrack.cpp

    r207720 r207907  
    128128        return;
    129129
    130     RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
    131     updateCueFromCueData(cue.get(), cueData.get());
    132     if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
     130    auto cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
     131    updateCueFromCueData(cue.ptr(), cueData.get());
     132    if (hasCue(cue.ptr(), TextTrackCue::IgnoreDuration)) {
    133133        LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%s, end=%s, content=\"%s\"\n", toString(cueData->startTime()).utf8().data(), toString(cueData->endTime()).utf8().data(), cueData->content().utf8().data());
    134134        return;
     
    138138
    139139    if (cueData->status() != GenericCueData::Complete)
    140         m_cueMap.add(*cueData, *cue);
     140        m_cueMap.add(*cueData, cue);
    141141
    142142    addCue(WTFMove(cue));
     
    160160    if (cue) {
    161161        LOG(Media, "InbandGenericTextTrack::removeGenericCue removing cue: start=%s, end=%s, content=\"%s\"\n",  toString(cueData->startTime()).utf8().data(), toString(cueData->endTime()).utf8().data(), cueData->content().utf8().data());
    162         removeCue(cue);
     162        removeCue(*cue);
    163163    } else {
    164164        LOG(Media, "InbandGenericTextTrack::removeGenericCue UNABLE to find cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
     
    166166}
    167167
    168 ExceptionOr<void> InbandGenericTextTrack::removeCue(TextTrackCue* cue)
     168ExceptionOr<void> InbandGenericTextTrack::removeCue(TextTrackCue& cue)
    169169{
    170170    auto result = TextTrack::removeCue(cue);
    171     if (!result.hasException() && cue)
    172         m_cueMap.remove(*cue);
     171    if (!result.hasException())
     172        m_cueMap.remove(cue);
    173173    return result;
    174174}
  • trunk/Source/WebCore/html/track/InbandGenericTextTrack.h

    r207720 r207907  
    6666    void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) final;
    6767    void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) final;
    68     ExceptionOr<void> removeCue(TextTrackCue*) final;
     68    ExceptionOr<void> removeCue(TextTrackCue&) final;
    6969
    7070    PassRefPtr<TextTrackCueGeneric> createCue(PassRefPtr<GenericCueData>);
  • trunk/Source/WebCore/html/track/TextTrack.cpp

    r207720 r207907  
    291291}
    292292
    293 ExceptionOr<void> TextTrack::addCue(RefPtr<TextTrackCue>&& cue)
    294 {
    295     if (!cue)
    296         return { };
    297 
     293ExceptionOr<void> TextTrack::addCue(Ref<TextTrackCue>&& cue)
     294{
    298295    // 4.7.10.12.6 Text tracks exposing in-band metadata
    299296    // The UA will use DataCue to expose only text track cue objects that belong to a text track that has a text
     
    321318    // 2. Add cue to the method's TextTrack object's text track's text track list of cues.
    322319    cue->setTrack(this);
    323     ensureTextTrackCueList().add(cue);
     320    ensureTextTrackCueList().add(cue.ptr());
    324321   
    325322    if (m_client)
    326         m_client->textTrackAddCue(this, *cue);
     323        m_client->textTrackAddCue(this, cue);
    327324
    328325    return { };
    329326}
    330327
    331 ExceptionOr<void> TextTrack::removeCue(TextTrackCue* cue)
    332 {
    333     if (!cue)
    334         return { };
    335 
     328ExceptionOr<void> TextTrack::removeCue(TextTrackCue& cue)
     329{
    336330    // 4.8.10.12.5 Text track API
    337331
     
    340334    // 1. If the given cue is not currently listed in the method's TextTrack
    341335    // object's text track's text track list of cues, then throw a NotFoundError exception.
    342     if (cue->track() != this)
     336    if (cue.track() != this)
    343337        return Exception { NOT_FOUND_ERR };
    344338
    345339    // 2. Remove cue from the method's TextTrack object's text track's text track list of cues.
    346     if (!m_cues || !m_cues->remove(cue))
     340    if (!m_cues || !m_cues->remove(&cue))
    347341        return Exception { INVALID_STATE_ERR };
    348342
    349     cue->setTrack(nullptr);
     343    cue.setTrack(nullptr);
    350344    if (m_client)
    351         m_client->textTrackRemoveCue(this, *cue);
     345        m_client->textTrackRemoveCue(this, cue);
    352346
    353347    return { };
  • trunk/Source/WebCore/html/track/TextTrack.h

    r207720 r207907  
    101101    TextTrackClient* client() { return m_client; }
    102102
    103     ExceptionOr<void> addCue(RefPtr<TextTrackCue>&&);
    104     virtual ExceptionOr<void> removeCue(TextTrackCue*);
     103    ExceptionOr<void> addCue(Ref<TextTrackCue>&&);
     104    virtual ExceptionOr<void> removeCue(TextTrackCue&);
    105105
    106106    bool hasCue(TextTrackCue*, TextTrackCue::CueMatchRules = TextTrackCue::MatchAllFields);
  • trunk/Source/WebCore/html/track/TextTrack.idl

    r207720 r207907  
    4444    readonly attribute TextTrackCueList? activeCues;
    4545
    46     // FIXME: cue parameter should not be nullable in addCue and removeCue.
    47     [MayThrowException] void addCue(TextTrackCue? cue);
    48     [MayThrowException] void removeCue(TextTrackCue? cue);
     46    [MayThrowException] void addCue(TextTrackCue cue);
     47    [MayThrowException] void removeCue(TextTrackCue cue);
    4948
    5049    attribute EventHandler oncuechange;
Note: See TracChangeset for help on using the changeset viewer.