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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 737883002: Allow perfect scroll bubbling between outer/inner viewports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore layer locking logic Created 6 years, 1 month 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 | « no previous file | 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 ffe2ddb731aad2a0efd5550b35f3a2bde2d45b4c..8c15beac798fd67e1b7f1078e1766a1f04599f82 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2622,40 +2622,49 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
}
}
+ // Scrolls should bubble perfectly between the outer and inner viewports.
+ bool allow_unrestricted_bubbling_for_current_layer =
+ layer_impl == OuterViewportScrollLayer();
+ bool allow_bubbling_for_current_layer =
+ allow_unrestricted_bubbling_for_current_layer || should_bubble_scrolls_;
+
// If the layer wasn't able to move, try the next one in the hierarchy.
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) {
- // Scrolls should always bubble between the outer and inner viewports
- if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ ||
- layer_impl == OuterViewportScrollLayer())
+ if (allow_bubbling_for_current_layer || !did_lock_scrolling_layer_)
continue;
else
break;
}
did_lock_scrolling_layer_ = true;
- if (!should_bubble_scrolls_) {
+ if (!allow_bubbling_for_current_layer) {
active_tree_->SetCurrentlyScrollingLayer(layer_impl);
break;
}
- // If the applied delta is within 45 degrees of the input delta, bail out to
- // make it easier to scroll just one layer in one direction without
- // affecting any of its parents.
- float angle_threshold = 45;
- if (MathUtil::SmallestAngleBetweenVectors(
- applied_delta, pending_delta) < angle_threshold) {
- pending_delta = gfx::Vector2dF();
- break;
- }
+ if (allow_unrestricted_bubbling_for_current_layer) {
+ pending_delta -= applied_delta;
+ } else {
+ // If the applied delta is within 45 degrees of the input delta, bail out
+ // to make it easier to scroll just one layer in one direction without
+ // affecting any of its parents.
+ float angle_threshold = 45;
+ if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) <
+ angle_threshold) {
+ pending_delta = gfx::Vector2dF();
bokan 2014/11/19 00:58:33 I know you didn't write this, but do we need to cl
jdduke (slow) 2014/11/19 16:20:14 I'm guessing there was some trailing code that use
+ break;
+ }
- // Allow further movement only on an axis perpendicular to the direction in
- // which the layer moved.
- gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x());
- pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis);
+ // Allow further movement only on an axis perpendicular to the direction
+ // in which the layer moved.
+ gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x());
+ pending_delta =
+ MathUtil::ProjectVector(pending_delta, perpendicular_axis);
+ }
if (gfx::ToRoundedVector2d(pending_delta).IsZero())
break;
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698