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 3127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3138 } | 3138 } |
3139 | 3139 |
3140 gfx::Vector2dF scroll_delta = | 3140 gfx::Vector2dF scroll_delta = |
3141 ComputeScrollDelta(scroll_node, pending_delta); | 3141 ComputeScrollDelta(scroll_node, pending_delta); |
3142 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { | 3142 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { |
3143 scroll_animating_latched_node_id_ = scroll_node->id; | 3143 scroll_animating_latched_node_id_ = scroll_node->id; |
3144 return scroll_status; | 3144 return scroll_status; |
3145 } | 3145 } |
3146 | 3146 |
3147 pending_delta -= scroll_delta; | 3147 pending_delta -= scroll_delta; |
3148 | |
3149 if (!CanPropagate(scroll_node, pending_delta.x(), pending_delta.y())) | |
3150 break; | |
3148 } | 3151 } |
3149 } | 3152 } |
3150 scroll_state.set_is_ending(true); | 3153 scroll_state.set_is_ending(true); |
3151 ScrollEnd(&scroll_state); | 3154 ScrollEnd(&scroll_state); |
3152 if (settings_.is_layer_tree_for_subframe && | 3155 if (settings_.is_layer_tree_for_subframe && |
3153 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 3156 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
3154 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise | 3157 // 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. | 3158 // we'll mark the scroll as handled and the scroll won't bubble. |
3156 scroll_status.thread = SCROLL_IGNORED; | 3159 scroll_status.thread = SCROLL_IGNORED; |
3157 scroll_status.main_thread_scrolling_reasons = | 3160 scroll_status.main_thread_scrolling_reasons = |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3373 // is not the case here. We eventually want to have the same behaviour on both | 3376 // is not the case here. We eventually want to have the same behaviour on both |
3374 // sides but it may become a non issue if we get rid of scroll chaining (see | 3377 // sides but it may become a non issue if we get rid of scroll chaining (see |
3375 // crbug.com/526462) | 3378 // crbug.com/526462) |
3376 std::list<ScrollNode*> current_scroll_chain; | 3379 std::list<ScrollNode*> current_scroll_chain; |
3377 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3380 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3378 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3381 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3379 ScrollNode* viewport_scroll_node = | 3382 ScrollNode* viewport_scroll_node = |
3380 viewport()->MainScrollLayer() | 3383 viewport()->MainScrollLayer() |
3381 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) | 3384 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) |
3382 : nullptr; | 3385 : nullptr; |
3386 | |
majidvp
2017/07/14 14:29:43
nit: remove the unnecessary blank line.
sunyunjia
2017/07/14 22:07:23
Done.
| |
3383 if (scroll_node) { | 3387 if (scroll_node) { |
3384 // 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 |
3385 // distribute to the root scroll node? | 3389 // distribute to the root scroll node? |
3386 for (; scroll_tree.parent(scroll_node); | 3390 for (; scroll_tree.parent(scroll_node); |
3387 scroll_node = scroll_tree.parent(scroll_node)) { | 3391 scroll_node = scroll_tree.parent(scroll_node)) { |
3388 if (scroll_node == viewport_scroll_node) { | 3392 if (scroll_node == viewport_scroll_node) { |
3389 // 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 |
3390 // 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 |
3391 // main viewport scroll layer. | 3395 // main viewport scroll layer. |
3392 DCHECK(viewport_scroll_node); | 3396 DCHECK(viewport_scroll_node); |
3393 current_scroll_chain.push_front(viewport_scroll_node); | 3397 current_scroll_chain.push_front(viewport_scroll_node); |
3394 break; | 3398 break; |
3395 } | 3399 } |
3396 | 3400 |
3397 if (!scroll_node->scrollable) | 3401 if (!scroll_node->scrollable) |
3398 continue; | 3402 continue; |
3399 | 3403 |
3400 if (CanConsumeDelta(scroll_node, *scroll_state)) | 3404 if (CanConsumeDelta(scroll_node, *scroll_state)) |
3401 current_scroll_chain.push_front(scroll_node); | 3405 current_scroll_chain.push_front(scroll_node); |
3406 | |
3407 float delta_x = scroll_state->is_beginning() | |
3408 ? scroll_state->delta_x_hint() | |
3409 : scroll_state->delta_x(); | |
3410 float delta_y = scroll_state->is_beginning() | |
3411 ? scroll_state->delta_y_hint() | |
3412 : scroll_state->delta_y(); | |
3413 | |
3414 if (!CanPropagate(scroll_node, delta_x, delta_y)) | |
3415 break; | |
3402 } | 3416 } |
3403 } | 3417 } |
3404 active_tree_->SetCurrentlyScrollingNode( | 3418 active_tree_->SetCurrentlyScrollingNode( |
3405 current_scroll_chain.empty() ? nullptr : current_scroll_chain.back()); | 3419 current_scroll_chain.empty() ? nullptr : current_scroll_chain.back()); |
3406 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, | 3420 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, |
3407 active_tree()); | 3421 active_tree()); |
3408 scroll_state->DistributeToScrollChainDescendant(); | 3422 scroll_state->DistributeToScrollChainDescendant(); |
3409 } | 3423 } |
3410 | 3424 |
3411 bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node, | 3425 bool LayerTreeHostImpl::CanConsumeDelta(ScrollNode* scroll_node, |
(...skipping 22 matching lines...) Expand all Loading... | |
3434 } | 3448 } |
3435 delta_to_scroll = local_scroll_delta; | 3449 delta_to_scroll = local_scroll_delta; |
3436 } | 3450 } |
3437 | 3451 |
3438 if (ComputeScrollDelta(scroll_node, delta_to_scroll) != gfx::Vector2dF()) | 3452 if (ComputeScrollDelta(scroll_node, delta_to_scroll) != gfx::Vector2dF()) |
3439 return true; | 3453 return true; |
3440 | 3454 |
3441 return false; | 3455 return false; |
3442 } | 3456 } |
3443 | 3457 |
3458 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.
| |
3459 float x, | |
3460 float y) { | |
3461 // ScrollBoundaryBehavior may have different values on x-axis and y-axis. | |
3462 // We need to find out the dominant axis of user's intended scroll to decide | |
3463 // which node's ScrollBoundaryBehavior should be applied, i.e. which node | |
3464 // 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.
| |
3465 bool x_dominant = std::abs(x) > std::abs(y); | |
3466 return (x_dominant && | |
3467 scroll_node->scroll_boundary_behavior.x == | |
3468 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) || | |
3469 (!x_dominant && | |
3470 scroll_node->scroll_boundary_behavior.y == | |
3471 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto); | |
3472 } | |
3473 | |
3444 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( | 3474 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
3445 ScrollState* scroll_state) { | 3475 ScrollState* scroll_state) { |
3446 DCHECK(scroll_state); | 3476 DCHECK(scroll_state); |
3447 | 3477 |
3448 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); | 3478 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |
3449 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3479 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3450 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3480 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3451 | 3481 |
3452 if (!scroll_node) | 3482 if (!scroll_node) |
3453 return InputHandlerScrollResult(); | 3483 return InputHandlerScrollResult(); |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4409 | 4439 |
4410 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { | 4440 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { |
4411 if (!element_id) | 4441 if (!element_id) |
4412 return; | 4442 return; |
4413 if (ScrollbarAnimationController* animation_controller = | 4443 if (ScrollbarAnimationController* animation_controller = |
4414 ScrollbarAnimationControllerForElementId(element_id)) | 4444 ScrollbarAnimationControllerForElementId(element_id)) |
4415 animation_controller->DidScrollUpdate(); | 4445 animation_controller->DidScrollUpdate(); |
4416 } | 4446 } |
4417 | 4447 |
4418 } // namespace cc | 4448 } // namespace cc |
OLD | NEW |