THIS DOCUMENT IS OUT-DATED, THE CONTENT HAS BEEN MERGED INTO THE WEBVTT SPEC. IT MERELY EXISTS FOR REFERENCE PURPOSES.

Introduction

This section is non-normative.

WebVTT [WEBVTT] is a pretty nifty caption format with lots of capabilities for formatting and positioning of cues. From a TV perspective it satisfies the needs of pop-on and paint-on captions. However, the need for rollup captions can only be satisfied with very clunky copying of cues and manual positioning.

This document introduces the concept of "regions" into WebVTT to specify rollup captions following a very similar concept to that used in CEA-708 Digital TV Captioning [CEA-708].

The "region" concept

WebVTT currently deals with two layout concepts: the text area that is to be rendered, and the video viewport. (Actually, there is a third: the line box - but it is orthogonal to the issue at hand.) In other caption formats (in particular in CEA-608 and CEA-708), a third concept exists: the concept of a rendering region which holds multiple cues. It is called "window" in CEA-708 [CEA-708].

This specification introduces the CEA-708 "window" concept into WebVTT under the term "region", because the term "window" already bears a different meaning on the Web. This specification's main goal is to allow for a simple implementation of rollup captions, but it also satisfies other use cases:

Many of these features are part of what the US FCC (Federal Communications Commission) has required for Captioning of Internet Video Programming [FCC].

This specification is the result of discussions in the W3C Text Tracks Community Group (CG). The intention is to provide a backwards compatible extension to the WebVTT specification [WEBVTT] such that the lack of support of the "region" feature in video players doesn't stop a WebVTT file with regions from being parsed and displayed on top of the video.

This document specifies the most fundamental concepts. There are many ways in which this "region" specification can be extended and in fact some ideas have been discussed on the W3C Text Tracks CG wiki. We will wait for browser vendors to implement the core features and for developers to provide feedback on their use cases and needs before extending this specification.

Example WebVTT file with regions

The following example shows two regions containing rollup captions for two different speakers. Fred's cues scroll up in a region in the left half of the video, Bill's cues scroll up in a region on the right half of the video. Fred's first cue disappears at 12.5sec even through it is defined until 20sec because its region is limited to 3 lines and at 12.5sec a fourth cue appears:

WEBVTT
Region: id=fred width=50% lines=3 regionanchor=0%,100% viewportanchor=10%,90% scroll=up
Region: id=bill width=50% lines=3 regionanchor=100%,100% viewportanchor=90%,90% scroll=up

00:00:00.000 --> 00:00:20.000 region:fred align:left
Hi, my name is Fred

00:00:02.500 --> 00:00:22.500 region:bill align:right
Hi, I'm Bill

00:00:05.000 --> 00:00:25.000 region:fred align:left
Would you like to get a coffee?

00:00:07.500 --> 00:00:27.500 region:bill align:right
Sure! I've only had one today.

00:00:10.000 --> 00:00:30.000 region:fred align:left
This is my fourth!

00:00:12.500 --> 00:00:32.500 region:fred align:left
OK, let's go.

Note that regions are only defined for horizontal cues at this time.

All terms used in this specification that are not (re-)defined in this specification rely on terms specified in the WebVTT specification [WEBVTT].

Extension of the HTML text track model

The WebVTT specification references the text track model of the HTML specification [HTML] to define the core terms of the WebVTT specification.

This specification introduces the concepts of a text track region and a text track list of regions, and extends the concept of a text track cue.

Text track region

A text track region represents a subpart of the video viewport and provides a rendering area for text track cues.

Each text track region consists of:

An identifier

An arbitrary string.

A width

A number giving the width of the box within which the text of each line of the containing cues is to be rendered, to be interpreted as a percentage of the video width. Defaults to 100.

A lines value

A number giving the number of lines of the box within which the text of each line of the containing cues is to be rendered. Defaults to 3.

A region anchor point

