OLD | NEW |
1 var captionsButtonElement; | 1 var captionsButtonElement; |
2 var captionsButtonCoordinates; | 2 var captionsButtonCoordinates; |
3 | 3 |
4 // As specified in mediaControls.css, this is how long it takes to fade out cont
rols | 4 // As specified in mediaControls.css, this is how long it takes to fade out cont
rols |
5 const controlsFadeOutDurationMs = 300; | 5 const controlsFadeOutDurationMs = 300; |
6 | 6 |
7 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and | 7 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and |
8 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls' | 8 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls' |
9 // in MediaControls.cpp. | 9 // in MediaControls.cpp. |
10 const controlsMouseMovementTimeoutMs = 3000; | 10 const controlsMouseMovementTimeoutMs = 3000; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 var button = mediaControlsButton(element, id); | 66 var button = mediaControlsButton(element, id); |
67 var buttonBoundingRect = button.getBoundingClientRect(); | 67 var buttonBoundingRect = button.getBoundingClientRect(); |
68 return new Array(buttonBoundingRect.width, buttonBoundingRect.height); | 68 return new Array(buttonBoundingRect.width, buttonBoundingRect.height); |
69 } | 69 } |
70 | 70 |
71 function textTrackContainerElement(parentElement) { | 71 function textTrackContainerElement(parentElement) { |
72 return mediaControlsElement(internals.shadowRoot(parentElement).firstChild, | 72 return mediaControlsElement(internals.shadowRoot(parentElement).firstChild, |
73 "-webkit-media-text-track-container"); | 73 "-webkit-media-text-track-container"); |
74 } | 74 } |
75 | 75 |
76 function textTrackCueDisplayElement(parentElement) { | |
77 var containerElement = textTrackContainerElement(parentElement); | |
78 return mediaControlsElement(containerElement.firstChild, "-webkit-media-text
-track-display"); | |
79 } | |
80 | |
81 function textTrackCueElementByIndex(parentElement, cueIndex) { | 76 function textTrackCueElementByIndex(parentElement, cueIndex) { |
82 var displayElement = textTrackCueDisplayElement(parentElement); | 77 var displayElement = textTrackDisplayElement(parentElement); |
83 if (displayElement) { | 78 if (displayElement) { |
84 for (i = 0; i < cueIndex; i++) | 79 for (i = 0; i < cueIndex; i++) |
85 displayElement = displayElement.nextSibling; | 80 displayElement = displayElement.nextSibling; |
86 } | 81 } |
87 | 82 |
88 return displayElement; | 83 return displayElement; |
89 } | 84 } |
90 | 85 |
91 function textTrackRegionElement(parentElement) | 86 function textTrackRegionElement(parentElement) |
92 { | 87 { |
93 var containerElement = textTrackContainerElement(parentElement); | 88 var containerElement = textTrackContainerElement(parentElement); |
94 return mediaControlsElement(containerElement.firstChild, "-webkit-media-text
-track-region"); | 89 return mediaControlsElement(containerElement.firstChild, "-webkit-media-text
-track-region"); |
95 } | 90 } |
96 | 91 |
97 function textTrackRegionContainerElement(parentElement) | 92 function textTrackRegionContainerElement(parentElement) |
98 { | 93 { |
99 var containerElement = textTrackContainerElement(parentElement); | 94 var containerElement = textTrackContainerElement(parentElement); |
100 return mediaControlsElement(containerElement.firstChild, "-webkit-media-text
-track-region-container"); | 95 return mediaControlsElement(containerElement.firstChild, "-webkit-media-text
-track-region-container"); |
101 } | 96 } |
102 | 97 |
103 // TODO(srirama.m): Phase out the uses of this function and | 98 function textTrackDisplayElement(parentElement) |
104 // replace with more specific functions at each call site. | |
105 function textTrackDisplayElement(parentElement, id, cueNumber) | |
106 { | 99 { |
107 var containerElement = textTrackContainerElement(parentElement); | 100 var containerElement = textTrackContainerElement(parentElement); |
108 | 101 return mediaControlsElement(containerElement.firstChild, "-webkit-media-text
-track-display"); |
109 if (!containerElement) | |
110 throw "Failed to find text track container element"; | |
111 | |
112 if (!id) | |
113 return containerElement; | |
114 | |
115 var controlID = id; | |
116 if (controlID != 'cue') | |
117 controlID = "-webkit-media-text-track-" + id; | |
118 | |
119 var displayElement = mediaControlsElement(containerElement.firstChild, contr
olID); | |
120 if (!displayElement) | |
121 throw "No text track cue with display id '" + controlID + "' is currentl
y visible"; | |
122 | |
123 if (cueNumber) { | |
124 for (i = 0; i < cueNumber; i++) | |
125 displayElement = displayElement.nextSibling; | |
126 | |
127 if (!displayElement) | |
128 throw "There are not " + cueNumber + " text track cues visible"; | |
129 } | |
130 | |
131 return displayElement; | |
132 } | 102 } |
133 | 103 |
134 function isClosedCaptionsButtonVisible(currentMediaElement) | 104 function isClosedCaptionsButtonVisible(currentMediaElement) |
135 { | 105 { |
136 var captionsButtonElement = mediaControlsButton(currentMediaElement, "toggle
-closed-captions-button"); | 106 var captionsButtonElement = mediaControlsButton(currentMediaElement, "toggle
-closed-captions-button"); |
137 var captionsButtonCoordinates = mediaControlsButtonCoordinates(currentMediaE
lement, "toggle-closed-captions-button"); | 107 var captionsButtonCoordinates = mediaControlsButtonCoordinates(currentMediaE
lement, "toggle-closed-captions-button"); |
138 | 108 |
139 if (!captionsButtonElement.disabled | 109 if (!captionsButtonElement.disabled |
140 && captionsButtonCoordinates[0] > 0 | 110 && captionsButtonCoordinates[0] > 0 |
141 && captionsButtonCoordinates[1] > 0) { | 111 && captionsButtonCoordinates[1] > 0) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 throw "The media will end before the controls have been hidden"; | 165 throw "The media will end before the controls have been hidden"; |
196 | 166 |
197 setTimeout(func, hideTimeoutMs); | 167 setTimeout(func, hideTimeoutMs); |
198 } | 168 } |
199 | 169 |
200 function hasFullscreenButton(element) | 170 function hasFullscreenButton(element) |
201 { | 171 { |
202 var size = mediaControlsButtonDimensions(element, "fullscreen-button"); | 172 var size = mediaControlsButtonDimensions(element, "fullscreen-button"); |
203 return size[0] > 0 && size[1] > 0; | 173 return size[0] > 0 && size[1] > 0; |
204 } | 174 } |
OLD | NEW |