Bug 114330 - Refactor TextTrack and TextTrackList to make it easier to add audio and video tracks
Summary: Refactor TextTrack and TextTrackList to make it easier to add audio and video...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 113965
  Show dependency treegraph
 
Reported: 2013-04-09 21:02 PDT by Brendan Long
Modified: 2013-04-12 15:03 PDT (History)
11 users (show)

See Also:


Attachments
Patch (50.61 KB, patch)
2013-04-09 21:12 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch (49.96 KB, patch)
2013-04-09 21:44 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch (51.49 KB, patch)
2013-04-09 21:48 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch (57.04 KB, patch)
2013-04-10 11:06 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion (490.86 KB, application/zip)
2013-04-10 16:28 PDT, Build Bot
no flags Details
Patch (56.95 KB, patch)
2013-04-10 18:24 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch (56.94 KB, patch)
2013-04-10 19:58 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch (57.55 KB, patch)
2013-04-12 10:25 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch (58.48 KB, patch)
2013-04-12 12:27 PDT, Brendan Long
no flags Details | Formatted Diff | Diff
Patch for committing (58.42 KB, patch)
2013-04-12 13:52 PDT, Brendan Long
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brendan Long 2013-04-09 21:02:58 PDT
Refactor TextTrack and TextTrackList to make it easier to add audio and video tracks
Comment 1 Brendan Long 2013-04-09 21:04:25 PDT
This bug is for some refactoring work we're doing before adding audio and video tracks in bug #113965.
Comment 2 Brendan Long 2013-04-09 21:12:03 PDT
Created attachment 197201 [details]
Patch
Comment 3 Brendan Long 2013-04-09 21:44:37 PDT
Created attachment 197203 [details]
Patch
Comment 4 Brendan Long 2013-04-09 21:48:37 PDT
Created attachment 197205 [details]
Patch
Comment 5 Build Bot 2013-04-09 22:00:15 PDT
Comment on attachment 197205 [details]
Patch

Attachment 197205 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-commit-queue.appspot.com/results/17739013
Comment 6 Build Bot 2013-04-09 22:34:17 PDT
Comment on attachment 197205 [details]
Patch

Attachment 197205 [details] did not pass mac-ews (mac):
Output: http://webkit-commit-queue.appspot.com/results/17671034
Comment 7 Build Bot 2013-04-09 23:18:37 PDT
Comment on attachment 197205 [details]
Patch

