Bug 70451 - Implement TextTrackCueList
Summary: Implement TextTrackCueList
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anna Cavender
URL:
Keywords:
Depends on:
Blocks: 62883
  Show dependency treegraph
 
Reported: 2011-10-19 16:38 PDT by Anna Cavender
Modified: 2011-11-03 13:29 PDT (History)
6 users (show)

See Also:


Attachments
Patch (5.08 KB, patch)
2011-10-19 17:23 PDT, Anna Cavender
no flags Details | Formatted Diff | Diff
addressing Sam's comments and removing iterators (4.76 KB, patch)
2011-10-20 10:58 PDT, Anna Cavender
no flags Details | Formatted Diff | Diff
updating to ToT (4.79 KB, patch)
2011-10-21 17:29 PDT, Anna Cavender
no flags Details | Formatted Diff | Diff
fixing typo (4.85 KB, patch)
2011-10-21 18:04 PDT, Anna Cavender
no flags Details | Formatted Diff | Diff
now with tests (10.28 KB, patch)
2011-11-03 09:21 PDT, Anna Cavender
no flags Details | Formatted Diff | Diff
Patch for landing (11.40 KB, patch)
2011-11-03 12:49 PDT, Anna Cavender
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anna Cavender 2011-10-19 16:38:44 PDT
TextTrackCueList is a dynamically updating list of text track cues.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#texttrackcuelist

TextTrackCueLists are primarily used as a mechanism to access a TextTrack's list of cues and list of active cues from JavaScript.  They are also used here as storage for TextTrackCues, i.e. TextTrackCues are owned by the TextTrackCueLists of their respective TextTracks.
Comment 1 Anna Cavender 2011-10-19 17:23:39 PDT
Created attachment 111700 [details]
Patch
Comment 2 Sam Weinig 2011-10-19 22:26:53 PDT
Comment on attachment 111700 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=111700&action=review

> Source/WebCore/ChangeLog:9
> +        Covered by existing tests:
> +        Any test in media/track, especially track-text-track-cue-list.html

How do the tests change? Is it a progression?  It makes reviewing much easier if the tests are included in the patch.

> Source/WebCore/html/TextTrackCueList.cpp:49
> +    for (Vector<RefPtr<TextTrackCue> >::const_iterator it = m_list.begin(); it != m_list.end(); it++) {
> +        TextTrackCue* cue = it->get();
> +        if (cue->id() == id)
> +            return cue;
> +    }

We generally use index style iteration for Vectors instead of iterator style.

> Source/WebCore/html/TextTrackCueList.cpp:63
> +    for (Vector<RefPtr<TextTrackCue> >::const_iterator it = newCues.begin(); it != newCues.end(); it++)
> +        add(*it);

Again, index style indexing preferred.

> Source/WebCore/html/TextTrackCueList.cpp:69
> +    RefPtr<TextTrackCue> newCue = cue;
> +    add(newCue, 0, m_list.size());

There doesn't seem a reason here to put cue in a RefPtr, just pass it along to the other add() function as is.

> Source/WebCore/html/TextTrackCueList.cpp:74
> +void TextTrackCueList::add(PassRefPtr<TextTrackCue> cue, size_t start, size_t end)
> +{
> +    // Maintain text track cue order:

It probably makes sense to sanity check start and end here in an ASSERT.

> Source/WebCore/html/TextTrackCueList.cpp:96
> +    if (m_list.contains(cue)) {
> +        cue->setIsActive(false);
> +        m_list.remove(m_list.find(cue));
> +    }

This looks like it does two searches of m_list.  Instead, you should use find(), test for not found, and if found, use the index to remove it.

> Source/WebCore/html/TextTrackCueList.h:60
> +    Iterator begin();
> +    Iterator end();

These don't seem to be used.
Comment 3 Anna Cavender 2011-10-20 10:38:05 PDT
Comment on attachment 111700 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=111700&action=review

Thanks Sam!

>> Source/WebCore/ChangeLog:9
>> +        Any test in media/track, especially track-text-track-cue-list.html
> 
> How do the tests change? Is it a progression?  It makes reviewing much easier if the tests are included in the patch.

Sorry for not including tests in with the patch.  I believe all the functionality in this patch is currently being tested.  media/track/track-text-track-cue-list.html thoroughly tests length(), getCueById(), item() as required for previous patches.  media/track/track-mutable.html thoroughly tests adding and removing cues from text tracks which will then use the internal add() and remove() to update their TextTrackCueLists.  I'll add that test to the changelog.

>> Source/WebCore/html/TextTrackCueList.cpp:49
>> +    }
> 
> We generally use index style iteration for Vectors instead of iterator style.