Two numbers giving the x and y coordinates within the region which is anchored to the video viewport and does not change location even when the region does, e.g. because of font size changes. Defaults to (0,100), i.e. the bottom left corner of the region.

A region viewport anchor point

Two numbers giving the x and y coordinates within the video viewport to which the region anchor point is anchored. Defaults to (0,100), i.e. the bottom left corner of the viewport.

A scroll value

One of the following:

None
Indicates that the cues in the region are not to scroll and instead stay fixed at the location they were first painted in.
Up
Indicates that the cues in the region will be added at the bottom of the region and push any already displayed cues in the region up until all lines of the new cue are visible in the region.

Text track list of regions

A list of zero or more regions

A list of text track regions . The list of regions of a text track can change dynamically, either because the text track has not yet been loaded or is still loading.

Extension of text track cue

In addition to the existing attributes, each text track cue also consists of:

A region identifier

A string that references by identifier the region that a cue belongs to, if it is not null.

Also, update the following text track cue attribute definitions:

A text position

A number giving the position of the text of the cue within each line. If the cue is not within a region, to be interpreted as a percentage of the video, as defined by the writing direction, otherwise to be interpreted as a percentage of the region width.

When a text track cue whose active flag is set has its writing direction, snap-to-lines flag, line position, text position, size, alignment, region identifier or text change value, then the user agent must empty the text track cue display state, and then immediately run the text track's rules for updating the display of WebVTT text tracks.

Region syntax

The WebVTT parser is flexible when parsing the header of a WebVTT file and allows for characters to be present before the first cue in the file. We take advantage of this extension point of the WebVTT spec to introduce the specification of regions in the header of WebTT files.

Extension of the WebVTT file body syntax

The specification of a the "WebVTT file body" syntax in the WebVTT specification is extended to the following:

A WebVTT file body consists of the following components, in the following order:

  1. An optional U+FEFF BYTE ORDER MARK (BOM) character.
  2. The string "WEBVTT".
  3. Optionally, either a U+0020 SPACE character or a U+0009 CHARACTER TABULATION (tab) character followed by any number of characters that are not U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.
  4. One or more WebVTT line terminator to terminate the line with the file magic and separate it from the rest of the file body.
  5. Zero or more WebVTT metadata headers and WebVTT comments separated from each other by two or more WebVTT line terminators.
  6. One or more WebVTT line terminators to terminate the header block and separate the cues from the file header.
  7. Zero or more WebVTT cues and WebVTT comments separated from each other by two or more WebVTT line terminators.
  8. Zero or more WebVTT line terminators.

WebVTT metadata header syntax

A WebVTT metadata header consists of the following components, in the given order:

  1. A WebVTT metadata header name.
  2. A U+003A COLON (colon) character.
  3. A WebVTT metadata header value.

A WebVTT metadata header name and a WebVTT metadata header value each consist of any sequence of zero or more characters other than U+000A LINE FEED (LF) characters and U+000D CARRIAGE RETURN (CR) characters except that the entire resulting string must not contain the substring "-->" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).

WebVTT region metadata header syntax

A WebVTT region metadata header is a special kind of WebVTT metadata header where both of the following apply:

WebVTT region and WebVTT region settings syntax

A WebVTT region represents its region settings.

The WebVTT region settings part of a WebVTT region metadata header consists of zero or more of the following components, in any order, separated from each other by one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters. Each component must not be included more than once per WebVTT region setting string.

WebVTT region settings give configuration options regarding the dimensions, positioning and anchoring of the region. For example, it allows a group of cues within a region to be anchored in the center of the region and the center of the video viewport. In this example, when the font size grows, the region grows uniformly in all directions from the center.

A WebVTT region identifier consists of the following components, in the order given:

  1. The string "id".

  2. A U+003D EQUALS SIGN character (=).

  3. An arbitrary string of one or more characters other than U+0020 SPACE or U+0009 CHARACTER TABULATION character. The string must not contain the substring "-->" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).

The WebVTT region identifier gives a name to the region so it can be referenced by the cues that belong to the region.