Attachment 197205 [details] did not pass win-ews (win):
Output: http://webkit-commit-queue.appspot.com/results/17624051
Comment 8 Brendan Long 2013-04-10 11:06:13 PDT
Created attachment 197316 [details]
Patch
Comment 9 Brendan Long 2013-04-10 11:07:03 PDT
I'm trying to get the Mac and Windows builds to work, but I'm not really sure where to add the .idl files to get them picked up.
Comment 10 Brendan Long 2013-04-10 12:28:01 PDT
(In reply to comment #9)
> I'm trying to get the Mac and Windows builds to work, but I'm not really sure where to add the .idl files to get them picked up.

Ignore this. This applies to the audio/video tracks, not this change.
Comment 11 Build Bot 2013-04-10 16:28:06 PDT
Comment on attachment 197316 [details]
Patch

Attachment 197316 [details] did not pass mac-ews (mac):
Output: http://webkit-commit-queue.appspot.com/results/17705099

New failing tests:
media/track/track-user-preferences.html
media/track/track-node-add-remove.html
Comment 12 Build Bot 2013-04-10 16:28:09 PDT
Created attachment 197415 [details]
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-01  Port: mac-mountainlion  Platform: Mac OS X 10.8.2
Comment 13 Brendan Long 2013-04-10 18:24:05 PDT
Created attachment 197460 [details]
Patch
Comment 14 Brendan Long 2013-04-10 19:58:19 PDT
Created attachment 197466 [details]
Patch
Comment 15 Brendan Long 2013-04-11 20:05:52 PDT
Comment on attachment 197466 [details]
Patch

This doesn't build since I added the removetrack event, and I need some time to figure out how to handle some things better.

The most annoying part of this is that Vector<RefPtr<TrackBase> > can't be cast to Vector<RefPtr<TextTrack> >, which makes TextTrackList.cpp significantly more complicated than it needs to be. I'm thinking I can just make m_elementTracks and m_addTrackTracks(?) into Vector<RefPtr<TrackBase> > also, but it will make the code more complicated. I think if I move the track index and isRendered() code into TrackBase it will work, I just need to make sure that those make sense for audio and video tracks.
Comment 16 Brendan Long 2013-04-12 09:47:02 PDT
The track index and isRendered() code only makes sense for text tracks, because it's all related to how to render subtitles.
Comment 17 Brendan Long 2013-04-12 10:25:22 PDT
Created attachment 197865 [details]
Patch
Comment 18 Brendan Long 2013-04-12 10:26:22 PDT
Let me know if you'd prefer that these patches be broken up differently.
Comment 19 Jer Noble 2013-04-12 10:34:00 PDT
I really don't like all the static_cast<TextTrack*> going on in TextTrackList.  Perhaps add the following to TextTrack.h?:

TextTrack* toTextTrack(TrackBase* track)
{
    ASSERT(track->type() == TrackBase::TextTrack);
    return static_cast<TextTrack*>(track);
}

Similar functions could go into AudioTrack.h and VideoTrack.h.

Then replace all the explicit casts with calls to toTextTrack(), and if ever another type sneaks into a TextTrackList, it'll be caught by this assert.
Comment 20 Eric Carlson 2013-04-12 10:41:00 PDT
Comment on attachment 197865 [details]
Patch

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

This is really close! 

Thanks for taking this on, refactoring isn't a lot of fun :-)

> Source/WebCore/ChangeLog:19
> +        (WebCore::HTMLMediaElement::mediaPlayerDidAddTextTrack):
> +        (WebCore::HTMLMediaElement::mediaPlayerDidRemoveTextTrack):
> +        (WebCore::HTMLMediaElement::addTextTrack):
> +        (WebCore::HTMLMediaElement::removeTextTrack):
> +        (WebCore::HTMLMediaElement::removeAllInbandTracks):
> +        (WebCore::HTMLMediaElement::didAddTextTrack):
> +        (WebCore::HTMLMediaElement::didRemoveTextTrack):

Nit: I think it is useful to have brief comments in the ChangeLog detailing what changed in each method.

> Source/WebCore/ChangeLog:21
> +        (WebCore):

Nit: all of these empty entries added by the script can be removed.

> Source/WebCore/html/track/TextTrack.h:87
> +    virtual const AtomicString& defaultKindKeyword() const { return subtitlesKeyword(); }

Nit: OVERRIDE.

> Source/WebCore/html/track/TextTrack.h:169
> +    virtual void refEventTarget() { ref(); }
> +    virtual void derefEventTarget() { deref(); }

OVERRIDE

> Source/WebCore/html/track/TextTrackList.cpp:58
> +    TextTrack* textTrack = static_cast<TextTrack*>(track);

This would be better if you had a toTextTrack() function that ASSERTs when passed the wrong type (see the various toXXX functions in Render classes).
Comment 21 Brendan Long 2013-04-12 12:27:58 PDT
Created attachment 197877 [details]
Patch
Comment 22 Brendan Long 2013-04-12 12:28:58 PDT
I added toTextTrack() and put some comments in the ChangeLog. I'm not sure if I was too detailed, or not detailed enough. Almost all of the changes involve renaming or changing a TextTrack* to a TrackBase*.
Comment 23 Jer Noble 2013-04-12 12:40:22 PDT
Comment on attachment 197877 [details]
Patch

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

r+, with nit:

> Source/WebCore/html/track/TextTrack.cpp:574
> +TextTrack* toTextTrack(TrackBase* track)
> +{
> +    ASSERT(track->type() == TrackBase::TextTrack);
> +    return static_cast<TextTrack*>(track);
>  }

Nit: please put the body of this function into the header file, so it can be inlined.

(If you don't have committer rights, just upload a new patch named "Patch for Committing" and either Eric or I will cq+ it.)
Comment 24 Brendan Long 2013-04-12 13:52:46 PDT
Created attachment 197881 [details]
Patch for committing

I needed to make it inline TextTrack* toTextTrack() to make it compile.
Comment 25 WebKit Commit Bot 2013-04-12 15:03:13 PDT
Comment on attachment 197881 [details]
Patch for committing

Clearing flags on attachment: 197881

Committed r148305: <http://trac.webkit.org/changeset/148305>
Comment 26 WebKit Commit Bot 2013-04-12 15:03:18 PDT
All reviewed patches have been landed.  Closing bug.