Bug 62886 - Basic display of WebVTT captions
Summary: Basic display of WebVTT captions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks: 43668
  Show dependency treegraph
 
Reported: 2011-06-17 11:01 PDT by Anna Cavender
Modified: 2011-12-19 09:26 PST (History)
7 users (show)

See Also:


Attachments
Proposed patch (36.51 KB, patch)
2011-12-18 16:20 PST, Eric Carlson
sam: review-
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
Updated patch (37.40 KB, patch)
2011-12-18 18:34 PST, Eric Carlson
sam: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
Updated, one more time. (38.25 KB, patch)
2011-12-18 20:55 PST, Eric Carlson
sam: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
One more patch for the EWS bot (38.36 KB, patch)
2011-12-18 22:59 PST, Eric Carlson
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
YAP (38.26 KB, patch)
2011-12-18 23:10 PST, Eric Carlson
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
Updated patch (39.85 KB, patch)
2011-12-19 08:38 PST, Eric Carlson
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-06-17 11:01:09 PDT
This change will enable rendering of text track cues on <video>s.
Comment 1 Eric Carlson 2011-12-18 14:58:59 PST
Because of the complexity of rendering WebVTT and because the rendering section of the spec is still in flux, I think it makes sense to implement a simple text track renderer using default positioning and style only. 

FWIW, this is the approach that Microsoft has taken for the beta (at least) of IE 10.
Comment 2 Eric Carlson 2011-12-18 15:52:32 PST
<rdar://problem/10320025>
Comment 3 Eric Carlson 2011-12-18 16:20:22 PST
Created attachment 119786 [details]
Proposed patch
Comment 4 WebKit Review Bot 2011-12-18 16:21:33 PST
Attachment 119786 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/medi..." exit_code: 1

Source/WebCore/html/shadow/MediaControlElements.h:500:  The parameter name "arena" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 WebKit Review Bot 2011-12-18 16:42:40 PST
Comment on attachment 119786 [details]
Proposed patch

Attachment 119786 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10933352
Comment 6 Sam Weinig 2011-12-18 16:59:21 PST
Comment on attachment 119786 [details]
Proposed patch

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

r- due to using innerHTML.  We should at the very least have tests which show the effect of using it.

