| 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(unsigned behaviorFlags) const |
| 211 { | 217 { |
| 212 return !m_panel->hovered() && mediaElement().hasVideo(); | 218 // Never hide for a media element without visual representation. |
| 219 if (!mediaElement().hasVideo()) |
| 220 return false; |
| 221 // Don't hide if the controls are hovered or the mouse is over the video are
a. |
| 222 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover; |
| 223 if (m_panel->hovered() || (!ignoreVideoHover && m_isMouseOverControls)) |
| 224 return false; |
| 225 // Don't hide if focus is on the HTMLMediaElement or within the |
| 226 // controls/shadow tree. (Perform the checks separately to avoid going |
| 227 // through all the potential ancestor hosts for the focused element.) |
| 228 const bool ignoreFocus = behaviorFlags & IgnoreFocus; |
| 229 if (!ignoreFocus && (mediaElement().focused() || contains(document().focused
Element()))) |
| 230 return false; |
| 231 return true; |
| 213 } | 232 } |
| 214 | 233 |
| 215 void MediaControls::playbackStarted() | 234 void MediaControls::playbackStarted() |
| 216 { | 235 { |
| 217 m_currentTimeDisplay->show(); | 236 m_currentTimeDisplay->show(); |
| 218 m_durationDisplay->hide(); | 237 m_durationDisplay->hide(); |
| 219 | 238 |
| 220 updatePlayState(); | 239 updatePlayState(); |
| 221 m_timeline->setPosition(mediaElement().currentTime()); | 240 m_timeline->setPosition(mediaElement().currentTime()); |
| 222 updateCurrentTimeDisplay(); | 241 updateCurrentTimeDisplay(); |
| 223 | 242 |
| 224 startHideMediaControlsTimer(); | 243 startHideMediaControlsTimer(); |
| 225 } | 244 } |
| 226 | 245 |
| 227 void MediaControls::playbackProgressed() | 246 void MediaControls::playbackProgressed() |
| 228 { | 247 { |
| 229 m_timeline->setPosition(mediaElement().currentTime()); | 248 m_timeline->setPosition(mediaElement().currentTime()); |
| 230 updateCurrentTimeDisplay(); | 249 updateCurrentTimeDisplay(); |
| 231 | 250 |
| 232 if (!m_isMouseOverControls && mediaElement().hasVideo()) | 251 if (shouldHideMediaControls()) |
| 233 makeTransparent(); | 252 makeTransparent(); |
| 234 } | 253 } |
| 235 | 254 |
| 236 void MediaControls::playbackStopped() | 255 void MediaControls::playbackStopped() |
| 237 { | 256 { |
| 238 updatePlayState(); | 257 updatePlayState(); |
| 239 m_timeline->setPosition(mediaElement().currentTime()); | 258 m_timeline->setPosition(mediaElement().currentTime()); |
| 240 updateCurrentTimeDisplay(); | 259 updateCurrentTimeDisplay(); |
| 241 makeOpaque(); | 260 makeOpaque(); |
| 242 | 261 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 m_isMouseOverControls = false; | 370 m_isMouseOverControls = false; |
| 352 stopHideMediaControlsTimer(); | 371 stopHideMediaControlsTimer(); |
| 353 } | 372 } |
| 354 return; | 373 return; |
| 355 } | 374 } |
| 356 | 375 |
| 357 if (event->type() == EventTypeNames::mousemove) { | 376 if (event->type() == EventTypeNames::mousemove) { |
| 358 // When we get a mouse move, show the media controls, and start a timer | 377 // When we get a mouse move, show the media controls, and start a timer |
| 359 // that will hide the media controls after a 3 seconds without a mouse m
ove. | 378 // that will hide the media controls after a 3 seconds without a mouse m
ove. |
| 360 makeOpaque(); | 379 makeOpaque(); |
| 361 if (shouldHideMediaControls()) | 380 if (shouldHideMediaControls(IgnoreVideoHover)) |
| 362 startHideMediaControlsTimer(); | 381 startHideMediaControlsTimer(); |
| 363 return; | 382 return; |
| 364 } | 383 } |
| 365 } | 384 } |
| 366 | 385 |
| 367 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 386 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 368 { | 387 { |
| 369 if (mediaElement().togglePlayStateWillPlay()) | 388 if (mediaElement().togglePlayStateWillPlay()) |
| 370 return; | 389 return; |
| 371 | 390 |
| 372 if (!shouldHideMediaControls()) | 391 if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover)) |
| 373 return; | 392 return; |
| 374 | 393 |
| 375 makeTransparent(); | 394 makeTransparent(); |
| 376 } | 395 } |
| 377 | 396 |
| 378 void MediaControls::startHideMediaControlsTimer() | 397 void MediaControls::startHideMediaControlsTimer() |
| 379 { | 398 { |
| 380 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe
diaControls, FROM_HERE); | 399 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe
diaControls, FROM_HERE); |
| 381 } | 400 } |
| 382 | 401 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 visitor->trace(m_muteButton); | 470 visitor->trace(m_muteButton); |
| 452 visitor->trace(m_volumeSlider); | 471 visitor->trace(m_volumeSlider); |
| 453 visitor->trace(m_toggleClosedCaptionsButton); | 472 visitor->trace(m_toggleClosedCaptionsButton); |
| 454 visitor->trace(m_fullScreenButton); | 473 visitor->trace(m_fullScreenButton); |
| 455 visitor->trace(m_durationDisplay); | 474 visitor->trace(m_durationDisplay); |
| 456 visitor->trace(m_enclosure); | 475 visitor->trace(m_enclosure); |
| 457 HTMLDivElement::trace(visitor); | 476 HTMLDivElement::trace(visitor); |
| 458 } | 477 } |
| 459 | 478 |
| 460 } | 479 } |
| OLD | NEW |