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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 3050
3051 mutator_host_->ImplOnlyScrollAnimationCreate( 3051 mutator_host_->ImplOnlyScrollAnimationCreate(
3052 scroll_node->element_id, target_offset, current_offset, delayed_by, 3052 scroll_node->element_id, target_offset, current_offset, delayed_by,
3053 animation_start_offset); 3053 animation_start_offset);
3054 3054
3055 SetNeedsOneBeginImplFrame(); 3055 SetNeedsOneBeginImplFrame();
3056 3056
3057 return true; 3057 return true;
3058 } 3058 }
3059 3059
3060 static bool CanPropagate(ScrollNode* scroll_node, float x, float y) {
3061 // ScrollBoundaryBehavior may have different values on x-axis and y-axis.
3062 // We need to find out the dominant axis of user's intended scroll to decide
3063 // which node's ScrollBoundaryBehavior should be applied, i.e. which the
3064 // scroll should be propagated from this node given its relevant*
3065 // ScrollBoundaryBehavior value. * relevant here depends on the dominant
3066 // axis of scroll gesture.
3067 bool x_dominant = std::abs(x) > std::abs(y);
3068 return (x_dominant &&
3069 scroll_node->scroll_boundary_behavior.x ==
3070 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) ||
3071 (!x_dominant &&
3072 scroll_node->scroll_boundary_behavior.y ==
3073 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto);
3074 }
3075
3060 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( 3076 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
3061 const gfx::Point& viewport_point, 3077 const gfx::Point& viewport_point,
3062 const gfx::Vector2dF& scroll_delta, 3078 const gfx::Vector2dF& scroll_delta,
3063 base::TimeDelta delayed_by) { 3079 base::TimeDelta delayed_by) {
3064 InputHandler::ScrollStatus scroll_status; 3080 InputHandler::ScrollStatus scroll_status;
3065 scroll_status.main_thread_scrolling_reasons = 3081 scroll_status.main_thread_scrolling_reasons =
3066 MainThreadScrollingReason::kNotScrollingOnMain; 3082 MainThreadScrollingReason::kNotScrollingOnMain;
3067 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 3083 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3068 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 3084 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
3069 3085
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3138 } 3154 }
3139 3155
3140 gfx::Vector2dF scroll_delta = 3156 gfx::Vector2dF scroll_delta =
3141 ComputeScrollDelta(scroll_node, pending_delta); 3157 ComputeScrollDelta(scroll_node, pending_delta);
3142 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { 3158 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) {
3143 scroll_animating_latched_node_id_ = scroll_node->id; 3159 scroll_animating_latched_node_id_ = scroll_node->id;
3144 return scroll_status; 3160 return scroll_status;
3145 } 3161 }
3146 3162
3147 pending_delta -= scroll_delta; 3163 pending_delta -= scroll_delta;
3164
3165 if (!CanPropagate(scroll_node, pending_delta.x(), pending_delta.y()))
3166 break;
3148 } 3167 }
3149 } 3168 }
3150 scroll_state.set_is_ending(true); 3169 scroll_state.set_is_ending(true);
3151 ScrollEnd(&scroll_state); 3170 ScrollEnd(&scroll_state);
3152 if (settings_.is_layer_tree_for_subframe && 3171 if (settings_.is_layer_tree_for_subframe &&
3153 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { 3172 scroll_status.thread == SCROLL_ON_IMPL_THREAD) {
3154 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise 3173 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise
3155 // we'll mark the scroll as handled and the scroll won't bubble. 3174 // we'll mark the scroll as handled and the scroll won't bubble.
3156 scroll_status.thread = SCROLL_IGNORED; 3175 scroll_status.thread = SCROLL_IGNORED;
3157 scroll_status.main_thread_scrolling_reasons = 3176 scroll_status.main_thread_scrolling_reasons =
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3392 DCHECK(viewport_scroll_node); 3411 DCHECK(viewport_scroll_node);
3393 current_scroll_chain.push_front(viewport_scroll_node); 3412 current_scroll_chain.push_front(viewport_scroll_node);
3394 break; 3413 break;
3395 } 3414 }
3396 3415
3397 if (!scroll_node->scrollable) 3416 if (!scroll_node->scrollable)
3398 continue; 3417 continue;
3399 3418
3400 if (CanConsumeDelta(scroll_node, *scroll_state)) 3419 if (CanConsumeDelta(scroll_node, *scroll_state))
3401 current_scroll_chain.push_front(scroll_node); 3420 current_scroll_chain.push_front(scroll_node);
3421
3422 float delta_x = scroll_state->is_beginning()
3423 ? scroll_state->delta_x_hint()
3424 : scroll_state->delta_x();
3425 float delta_y = scroll_state->is_beginning()
3426 ? scroll_state->delta_y_hint()
3427 : scroll_state->delta_y();
3428
3429 if (!CanPropagate(scroll_node, delta_x, delta_y))
3430 break;
3402 } 3431 }
3403 } 3432 }
3404 active_tree_->SetCurrentlyScrollingNode( 3433 active_tree_->SetCurrentlyScrollingNode(
3405 current_scroll_chain.empty() ? nullptr : current_scroll_chain.back()); 3434 current_scroll_chain.empty() ? nullptr : current_scroll_chain.back());
3406 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, 3435 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain,
3407 active_tree()); 3436 active_tree());
3408 scroll_state->DistributeToScrollChainDescendant(); 3437 scroll_state->DistributeToScrollChainDescendant();
3409 } 3438 }
3410 3439
3411 bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node, 3440 bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node,
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
4409 4438
4410 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { 4439 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) {
4411 if (!element_id) 4440 if (!element_id)
4412 return; 4441 return;
4413 if (ScrollbarAnimationController* animation_controller = 4442 if (ScrollbarAnimationController* animation_controller =
4414 ScrollbarAnimationControllerForElementId(element_id)) 4443 ScrollbarAnimationControllerForElementId(element_id))
4415 animation_controller->DidScrollUpdate(); 4444 animation_controller->DidScrollUpdate();
4416 } 4445 }
4417 4446
4418 } // namespace cc 4447 } // namespace cc
OLDNEW
« 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