Chromium Code Reviews| Index: Source/core/html/shadow/MediaControls.cpp |
| diff --git a/Source/core/html/shadow/MediaControls.cpp b/Source/core/html/shadow/MediaControls.cpp |
| index 5b521ce71d70c41027545b52b1a4ee1b72762158..178f2ff1b2f1ef25aa6b9c684130afa80886b736 100644 |
| --- a/Source/core/html/shadow/MediaControls.cpp |
| +++ b/Source/core/html/shadow/MediaControls.cpp |
| @@ -45,11 +45,6 @@ static bool fullscreenIsSupported(const Document& document) |
| return !document.settings() || document.settings()->fullscreenSupported(); |
| } |
| -static bool deviceSupportsMouse(const Document& document) |
| -{ |
| - return !document.settings() || document.settings()->deviceSupportsMouse(); |
| -} |
| - |
| MediaControls::MediaControls(HTMLMediaElement& mediaElement) |
| : HTMLDivElement(mediaElement.document()) |
| , m_mediaElement(&mediaElement) |
| @@ -69,6 +64,7 @@ MediaControls::MediaControls(HTMLMediaElement& mediaElement) |
| , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired) |
| , m_isMouseOverControls(false) |
| , m_isPausedForScrubbing(false) |
| + , m_wasLastEventTouch(false) |
| { |
| } |
| @@ -224,6 +220,16 @@ void MediaControls::makeOpaque() |
| m_panel->makeOpaque(); |
| } |
| +void MediaControls::makeOpaqueIfNeeded(Event* event) |
| +{ |
| + // Fake mouse events generated by blink that do not derive from |
| + // real input should not make the controls visible. |
| + if (event->isMouseEvent() && toMouseEvent(event)->notFromInput()) |
| + return; |
| + |
| + makeOpaque(); |
| +} |
| + |
| void MediaControls::makeTransparent() |
| { |
| m_panel->makeTransparent(); |
| @@ -372,12 +378,13 @@ void MediaControls::exitedFullscreen() |
| void MediaControls::defaultEventHandler(Event* event) |
| { |
| HTMLDivElement::defaultEventHandler(event); |
| + m_wasLastEventTouch = event->isTouchEvent() || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); |
|
Rick Byers
2014/08/22 18:11:13
Do you really want to consider touch events here?
Ignacio Solla
2014/08/26 13:40:53
Good catch, I consider gesture events now too.
I
Rick Byers
2014/08/26 15:25:46
I see. Seems fine to me. Ideally maybe this woul
Ignacio Solla
2014/08/26 17:30:42
Acknowledged.
|
| if (event->type() == EventTypeNames::mouseover) { |
| if (!containsRelatedTarget(event)) { |
| m_isMouseOverControls = true; |
| if (!mediaElement().togglePlayStateWillPlay()) { |
| - makeOpaque(); |
| + makeOpaqueIfNeeded(event); |
| if (shouldHideMediaControls()) |
| startHideMediaControlsTimer(); |
| } |
| @@ -396,7 +403,7 @@ void MediaControls::defaultEventHandler(Event* event) |
| if (event->type() == EventTypeNames::mousemove) { |
| // When we get a mouse move, show the media controls, and start a timer |
| // that will hide the media controls after a 3 seconds without a mouse move. |
| - makeOpaque(); |
| + makeOpaqueIfNeeded(event); |
| if (shouldHideMediaControls(IgnoreVideoHover)) |
| startHideMediaControlsTimer(); |
| return; |
| @@ -409,8 +416,7 @@ void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| return; |
| unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover; |
| - // FIXME: improve this check, see http://www.crbug.com/401177. |
| - if (!deviceSupportsMouse(document())) { |
| + if (m_wasLastEventTouch) { |
| behaviorFlags |= IgnoreControlsHover; |
| } |
| if (!shouldHideMediaControls(behaviorFlags)) |