Enable raw pixel scrolling for wheel events in web contents
We now support raw pixel scroll with touch pad on high resolution Chromebook.
The web content should be scrolled as smoothly as from touch screen even
after we do pinch-zoom. We changed wheel events to be scaled by page scale
same as gesture events.
BUG=344614
Review URL: https://codereview.chromium.org/613043003
Cr-Commit-Position: refs/heads/master@{#306218}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 7593965..ea30d85 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2551,10 +2551,14 @@
return actual_viewport_end_point - viewport_point;
}
-static gfx::Vector2dF ScrollLayerWithLocalDelta(LayerImpl* layer_impl,
- const gfx::Vector2dF& local_delta) {
+static gfx::Vector2dF ScrollLayerWithLocalDelta(
+ LayerImpl* layer_impl,
+ const gfx::Vector2dF& local_delta,
+ float page_scale_factor) {
gfx::Vector2dF previous_delta(layer_impl->ScrollDelta());
- layer_impl->ScrollBy(local_delta);
+ gfx::Vector2dF delta = local_delta;
+ delta.Scale(1.f / page_scale_factor);
+ layer_impl->ScrollBy(delta);
return layer_impl->ScrollDelta() - previous_delta;
}
@@ -2632,7 +2636,8 @@
// Gesture events need to be transformed from viewport coordinates to local
// layer coordinates so that the scrolling contents exactly follow the
// user's finger. In contrast, wheel events represent a fixed amount of
- // scrolling so we can just apply them directly.
+ // scrolling so we can just apply them directly, but the page scale factor
+ // is applied to the scroll delta.
if (!wheel_scrolling_) {
float scale_from_viewport_to_screen_space = device_scale_factor_;
applied_delta =
@@ -2640,7 +2645,8 @@
scale_from_viewport_to_screen_space,
viewport_point, pending_delta);
} else {
- applied_delta = ScrollLayerWithLocalDelta(layer_impl, pending_delta);
+ applied_delta = ScrollLayerWithLocalDelta(
+ layer_impl, pending_delta, active_tree_->total_page_scale_factor());
}
const float kEpsilon = 0.1f;
@@ -2762,7 +2768,8 @@
gfx::Vector2dF delta = gfx::Vector2dF(0.f, page);
- gfx::Vector2dF applied_delta = ScrollLayerWithLocalDelta(layer_impl, delta);
+ gfx::Vector2dF applied_delta =
+ ScrollLayerWithLocalDelta(layer_impl, delta, 1.f);
if (!applied_delta.IsZero()) {
client_->SetNeedsCommitOnImplThread();