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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 2769793002: Implement CSS: scroll-boundary-behavior (Closed)
Patch Set: Add documentation Created 3 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/layers/layer_impl_test_properties.cc ('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 cd185fa100cb204a89b18a6a8b3235a52af9c9ca..9f938c1552bcdeaaecd659454003a5edd42b745c 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -3057,6 +3057,22 @@ bool LayerTreeHostImpl::ScrollAnimationCreate(ScrollNode* scroll_node,
return true;
}
+static bool CanPropagate(ScrollNode* scroll_node, float x, float y) {
+ // ScrollBoundaryBehavior may have different values on x-axis and y-axis.
+ // We need to find out the dominant axis of user's intended scroll to decide
+ // which node's ScrollBoundaryBehavior should be applied, i.e. which the
+ // scroll should be propagated from this node given its relevant*
+ // ScrollBoundaryBehavior value. * relevant here depends on the dominant
+ // axis of scroll gesture.
+ bool x_dominant = std::abs(x) > std::abs(y);
+ return (x_dominant &&
+ scroll_node->scroll_boundary_behavior.x ==
+ ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) ||
+ (!x_dominant &&
+ scroll_node->scroll_boundary_behavior.y ==
+ ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto);
+}
+
InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
const gfx::Point& viewport_point,
const gfx::Vector2dF& scroll_delta,
@@ -3145,6 +3161,9 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
}
pending_delta -= scroll_delta;
+
+ if (!CanPropagate(scroll_node, pending_delta.x(), pending_delta.y()))
+ break;
}
}
scroll_state.set_is_ending(true);
@@ -3399,6 +3418,16 @@ void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) {
if (CanConsumeDelta(scroll_node, *scroll_state))
current_scroll_chain.push_front(scroll_node);
+
+ float delta_x = scroll_state->is_beginning()
+ ? scroll_state->delta_x_hint()
+ : scroll_state->delta_x();
+ float delta_y = scroll_state->is_beginning()
+ ? scroll_state->delta_y_hint()
+ : scroll_state->delta_y();
+
+ if (!CanPropagate(scroll_node, delta_x, delta_y))
+ break;
}
}
active_tree_->SetCurrentlyScrollingNode(
« no previous file with comments | « cc/layers/layer_impl_test_properties.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698