A WebVTT region width setting consists of the following components, in the order given:

  1. The string "width".

  2. A U+003D EQUALS SIGN character (=).

  3. One or more ASCII digits.

  4. An optional U+002E DOT character (.).

  5. One or more ASCII digits.

  6. A U+0025 PERCENT SIGN character (%).

The WebVTT region width setting provides a fixed width as a percentage of the video width for the region into which cues are rendered and based on which alignment is calculated.

A WebVTT region lines setting consists of the following components, in the order given:

  1. The string "lines".

  2. A U+003D EQUALS SIGN character (=).

  3. One or more ASCII digits.

The WebVTT region lines setting provides a fixed height as a number of lines for the region into which cues are rendered. As such, it defines the height of the roll-up region if it is a scroll region.

A WebVTT region anchor setting consists of the following components, in the order given:

  1. The string "regionanchor".

  2. A U+003D EQUALS SIGN character (=).

  3. One or more ASCII digits.

  4. An optional U+002E DOT character (.).

  5. One or more ASCII digits.

  6. A U+0025 PERCENT SIGN character (%).

  7. A U+002C COMMA character (,).

  8. One or more ASCII digits.

  9. An optional U+002E DOT character (.).

  10. One or more ASCII digits.

  11. A U+0025 PERCENT SIGN character (%).

The WebVTT region anchor setting provides a tuple of two percentages that specify the point within the region box that is fixed in location. The first percentage measures the x-dimension and the second percentage y-dimension from the top left corner of the region box. If no WebVTT region anchor setting is given, the anchor defaults to 0%, 100% (i.e. the bottom left corner).

A WebVTT region viewport anchor setting consists of the following components, in the order given:

  1. The string "viewportanchor".

  2. A U+003D EQUALS SIGN character (=).

  3. One or more ASCII digits.

  4. An optional U+002E DOT character (.).

  5. One or more ASCII digits.

  6. A U+0025 PERCENT SIGN character (%).

  7. A U+002C COMMA character (,).

  8. One or more ASCII digits.

  9. An optional U+002E DOT character (.).

  10. One or more ASCII digits.

  11. A U+0025 PERCENT SIGN character (%).

The WebVTT region viewport anchor setting provides a tuple of two percentages that specify the point within the video viewport that the region anchor point is anchored to. The first percentage measures the x-dimension and the second percentage measures the y-dimension from the top left corner of the video viewport box. If no viewport anchor is given, it defaults to 0%, 100% (i.e. the bottom left corner).

For browsers, the region maps to an absolute positioned CSS box relative to the video viewport, i.e. there is a relative positioned box that represents the video viewport relative to which the regions are absolutely positioned. Overflow is hidden.

A WebVTT region scroll setting consists of the following components, in the order given:

  1. The string "scroll".

  2. A U+003D EQUALS SIGN character (=).

  3. The string "up".

The WebVTT region scroll setting specifies whether cues rendered into the region are allowed to move out of their initial rendering place and roll up, i.e. move towards the top of the video viewport. If the scroll setting is omitted, cues do not move from their rendered position.

Cues are added to a region one line at a time below existing cue lines. When an existing rendered cue line is removed, and it was above another already rendered cue line, that cue line moves into its space, thus scrolling in the given direction. If there is not enough space for a new cue line to be added to a region, the top-most cue line is pushed off the visible region (thus slowly becoming invisible as it moves into overflow:hidden). This eventually makes space for the new cue line and allows it to be added.

When there is no scroll direction, cue lines are added in the empty line closest to the line in the bottom of the region. If no empty line is available, the oldest line is replaced.

WebVTT region cue setting syntax

This specification extends the existing set of WebVTT cue settings with a new setting.

A WebVTT region cue setting consists of the following components, in the order given:

  1. The string "region".

  2. A U+003A COLON character (:).

  3. An arbitrary string of one or more characters other than U+0020 SPACE or U+0009 CHARACTER TABULATION character. The string must not contain the substring "-->" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).

