Commit 406c33ba authored by Jazz Xu's avatar Jazz Xu Committed by Commit Bot

[Media Controls] Fix control won't hide after mouse interaction while focused

Fix two problems:
1. While focused, mouse move in and move out, control won't hide.
2. While focused, mouse move in and stay, control won't hide after 3 seconds.

Bug: 909087
Change-Id: I4a2c009758e36fd7f3cec5dd9f8042773cc6d454
Reviewed-on: https://chromium-review.googlesource.com/c/1354573Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612459}
parent c3df552e
......@@ -1556,13 +1556,22 @@ void MediaControlsImpl::HandlePointerEvent(Event* event) {
if (!ContainsRelatedTarget(event)) {
is_mouse_over_controls_ = false;
StopHideMediaControlsTimer();
// When we get a mouse out, if video is playing and control should
// hide regardless of focus, hide the control.
// This will fix the issue that when mouse out event happen while video is
// focused, control never hides.
if (!MediaElement().paused() && ShouldHideMediaControls(kIgnoreFocus))
MakeTransparent();
}
} else if (event->type() == event_type_names::kPointermove) {
// 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.
is_mouse_over_controls_ = true;
MakeOpaqueFromPointerEvent();
if (ShouldHideMediaControls(kIgnoreVideoHover))
// Start the timer regardless of focus state
if (ShouldHideMediaControls(kIgnoreVideoHover | kIgnoreFocus))
StartHideMediaControlsTimer();
}
}
......
......@@ -1070,6 +1070,53 @@ TEST_F(MediaControlsImplTestWithMockScheduler,
EXPECT_FALSE(IsElementVisible(*panel));
}
TEST_F(MediaControlsImplTestWithMockScheduler,
ControlsHideAfterFocusedAndMouseMovement) {
EnsureSizing();
Element* panel = MediaControls().PanelElement();
MediaControls().MediaElement().SetSrc("http://example.com");
MediaControls().MediaElement().Play();
// Controls start out visible
EXPECT_TRUE(IsElementVisible(*panel));
platform()->RunForPeriodSeconds(1);
// Mouse move while focused
MediaControls().DispatchEvent(*Event::Create("focusin"));
MediaControls().MediaElement().SetFocused(true,
WebFocusType::kWebFocusTypeNone);
MediaControls().DispatchEvent(*Event::Create("pointermove"));
// Controls should remain visible
platform()->RunForPeriodSeconds(2);
EXPECT_TRUE(IsElementVisible(*panel));
// Controls should hide after being inactive for 4 seconds.
platform()->RunForPeriodSeconds(2);
EXPECT_FALSE(IsElementVisible(*panel));
}
TEST_F(MediaControlsImplTestWithMockScheduler,
ControlsHideAfterFocusedAndMouseMoveout) {
EnsureSizing();
Element* panel = MediaControls().PanelElement();
MediaControls().MediaElement().SetSrc("http://example.com");
MediaControls().MediaElement().Play();
// Controls start out visible
EXPECT_TRUE(IsElementVisible(*panel));
platform()->RunForPeriodSeconds(1);
// Mouse move out while focused, controls should hide
MediaControls().DispatchEvent(*Event::Create("focusin"));
MediaControls().MediaElement().SetFocused(true,
WebFocusType::kWebFocusTypeNone);
MediaControls().DispatchEvent(*Event::Create("pointerout"));
EXPECT_FALSE(IsElementVisible(*panel));
}
TEST_F(MediaControlsImplTestWithMockScheduler, CursorHidesWhenControlsHide) {
EnsureSizing();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment