Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/html/shadow/MediaControls.h" | 28 #include "core/html/shadow/MediaControls.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 31 #include "core/dom/ClientRect.h" | 31 #include "core/dom/ClientRect.h" |
| 32 #include "core/events/MouseEvent.h" | 32 #include "core/events/MouseEvent.h" |
| 33 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 34 #include "core/html/HTMLMediaElement.h" | 34 #include "core/html/HTMLMediaElement.h" |
| 35 #include "core/html/MediaController.h" | 35 #include "core/html/MediaController.h" |
| 36 #include "core/layout/LayoutTheme.h" | 36 #include "core/layout/LayoutTheme.h" |
| 37 #include "core/page/EventHandler.h" | |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 // If you change this value, then also update the corresponding value in | 41 // If you change this value, then also update the corresponding value in |
| 41 // LayoutTests/media/media-controls.js. | 42 // LayoutTests/media/media-controls.js. |
| 42 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; | 43 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; |
| 43 | 44 |
| 44 static bool fullscreenIsSupported(const Document& document) | 45 static bool fullscreenIsSupported(const Document& document) |
| 45 { | 46 { |
| 46 return !document.settings() || document.settings()->fullscreenSupported(); | 47 return !document.settings() || document.settings()->fullscreenSupported(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 void MediaControls::makeTransparent() | 233 void MediaControls::makeTransparent() |
| 233 { | 234 { |
| 234 m_panel->makeTransparent(); | 235 m_panel->makeTransparent(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const | 238 bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const |
| 238 { | 239 { |
| 239 // Never hide for a media element without visual representation. | 240 // Never hide for a media element without visual representation. |
| 240 if (!mediaElement().hasVideo() || mediaElement().isPlayingRemotely()) | 241 if (!mediaElement().hasVideo() || mediaElement().isPlayingRemotely()) |
| 241 return false; | 242 return false; |
| 243 | |
| 244 // Update hover status before check it | |
| 245 if (document().frame()) | |
| 246 document().frame()->eventHandler().scheduleHoverStateUpdate(); | |
|
fs
2015/02/02 13:13:46
All this does is to start a timer, so this doesn't
william.xie1
2015/02/02 14:29:18
Hi fs,
yes, here it schedule a time for hover stat
| |
| 247 | |
| 242 // Don't hide if the mouse is over the controls. | 248 // Don't hide if the mouse is over the controls. |
| 243 const bool ignoreControlsHover = behaviorFlags & IgnoreControlsHover; | 249 const bool ignoreControlsHover = behaviorFlags & IgnoreControlsHover; |
| 244 if (!ignoreControlsHover && m_panel->hovered()) | 250 if (!ignoreControlsHover && m_panel->hovered()) |
| 245 return false; | 251 return false; |
| 246 // Don't hide if the mouse is over the video area. | 252 // Don't hide if the mouse is over the video area. |
| 247 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover; | 253 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover; |
| 248 if (!ignoreVideoHover && m_isMouseOverControls) | 254 if (!ignoreVideoHover && m_isMouseOverControls) |
| 249 return false; | 255 return false; |
| 250 // Don't hide if focus is on the HTMLMediaElement or within the | 256 // Don't hide if focus is on the HTMLMediaElement or within the |
| 251 // controls/shadow tree. (Perform the checks separately to avoid going | 257 // controls/shadow tree. (Perform the checks separately to avoid going |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 266 updateCurrentTimeDisplay(); | 272 updateCurrentTimeDisplay(); |
| 267 | 273 |
| 268 startHideMediaControlsTimer(); | 274 startHideMediaControlsTimer(); |
| 269 } | 275 } |
| 270 | 276 |
| 271 void MediaControls::playbackProgressed() | 277 void MediaControls::playbackProgressed() |
| 272 { | 278 { |
| 273 m_timeline->setPosition(mediaElement().currentTime()); | 279 m_timeline->setPosition(mediaElement().currentTime()); |
| 274 updateCurrentTimeDisplay(); | 280 updateCurrentTimeDisplay(); |
| 275 | 281 |
| 276 if (shouldHideMediaControls()) | 282 if (m_panel->isOpaque() && shouldHideMediaControls()) |
|
fs
2015/02/02 13:13:46
makeTransparent already checks this, so this just
william.xie1
2015/02/02 14:29:18
Yes, correct, to avoid schedule the hover state up
| |
| 277 makeTransparent(); | 283 makeTransparent(); |
| 278 } | 284 } |
| 279 | 285 |
| 280 void MediaControls::playbackStopped() | 286 void MediaControls::playbackStopped() |
| 281 { | 287 { |
| 282 updatePlayState(); | 288 updatePlayState(); |
| 283 m_timeline->setPosition(mediaElement().currentTime()); | 289 m_timeline->setPosition(mediaElement().currentTime()); |
| 284 updateCurrentTimeDisplay(); | 290 updateCurrentTimeDisplay(); |
| 285 makeOpaque(); | 291 makeOpaque(); |
| 286 | 292 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 visitor->trace(m_toggleClosedCaptionsButton); | 571 visitor->trace(m_toggleClosedCaptionsButton); |
| 566 visitor->trace(m_fullScreenButton); | 572 visitor->trace(m_fullScreenButton); |
| 567 visitor->trace(m_durationDisplay); | 573 visitor->trace(m_durationDisplay); |
| 568 visitor->trace(m_enclosure); | 574 visitor->trace(m_enclosure); |
| 569 visitor->trace(m_castButton); | 575 visitor->trace(m_castButton); |
| 570 visitor->trace(m_overlayCastButton); | 576 visitor->trace(m_overlayCastButton); |
| 571 HTMLDivElement::trace(visitor); | 577 HTMLDivElement::trace(visitor); |
| 572 } | 578 } |
| 573 | 579 |
| 574 } | 580 } |
| OLD | NEW |