A WebVTT region cue setting configures a cue to become part of a region by referencing the region's identifier unless the cue has a "vertical", "line" or "size" cue setting. If a cue is part of a region, its cue settings for "position" and "align" are applied to the line boxes in the cue relative to the region box.

Extension of the WebVTT parser algorithm

The WebVTT parser algorithm is extended to parse the WebVTT region metadata header and the WebVTT region cue setting.

Extension of WebVTT header parsing (step 11-15)

This is an extension of the WebVTT parser algorithm.

Introduce an additional variable regions to be a text track list of regions, which the WebVTT parser will create in addition to the text track list of cues output.

  1. Metadata header loop: If line is not the empty string, run the following substeps:
    1. Metadata header creation: Let metadata be a new WebVTT metadata header.

    2. Let metadata's name be the empty string.

    3. Let metadata's value be the empty string.

    4. If line contains the character ":" (A U+003A COLON), then set metadata's name to the substring of line before the first ":" character and metadata's value to the substring after this character.

    5. If metadata's name equals "Region":

      1. Region creation: Let region be a new text track region.
      2. Let region's identifier be the empty string.
      3. Let region's width be 100.
      4. Let region's lines be 3.
      5. Let region's anchor point be (0,100).
      6. Let region's viewport anchor point be (0,100).
      7. Let region's scroll value be NONE.
      8. Collect WebVTT region settings from metadata's value using region for the results.
      9. Region processing: Construct a WebVTT Region Object from region, follow the WebVTT region DOM construction rule and have the WebVTT Region Object take part in the WebVTT cue text rendering rules extended as below.
      10. If the text track list of regions regions contains a region with the same region identifier value as region, remove that region.
      11. Add region to the text track list of regions regions.
    6. Jump back to the step labeled header.

This specification ignores all WebVTT metadata headers that don't specify regions.

Introduction of a WebVTT region settings parser

We first introduce an algorithm to parse a percentage string and then the algorithm to collect WebVTT region settings.

The rules to parse a percentage string are as follows. This will return a percentage value or, if at any point the algorithm says that it "fails", this means that it is aborted at that point with an IndexSizeError and returns nothing.

  1. Let input be the string being parsed.

  2. If input contains any characters other than U+0025 PERCENT SIGN characters (%), U+002E DOT characters (.) and ASCII digits, then fail.

  3. If input does not contain at least one ASCII digit, then fail.

  4. If input contains more than one U+002E DOT character (.), then fail.

  5. If any character in input other than the last character is a U+0025 PERCENT SIGN character (%), then fail.

  6. If the last character in input is not a U+0025 PERCENT SIGN character (%), then fail.

  7. Ignoring the trailing percent sign, interpret input as a real number. Let that number be the percentage.

  8. If percentage is outside Throws an the range 0.0% .. 100.0%, fail.

  9. Return percentage.

