2 function mediaControlsElement(first, id)
4 for (var element = first; element; element = element.nextSibling) {
5 // Not every element in the media controls has a shadow pseudo ID, eg. the
6 // text nodes for the time values, so guard against exceptions.
8 if (internals.shadowPseudoId(element) == id)
10 } catch (exception) { }
12 if (element.firstChild) {
13 var childElement = mediaControlsElement(element.firstChild, id);
22 function mediaControlsButtonCoordinates(element, id)
24 var controlID = "-webkit-media-controls-" + id;
25 var button = mediaControlsElement(internals.shadowRoot(element).firstChild, controlID);
27 throw "Failed to find media control element ID '" + id + "'";
29 var buttonBoundingRect = button.getBoundingClientRect();
30 var x = buttonBoundingRect.left + buttonBoundingRect.width / 2;
31 var y = buttonBoundingRect.top + buttonBoundingRect.height / 2;
32 return new Array(x, y);
35 function mediaControlsButtonDimensions(element, id)
37 var controlID = "-webkit-media-controls-" + id;
38 var button = mediaControlsElement(internals.shadowRoot(element).firstChild, controlID);
40 throw "Failed to find media control element ID '" + id + "'";
42 var buttonBoundingRect = button.getBoundingClientRect();
43 return new Array(buttonBoundingRect.width, buttonBoundingRect.height);
46 function textTrackDisplayElement(parentElement, id, cueNumber)
48 var textTrackContainerID = "-webkit-media-text-track-container";
49 var containerElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, "-webkit-media-text-track-container");
51 if (!containerElement)
52 throw "Failed to find text track container element";
55 return containerElement;
57 var controlID = "-webkit-media-text-track-" + arguments[1];
59 var displayElement = mediaControlsElement(containerElement.firstChild, controlID);
61 throw "No text track cue with display id '" + controlID + "' is currently visible";
64 for (i = 0; i < cueNumber; i++)
65 displayElement = displayElement.nextSibling;
68 throw "There are not " + cueNumber + " text track cues visible";
71 return displayElement;