OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 26 matching lines...) Expand all Loading... | |
37 static const double timeWithoutMouseMovementBeforeHidingFullscreenControls = 3; | 37 static const double timeWithoutMouseMovementBeforeHidingFullscreenControls = 3; |
38 | 38 |
39 MediaControls::MediaControls(Document& document) | 39 MediaControls::MediaControls(Document& document) |
40 : HTMLDivElement(document) | 40 : HTMLDivElement(document) |
41 , m_mediaController(0) | 41 , m_mediaController(0) |
42 , m_panel(0) | 42 , m_panel(0) |
43 , m_textDisplayContainer(0) | 43 , m_textDisplayContainer(0) |
44 , m_playButton(0) | 44 , m_playButton(0) |
45 , m_currentTimeDisplay(0) | 45 , m_currentTimeDisplay(0) |
46 , m_timeline(0) | 46 , m_timeline(0) |
47 , m_panelMuteButton(0) | 47 , m_muteButton(0) |
48 , m_volumeSlider(0) | 48 , m_volumeSlider(0) |
49 , m_toggleClosedCaptionsButton(0) | 49 , m_toggleClosedCaptionsButton(0) |
50 , m_fullScreenButton(0) | 50 , m_fullScreenButton(0) |
51 , m_durationDisplay(0) | 51 , m_durationDisplay(0) |
52 , m_enclosure(0) | 52 , m_enclosure(0) |
53 , m_hideFullscreenControlsTimer(this, &MediaControls::hideFullscreenControls TimerFired) | 53 , m_hideFullscreenControlsTimer(this, &MediaControls::hideFullscreenControls TimerFired) |
54 , m_isFullscreen(false) | 54 , m_isFullscreen(false) |
55 , m_isMouseOverControls(false) | 55 , m_isMouseOverControls(false) |
56 { | 56 { |
57 } | 57 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 panel->appendChild(currentTimeDisplay.release(), exceptionState); | 101 panel->appendChild(currentTimeDisplay.release(), exceptionState); |
102 if (exceptionState.hadException()) | 102 if (exceptionState.hadException()) |
103 return false; | 103 return false; |
104 | 104 |
105 RefPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaContr olTimeRemainingDisplayElement::create(document); | 105 RefPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaContr olTimeRemainingDisplayElement::create(document); |
106 m_durationDisplay = durationDisplay.get(); | 106 m_durationDisplay = durationDisplay.get(); |
107 panel->appendChild(durationDisplay.release(), exceptionState); | 107 panel->appendChild(durationDisplay.release(), exceptionState); |
108 if (exceptionState.hadException()) | 108 if (exceptionState.hadException()) |
109 return false; | 109 return false; |
110 | 110 |
111 RefPtr<MediaControlPanelMuteButtonElement> panelMuteButton = MediaControlPan elMuteButtonElement::create(document, this); | 111 RefPtr<MediaControlMuteButtonElement> muteButton = MediaControlMuteButtonEle ment::create(document); |
112 m_panelMuteButton = panelMuteButton.get(); | 112 m_muteButton = muteButton.get(); |
113 panel->appendChild(panelMuteButton.release(), exceptionState); | 113 panel->appendChild(muteButton.release(), exceptionState); |
114 if (exceptionState.hadException()) | 114 if (exceptionState.hadException()) |
115 return false; | 115 return false; |
116 | 116 |
117 RefPtr<MediaControlPanelVolumeSliderElement> slider = MediaControlPanelVolum eSliderElement::create(document); | 117 RefPtr<MediaControlVolumeSliderElement> slider = MediaControlVolumeSliderEle ment::create(document); |
118 m_volumeSlider = slider.get(); | 118 m_volumeSlider = slider.get(); |
119 panel->appendChild(slider.release(), exceptionState); | 119 panel->appendChild(slider.release(), exceptionState); |
120 if (exceptionState.hadException()) | 120 if (exceptionState.hadException()) |
121 return false; | 121 return false; |
122 | 122 |
123 RefPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClosedCaptionsBu tton = MediaControlToggleClosedCaptionsButtonElement::create(document, this); | 123 RefPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClosedCaptionsBu tton = MediaControlToggleClosedCaptionsButtonElement::create(document, this); |
124 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); | 124 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); |
125 panel->appendChild(toggleClosedCaptionsButton.release(), exceptionState); | 125 panel->appendChild(toggleClosedCaptionsButton.release(), exceptionState); |
126 if (exceptionState.hadException()) | 126 if (exceptionState.hadException()) |
127 return false; | 127 return false; |
(...skipping 22 matching lines...) Expand all Loading... | |
150 if (m_mediaController == controller) | 150 if (m_mediaController == controller) |
151 return; | 151 return; |
152 m_mediaController = controller; | 152 m_mediaController = controller; |
153 | 153 |
154 m_panel->setMediaController(controller); | 154 m_panel->setMediaController(controller); |
155 if (m_textDisplayContainer) | 155 if (m_textDisplayContainer) |
156 m_textDisplayContainer->setMediaController(controller); | 156 m_textDisplayContainer->setMediaController(controller); |
157 m_playButton->setMediaController(controller); | 157 m_playButton->setMediaController(controller); |
158 m_currentTimeDisplay->setMediaController(controller); | 158 m_currentTimeDisplay->setMediaController(controller); |
159 m_timeline->setMediaController(controller); | 159 m_timeline->setMediaController(controller); |
160 m_panelMuteButton->setMediaController(controller); | 160 m_muteButton->setMediaController(controller); |
161 m_volumeSlider->setMediaController(controller); | 161 m_volumeSlider->setMediaController(controller); |
162 m_toggleClosedCaptionsButton->setMediaController(controller); | 162 m_toggleClosedCaptionsButton->setMediaController(controller); |
163 m_fullScreenButton->setMediaController(controller); | 163 m_fullScreenButton->setMediaController(controller); |
164 m_durationDisplay->setMediaController(controller); | 164 m_durationDisplay->setMediaController(controller); |
165 m_enclosure->setMediaController(controller); | 165 m_enclosure->setMediaController(controller); |
166 } | 166 } |
167 | 167 |
168 void MediaControls::reset() | 168 void MediaControls::reset() |
169 { | 169 { |
170 Page* page = document().page(); | 170 Page* page = document().page(); |
171 if (!page) | 171 if (!page) |
172 return; | 172 return; |
173 | 173 |
174 double duration = m_mediaController->duration(); | 174 double duration = m_mediaController->duration(); |
175 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION); | 175 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION); |
176 m_durationDisplay->setCurrentValue(duration); | 176 m_durationDisplay->setCurrentValue(duration); |
177 | 177 |
178 m_playButton->updateDisplayType(); | 178 m_playButton->updateDisplayType(); |
179 | 179 |
180 updateCurrentTimeDisplay(); | 180 updateCurrentTimeDisplay(); |
181 | 181 |
182 m_timeline->setDuration(m_mediaController->duration()); | 182 m_timeline->setDuration(m_mediaController->duration()); |
183 m_timeline->setPosition(m_mediaController->currentTime()); | 183 m_timeline->setPosition(m_mediaController->currentTime()); |
184 | 184 |
185 m_panelMuteButton->show(); | |
acolwell GONE FROM CHROMIUM
2014/03/04 23:49:28
No longer needed because it is never hidden?
philipj_slow
2014/03/05 13:12:08
Indeed, "there is nothing that ever hides the butt
| |
186 | |
187 if (!m_mediaController->hasAudio()) { | 185 if (!m_mediaController->hasAudio()) { |
188 m_volumeSlider->hide(); | 186 m_volumeSlider->hide(); |
acolwell GONE FROM CHROMIUM
2014/03/04 23:49:28
We hide the volume slider, but not the mute button
philipj_slow
2014/03/05 13:12:08
Yeah, my guess is that once upon a time the mute b
| |
189 } else { | 187 } else { |
190 m_volumeSlider->show(); | 188 m_volumeSlider->show(); |
191 m_volumeSlider->setVolume(m_mediaController->volume()); | 189 m_volumeSlider->setVolume(m_mediaController->volume()); |
192 } | 190 } |
193 | 191 |
194 refreshClosedCaptionsButtonVisibility(); | 192 refreshClosedCaptionsButtonVisibility(); |
195 | 193 |
196 if (m_mediaController->hasVideo()) | 194 if (m_mediaController->hasVideo()) |
197 m_fullScreenButton->show(); | 195 m_fullScreenButton->show(); |
198 else | 196 else |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 m_durationDisplay->hide(); | 282 m_durationDisplay->hide(); |
285 } | 283 } |
286 | 284 |
287 // Allow the theme to format the time. | 285 // Allow the theme to format the time. |
288 m_currentTimeDisplay->setInnerText(RenderTheme::theme().formatMediaControlsC urrentTime(now, duration), IGNORE_EXCEPTION); | 286 m_currentTimeDisplay->setInnerText(RenderTheme::theme().formatMediaControlsC urrentTime(now, duration), IGNORE_EXCEPTION); |
289 m_currentTimeDisplay->setCurrentValue(now); | 287 m_currentTimeDisplay->setCurrentValue(now); |
290 } | 288 } |
291 | 289 |
292 void MediaControls::changedMute() | 290 void MediaControls::changedMute() |
293 { | 291 { |
294 m_panelMuteButton->changedMute(); | 292 m_muteButton->updateDisplayType(); |
295 | 293 |
296 if (m_mediaController->muted()) | 294 if (m_mediaController->muted()) |
297 m_volumeSlider->setVolume(0); | 295 m_volumeSlider->setVolume(0); |
298 else | 296 else |
299 m_volumeSlider->setVolume(m_mediaController->volume()); | 297 m_volumeSlider->setVolume(m_mediaController->volume()); |
300 } | 298 } |
301 | 299 |
302 void MediaControls::changedVolume() | 300 void MediaControls::changedVolume() |
303 { | 301 { |
304 m_volumeSlider->setVolume(m_mediaController->volume()); | 302 m_volumeSlider->setVolume(m_mediaController->volume()); |
305 if (m_panelMuteButton->renderer()) | 303 if (m_muteButton->renderer()) |
306 m_panelMuteButton->renderer()->repaint(); | 304 m_muteButton->renderer()->repaint(); |
307 } | 305 } |
308 | 306 |
309 void MediaControls::changedClosedCaptionsVisibility() | 307 void MediaControls::changedClosedCaptionsVisibility() |
310 { | 308 { |
311 m_toggleClosedCaptionsButton->updateDisplayType(); | 309 m_toggleClosedCaptionsButton->updateDisplayType(); |
312 } | 310 } |
313 | 311 |
314 void MediaControls::refreshClosedCaptionsButtonVisibility() | 312 void MediaControls::refreshClosedCaptionsButtonVisibility() |
315 { | 313 { |
316 if (m_mediaController->hasClosedCaptions()) | 314 if (m_mediaController->hasClosedCaptions()) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 m_textDisplayContainer->updateDisplay(); | 454 m_textDisplayContainer->updateDisplay(); |
457 } | 455 } |
458 | 456 |
459 void MediaControls::insertTextTrackContainer(PassRefPtr<MediaControlTextTrackCon tainerElement> textTrackContainer) | 457 void MediaControls::insertTextTrackContainer(PassRefPtr<MediaControlTextTrackCon tainerElement> textTrackContainer) |
460 { | 458 { |
461 // Insert it before the first controller element so it always displays behin d the controls. | 459 // Insert it before the first controller element so it always displays behin d the controls. |
462 insertBefore(textTrackContainer, m_enclosure); | 460 insertBefore(textTrackContainer, m_enclosure); |
463 } | 461 } |
464 | 462 |
465 } | 463 } |
OLD | NEW |