When the algorithm above requires that the user agent collect WebVTT region settings from a string input for a text track, the user agent must run the following algorithm. This algorithm returns a list of WebVTT Region Objects.

  1. Let settings be the result of splitting input on spaces.

  2. For each token setting in the list settings, run the following substeps:

    1. If setting does not contain a U+003D EQUALS SIGN character (=), or if the first U+003D EQUALS SIGN character (=) in setting is either the first or last character of setting, then jump to the step labeled next setting.

    2. Let name be the leading substring of setting up to and excluding the first U+003D EQUALS SIGN character (=) in that string.

    3. Let value be the trailing substring of setting starting from the character immediately after the first U+003D EQUALS SIGN character (=) in that string.

    4. Run the appropriate substeps that apply for the value of name, as follows:

      If name is a case-sensitive match for "id"

      Let region's identifier be value.

      Otherwise if name is a case-sensitive match for "width"

      If parse a percentage string from value returns a percentage, let region's text track region width be percentage.

      Otherwise if name is a case-sensitive match for "lines"
      1. If value contains any characters other than ASCII digits, then jump to the step labeled next setting.

      2. Interpret value as an integer, and let number be that number.

      3. Let region's text track region lines be number.

      Otherwise if name is a case-sensitive match for "regionanchor"
      1. If value does not contain a U+002C COMMA character (,), then jump to the step labeled next setting.

      2. Let anchorX be the leading substring of value up to and excluding the first U+002C COMMA character (,) in that string.

      3. Let anchorY be the trailing substring of value starting from the character immediately after the first U+002C COMMA character (,) in that string.

      4. If parse a percentage string from anchorX or parse a percentage string from anchorY don't return a percentage, then jump to the step labeled next setting.

      5. Let region's text track region anchor point be the tuple of the percentage values calculated from anchorX and anchorY.

      Otherwise if name is a case-sensitive match for "viewportanchor"
      1. If value does not contain a U+002C COMMA character (,), then jump to the step labeled next setting.

      2. Let viewportanchorX be the leading substring of value up to and excluding the first U+002C COMMA character (,) in that string.

      3. Let viewportanchorY be the trailing substring of value starting from the character immediately after the first U+002C COMMA character (,) in that string.

      4. If parse a percentage string from viewportanchorX or parse a percentage string from viewportanchorY don't return a percentage, then jump to the step labeled next setting.

      5. Let region's text track region viewport anchor point be the tuple of the percentage values calculated from viewportanchorX and viewportanchorY.

      Otherwise if name is a case-sensitive match for "scroll"
      1. If value is a case-sensitive match for the string "up", then let region's scroll value be "scroll up".

    5. Next setting: Continue to the next setting, if any.

Extension of WebVTT cue creation (step 20-35)

This is an extension of the WebVTT parser algorithm.

Introduce an additional assignment step after step 28.

Extension of WebVTT cue setting parsing

This is an extension of the algorithm to parse the WebVTT settings.

Introduce an additional substep for step 4.

If name is a case-sensitive match for "region"
  1. Let cue's region identifier be value.

Also add an additional step 5 to the algorithm to parse the WebVTT settings:

  1. If cue's line position is not auto or cue's size is not 100 or cue's writing direction is not horizontal, but cue's region identifier is not the empty string, let cue's region identifier be the empty string.

This makes sure that no matter in which order the cue settings are provided, if the cue has a line position or a size setting or is vertical, the region identifier will be ignored.

WebVTT region object

A WebVTT region object is a conceptual construct to represent a WebVTT region that is used as a root node for lists of WebVTT node objects.

WebVTT DOM construction rules

In addition to the WebVTT cue text DOM construction rules we also need to create nodes for WebVTT region objects and WebVTT region cue span objects.

To convert a WebVTT region object to a DOM tree for Document owner, user agents must map a WebVTT region object to a DocumentFragment node.

Rules for updating the display of WebVTT text tracks

The rules for updating the display of WebVTT text tracks are defined in the WebVTT specification to render the text tracks of a HTML video element and result in a set of CSS boxes that cover the rendering area of the video element.

These rules are extended with the following steps.

Prepare region list

Extend step 7 to include regions and prepare the region list:

  1. Let cues be an empty list of text track cues and regions be an empty list of text track regions. For each track track in tracks append to regions all the regions from track's text track list of regions.

Prepare region CSS boxes

Add the following steps after step 8 to prepare the CSS boxes for regions:

Extend reusing already rendered CSS boxes of cues

Replace step 9 with the following extended step 9:

  1. If reset is false, then, for each text track cue cue in cues: if cue's text track cue display state has a set of CSS boxes, then:

Extend rendering cues into region CSS boxes