Done.

>> Source/WebCore/html/TextTrackCueList.cpp:63
>> +        add(*it);
> 
> Again, index style indexing preferred.

Done.

>> Source/WebCore/html/TextTrackCueList.cpp:69
>> +    add(newCue, 0, m_list.size());
> 
> There doesn't seem a reason here to put cue in a RefPtr, just pass it along to the other add() function as is.

Done.

>> Source/WebCore/html/TextTrackCueList.cpp:74
>> +    // Maintain text track cue order:
> 
> It probably makes sense to sanity check start and end here in an ASSERT.

Done.

>> Source/WebCore/html/TextTrackCueList.cpp:96
>> +    }
> 
> This looks like it does two searches of m_list.  Instead, you should use find(), test for not found, and if found, use the index to remove it.

Done.

>> Source/WebCore/html/TextTrackCueList.h:60
>> +    Iterator end();
> 
> These don't seem to be used.

Gone.
Comment 4 Anna Cavender 2011-10-20 10:58:52 PDT
Created attachment 111807 [details]
addressing Sam's comments and removing iterators
Comment 5 Anna Cavender 2011-10-21 17:29:29 PDT
Created attachment 112048 [details]
updating to ToT

I think that the remaining bots weren't able to process the patch because of eric's renaming patch: http://trac.webkit.org/changeset/98000.  This patch just updates.
Comment 6 WebKit Review Bot 2011-10-21 17:32:59 PDT
Comment on attachment 112048 [details]
updating to ToT

Attachment 112048 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10203045
Comment 7 Collabora GTK+ EWS bot 2011-10-21 17:40:49 PDT
Comment on attachment 112048 [details]
updating to ToT

Attachment 112048 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/10204035
Comment 8 Anna Cavender 2011-10-21 18:04:49 PDT
Created attachment 112053 [details]
fixing typo
Comment 9 Sam Weinig 2011-10-23 12:06:54 PDT
(In reply to comment #3)
> (From update of attachment 111700 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=111700&action=review
> 
> Thanks Sam!
> 
> >> Source/WebCore/ChangeLog:9
> >> +        Any test in media/track, especially track-text-track-cue-list.html
> > 
> > How do the tests change? Is it a progression?  It makes reviewing much easier if the tests are included in the patch.
> 
> Sorry for not including tests in with the patch.  I believe all the functionality in this patch is currently being tested.  media/track/track-text-track-cue-list.html thoroughly tests length(), getCueById(), item() as required for previous patches.  media/track/track-mutable.html thoroughly tests adding and removing cues from text tracks which will then use the internal add() and remove() to update their TextTrackCueLists.  I'll add that test to the changelog.

I would really rather you include the actual changes to the test results in the patch as we require of everyone else.
Comment 10 Anna Cavender 2011-10-23 21:50:43 PDT
Sam, I didn't include any changes to tests because existing tests already cover this functionality.  This feature is a work in progress and I am incrementally adding functionality in small, easy to digest patches.  As a result, layout tests have been submitted with prior patches even though not enough functionality existed at that time to actually run the tests successfully.  This patch adds some of that functionality, so that existing tests can soon be un-skipped.

I am certainly not opposed to adding new test cases, but please take a look at media/track/track-text-track-cue-list.html and media/track/track-mutable.html and let me know if you think there is functionality in this patch that is not covered by those tests.

Thanks!
Comment 11 Sam Weinig 2011-10-30 12:18:26 PDT
I understand that you implemented a bunch of stuff out of the main tree and are trying to commit it piecemeal, but part of the breaking up of the large change needs to include the test result changes so we can see the progress.
Comment 12 Anna Cavender 2011-10-31 07:29:10 PDT
Thanks Sam, I understand.  I'm working on some other patches to put the functionality in place first to be able to run tests against this patch and others.  After that I'll come back to this patch and include tests.  Stay tuned :).
Comment 13 Anna Cavender 2011-11-03 09:21:06 PDT
Created attachment 113504 [details]
now with tests

A functional TextTrackCueList with passing tests.
Comment 14 Eric Carlson 2011-11-03 10:58:43 PDT
Comment on attachment 113504 [details]
now with tests

View in context: https://bugs.webkit.org/attachment.cgi?id=113504&action=review

> Source/WebCore/html/TextTrack.cpp:49
> +    m_cues = TextTrackCueList::create();

Can this be done when newCuesAvailable is called for the first time?

> Source/WebCore/html/TextTrack.cpp:103
>  PassRefPtr<TextTrackCueList> TextTrack::cues() const

Returning a PassRefPtr?

> Source/WebCore/html/TextTrack.cpp:107
> -    // FIXME(62885): Implement.
> +    if (m_mode != TextTrack::DISABLED)
> +        return m_cues;
>      return 0;

I am a big fan of quoting the spec text and noting the spec section number to make it easier to find the relevant section in the spec, and to make it easier to figure out when the logic is out of sync with spec changes.

> Source/WebCore/html/TextTrackCueList.cpp:50
> +TextTrackCue* TextTrackCueList::getCueById(const String& id) const

This would be more efficient if the cue id and parameters were both AtomicString so the == is a pointer comparison. This change could be made as a follow up optimization.

> Source/WebCore/html/TextTrackCueList.cpp:86
> +        || (newCue->startTime() == m_list[index]->startTime()
> +        && newCue->endTime() > m_list[index]->endTime()))

