Commit 7f617841 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Add wheel scroll options "scroll_by_page" to GpuBenchmarking

In GpuBenchmarking, for mouse wheel and touchpad scroll, we want to add
"scroll_by_page" scroll option to GpuBenchmarking::SmoothScrollBy.

Bug: 871970
Change-Id: If73cc2bb41a77499cfc6215b5d8fde09f33f6caa
Reviewed-on: https://chromium-review.googlesource.com/1174993
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585656}
parent 8a6d66b9
......@@ -189,7 +189,9 @@ class MockSyntheticGestureTarget : public SyntheticGestureTarget {
class MockMoveGestureTarget : public MockSyntheticGestureTarget {
public:
MockMoveGestureTarget()
: total_abs_move_distance_length_(0), precise_scrolling_deltas_(false) {}
: total_abs_move_distance_length_(0),
precise_scrolling_deltas_(false),
scroll_by_page_(false) {}
~MockMoveGestureTarget() override {}
gfx::Vector2dF start_to_end_distance() const {
......@@ -199,11 +201,13 @@ class MockMoveGestureTarget : public MockSyntheticGestureTarget {
return total_abs_move_distance_length_;
}
bool precise_scrolling_deltas() const { return precise_scrolling_deltas_; }
bool scroll_by_page() const { return scroll_by_page_; }
protected:
gfx::Vector2dF start_to_end_distance_;
float total_abs_move_distance_length_;
bool precise_scrolling_deltas_;
bool scroll_by_page_;
};
class MockScrollMouseTarget : public MockMoveGestureTarget {
......@@ -219,6 +223,7 @@ class MockScrollMouseTarget : public MockMoveGestureTarget {
start_to_end_distance_ += delta;
total_abs_move_distance_length_ += delta.Length();
precise_scrolling_deltas_ = mouse_wheel_event.has_precise_scrolling_deltas;
scroll_by_page_ = mouse_wheel_event.scroll_by_page;
}
};
......@@ -1258,6 +1263,27 @@ TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMousePreciseScroll) {
scroll_target->precise_scrolling_deltas());
}
TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseScrollByPage) {
CreateControllerAndTarget<MockScrollMouseTarget>();
SyntheticSmoothMoveGestureParams params;
params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(39, 86);
params.distances.push_back(gfx::Vector2d(0, -132));
params.scroll_by_page = true;
std::unique_ptr<SyntheticSmoothMoveGesture> gesture(
new SyntheticSmoothMoveGesture(params));
QueueSyntheticGesture(std::move(gesture));
FlushInputUntilComplete();
MockMoveGestureTarget* scroll_target =
static_cast<MockMoveGestureTarget*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.scroll_by_page, scroll_target->scroll_by_page());
}
void CheckIsWithinRangeMulti(float scroll_distance,
int target_distance,
SyntheticGestureTarget* target) {
......
......@@ -81,9 +81,13 @@ void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
return;
}
base::TimeTicks timestamp = web_wheel.TimeStamp();
int modifiers = web_wheel.has_precise_scrolling_deltas
? ui::EF_PRECISION_SCROLLING_DELTA
: ui::EF_NONE;
int modifiers = ui::EF_NONE;
if (web_wheel.has_precise_scrolling_deltas)
modifiers |= ui::EF_PRECISION_SCROLLING_DELTA;
if (web_wheel.scroll_by_page)
modifiers |= ui::EF_SCROLL_BY_PAGE;
ui::MouseWheelEvent wheel_event(
gfx::Vector2d(web_wheel.delta_x, web_wheel.delta_y), gfx::Point(),
gfx::Point(), timestamp, modifiers, ui::EF_NONE);
......
......@@ -33,7 +33,8 @@ SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams()
fling_velocity_y(0),
prevent_fling(true),
add_slop(true),
precise_scrolling_deltas(false) {}
precise_scrolling_deltas(false),
scroll_by_page(false) {}
SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams(
const SyntheticSmoothMoveGestureParams& other) = default;
......@@ -270,7 +271,8 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelEvent(
const base::TimeTicks& timestamp) const {
blink::WebMouseWheelEvent mouse_wheel_event =
SyntheticWebMouseWheelEventBuilder::Build(
0, 0, delta.x(), delta.y(), 0, params_.precise_scrolling_deltas);
0, 0, delta.x(), delta.y(), 0, params_.precise_scrolling_deltas,
params_.scroll_by_page);
mouse_wheel_event.SetPositionInWidget(
current_move_segment_start_position_.x(),
......
......@@ -39,6 +39,7 @@ class CONTENT_EXPORT SyntheticSmoothMoveGestureParams {
bool prevent_fling;
bool add_slop;
bool precise_scrolling_deltas;
bool scroll_by_page;
};
// This class is used as helper class for simulation of scroll and drag.
......
......@@ -51,6 +51,7 @@ bool SyntheticSmoothScrollGesture::InitializeMoveGesture(
move_params.input_type = GetInputSourceType(gesture_type);
move_params.add_slop = true;
move_params.precise_scrolling_deltas = params_.precise_scrolling_deltas;
move_params.scroll_by_page = params_.scroll_by_page;
move_gesture_.reset(new SyntheticSmoothMoveGesture(move_params));
return true;
}
......
......@@ -18,7 +18,8 @@ SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams()
speed_in_pixels_s(kDefaultSpeedInPixelsS),
fling_velocity_x(0),
fling_velocity_y(0),
precise_scrolling_deltas(false) {}
precise_scrolling_deltas(false),
scroll_by_page(false) {}
SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams(
const SyntheticSmoothScrollGestureParams& other) = default;
......
......@@ -31,6 +31,7 @@ struct CONTENT_EXPORT SyntheticSmoothScrollGestureParams
float fling_velocity_x;
float fling_velocity_y;
bool precise_scrolling_deltas;
bool scroll_by_page;
static const SyntheticSmoothScrollGestureParams* Cast(
const SyntheticGestureParams* gesture_params);
......
......@@ -50,23 +50,27 @@ WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(
return result;
}
WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x,
float y,
float dx,
float dy,
int modifiers,
bool precise) {
return Build(x, y, 0, 0, dx, dy, modifiers, precise);
WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(
float x,
float y,
float dx,
float dy,
int modifiers,
bool precise,
bool scroll_by_page) {
return Build(x, y, 0, 0, dx, dy, modifiers, precise, scroll_by_page);
}
WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x,
float y,
float global_x,
float global_y,
float dx,
float dy,
int modifiers,
bool precise) {
WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(
float x,
float y,
float global_x,
float global_y,
float dx,
float dy,
int modifiers,
bool precise,
bool scroll_by_page) {
WebMouseWheelEvent result(WebInputEvent::kMouseWheel, modifiers,
ui::EventTimeForNow());
result.SetPositionInScreen(global_x, global_y);
......@@ -78,6 +82,7 @@ WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x,
if (dy)
result.wheel_ticks_y = dy > 0.0f ? 1.0f : -1.0f;
result.has_precise_scrolling_deltas = precise;
result.scroll_by_page = scroll_by_page;
return result;
}
......
......@@ -38,7 +38,8 @@ class CONTENT_EXPORT SyntheticWebMouseWheelEventBuilder {
float dx,
float dy,
int modifiers,
bool precise);
bool precise,
bool scroll_by_page = false);
static blink::WebMouseWheelEvent Build(float x,
float y,
float global_x,
......@@ -46,7 +47,8 @@ class CONTENT_EXPORT SyntheticWebMouseWheelEventBuilder {
float dx,
float dy,
int modifiers,
bool precise);
bool precise,
bool scroll_by_page = false);
};
class CONTENT_EXPORT SyntheticWebKeyboardEventBuilder {
......
......@@ -122,6 +122,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::SyntheticSmoothScrollGestureParams)
IPC_STRUCT_TRAITS_MEMBER(speed_in_pixels_s)
IPC_STRUCT_TRAITS_MEMBER(fling_velocity_x)
IPC_STRUCT_TRAITS_MEMBER(fling_velocity_y)
IPC_STRUCT_TRAITS_MEMBER(precise_scrolling_deltas)
IPC_STRUCT_TRAITS_MEMBER(scroll_by_page)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPinchGestureParams)
......
......@@ -289,7 +289,8 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context,
float start_x,
float start_y,
float fling_velocity,
bool precise_scrolling_deltas) {
bool precise_scrolling_deltas,
bool scroll_by_page) {
gfx::Rect rect = context->render_view_impl()->GetWidget()->ViewRect();
rect -= rect.OffsetFromOrigin();
if (!rect.Contains(start_x, start_y)) {
......@@ -327,6 +328,7 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context,
gesture_params.speed_in_pixels_s = speed_in_pixels_s;
gesture_params.prevent_fling = prevent_fling;
gesture_params.precise_scrolling_deltas = precise_scrolling_deltas;
gesture_params.scroll_by_page = scroll_by_page;
gesture_params.anchor.SetPoint(start_x, start_y);
......@@ -659,6 +661,7 @@ bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) {
std::string direction = "down";
float speed_in_pixels_s = 800;
bool precise_scrolling_deltas = true;
bool scroll_by_page = false;
if (!GetOptionalArg(args, &pixels_to_scroll) ||
!GetOptionalArg(args, &callback) || !GetOptionalArg(args, &start_x) ||
......@@ -666,17 +669,23 @@ bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) {
!GetOptionalArg(args, &gesture_source_type) ||
!GetOptionalArg(args, &direction) ||
!GetOptionalArg(args, &speed_in_pixels_s) ||
!GetOptionalArg(args, &precise_scrolling_deltas)) {
!GetOptionalArg(args, &precise_scrolling_deltas) ||
!GetOptionalArg(args, &scroll_by_page)) {
return false;
}
// For all touch inputs, always scroll by precise deltas.
DCHECK(gesture_source_type != SyntheticGestureParams::TOUCH_INPUT ||
precise_scrolling_deltas);
// Scroll by page only for mouse inputs.
DCHECK(!scroll_by_page ||
gesture_source_type == SyntheticGestureParams::MOUSE_INPUT);
EnsureRemoteInterface();
return BeginSmoothScroll(&context, args, input_injector_, pixels_to_scroll,
callback, gesture_source_type, direction,
speed_in_pixels_s, true, start_x, start_y, 0,
precise_scrolling_deltas);
precise_scrolling_deltas, scroll_by_page);
}
bool GpuBenchmarking::SmoothDrag(gin::Arguments* args) {
......@@ -745,7 +754,8 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) {
return BeginSmoothScroll(&context, args, input_injector_, -pixels_to_scroll,
callback, gesture_source_type, direction,
speed_in_pixels_s, false, start_x, start_y,
fling_velocity, true);
fling_velocity, true /* precise_scrolling_deltas */,
false /* scroll_by_page */);
}
bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) {
......
......@@ -2242,6 +2242,7 @@ crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/pointerevents/po
# regularly on Windows. crbug.com/850964
crbug.com/613672 [ Mac Win ] virtual/threaded/external/wpt/feature-policy/experimental-features/vertical-scroll-touch-block-manual.tentative.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scroll-by-page.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
......@@ -2260,6 +2261,7 @@ crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-scroll-page-pas
crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scroll-by-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
......@@ -2278,6 +2280,7 @@ crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scroll-by-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
......@@ -2296,6 +2299,7 @@ crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scroll-by-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
......@@ -2314,6 +2318,7 @@ crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/to
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scroll-by-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scrollbar.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/paint-touchaction-rects/fast/events/touch/gesture/touch-gesture-noscroll-body-xhidden.html [ Skip ]
......
This tests gesture scrolling by pages.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.scrollingElement.scrollTop >= window.innerHeight * 0.875 * 2 became true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/js-test.js"></script>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
<style type="text/css">
::-webkit-scrollbar {
width: 0px;
......@@ -20,8 +20,8 @@
}
</style>
</head>
<body style="margin:0" onload="runTest();">
<body style="margin:0">
<div id="greenbox"></div>
<div id="redbox"></div>
......@@ -29,32 +29,20 @@
<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
// Turn on smooth scrolling.
internals.settings.setScrollAnimatorEnabled(true);
function gestureScroll()
{
eventSender.gestureScrollBegin("touchpad", 10, 20);
eventSender.gestureScrollUpdate("touchpad", 0, -1, "Page");
eventSender.gestureScrollUpdate("touchpad", 0, -2, "Page");
eventSender.gestureScrollUpdate("touchpad", 0, 1, "Page");
eventSender.gestureScrollEnd("touchpad", 0, 0);
// see kMinFractionToStepWhenPaging in ScrollableArea.cppP
// 2 is the expected number of pages scrolled (-1 + -2 + 1)
shouldBecomeEqual("document.scrollingElement.scrollTop >= window.innerHeight * 0.875 * 2", "true", finishJSTest, 1000);
}
var x = 30;
var y = 30;
var mouse_input = GestureSourceType.MOUSE_INPUT;
jsTestIsAsync = true;
promise_test (async () => {
await smoothScroll(1, x, y, mouse_input, 'down', SPEED_INSTANT, false, true);
await smoothScroll(1, x, y, mouse_input, 'down', SPEED_INSTANT, false, true);
await waitFor(() => {
return document.scrollingElement.scrollTop >= window.innerHeight * 0.875 * 2; })
});
function runTest()
{
if (window.eventSender) {
description('This tests gesture scrolling by pages.');
gestureScroll();
} else {
debug("This test requires DumpRenderTree. Gesture-scroll the page to validate the implementation.");
}
}
</script>
</body>
</html>
......@@ -89,7 +89,7 @@ const GestureSourceType = {
// the synthetic gesture code modified to guarantee the single update behavior.
const SPEED_INSTANT = 200000;
function smoothScroll(pixels_to_scroll, start_x, start_y, gesture_source_type, direction, speed_in_pixels_s) {
function smoothScroll(pixels_to_scroll, start_x, start_y, gesture_source_type, direction, speed_in_pixels_s, precise_scrolling_deltas, scroll_by_page) {
return new Promise((resolve, reject) => {
if (chrome && chrome.gpuBenchmarking) {
chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
......@@ -98,7 +98,9 @@ function smoothScroll(pixels_to_scroll, start_x, start_y, gesture_source_type, d
start_y,
gesture_source_type,
direction,
speed_in_pixels_s);
speed_in_pixels_s,
precise_scrolling_deltas,
scroll_by_page);
} else {
reject('This test requires chrome.gpuBenchmarking');
}
......
......@@ -44,6 +44,7 @@ It should not be possible to scroll this content:<br>
50 /* start_y */,
GESTURE_SOURCE_TYPE,
'down',
20000 /* speed */);
20000 /* speed */,
false /* precise_scrolling_deltas */);
});
</script>
......@@ -502,6 +502,8 @@ blink::WebMouseWheelEvent MakeWebMouseWheelEventFromUiEvent(
if (event.flags() & ui::EF_PRECISION_SCROLLING_DELTA)
webkit_event.has_precise_scrolling_deltas = true;
if (event.flags() & ui::EF_SCROLL_BY_PAGE)
webkit_event.scroll_by_page = true;
webkit_event.wheel_ticks_x =
webkit_event.delta_x / MouseWheelEvent::kWheelDelta;
......
......@@ -153,6 +153,9 @@ enum MouseEventFlags {
EF_PRECISION_SCROLLING_DELTA = // Indicates this mouse event is from high
1 << 21, // precision touchpad and will come with a
// high precision delta.
EF_SCROLL_BY_PAGE = 1 << 22, // Indicates this mouse event is generated
// when users is requesting to scroll by
// pages.
};
// Result of dispatching an event.
......
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