Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 1227823005: Revert of Cleanup viewport scrolling for future scroll customization work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 6a1b88b1527f605eeec1043541706f264b802df2..ddb4dc951a8ea75b5a68c3fd9ad5dad38e24bd21 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2610,18 +2610,22 @@
gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl,
const gfx::Vector2dF& delta,
const gfx::Point& viewport_point,
- bool is_direct_manipulation) {
- // Events representing direct manipulation of the screen (such as 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, events not representing direct manipulation of the
- // screen (such as wheel events) represent a fixed amount of scrolling so we
- // can just apply them directly, but the page scale factor is applied to the
- // scroll delta.
- if (is_direct_manipulation)
- return ScrollLayerWithViewportSpaceDelta(layer_impl, viewport_point, delta);
- float scale_factor = active_tree()->current_page_scale_factor();
- return ScrollLayerWithLocalDelta(layer_impl, delta, scale_factor);
+ bool is_wheel_scroll) {
+ // 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, but the page scale
+ // factor is applied to the scroll delta.
+ if (is_wheel_scroll) {
+ float scale_factor = active_tree()->current_page_scale_factor();
+ return ScrollLayerWithLocalDelta(layer_impl,
+ delta,
+ scale_factor);
+ }
+
+ return ScrollLayerWithViewportSpaceDelta(layer_impl,
+ viewport_point,
+ delta);
}
static LayerImpl* nextLayerInScrollOrder(LayerImpl* layer) {
@@ -2642,6 +2646,7 @@
gfx::Vector2dF unused_root_delta;
bool did_scroll_x = false;
bool did_scroll_y = false;
+ bool did_scroll_top_controls = false;
if (pinch_gesture_active_ && settings().invert_viewport_scroll_order) {
// Scrolls during a pinch gesture should pan the visual viewport, rather
@@ -2662,24 +2667,28 @@
gfx::Vector2dF applied_delta;
if (layer_impl == InnerViewportScrollLayer()) {
bool affect_top_controls = true;
- applied_delta =
- viewport()->ScrollBy(pending_delta, viewport_point, !wheel_scrolling_,
- affect_top_controls);
- unused_root_delta = pending_delta - applied_delta;
+ Viewport::ScrollResult result = viewport()->ScrollBy(pending_delta,
+ viewport_point,
+ wheel_scrolling_,
+ affect_top_controls);
+ applied_delta = result.applied_delta;
+ unused_root_delta = result.unused_scroll_delta;
+ did_scroll_top_controls = result.top_controls_applied_delta.y() != 0;
} else {
- applied_delta = ScrollLayer(layer_impl, pending_delta, viewport_point,
- !wheel_scrolling_);
+ applied_delta = ScrollLayer(layer_impl,
+ pending_delta,
+ viewport_point,
+ wheel_scrolling_);
}
// If the layer wasn't able to move, try the next one in the hierarchy.
const float kEpsilon = 0.1f;
- bool did_layer_consume_delta_x = std::abs(applied_delta.x()) > kEpsilon;
- bool did_layer_consume_delta_y = std::abs(applied_delta.y()) > kEpsilon;
-
- did_scroll_x |= did_layer_consume_delta_x;
- did_scroll_y |= did_layer_consume_delta_y;
-
- if (did_layer_consume_delta_x || did_layer_consume_delta_y) {
+ bool did_move_layer_x = std::abs(applied_delta.x()) > kEpsilon;
+ bool did_move_layer_y = std::abs(applied_delta.y()) > kEpsilon;
+ did_scroll_x |= did_move_layer_x;
+ did_scroll_y |= did_move_layer_y;
+
+ if (did_move_layer_x || did_move_layer_y) {
did_lock_scrolling_layer_ = true;
// When scrolls are allowed to bubble, it's important that the original
@@ -2733,7 +2742,7 @@
accumulated_root_overscroll_ += unused_root_delta;
InputHandlerScrollResult scroll_result;
- scroll_result.did_scroll = did_scroll_content;
+ scroll_result.did_scroll = did_scroll_content || did_scroll_top_controls;
scroll_result.did_overscroll_root = !unused_root_delta.IsZero();
scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_;
scroll_result.unused_scroll_delta = unused_root_delta;
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698