Re: TextTrackCue discussions

On 08/23/2013 03:21 PM, Silvia Pfeiffer wrote:
> You can't define a conversion to HTML for something for which you
> don't know the format. That's too much magic. For example, if somebody
> provides some JSON text in the text attribute of the TextTrackCue, how
> is the browser to know how to convert this to HTML?
It just wouldn't. getTextAsHTML() would return null.

Maybe a better option though, would be to have two different interfaces,
since not all cues are going to be fully parsed:

// For a cue that the browser doesn't understand
interface TextTrackCue : EventTarget {
    attribute DOMString text;
};

// For a cue that the browser does understand
interface ParsedTextTrackCue : TextTrackCue {
    attribute DOMString id <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#dom-texttrackcue-id>;
    attribute double startTime <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#dom-texttrackcue-starttime>;
    attribute double endTime <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#dom-texttrackcue-endtime>;
    attribute boolean pauseOnExit <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#dom-texttrackcue-pauseonexit>;
    attribute DOMString text <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#dom-texttrackcue-text>;
    DocumentFragment <http://www.w3.org/TR/2012/CR-html5-20121217/infrastructure.html#documentfragment> getCueAsHTML <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#dom-texttrackcue-getcueashtml>();

    attribute EventHandler <http://www.w3.org/TR/2012/CR-html5-20121217/webappapis.html#eventhandler> onenter <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#handler-texttrackcue-onenter>;
    attribute EventHandler <http://www.w3.org/TR/2012/CR-html5-20121217/webappapis.html#eventhandler> onexit <http://www.w3.org/TR/2012/CR-html5-20121217/embedded-content-0.html#handler-texttrackcue-onexit>; ...
};

// And then if you want this..
interface WebVTTCue : ParsedTextTrackCue {
    attribute DOMString regionId <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-regionid>;
    attribute DirectionSetting <http://dev.w3.org/html5/webvtt/#dfn-directionsetting> vertical <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical>;
    attribute boolean snapToLines <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-snaptolines>;
    attribute (long or AutoKeyword <http://dev.w3.org/html5/webvtt/#dfn-autokeyword>) line <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-line>;
    attribute long position <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-position>;
    attribute long size <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-size>;
    attribute AlignSetting <http://dev.w3.org/html5/webvtt/#dfn-alignsetting> align <http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align>;
};

interface TTMLCue : ParsedTextTrackCue {
    ...
};

interface CEA708Cue: ParsedTextTrackCue {
    ...
};

This way, all of the most important information is guaranteed to be
present in the same form, and developers don't need to know about the
various formats unless they want format-specific information.

Received on Monday, 26 August 2013 21:36:57 UTC