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 2994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 | 3005 |
3006 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 3006 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
3007 const gfx::Point& viewport_point, | 3007 const gfx::Point& viewport_point, |
3008 const gfx::Vector2dF& scroll_delta, | 3008 const gfx::Vector2dF& scroll_delta, |
3009 base::TimeDelta delayed_by) { | 3009 base::TimeDelta delayed_by) { |
3010 InputHandler::ScrollStatus scroll_status; | 3010 InputHandler::ScrollStatus scroll_status; |
3011 scroll_status.main_thread_scrolling_reasons = | 3011 scroll_status.main_thread_scrolling_reasons = |
3012 MainThreadScrollingReason::kNotScrollingOnMain; | 3012 MainThreadScrollingReason::kNotScrollingOnMain; |
3013 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3013 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3014 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3014 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 3015 bool x_dominated = (std::abs(scroll_delta.x()) > std::abs(scroll_delta.y())); |
3015 | 3016 |
3016 if (scroll_node) { | 3017 if (scroll_node) { |
3017 // Flash the overlay scrollbar even if the scroll dalta is 0. | 3018 // Flash the overlay scrollbar even if the scroll dalta is 0. |
3018 ScrollbarAnimationController* animation_controller = | 3019 ScrollbarAnimationController* animation_controller = |
3019 ScrollbarAnimationControllerForElementId(scroll_node->element_id); | 3020 ScrollbarAnimationControllerForElementId(scroll_node->element_id); |
3020 | 3021 |
3021 if (animation_controller) | 3022 if (animation_controller) |
3022 animation_controller->WillUpdateScroll(); | 3023 animation_controller->WillUpdateScroll(); |
3023 | 3024 |
3024 gfx::Vector2dF delta = scroll_delta; | 3025 gfx::Vector2dF delta = scroll_delta; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 } | 3085 } |
3085 | 3086 |
3086 gfx::Vector2dF scroll_delta = | 3087 gfx::Vector2dF scroll_delta = |
3087 ComputeScrollDelta(scroll_node, pending_delta); | 3088 ComputeScrollDelta(scroll_node, pending_delta); |
3088 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { | 3089 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) { |
3089 scroll_animating_latched_node_id_ = scroll_node->id; | 3090 scroll_animating_latched_node_id_ = scroll_node->id; |
3090 return scroll_status; | 3091 return scroll_status; |
3091 } | 3092 } |
3092 | 3093 |
3093 pending_delta -= scroll_delta; | 3094 pending_delta -= scroll_delta; |
| 3095 |
| 3096 if ((x_dominated && |
| 3097 scroll_node->scroll_boundary_behavior.x != |
| 3098 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) || |
| 3099 (!x_dominated && |
| 3100 scroll_node->scroll_boundary_behavior.y != |
| 3101 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto)) |
| 3102 break; |
3094 } | 3103 } |
3095 } | 3104 } |
3096 scroll_state.set_is_ending(true); | 3105 scroll_state.set_is_ending(true); |
3097 ScrollEnd(&scroll_state); | 3106 ScrollEnd(&scroll_state); |
3098 if (settings_.is_layer_tree_for_subframe && | 3107 if (settings_.is_layer_tree_for_subframe && |
3099 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 3108 scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
3100 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise | 3109 // If we get to here, we shouldn't return SCROLL_ON_IMPL_THREAD as otherwise |
3101 // we'll mark the scroll as handled and the scroll won't bubble. | 3110 // we'll mark the scroll as handled and the scroll won't bubble. |
3102 scroll_status.thread = SCROLL_IGNORED; | 3111 scroll_status.thread = SCROLL_IGNORED; |
3103 scroll_status.main_thread_scrolling_reasons = | 3112 scroll_status.main_thread_scrolling_reasons = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3291 | 3300 |
3292 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { | 3301 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { |
3293 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which | 3302 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which |
3294 // is not the case here. We eventually want to have the same behaviour on both | 3303 // is not the case here. We eventually want to have the same behaviour on both |
3295 // sides but it may become a non issue if we get rid of scroll chaining (see | 3304 // sides but it may become a non issue if we get rid of scroll chaining (see |
3296 // crbug.com/526462) | 3305 // crbug.com/526462) |
3297 std::list<ScrollNode*> current_scroll_chain; | 3306 std::list<ScrollNode*> current_scroll_chain; |
3298 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3307 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3299 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3308 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3300 ScrollNode* viewport_scroll_node = OuterViewportScrollNode(); | 3309 ScrollNode* viewport_scroll_node = OuterViewportScrollNode(); |
| 3310 bool x_dominated = |
| 3311 (std::abs(scroll_state->delta_x()) > std::abs(scroll_state->delta_y())); |
3301 if (scroll_node) { | 3312 if (scroll_node) { |
3302 // TODO(bokan): The loop checks for a null parent but don't we still want to | 3313 // TODO(bokan): The loop checks for a null parent but don't we still want to |
3303 // distribute to the root scroll node? | 3314 // distribute to the root scroll node? |
3304 for (; scroll_tree.parent(scroll_node); | 3315 for (; scroll_tree.parent(scroll_node); |
3305 scroll_node = scroll_tree.parent(scroll_node)) { | 3316 scroll_node = scroll_tree.parent(scroll_node)) { |
3306 if (scroll_node == viewport_scroll_node) { | 3317 if (scroll_node == viewport_scroll_node) { |
3307 // Don't chain scrolls past the outer viewport scroll layer. Once we | 3318 // Don't chain scrolls past the outer viewport scroll layer. Once we |
3308 // reach that, we should scroll the viewport which is represented by the | 3319 // reach that, we should scroll the viewport which is represented by the |
3309 // main viewport scroll layer. | 3320 // main viewport scroll layer. |
3310 DCHECK(viewport_scroll_node); | 3321 DCHECK(viewport_scroll_node); |
3311 current_scroll_chain.push_front(viewport_scroll_node); | 3322 current_scroll_chain.push_front(viewport_scroll_node); |
3312 break; | 3323 break; |
3313 } | 3324 } |
3314 | 3325 |
3315 if (!scroll_node->scrollable) | 3326 if (scroll_node->scrollable) |
3316 continue; | 3327 current_scroll_chain.push_front(scroll_node); |
3317 | 3328 |
3318 current_scroll_chain.push_front(scroll_node); | 3329 if ((x_dominated && |
| 3330 scroll_node->scroll_boundary_behavior.x != |
| 3331 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) || |
| 3332 (!x_dominated && |
| 3333 scroll_node->scroll_boundary_behavior.y != |
| 3334 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto)) |
| 3335 break; |
3319 } | 3336 } |
3320 } | 3337 } |
3321 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, | 3338 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, |
3322 active_tree()); | 3339 active_tree()); |
3323 scroll_state->DistributeToScrollChainDescendant(); | 3340 scroll_state->DistributeToScrollChainDescendant(); |
3324 } | 3341 } |
3325 | 3342 |
3326 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( | 3343 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
3327 ScrollState* scroll_state) { | 3344 ScrollState* scroll_state) { |
3328 DCHECK(scroll_state); | 3345 DCHECK(scroll_state); |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4356 | 4373 |
4357 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { | 4374 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { |
4358 if (!element_id) | 4375 if (!element_id) |
4359 return; | 4376 return; |
4360 if (ScrollbarAnimationController* animation_controller = | 4377 if (ScrollbarAnimationController* animation_controller = |
4361 ScrollbarAnimationControllerForElementId(element_id)) | 4378 ScrollbarAnimationControllerForElementId(element_id)) |
4362 animation_controller->DidScrollUpdate(); | 4379 animation_controller->DidScrollUpdate(); |
4363 } | 4380 } |
4364 | 4381 |
4365 } // namespace cc | 4382 } // namespace cc |
OLD | NEW |