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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 2769793002: Implement CSS: scroll-boundary-behavior (Closed)
Patch Set: Update promises tests and Scroll Manager 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
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..3fc05c913fb8219adc2627a9001c2c52f5aadf81 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -3145,6 +3145,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);
@@ -3380,6 +3383,7 @@ void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) {
viewport()->MainScrollLayer()
? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index())
: nullptr;
+
majidvp 2017/07/14 14:29:43 nit: remove the unnecessary blank line.
sunyunjia 2017/07/14 22:07:23 Done.
if (scroll_node) {
// TODO(bokan): The loop checks for a null parent but don't we still want to
// distribute to the root scroll node?
@@ -3399,6 +3403,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(
@@ -3441,6 +3455,22 @@ bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node,
return false;
}
+bool LayerTreeHostImpl::CanPropagate(ScrollNode* scroll_node,
majidvp 2017/07/14 14:29:43 This function is not using any state in LayerTreeH
sunyunjia 2017/07/14 22:07:24 Done.
+ 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 node
+ // should be scrolled.
majidvp 2017/07/14 14:29:43 The last sentence is not accurate. We don't decide
sunyunjia 2017/07/14 22:07:23 Done.
+ 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);
+}
+
InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
ScrollState* scroll_state) {
DCHECK(scroll_state);

Powered by Google App Engine
This is Rietveld 408576698