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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 makeOpaque(); | 184 makeOpaque(); |
185 } | 185 } |
186 | 186 |
187 void MediaControls::show() | 187 void MediaControls::show() |
188 { | 188 { |
189 makeOpaque(); | 189 makeOpaque(); |
190 m_panel->setIsDisplayed(true); | 190 m_panel->setIsDisplayed(true); |
191 m_panel->show(); | 191 m_panel->show(); |
192 } | 192 } |
193 | 193 |
194 void MediaControls::mediaElementFocused() | |
195 { | |
196 show(); | |
197 stopHideMediaControlsTimer(); | |
198 } | |
199 | |
194 void MediaControls::hide() | 200 void MediaControls::hide() |
195 { | 201 { |
196 m_panel->setIsDisplayed(false); | 202 m_panel->setIsDisplayed(false); |
197 m_panel->hide(); | 203 m_panel->hide(); |
198 } | 204 } |
199 | 205 |
200 void MediaControls::makeOpaque() | 206 void MediaControls::makeOpaque() |
201 { | 207 { |
202 m_panel->makeOpaque(); | 208 m_panel->makeOpaque(); |
203 } | 209 } |
204 | 210 |
205 void MediaControls::makeTransparent() | 211 void MediaControls::makeTransparent() |
206 { | 212 { |
207 m_panel->makeTransparent(); | 213 m_panel->makeTransparent(); |
208 } | 214 } |
209 | 215 |
210 bool MediaControls::shouldHideMediaControls() | 216 bool MediaControls::shouldHideMediaControls(HideBehavior behavior) const |
211 { | 217 { |
212 return !m_panel->hovered(); | 218 // Never hide for <audio>. |
philipj_slow
2014/05/23 13:22:43
The comment doesn't quite match the code. isHTMLAu
fs
2014/05/23 14:39:30
Will change to something more long-winded about "v
| |
219 if (!mediaElement().hasVideo()) | |
220 return false; | |
221 // Don't hide if hovered or the mouse is over the controls. | |
222 if (m_panel->hovered() || m_isMouseOverControls) | |
philipj_slow
2014/05/23 13:22:43
Almost completely off topic: When I've seen m_isMo
fs
2014/05/23 14:39:30
Yes... Personally I'm more worried that this is to
| |
223 return false; | |
224 // Don't hide if focus is on the HTMLMediaElement or within the | |
225 // controls/shadow tree. (Perform the checks separately to avoid going | |
philipj_slow
2014/05/23 13:22:43
I feel like this comment should make me understand
fs
2014/05/23 14:39:30
contains(...) will not cross into the shadow tree.
philipj_slow
2014/05/23 20:08:34
Ah, that's what I overlooked, thanks! The comment
| |
226 // through all the potential ancestor hosts for the focused element.) | |
227 if (behavior != IgnoreFocus && (mediaElement().focused() || contains(documen t().focusedElement()))) | |
228 return false; | |
229 return true; | |
213 } | 230 } |
214 | 231 |
215 void MediaControls::playbackStarted() | 232 void MediaControls::playbackStarted() |
216 { | 233 { |
217 m_currentTimeDisplay->show(); | 234 m_currentTimeDisplay->show(); |
218 m_durationDisplay->hide(); | 235 m_durationDisplay->hide(); |
219 | 236 |
220 updatePlayState(); | 237 updatePlayState(); |
221 m_timeline->setPosition(mediaElement().currentTime()); | 238 m_timeline->setPosition(mediaElement().currentTime()); |
222 updateCurrentTimeDisplay(); | 239 updateCurrentTimeDisplay(); |
223 | 240 |
224 startHideMediaControlsTimer(); | 241 startHideMediaControlsTimer(); |
225 } | 242 } |
226 | 243 |
227 void MediaControls::playbackProgressed() | 244 void MediaControls::playbackProgressed() |
228 { | 245 { |
229 m_timeline->setPosition(mediaElement().currentTime()); | 246 m_timeline->setPosition(mediaElement().currentTime()); |
230 updateCurrentTimeDisplay(); | 247 updateCurrentTimeDisplay(); |
231 | 248 |
232 if (!m_isMouseOverControls && mediaElement().hasVideo()) | 249 if (shouldHideMediaControls()) |
233 makeTransparent(); | 250 makeTransparent(); |
234 } | 251 } |
235 | 252 |
236 void MediaControls::playbackStopped() | 253 void MediaControls::playbackStopped() |
237 { | 254 { |
238 updatePlayState(); | 255 updatePlayState(); |
239 m_timeline->setPosition(mediaElement().currentTime()); | 256 m_timeline->setPosition(mediaElement().currentTime()); |
240 updateCurrentTimeDisplay(); | 257 updateCurrentTimeDisplay(); |
241 makeOpaque(); | 258 makeOpaque(); |
242 | 259 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 startHideMediaControlsTimer(); | 379 startHideMediaControlsTimer(); |
363 return; | 380 return; |
364 } | 381 } |
365 } | 382 } |
366 | 383 |
367 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 384 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
368 { | 385 { |
369 if (mediaElement().togglePlayStateWillPlay()) | 386 if (mediaElement().togglePlayStateWillPlay()) |
370 return; | 387 return; |
371 | 388 |
372 if (!shouldHideMediaControls()) | 389 if (!shouldHideMediaControls(IgnoreFocus)) |
acolwell GONE FROM CHROMIUM
2014/05/22 18:44:09
What is the situation where we would want the cont
fs
2014/05/23 07:05:40
The case where I found this a useful behavior was
| |
373 return; | 390 return; |
374 | 391 |
375 makeTransparent(); | 392 makeTransparent(); |
376 } | 393 } |
377 | 394 |
378 void MediaControls::startHideMediaControlsTimer() | 395 void MediaControls::startHideMediaControlsTimer() |
379 { | 396 { |
380 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); | 397 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); |
381 } | 398 } |
382 | 399 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 visitor->trace(m_muteButton); | 468 visitor->trace(m_muteButton); |
452 visitor->trace(m_volumeSlider); | 469 visitor->trace(m_volumeSlider); |
453 visitor->trace(m_toggleClosedCaptionsButton); | 470 visitor->trace(m_toggleClosedCaptionsButton); |
454 visitor->trace(m_fullScreenButton); | 471 visitor->trace(m_fullScreenButton); |
455 visitor->trace(m_durationDisplay); | 472 visitor->trace(m_durationDisplay); |
456 visitor->trace(m_enclosure); | 473 visitor->trace(m_enclosure); |
457 HTMLDivElement::trace(visitor); | 474 HTMLDivElement::trace(visitor); |
458 } | 475 } |
459 | 476 |
460 } | 477 } |
OLD | NEW |