Make step 10's substeps apply only to text track cues whose text track cue region identifier does not match with the region identifier of a WebVTT region, if any. Add alternative substeps for text track cues in regions:

  1. For each text track cue cue in cues that has not yet had corresponding CSS boxes added to output, in text track cue order, run the following substeps:

    • If cue has an empty text track cue region identifier or there is no WebVTT region whose region identifier is identical to cue's text track cue region identifier, run the following substeps:

      [Run substep 1-17 as defined in the WebVTT spec.]

    • Otherwise run the following substeps:

      1. Let region be the WebVTT region whose region identifier matches the text track cue region identifier of cue.

      2. If region's text track region scroll setting is 'up' and region already has one child, set region's 'transition-property' to 'top' and 'transition-duration' to '0.433s'.

      3. Let nodes be the list of WebVTT Node Objects obtained by applying the WebVTT cue text parsing rules to the cue's text track cue text.

      4. Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the concatenation of the values of each WebVTT Text Object in nodes, in a pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and their descendants, to determine the paragraph embedding level of the first Unicode paragraph of the cue. [BIDI]

        Within a cue, paragraph boundaries are only denoted by Type B characters, such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRAPH SEPARATOR. (This means each line of the cue is reordered as if it was a separate paragraph.)

      5. If the paragraph embedding level determined in the previous step is even (the paragraph direction is left-to-right), let direction be 'ltr', otherwise, let it be 'rtl'.

      6. Let offset be the text track cue text position multiplied by the width of the WebVTT region object whose region identifier is identical to cue's text track cue region identifier and divided by 100 (i.e. interpret it as a percentage of the region width).

      7. If direction is 'ltr' and 'text-align' is 'start' or 'left', or if direction is 'rtl' and 'text-align' is 'end' or 'left', let left be offset and let right be 'auto'

        If direction is 'ltr' and 'text-align' is 'end' or 'right', or if direction is 'rtl' and 'text-align' is 'start' or 'right', let left be 'auto' and right be offset.

        If 'text-align' is 'middle', ignore the offset.

      8. Apply the terms of the CSS specifications to nodes in the same way that they are applied to in step 10, substep 12 is applied to nodes of a cue that is not part of a region, except that the initial containing block is region.

        Let boxes be the boxes generated as descendants of the initial containing block, along with their positions.

      9. If there are no line boxes in boxes, skip the remainder of these substeps for cue. The cue is ignored.

      10. Let cue's text track cue display state have the CSS boxes in boxes.

      11. Add the CSS boxes in boxes to region.

Applying CSS properties to WebVTT Region Objects and their children

When following the extended rules for updating the display of WebVTT text tracks, user agents must set properties of WebVTT region objects at the CSS user agent cascade layer as defined in this section. [CSS]

Every WebVTT region object is initialised with the following CSS settings:

The variables width, height, top, and left are the values with those names determined by the rules for updating the display of WebVTT text tracks for the text track region from which the WebVTT region object was constructed.

The children of every WebVTT region object are not initialised with the CSS properties of (root) List of WebVTT Node Objects but instead with these CSS settings:

All other non-inherited properties must be set to their initial values; inherited properties must inherit their values from the media element for which the text track region is being rendered, if any. If there is no media element (i.e. if the text track is being rendered for another media playback mechanism), then inherited properties on the WebVTT region objects must take their initial values.

If there are style sheets that apply to the media element or other playback mechanism, then they must be interpreted as defined in the next section.

CSS extension '::cue-region' pseudo-element

Pseudo-elements apply to elements that are matched by selectors. For the purpose of this section, that element is the matched element. The pseudo-element defined below affects the styling of text track regions that are being rendered for the matched element.

If the matched element is not a video element, the pseudo-element defined below won't have any effect according to this specification.

The '::cue-region' pseudo-element (with no argument) matches any List of WebVTT region objects constructed for the matched element.

The same properties that apply to '::cue' apply to the '::cue-region' pseudo-element with no argument; other properties set on the pseudo-element must be ignored.

When a user agent is rendering one or more text track regions according to the WebVTT cue text rendering rules, WebVTT region objects used in the rendering can be matched by the above pseudo-element. User agents that support the pseudo-element must dynamically update renderings accordingly. When either 'white-space' or one of the properties corresponding to the 'font' shorthand (including 'line-height') changes value, then the text track cue display state of all the text track cues in the region must be emptied and the text track's rules for updating the text track rendering must be immediately rerun.

A CSS user agent that implements the text tracks model must implement the '::cue-region' pseudo-element.

Extension of the HTML TextTrack API

The functionality of the "region" extension of WebVTT should also be available to JavaScript developers of Web applications. Therefore, the HTML TextTrack API is also extended. In particular, the TextTrack and the TextTrackCueobject are extended and TextTrackRegion and TextTrackRegionList objects are introduced.

Extension of the TextTrack object

The following attribute and method are introduced into the TextTrack object:

attribute TextTrackRegionList? regions
Returns the text track list of regions, as a TextTrackRegionList object.
void addRegion(TextTrackRegion region)
Adds the given region to TextTrack's text track list of regions. If that list already contains a region with the same identifier, update that region's attributes with those of region.
void removeRegion(TextTrackRegion region)
Removes the given region from TextTrack's text track list of regions.

Implementation

If the text track mode of the text track that the TextTrack object represents is not the text track disabled mode, then the regions attribute must return a live TextTrackRegionList object that represents the text track list of regions of the text track. Otherwise, it must return null. When an object is returned, the same object must be returned each time.

The addRegion(region) method of TextTrack objects, when invoked, must run the following steps:

  1. If the given region is in a text track list of regions, then remove region from that text track list of regions.

  2. If the method's TextTrack object's text track list of regions contains a region with the same identifier as region replace the values of that region's width, lines, anchor point, viewport anchor point and scroll attributes with those of region.

    Otherwise: add region to the method's TextTrack object's text track list of regions.

The removeRegion(region) method of TextTrack objects, when invoked, must run the following steps:

  1. If the given region is not currently listed in the method's TextTrack object's text track list of regions, then throw a NotFoundError exception.

  2. Otherwise: remove region from that text track list of regions.

Extension of the TextTrackCue object

The following attribute is introduced into the TextTrackCue object:

attribute DOMString regionId
Returns the text track cue region identifier.

Implementation

Initialise regionId in the TextTrackCue constructor with the empty string.

The regionId attribute, on getting, must return the text track cue region identifier of the text track cue that the TextTrackCue object represents. On setting, the text track region identifier must be set to the new value.

TextTrackRegion object

readonly attribute TextTrack? track
Returns the TextTrack object to which this text track region belongs, if any, or null otherwise.
attribute DOMString id
Returns the text track region identifier. Can be set.
attribute double width
Returns the text track region width as a percentage of the video width. Can be set. Throws an IndexSizeError if the new value is not in the range 0.0% .. 100.0%.
attribute long lines
Returns the text track region height as a number of lines. Can be set.
attribute double regionAnchorX
Returns the text track region anchor X offset as a percentage of the region width. Can be set. Throws an IndexSizeError if the new value is not in the range 0.0% .. 100.0%.
attribute double regionAnchorY
Returns the text track region anchor Y offset as a percentage of the region height. Can be set. Throws an IndexSizeError if the new value is not in the range 0.0% .. 100.0%.
attribute double viewportAnchorX
Returns the text track viewport anchor X offset as a percentage of the video width. Can be set. Throws an IndexSizeError if the new value is not in the range 0.0% .. 100.0%.
attribute double viewportAnchorY
Returns the text track viewport anchor Y offset as a percentage of the video height. Can be set. Throws an IndexSizeError if the new value is not in the range 0.0% .. 100.0%.
attribute DOMString scroll

Returns a string representing the text track region scroll as follows:

If it is unset.

The empty string.

If it is up

The string "up".

Can be set.

Implementation

The TextTrackRegion() constructor, when invoked, must run the following steps:

  1. Create a new text track region. Let region be that text track region.

  2. Let region's text track region identifier be the empty string.

  3. Let region's text track region width be 100.

  4. Let region's text track region lines be 3.

  5. Let region's text track region regionAnchorX be 0.

  6. Let region's text track region regionAnchorY be 100.

  7. Let region's text track region viewportAnchorX be 0.

  8. Let region's text track region viewportAnchorY be 100.

  9. Let region's text track region scroll be the empty string.

  10. Return the TextTrackRegion object representing region.