Having these on the same line will make it easier to follow the logic.

> Source/WebCore/html/TextTrackCueList.cpp:89
> +        add(newCue, start, index);
> +    else
> +        add(newCue, index + 1, end);

newCue.release() will prevent reference count churn.

> Source/WebCore/html/TextTrackCueList.h:50
>      PassRefPtr<TextTrackCueList> activeCues();

PassRefPtr?

> LayoutTests/media/track/track-text-track-cue-list.html:12
> +                cues = testTrack.track.cues;

Using "testTrack" as a global without looking it up works, but it is an old crusty compat feature so please add a getElementById().
Comment 15 Anna Cavender 2011-11-03 12:45:24 PDT
Comment on attachment 113504 [details]
now with tests

View in context: https://bugs.webkit.org/attachment.cgi?id=113504&action=review

Thanks Eric!

>> Source/WebCore/html/TextTrack.cpp:49
>> +    m_cues = TextTrackCueList::create();
> 
> Can this be done when newCuesAvailable is called for the first time?

Sure.  It would also have to be checked and possibly created in addCue, but that's fine.

>> Source/WebCore/html/TextTrack.cpp:103
>>  PassRefPtr<TextTrackCueList> TextTrack::cues() const
> 
> Returning a PassRefPtr?

Huh, good call.  Can't remember why it got changed to PassRefPtr, but it should definitely be a raw pointer (ownership is not being transfered).

>> Source/WebCore/html/TextTrack.cpp:107
>>      return 0;
> 
> I am a big fan of quoting the spec text and noting the spec section number to make it easier to find the relevant section in the spec, and to make it easier to figure out when the logic is out of sync with spec changes.

Done.

>> Source/WebCore/html/TextTrackCueList.cpp:50
>> +TextTrackCue* TextTrackCueList::getCueById(const String& id) const
> 
> This would be more efficient if the cue id and parameters were both AtomicString so the == is a pointer comparison. This change could be made as a follow up optimization.

Good idea.  Noted for follow up patch.

>> Source/WebCore/html/TextTrackCueList.cpp:86
>> +        && newCue->endTime() > m_list[index]->endTime()))
> 
> Having these on the same line will make it easier to follow the logic.

Done.

>> Source/WebCore/html/TextTrackCueList.cpp:89
>> +        add(newCue, index + 1, end);
> 
> newCue.release() will prevent reference count churn.

Done.

>> Source/WebCore/html/TextTrackCueList.h:50
>>      PassRefPtr<TextTrackCueList> activeCues();
> 
> PassRefPtr?

Done.  Raw pointer now.  Thanks.

>> LayoutTests/media/track/track-text-track-cue-list.html:12
>> +                cues = testTrack.track.cues;
> 
> Using "testTrack" as a global without looking it up works, but it is an old crusty compat feature so please add a getElementById().

Done.
Comment 16 Anna Cavender 2011-11-03 12:49:06 PDT
Created attachment 113543 [details]
Patch for landing
Comment 17 WebKit Review Bot 2011-11-03 13:29:12 PDT
Comment on attachment 113543 [details]
Patch for landing

Clearing flags on attachment: 113543

Committed r99234: <http://trac.webkit.org/changeset/99234>
Comment 18 WebKit Review Bot 2011-11-03 13:29:20 PDT
All reviewed patches have been landed.  Closing bug.