Commit cfc807fb authored by Rahul Arakeri's avatar Rahul Arakeri Committed by Commit Bot

[Compositor threaded scrollbar scrolling] Option + click for Mac.

Mac uses Option + click instead of Shift + click (on Windows/Linux).

Bug: 1016955
Change-Id: I49c54fb8773c68d37d4bc0b7fc677f259767967b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885975
Commit-Queue: Rahul Arakeri <arakeri@microsoft.com>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714864}
parent dfcb1a3f
......@@ -198,6 +198,8 @@ class CC_EXPORT InputHandler {
virtual InputHandlerPointerResult MouseMoveAt(
const gfx::Point& mouse_position) = 0;
// TODO(arakeri): Pass in the modifier instead of a bool once the refactor
// (crbug.com/1022097) is done. For details, see crbug.com/1016955.
virtual InputHandlerPointerResult MouseDown(const gfx::PointF& mouse_position,
bool shift_modifier) = 0;
virtual InputHandlerPointerResult MouseUp(
......
......@@ -201,7 +201,7 @@ ui::input_types::ScrollGranularity ScrollbarController::Granularity(
return ui::input_types::ScrollGranularity::kScrollByPixel;
}
float ScrollbarController::GetScrollDeltaForShiftClick(
float ScrollbarController::GetScrollDeltaForAbsoluteJump(
const ScrollbarLayerImplBase* scrollbar) {
layer_tree_host_impl_->active_tree()->UpdateScrollbarGeometries();
......@@ -605,7 +605,7 @@ int ScrollbarController::GetScrollDeltaForScrollbarPart(
case ScrollbarPart::BACK_TRACK:
case ScrollbarPart::FORWARD_TRACK:
if (shift_modifier) {
scroll_delta = GetScrollDeltaForShiftClick(scrollbar);
scroll_delta = GetScrollDeltaForAbsoluteJump(scrollbar);
break;
}
owner_scroll_layer =
......
......@@ -125,8 +125,9 @@ class CC_EXPORT ScrollbarController {
void RecomputeAutoscrollStateIfNeeded();
void ResetState();
// Shift + click is expected to do a non-animated jump to a certain offset.
float GetScrollDeltaForShiftClick(const ScrollbarLayerImplBase* scrollbar);
// Shift (or "Option" in case of Mac) + click is expected to do a non-animated
// jump to a certain offset.
float GetScrollDeltaForAbsoluteJump(const ScrollbarLayerImplBase* scrollbar);
// Determines if the delta needs to be animated.
ui::input_types::ScrollGranularity Granularity(
......
......@@ -2649,13 +2649,6 @@ crbug.com/953847 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/sc
# 1px scroll offset difference for compositor threaded scrollbar scrolling on Linux.
crbug.com/1009892 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling_hidpi/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
# TODO (arakeri): Mac uses the "Option" modifier instead of "Shift" to do the non-animated jump. This hasn't been implemented yet.
crbug.com/1016955 [ Mac ] fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
crbug.com/1016955 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
crbug.com/1016955 [ Mac ] virtual/scroll_customization/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
crbug.com/1016955 [ Mac ] virtual/hidpi/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
crbug.com/1016955 [ Mac ] virtual/compositor_threaded_scrollbar_scrolling/fast/scrolling/scrollbars/dsf-ready/mouse-interactions-dsf-2.html [ Failure Timeout ]
# Some control characters still not visible
crbug.com/893490 [ Mac ] external/wpt/css/css-text/white-space/control-chars-001.html [ Failure ]
crbug.com/893490 [ Mac ] external/wpt/css/css-text/white-space/control-chars-002.html [ Failure ]
......
......@@ -102,14 +102,23 @@ window.onload = () => {
promise_test (async (test) => {
resetScrollOffset(standardDivFast);
// Testing forward scroll on vertical scrollbar.
await mouseClickOn(SCROLLBAR_BUTTON_FWD.x, standardRectFast.top + 50, /*left_click*/0, /*modifier*/ "Shift");
let expected_offset = 0;
if (onLinuxPlatform)
expected_offset = window.devicePixelRatio == 1 ? 695 : 606;
else
expected_offset = window.devicePixelRatio == 1 ? 626 : 579.5;
assert_equals(standardDivFast.scrollTop, expected_offset, "Shift + click forward didn't scroll.");
}, "Test shift + click on non-custom composited scrollbars.");
// Testing forward scroll on vertical scrollbar. Mac uses "Option" key
// instead of "Shift". The Option key is mapped to "Alt" in GPUbenchmarking.
await mouseClickOn(SCROLLBAR_BUTTON_FWD.x, standardRectFast.top + 50,
/*left_click*/0, /*modifier*/ onMacPlatform ? "Alt" : "Shift");
if (onMacPlatform) {
// TODO(arakeri): crbug.com/1019076 Option + click is off by 3-4 px.
assert_approx_equals(standardDivFast.scrollTop, 549, 3,
"Option + click forward didn't scroll.");
} else {
let expected_offset = 0;
if (onLinuxPlatform)
expected_offset = window.devicePixelRatio == 1 ? 695 : 606;
else
expected_offset = window.devicePixelRatio == 1 ? 626 : 579.5;
assert_equals(standardDivFast.scrollTop, expected_offset,
"Shift + click forward didn't scroll.");
}
}, "Test non-animated click scroll on non-custom composited scrollbars.");
}
</script>
......@@ -20,6 +20,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "third_party/blink/public/platform/web_input_event.h"
#include "third_party/blink/public/platform/web_mouse_wheel_event.h"
......@@ -445,6 +446,15 @@ void InputHandlerProxy::InjectScrollbarGestureScroll(
input_handler_->SetNeedsAnimateInput();
}
bool HasModifier(const WebInputEvent& event) {
#if defined(OS_MACOSX)
// Mac uses the "Option" key (which is mapped to the enum "kAltKey").
return event.GetModifiers() & WebInputEvent::kAltKey;
#else
return event.GetModifiers() & WebInputEvent::kShiftKey;
#endif
}
InputHandlerProxy::EventDisposition
InputHandlerProxy::RouteToTypeSpecificHandler(
const WebInputEvent& event,
......@@ -519,10 +529,13 @@ InputHandlerProxy::RouteToTypeSpecificHandler(
if (mouse_event.button == blink::WebMouseEvent::Button::kLeft) {
CHECK(input_handler_);
// TODO(arakeri): Pass in the modifier instead of a bool once the
// refactor (crbug.com/1022097) is done. For details, see
// crbug.com/1016955.
cc::InputHandlerPointerResult pointer_result =
input_handler_->MouseDown(
gfx::PointF(mouse_event.PositionInWidget()),
event.GetModifiers() & WebInputEvent::kShiftKey);
HasModifier(event));
if (pointer_result.type == cc::PointerResultType::kScrollbarScroll) {
// Generate GSB and GSU events and add them to the
// CompositorThreadEventQueue.
......
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