Index: Source/core/html/shadow/MediaControls.cpp |
diff --git a/Source/core/html/shadow/MediaControls.cpp b/Source/core/html/shadow/MediaControls.cpp |
index 3a96327c6ad59a04845331f6539d70c2bafedec6..db0a3f548342ee50489f246b77351787bb97eae5 100644 |
--- a/Source/core/html/shadow/MediaControls.cpp |
+++ b/Source/core/html/shadow/MediaControls.cpp |
@@ -40,6 +40,11 @@ namespace blink { |
// LayoutTests/media/media-controls.js. |
static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; |
+static bool deviceSupportsMouse(const Document& document) |
+{ |
+ return !document.settings() || document.settings()->deviceSupportsMouse(); |
+} |
+ |
MediaControls::MediaControls(HTMLMediaElement& mediaElement) |
: HTMLDivElement(mediaElement.document()) |
, m_mediaElement(&mediaElement) |
@@ -224,9 +229,13 @@ bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const |
// Never hide for a media element without visual representation. |
if (!mediaElement().hasVideo()) |
return false; |
- // Don't hide if the controls are hovered or the mouse is over the video area. |
+ // Don't hide if the mouse is over the controls. |
+ const bool ignoreControlsHover = behaviorFlags & IgnoreControlsHover; |
+ if (!ignoreControlsHover && m_panel->hovered()) |
+ return false; |
+ // Don't hide if the mouse is over the video area. |
const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover; |
- if (m_panel->hovered() || (!ignoreVideoHover && m_isMouseOverControls)) |
+ if (!ignoreVideoHover && m_isMouseOverControls) |
return false; |
// Don't hide if focus is on the HTMLMediaElement or within the |
// controls/shadow tree. (Perform the checks separately to avoid going |
@@ -394,7 +403,12 @@ void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
if (mediaElement().togglePlayStateWillPlay()) |
return; |
- if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover)) |
+ unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover; |
+ // This check could be improved, see http://www.crbug.com/401177. |
+ if (!deviceSupportsMouse(document())) { |
+ behaviorFlags |= IgnoreControlsHover; |
+ } |
+ if (!shouldHideMediaControls(behaviorFlags)) |
return; |
makeTransparent(); |