OLD | NEW |
---|---|
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 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3048 | 3048 |
3049 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 3049 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
3050 const gfx::Point& viewport_point, | 3050 const gfx::Point& viewport_point, |
3051 const gfx::Vector2dF& scroll_delta, | 3051 const gfx::Vector2dF& scroll_delta, |
3052 base::TimeDelta delayed_by) { | 3052 base::TimeDelta delayed_by) { |
3053 InputHandler::ScrollStatus scroll_status; | 3053 InputHandler::ScrollStatus scroll_status; |
3054 scroll_status.main_thread_scrolling_reasons = | 3054 scroll_status.main_thread_scrolling_reasons = |
3055 MainThreadScrollingReason::kNotScrollingOnMain; | 3055 MainThreadScrollingReason::kNotScrollingOnMain; |
3056 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3056 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3057 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3057 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3058 bool x_dominated = (std::abs(scroll_delta.x()) > std::abs(scroll_delta.y())); | |
bokan
2017/06/30 15:44:11
nit: no need for outer parentheses
sunyunjia
2017/06/30 18:26:57
Done.
| |
3058 | 3059 |
3059 if (scroll_node) { | 3060 if (scroll_node) { |
3060 // Flash the overlay scrollbar even if the scroll dalta is 0. | 3061 // Flash the overlay scrollbar even if the scroll dalta is 0. |
3061 ScrollbarAnimationController* animation_controller = | 3062 ScrollbarAnimationController* animation_controller = |
3062 ScrollbarAnimationControllerForElementId(scroll_node->element_id); | 3063 ScrollbarAnimationControllerForElementId(scroll_node->element_id); |
3063 | 3064 |
3064 if (animation_controller) | 3065 if (animation_controller) |
3065 animation_controller->WillUpdateScroll(); | 3066 animation_controller->WillUpdateScroll(); |
3066 | 3067 |
3067 gfx::Vector2dF delta = scroll_delta; | 3068 gfx::Vector2dF delta = scroll_delta; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3127 } | 3128 } |
3128 | 3129 |
3129 gfx::Vector2dF scroll_delta = | 3130 gfx::Vector2dF scroll_delta = |
3130 ComputeScrollDelta(scroll_node, pending_delta); | 3131 ComputeScrollDelta(scroll_node, pending_delta); |
3131 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { | 3132 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { |
3132 scroll_animating_latched_node_id_ = scroll_node->id; | 3133 scroll_animating_latched_node_id_ = scroll_node->id; |
3133 return scroll_status; | 3134 return scroll_status; |
3134 } | 3135 } |
3135 | 3136 |
3136 pending_delta -= scroll_delta; | 3137 pending_delta -= scroll_delta; |
3138 | |
3139 if ((x_dominated && | |
3140 scroll_node->scroll_boundary_behavior.x != | |
3141 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) || | |
3142 (!x_dominated && | |
3143 scroll_node->scroll_boundary_behavior.y != | |
3144 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto)) | |
3145 break; | |
3137 } | 3146 } |
3138 } | 3147 } |
3139 scroll_state.set_is_ending(true); | 3148 scroll_state.set_is_ending(true); |
3140 ScrollEnd(&scroll_state); | 3149 ScrollEnd(&scroll_state); |
3141 if (settings_.is_layer_tree_for_subframe && | 3150 if (settings_.is_layer_tree_for_subframe && |
3142 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 3151 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
3143 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise | 3152 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise |
3144 // we'll mark the scroll as handled and the scroll won't bubble. | 3153 // we'll mark the scroll as handled and the scroll won't bubble. |
3145 scroll_status.thread = SCROLL_IGNORED; | 3154 scroll_status.thread = SCROLL_IGNORED; |
3146 scroll_status.main_thread_scrolling_reasons = | 3155 scroll_status.main_thread_scrolling_reasons = |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3362 // is not the case here. We eventually want to have the same behaviour on both | 3371 // is not the case here. We eventually want to have the same behaviour on both |
3363 // sides but it may become a non issue if we get rid of scroll chaining (see | 3372 // sides but it may become a non issue if we get rid of scroll chaining (see |
3364 // crbug.com/526462) | 3373 // crbug.com/526462) |
3365 std::list<ScrollNode*> current_scroll_chain; | 3374 std::list<ScrollNode*> current_scroll_chain; |
3366 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3375 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3367 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3376 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3368 ScrollNode* viewport_scroll_node = | 3377 ScrollNode* viewport_scroll_node = |
3369 viewport()->MainScrollLayer() | 3378 viewport()->MainScrollLayer() |
3370 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) | 3379 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) |
3371 : nullptr; | 3380 : nullptr; |
3381 bool x_dominated = | |
3382 (std::abs(scroll_state->delta_x()) > std::abs(scroll_state->delta_y())); | |
bokan
2017/06/30 15:44:11
ditto
sunyunjia
2017/06/30 18:26:58
Done.
| |
3383 if (scroll_state->is_beginning()) { | |
3384 x_dominated = (std::abs(scroll_state->delta_x_hint()) > | |
3385 std::abs(scroll_state->delta_y_hint())); | |
3386 } | |
3372 if (scroll_node) { | 3387 if (scroll_node) { |
3373 // TODO(bokan): The loop checks for a null parent but don't we still want to | 3388 // TODO(bokan): The loop checks for a null parent but don't we still want to |
3374 // distribute to the root scroll node? | 3389 // distribute to the root scroll node? |
3375 for (; scroll_tree.parent(scroll_node); | 3390 for (; scroll_tree.parent(scroll_node); |
3376 scroll_node = scroll_tree.parent(scroll_node)) { | 3391 scroll_node = scroll_tree.parent(scroll_node)) { |
3377 if (scroll_node == viewport_scroll_node) { | 3392 if (scroll_node == viewport_scroll_node) { |
3378 // Don't chain scrolls past the outer viewport scroll layer. Once we | 3393 // Don't chain scrolls past the outer viewport scroll layer. Once we |
3379 // reach that, we should scroll the viewport which is represented by the | 3394 // reach that, we should scroll the viewport which is represented by the |
3380 // main viewport scroll layer. | 3395 // main viewport scroll layer. |
3381 DCHECK(viewport_scroll_node); | 3396 DCHECK(viewport_scroll_node); |
3382 current_scroll_chain.push_front(viewport_scroll_node); | 3397 current_scroll_chain.push_front(viewport_scroll_node); |
3383 break; | 3398 break; |
3384 } | 3399 } |
3385 | 3400 |
3386 if (!scroll_node->scrollable) | 3401 if (scroll_node->scrollable && |
3387 continue; | 3402 CanConsumeDelta(scroll_node, *scroll_state)) |
3403 current_scroll_chain.push_front(scroll_node); | |
3388 | 3404 |
3389 if (CanConsumeDelta(scroll_node, *scroll_state)) | 3405 if ((x_dominated && |
3390 current_scroll_chain.push_front(scroll_node); | 3406 scroll_node->scroll_boundary_behavior.x != |
3407 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) || | |
3408 (!x_dominated && | |
3409 scroll_node->scroll_boundary_behavior.y != | |
3410 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto)) | |
3411 break; | |
3391 } | 3412 } |
3392 } | 3413 } |
3393 active_tree_->SetCurrentlyScrollingNode( | 3414 active_tree_->SetCurrentlyScrollingNode( |
3394 current_scroll_chain.empty() ? nullptr : current_scroll_chain.back()); | 3415 current_scroll_chain.empty() ? nullptr : current_scroll_chain.back()); |
3395 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, | 3416 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, |
3396 active_tree()); | 3417 active_tree()); |
3397 scroll_state->DistributeToScrollChainDescendant(); | 3418 scroll_state->DistributeToScrollChainDescendant(); |
3398 } | 3419 } |
3399 | 3420 |
3400 bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node, | 3421 bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node, |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4404 | 4425 |
4405 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { | 4426 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { |
4406 if (!element_id) | 4427 if (!element_id) |
4407 return; | 4428 return; |
4408 if (ScrollbarAnimationController* animation_controller = | 4429 if (ScrollbarAnimationController* animation_controller = |
4409 ScrollbarAnimationControllerForElementId(element_id)) | 4430 ScrollbarAnimationControllerForElementId(element_id)) |
4410 animation_controller->DidScrollUpdate(); | 4431 animation_controller->DidScrollUpdate(); |
4411 } | 4432 } |
4412 | 4433 |
4413 } // namespace cc | 4434 } // namespace cc |
OLD | NEW |