upload tizen1.0 source
[framework/web/webkit-efl.git] / LayoutTests / media / media-controls.js
1
2 function mediaControlsElement(first, id)
3 {
4     for (var element = first; element; element = element.nextSibling) {
5
6         // Not every element in the media controls has a shadow pseudo ID, eg. the
7         // text nodes for the time values, so guard against exceptions.
8         try {
9             if (internals.shadowPseudoId(element) == id)
10                 return element;
11         } catch (exception) { }
12
13         if (element.firstChild) {
14             var childElement = mediaControlsElement(element.firstChild, id);
15             if (childElement)
16                 return childElement;
17         }
18     }
19
20     return null;
21 }
22
23 function mediaControlsButtonCoordinates(element, id)
24 {
25     var controlID = "-webkit-media-controls-" + id;
26     var button = mediaControlsElement(internals.shadowRoot(element).firstChild, controlID);
27     if (!button)
28         throw "Failed to find media control element ID '" + id + "'";
29
30     var buttonBoundingRect = button.getBoundingClientRect();
31     var x = buttonBoundingRect.left + buttonBoundingRect.width / 2;
32     var y = buttonBoundingRect.top + buttonBoundingRect.height / 2;
33     return new Array(x, y);
34 }
35
36 function textTrackDisplayElement(parentElement, id)
37 {
38     var controlID = "-webkit-media-text-track-" + id;
39     var displayElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, controlID);
40     if (!displayElement)
41         throw "Failed to find media control element ID '" + controlID + "'";
42     return displayElement;
43 }