> Source/WebCore/html/HTMLMediaElement.cpp:1007
> +        HTMLTrackElement* trackElement;
> +        for (Node* node = firstChild(); node; node = node->nextSibling()) {
> +            if (!node->hasTagName(trackTag))
> +                continue;
> +            trackElement = static_cast<HTMLTrackElement*>(node);
> +            if (trackElement->track() != track)
> +                continue;

I don't think it is necessary to have the trackElement outside of the loop.

> Source/WebCore/html/HTMLMediaElement.h:70
> +typedef PODIntervalTree <double, TextTrackCue*> CueIntervalTree;

Don't want the space after PODIntervalTree.

> Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp:379
> +    StringBuilder cues;
> +    for (size_t i = 0; i < visibleCues.size(); ++i) {
> +        if (i > 0 && cues.length())
> +            cues.append("<br>");
> +
> +        TextTrackCue* cue = visibleCues[i].data();
> +        ASSERT(cue->isActive());
> +        if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
> +            continue;
> +
> +        cues.append(cue->getCueAsSource());
> +    }
> +
> +    ExceptionCode e; 
> +    m_textTrackDisplay->setInnerHTML(cues.toString(), e);
> +    if (cues.length())
> +        m_textDisplayContainer->show();
> +    else
> +        m_textDisplayContainer->hide();

I think it would be nicer/safer to use programatic DOM APIs (appendChild, etc) instead of building a string and using innerHTML.  If you do need to parse the cues as HTML, I would recommend doing it one cue at a time and not as a concatenated string.
Comment 7 Eric Carlson 2011-12-18 18:34:44 PST
Created attachment 119795 [details]
Updated patch
Comment 8 Eric Carlson 2011-12-18 18:35:26 PST
(In reply to comment #6)
> (From update of attachment 119786 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=119786&action=review
> 
> r- due to using innerHTML.  We should at the very least have tests which show the effect of using it.
> 
> > Source/WebCore/html/HTMLMediaElement.cpp:1007
> > +        HTMLTrackElement* trackElement;
> > +        for (Node* node = firstChild(); node; node = node->nextSibling()) {
> > +            if (!node->hasTagName(trackTag))
> > +                continue;
> > +            trackElement = static_cast<HTMLTrackElement*>(node);
> > +            if (trackElement->track() != track)
> > +                continue;
> 
> I don't think it is necessary to have the trackElement outside of the loop.
> 
Fixed.

> > Source/WebCore/html/HTMLMediaElement.h:70
> > +typedef PODIntervalTree <double, TextTrackCue*> CueIntervalTree;
> 
> Don't want the space after PODIntervalTree.
> 
Fixed.

> > Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp:379
> > +    StringBuilder cues;
> > +    for (size_t i = 0; i < visibleCues.size(); ++i) {
> > +        if (i > 0 && cues.length())
> > +            cues.append("<br>");
> > +
> > +        TextTrackCue* cue = visibleCues[i].data();
> > +        ASSERT(cue->isActive());
> > +        if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
> > +            continue;
> > +
> > +        cues.append(cue->getCueAsSource());
> > +    }
> > +
> > +    ExceptionCode e; 
> > +    m_textTrackDisplay->setInnerHTML(cues.toString(), e);
> > +    if (cues.length())
> > +        m_textDisplayContainer->show();
> > +    else
> > +        m_textDisplayContainer->hide();
> 
> I think it would be nicer/safer to use programatic DOM APIs (appendChild, etc) instead of building a string and using innerHTML.  If you do need to parse the cues as HTML, I would recommend doing it one cue at a time and not as a concatenated string.

Fixed.

Thanks!
Comment 9 WebKit Review Bot 2011-12-18 18:57:08 PST
Comment on attachment 119795 [details]
Updated patch

Attachment 119795 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10935368
Comment 10 Sam Weinig 2011-12-18 20:38:56 PST
Comment on attachment 119795 [details]
Updated patch

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

r=me, but please consider adding a test with tags in the content.  (Also, make sure all the parts of the test are there.)

> LayoutTests/media/track/track-cue-rendering.html:65
> +            testTrack = document.querySelectorAll('track')[0];

Nit: This could just use querySelector('track') if you so felt.
Comment 11 Eric Carlson 2011-12-18 20:55:03 PST
Created attachment 119806 [details]
Updated, one more time.
Comment 12 Eric Carlson 2011-12-18 20:59:35 PST
Comment on attachment 119806 [details]
Updated, one more time.

Remove r? because Sam already r+'d the previous version. This one is just so the ews bots can tell me if the Chromium specific code compiles.
Comment 13 WebKit Review Bot 2011-12-18 21:11:35 PST
Comment on attachment 119806 [details]
Updated, one more time.

Attachment 119806 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10932449
Comment 14 Eric Carlson 2011-12-18 22:59:59 PST
Created attachment 119820 [details]
One more patch for the EWS bot
Comment 15 WebKit Review Bot 2011-12-18 23:05:26 PST
Comment on attachment 119820 [details]
One more patch for the EWS bot

Attachment 119820 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10921510
Comment 16 Eric Carlson 2011-12-18 23:10:43 PST
Created attachment 119822 [details]
YAP
Comment 17 WebKit Review Bot 2011-12-19 08:23:22 PST
Comment on attachment 119822 [details]
YAP

Attachment 119822 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10942012
Comment 18 Eric Carlson 2011-12-19 08:38:00 PST
Created attachment 119867 [details]
Updated patch

Updated to fix a problem the Chromium EWS bot found.
Comment 19 Eric Carlson 2011-12-19 09:26:07 PST
 http://trac.webkit.org/changeset/103242