Commit 4849af47 authored by Mario Bianucci's avatar Mario Bianucci Committed by Commit Bot

Allow autoscrolling to continue when the cursor leaves the page.

A CL[1] over a year ago added an if check that caused autoscrolling to stop
if the cursor left the page and the middle button wasn't held in. Since
other Windows apps allow auto scrolling to continue in this case, it
makes sense to match that behavior and also allow it.

[1] https://crrev.com/5971e47dc08dbb773f58fd6fb13b1df7917fd295

Bug: 806562
Change-Id: Id7259b5242f21c2042f300d7f0a606179be89b5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618141
Commit-Queue: Mario Bianucci <mabian@microsoft.com>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662184}
parent 010fe4a6
...@@ -888,14 +888,9 @@ WebInputEventResult EventHandler::HandleMouseMoveOrLeaveEvent( ...@@ -888,14 +888,9 @@ WebInputEventResult EventHandler::HandleMouseMoveOrLeaveEvent(
if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) { if (RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()) {
if (Page* page = frame_->GetPage()) { if (Page* page = frame_->GetPage()) {
if (mouse_event.GetType() == WebInputEvent::kMouseLeave && page->GetAutoscrollController().HandleMouseMoveForMiddleClickAutoscroll(
mouse_event.button != WebPointerProperties::Button::kMiddle) { frame_, mouse_event_manager_->LastKnownMouseScreenPosition(),
page->GetAutoscrollController().StopMiddleClickAutoscroll(frame_); mouse_event.button == WebPointerProperties::Button::kMiddle);
} else {
page->GetAutoscrollController().HandleMouseMoveForMiddleClickAutoscroll(
frame_, mouse_event_manager_->LastKnownMouseScreenPosition(),
mouse_event.button == WebPointerProperties::Button::kMiddle);
}
} }
} }
......
...@@ -117,6 +117,8 @@ class CORE_EXPORT AutoscrollController final ...@@ -117,6 +117,8 @@ class CORE_EXPORT AutoscrollController final
FRIEND_TEST_ALL_PREFIXES(AutoscrollControllerTest, FRIEND_TEST_ALL_PREFIXES(AutoscrollControllerTest,
CrashWhenLayoutStopAnimationBeforeScheduleAnimation); CrashWhenLayoutStopAnimationBeforeScheduleAnimation);
FRIEND_TEST_ALL_PREFIXES(AutoscrollControllerTest,
ContinueAutoscrollAfterMouseLeaveEvent);
}; };
} // namespace blink } // namespace blink
......
...@@ -78,4 +78,25 @@ TEST_F(AutoscrollControllerTest, ...@@ -78,4 +78,25 @@ TEST_F(AutoscrollControllerTest,
EXPECT_FALSE(controller.IsAutoscrolling()); EXPECT_FALSE(controller.IsAutoscrolling());
} }
// Ensure that autoscrolling continues when the MouseLeave event is fired.
TEST_F(AutoscrollControllerTest, ContinueAutoscrollAfterMouseLeaveEvent) {
AutoscrollController& controller = GetAutoscrollController();
LocalFrame* frame = GetDocument().GetFrame();
EXPECT_FALSE(controller.IsAutoscrolling());
controller.StartMiddleClickAutoscroll(frame, FloatPoint(), FloatPoint());
EXPECT_TRUE(controller.IsAutoscrolling());
WebMouseEvent mouse_leave_event(WebInputEvent::kMouseLeave,
WebInputEvent::kNoModifiers,
CurrentTimeTicks());
mouse_leave_event.SetFrameScale(1);
frame->GetEventHandler().HandleMouseLeaveEvent(mouse_leave_event);
EXPECT_TRUE(controller.IsAutoscrolling());
}
} // namespace blink } // namespace blink
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