The track attribute, on getting, must return the TextTrack object of the text track in whose list of regions the text track region that the TextTrackRegion object represents finds itself, if any; or null otherwise.

The width attribute, on getting, must return the text track region width of the text track region that the TextTrackRegion object represents, in percent of video width. On setting, the text track region width must be set to the new value, interpreted as a percentage.

The lines attribute, on getting, must return the text track region lines of the text track region that the TextTrackRegion object represents, as number of lines. On setting, the text track region lines must be set to the new value, interpreted as a number of lines.

The regionAnchor X attribute, on getting, must return the text track region anchor X offset of the text track region that the TextTrackRegion object represents, in percent of region width. On setting, the text track regionAnchor X distance must be set to the new value, interpreted as a percentage.

The regionAnchor Y attribute, on getting, must return the text track region anchor Y offset of the text track region that the TextTrackRegion object represents, in percent of region height. On setting, the text track regionAnchor Y distance must be set to the new value, interpreted as a percentage.

The viewportAnchor X attribute, on getting, must return the text track region viewport anchor X offset of the text track region that the TextTrackRegion object represents, in percent of video width. On setting, the text track viewportAnchor X distance must be set to the new value, interpreted as a percentage.

The viewportAnchor Y attribute, on getting, must return the text track region viewport anchor Y offset of the text track region that the TextTrackRegion object represents, in percent of video height. On setting, the text track viewportAnchor Y distance must be set to the new value, interpreted as a percentage.

The scroll attribute, on getting, must return the string from the second cell of the row in the table below whose first cell is the text track region scroll setting of the text track region that the TextTrackRegion object represents:

Text track region scroll setting scroll value
None "" (the empty string)
"Up "up"

On setting, the text track scroll must be set to the value given on the first cell of the row in the table above whose second cell is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.

TextTrackRegionList object

readonly attribute unsigned long length
Returns the number of regions in the list.
getter TextTrackRegion (unsigned long index)
Returns the text track region with index index in the list. The regions are sorted in the order in which they were inserted.
TextTrackRegion? getRegionById(DOMString id)
Returns the first text track region with text track region identifier id.

Returns null if none of the regions have the given identifier or if the argument is the empty string.

Implementation

A TextTrackRegionList object represents a dynamically updating list of text track regions in a given order.

The length attribute must return the number of regions in the list represented by the TextTrackRegionList object.

The supported property indices of a TextTrackRegionList object at any instant are the numbers from zero to the number of regions in the list represented by the TextTrackRegionList object minus one, if any. If there are no regions in the list, there are no supported property indices.

To determine the value of an indexed property for a given index index, the user agent must return the index of the text track region in the list represented by the TextTrackRegionList object.

The getRegionById(id) method, when called with an argument other than the empty string, must return the first text track region in the list represented by the TextTrackRegionList object whose text track region identifier is id, if any, or null otherwise. If the argument is the empty string, then the method must return null.

References

[CEA-708]
CEA-708-D: Digital Television (DTV) Closed Captioning, CEA (Consumer Electronics Association).
[CSS]
Cascading Style Sheets Level 2 Revision 1, B. Bos, T. Çelik, I. Hickson, H. Lie. W3C.
[CSSVALUES]
CSS3 Values and Units, H. Lie, T. Atkins, E. Etemad. W3C.
[FCC]
Captioning of Internet Video Programming, 13 June 2012, US FCC (Federal Communications Commission).
[HTML]
HTML 5.1 Nightly: A vocabulary and associated APIs for HTML and XHTML, Robin Berjon, Travis Leithead, Erika Doyle Navara, Edward O'Connor, Silvia Pfeiffer. W3C.
[WEBVTT]
WebVTT: Web Video Text Tracks, Ian Hickson. W3C.