From cb842a61ef21cb0c6cba46869ec7b81e56c72c57 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 21 Sep 2023 19:47:48 +0100 Subject: [PATCH] Add TextTrackCue ctor & cue + cuebackground attrs --- source | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/source b/source index 73646634775..b710c0c3c04 100644 --- a/source +++ b/source @@ -2880,6 +2880,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • "DataCloneError"
  • "EncodingError"
  • "NotAllowedError"
  • +
  • "InvalidNodeTypeError"
  • When this specification requires a user agent to create a Date object @@ -3271,6 +3272,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

  • aborted
  • signal abort
  • The get an attribute by name algorithm
  • +
  • The exclusive Text node concept
  • The following features are defined in UI Events: UIEVENTS

    @@ -12941,6 +12943,8 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%
  • autocapitalize
  • autofocus
  • contenteditable
  • +
  • cue
  • +
  • cuebackground
  • dir
  • draggable
  • enterkeyhint
  • @@ -39074,6 +39078,16 @@ interface VideoTrack {

    An arbitrary string.

    +
    A fragment +
    +

    A DocumentFragment that is the content of the cue.

    +
    + +
    Pseudo-elements +
    +

    A map representing the pseudo-element associated with the cue.

    +
    +
    A start time

    The time, in seconds and fractions of a second, that describes the beginning of the range of @@ -40124,6 +40138,7 @@ interface TextTrackCueList {

    [Exposed=Window]
     interface TextTrackCue : EventTarget {
    +  constructor(double startTime, double endTime, DocumentFragment cueFragment);
       readonly attribute TextTrack? track;
     
       attribute DOMString id;
    @@ -40136,6 +40151,10 @@ interface TextTrackCue : EventTarget {
     };
    +
    cue = new TextTrackCue(startTime, endTime, cueFragment)
    +
    +

    Creates a TextTrackCue instance with the given parameters.

    +
    cue.track

    Returns the TextTrack object to which this text track cue belongs, @@ -40175,6 +40194,110 @@ interface TextTrackCue : EventTarget {

    +

    The TextTrackCue(startTime, endTime, + cueFragment) constructor runs the following steps:

    +
      +
    1. If cueFragment first child is null, then throw an + "InvalidNodeTypeError" DOMException.

    2. +
    3. For each child in cueFragment's children:

      +
        +
      1. Ensure child is an allowed cue descendant.

      2. +
      +
    4. +
    5. Let fragment be a newly created DocumentFragment using + this's relevant global object's associated Document.

    6. +
    7. Let clones be a clone of cueFragment, with the clone children flag + set to true.

      This is to prevent mutation of the cueFragment + after construction.

      +
    8. +
    9. Append clones into fragment.

      "Append" ensures pre-insertion + validity, which can throw.

      +
    10. +
    11. Initialize this's text track cue pseudo-elements to a new map + «[ "::cue" → null, "::cue-background" → null ]».

    12. +
    13. Assign the required pseudo-elements for + cue passing this and fragment.

    14. +
    15. Set this's text track cue fragment to + fragment.

    16. +
    17. Set this's text track cue start time to + startTime.

    18. +
    19. Set this's text track cue end time to + endTime.

    20. +
    21. Return this.

    22. +
    + +

    To ensure Node node is an + allowed cue descendant, run these steps:

    +
      +
    1. If node is not an exclusive Text node or is not an + Element, then throw "InvalidNodeTypeError" + DOMException.

    2. +
    3. If node is an Element:

      +
        +
      1. If node's namespace is not in the HTML namespace, then throw + "InvalidNodeTypeError" DOMException.

      2. +
      3. If node's local name is not one of the following: "b", "br", "i", "div", + "p", "rb", "rt", "rtc", "ruby", "span", then throw + "InvalidNodeTypeError" DOMException.

      4. +
      5. For each child of node in tree order: +

          +
        1. Ensure child is an allowed cue descendant.

        2. +
        +
      6. +
      +
    4. +
    + +

    To assign required pseudo-elements for + cue to a TextTrack track with a Node node + and an optional boolean isRoot (default true):

    +
      +
    1. If node is an Element:

      +
        +
      1. Let pseudos be track's text track cue + pseudo-elements.

      2. +
      3. If pseudos["::cue-background"] is null:

        +
          +
        1. Set pseudos["::cue-background"] to the result of getting an attribute in + the HTML namespace, "cuebackground", node.

        2. +
        +
      4. +
      5. If pseudos["::cue"] is null:

        +
          +
        1. Let cue be the result of getting an attribute in the HTML + namespace, "cue", node.

        2. +
        3. If cue is not null:

          +
            +
          1. Let backgroundCue be pseudos["::cue-background"].

          2. +
          3. If backgroundCue is null, then throw a + "HierarchyRequestError" DOMException.

          4. +
          5. If backgroundCue is not an inclusive ancestor of cue, then + throw a "HierarchyRequestError" + DOMException.

          6. +
          7. Set pseudos["::cue"] to cue.

          8. +
          9. Return.

          10. +
          +
        4. +
        +
      6. +
      7. For each child of node in tree order:

        +
          +
        1. Assign required pseudo-elements for cue passing track, child, + and false.

        2. +
        +
      8. +
      +
    2. +
    3. If isRoot is true:

      +
        +
      1. If pseudos["::cue"] is null or pseudos["::cue-background"] is + null, then throw an "InvalidStateError" + DOMException.

      2. +
      +
    4. +

    The track attribute, on getting, must return the TextTrack object of the text @@ -40262,7 +40385,18 @@ interface TextTrackCue : EventTarget {

    +
    The cue and cuebackground attributes
    + +

    When the cue attribute is present, the element serves as a text track + cue.

    + +

    When the cuebackground attribute is present, the element serves as cue background + for a text track cue.

    + +

    The cue and cuebackground attributes must each be present once.

    +

    The cue and cuebackground can be present on the same element.

    Best practices for metadata text tracks