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 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2560 } | 2560 } |
2561 | 2561 |
2562 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && | 2562 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && |
2563 !potentially_scrolling_layer_impl) { | 2563 !potentially_scrolling_layer_impl) { |
2564 potentially_scrolling_layer_impl = | 2564 potentially_scrolling_layer_impl = |
2565 active_tree_->LayerById(scroll_node->owner_id); | 2565 active_tree_->LayerById(scroll_node->owner_id); |
2566 } | 2566 } |
2567 } | 2567 } |
2568 } | 2568 } |
2569 | 2569 |
2570 // The outer viewport layer represents the viewport. | |
2571 if (potentially_scrolling_layer_impl == InnerViewportScrollLayer()) | |
2572 potentially_scrolling_layer_impl = OuterViewportScrollLayer(); | |
2573 | |
2570 // Falling back to the root scroll layer ensures generation of root overscroll | 2574 // Falling back to the root scroll layer ensures generation of root overscroll |
2571 // notifications. The inner viewport layer represents the viewport during | 2575 // notifications. |
2572 // scrolling. | |
2573 if (!potentially_scrolling_layer_impl) | 2576 if (!potentially_scrolling_layer_impl) |
2574 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); | 2577 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); |
tdresser
2016/09/23 15:59:58
Shouldn't this be OuterViewportScrollLayer?
bokan
2016/09/23 19:57:01
Yah, I wasn't sure since changing it broke some te
| |
2575 | 2578 |
2576 // The inner viewport layer represents the viewport. | |
2577 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) | |
2578 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); | |
2579 | |
2580 if (potentially_scrolling_layer_impl) { | 2579 if (potentially_scrolling_layer_impl) { |
2581 // Ensure that final layer scrolls on impl thread (crbug.com/625100) | 2580 // Ensure that final layer scrolls on impl thread (crbug.com/625100) |
2582 ScrollNode* scroll_node = | 2581 ScrollNode* scroll_node = |
2583 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index()); | 2582 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index()); |
2584 ScrollStatus status = | 2583 ScrollStatus status = |
2585 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); | 2584 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); |
2586 if (IsMainThreadScrolling(status, scroll_node)) { | 2585 if (IsMainThreadScrolling(status, scroll_node)) { |
2587 *scroll_on_main_thread = true; | 2586 *scroll_on_main_thread = true; |
2588 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2587 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
2589 return NULL; | 2588 return NULL; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2841 // that can scroll and set up an animation of its scroll offset. Note that | 2840 // that can scroll and set up an animation of its scroll offset. Note that |
2842 // this does not currently go through the scroll customization machinery | 2841 // this does not currently go through the scroll customization machinery |
2843 // that ScrollBy uses for non-animated wheel scrolls. | 2842 // that ScrollBy uses for non-animated wheel scrolls. |
2844 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2843 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
2845 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2844 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
2846 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2845 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
2847 gfx::Vector2dF pending_delta = scroll_delta; | 2846 gfx::Vector2dF pending_delta = scroll_delta; |
2848 if (scroll_node) { | 2847 if (scroll_node) { |
2849 for (; scroll_tree.parent(scroll_node); | 2848 for (; scroll_tree.parent(scroll_node); |
2850 scroll_node = scroll_tree.parent(scroll_node)) { | 2849 scroll_node = scroll_tree.parent(scroll_node)) { |
2851 if (!scroll_node->scrollable || | 2850 if (!scroll_node->scrollable) |
2852 scroll_node->is_outer_viewport_scroll_layer) | |
2853 continue; | 2851 continue; |
2854 | 2852 |
2855 if (scroll_node->is_inner_viewport_scroll_layer) { | 2853 if (scroll_node->is_outer_viewport_scroll_layer || |
2854 scroll_node->is_inner_viewport_scroll_layer) { | |
2856 gfx::Vector2dF scrolled = | 2855 gfx::Vector2dF scrolled = |
2857 viewport()->ScrollAnimated(pending_delta, delayed_by); | 2856 viewport()->ScrollAnimated(pending_delta, delayed_by); |
2858 // Viewport::ScrollAnimated returns pending_delta as long as it | 2857 // Viewport::ScrollAnimated returns pending_delta as long as it |
2859 // starts an animation. | 2858 // starts an animation. |
2860 if (scrolled == pending_delta) | 2859 if (scrolled == pending_delta) |
2861 return scroll_status; | 2860 return scroll_status; |
2862 pending_delta -= scrolled; | 2861 break; |
2863 continue; | |
2864 } | 2862 } |
2865 | 2863 |
2866 gfx::Vector2dF scroll_delta = | 2864 gfx::Vector2dF scroll_delta = |
2867 ComputeScrollDelta(scroll_node, pending_delta); | 2865 ComputeScrollDelta(scroll_node, pending_delta); |
2868 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) | 2866 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) |
2869 return scroll_status; | 2867 return scroll_status; |
2870 | 2868 |
2871 pending_delta -= scroll_delta; | 2869 pending_delta -= scroll_delta; |
2872 } | 2870 } |
2873 } | 2871 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2996 ScrollState* scroll_state) { | 2994 ScrollState* scroll_state) { |
2997 DCHECK(scroll_state); | 2995 DCHECK(scroll_state); |
2998 gfx::Point viewport_point(scroll_state->position_x(), | 2996 gfx::Point viewport_point(scroll_state->position_x(), |
2999 scroll_state->position_y()); | 2997 scroll_state->position_y()); |
3000 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); | 2998 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); |
3001 gfx::Vector2dF applied_delta; | 2999 gfx::Vector2dF applied_delta; |
3002 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for | 3000 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for |
3003 // details. | 3001 // details. |
3004 const float kEpsilon = 0.1f; | 3002 const float kEpsilon = 0.1f; |
3005 | 3003 |
3006 if (scroll_node->is_inner_viewport_scroll_layer) { | 3004 if (scroll_node->is_outer_viewport_scroll_layer) { |
3007 bool affect_top_controls = !wheel_scrolling_; | 3005 bool affect_top_controls = !wheel_scrolling_; |
3008 Viewport::ScrollResult result = viewport()->ScrollBy( | 3006 Viewport::ScrollResult result = viewport()->ScrollBy( |
3009 delta, viewport_point, scroll_state->is_direct_manipulation(), | 3007 delta, viewport_point, scroll_state->is_direct_manipulation(), |
3010 affect_top_controls); | 3008 affect_top_controls); |
3011 applied_delta = result.consumed_delta; | 3009 applied_delta = result.consumed_delta; |
3012 scroll_state->set_caused_scroll( | 3010 scroll_state->set_caused_scroll( |
3013 std::abs(result.content_scrolled_delta.x()) > kEpsilon, | 3011 std::abs(result.content_scrolled_delta.x()) > kEpsilon, |
3014 std::abs(result.content_scrolled_delta.y()) > kEpsilon); | 3012 std::abs(result.content_scrolled_delta.y()) > kEpsilon); |
3015 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); | 3013 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); |
3016 } else { | 3014 } else { |
3017 applied_delta = ScrollSingleNode( | 3015 applied_delta = ScrollSingleNode( |
3018 scroll_node, delta, viewport_point, | 3016 scroll_node, delta, viewport_point, |
3019 scroll_state->is_direct_manipulation(), | 3017 scroll_state->is_direct_manipulation(), |
3020 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); | 3018 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); |
3021 } | 3019 } |
3022 | 3020 |
3023 // If the layer wasn't able to move, try the next one in the hierarchy. | 3021 // If the layer wasn't able to move, try the next one in the hierarchy. |
3024 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; | 3022 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; |
3025 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; | 3023 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; |
3026 | 3024 |
3027 if (scrolled && !scroll_node->is_inner_viewport_scroll_layer) { | 3025 if (scrolled && !scroll_node->is_outer_viewport_scroll_layer) { |
3028 // If the applied delta is within 45 degrees of the input | 3026 // If the applied delta is within 45 degrees of the input |
3029 // delta, bail out to make it easier to scroll just one layer | 3027 // delta, bail out to make it easier to scroll just one layer |
3030 // in one direction without affecting any of its parents. | 3028 // in one direction without affecting any of its parents. |
3031 float angle_threshold = 45; | 3029 float angle_threshold = 45; |
3032 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < | 3030 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < |
3033 angle_threshold) { | 3031 angle_threshold) { |
3034 applied_delta = delta; | 3032 applied_delta = delta; |
3035 } else { | 3033 } else { |
3036 // Allow further movement only on an axis perpendicular to the direction | 3034 // Allow further movement only on an axis perpendicular to the direction |
3037 // in which the layer moved. | 3035 // in which the layer moved. |
(...skipping 16 matching lines...) Expand all Loading... | |
3054 // sides but it may become a non issue if we get rid of scroll chaining (see | 3052 // sides but it may become a non issue if we get rid of scroll chaining (see |
3055 // crbug.com/526462) | 3053 // crbug.com/526462) |
3056 std::list<const ScrollNode*> current_scroll_chain; | 3054 std::list<const ScrollNode*> current_scroll_chain; |
3057 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3055 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3058 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3056 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3059 if (scroll_node) { | 3057 if (scroll_node) { |
3060 for (; scroll_tree.parent(scroll_node); | 3058 for (; scroll_tree.parent(scroll_node); |
3061 scroll_node = scroll_tree.parent(scroll_node)) { | 3059 scroll_node = scroll_tree.parent(scroll_node)) { |
3062 if (scroll_node->is_outer_viewport_scroll_layer) { | 3060 if (scroll_node->is_outer_viewport_scroll_layer) { |
3063 // Don't chain scrolls past the outer viewport scroll layer. Once we | 3061 // Don't chain scrolls past the outer viewport scroll layer. Once we |
3064 // reach that, we should scroll the viewport, which is represented by | 3062 // reach that, we're viewport scrolling which is special and handled by |
3065 // the inner viewport scroll layer. | 3063 // cc's Viewport class. |
3066 ScrollNode* inner_viewport_scroll_node = | 3064 current_scroll_chain.push_front(scroll_node); |
3067 scroll_tree.Node(InnerViewportScrollLayer()->scroll_tree_index()); | |
3068 current_scroll_chain.push_front(inner_viewport_scroll_node); | |
3069 break; | 3065 break; |
3070 } | 3066 } |
3071 | 3067 |
3072 if (!scroll_node->scrollable) | 3068 if (!scroll_node->scrollable) |
3073 continue; | 3069 continue; |
3074 | 3070 |
3075 current_scroll_chain.push_front(scroll_node); | 3071 current_scroll_chain.push_front(scroll_node); |
3076 } | 3072 } |
3077 } | 3073 } |
3078 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, | 3074 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3232 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3228 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
3233 HandleMouseOverScrollbar(layer_impl); | 3229 HandleMouseOverScrollbar(layer_impl); |
3234 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) | 3230 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) |
3235 return; | 3231 return; |
3236 | 3232 |
3237 bool scroll_on_main_thread = false; | 3233 bool scroll_on_main_thread = false; |
3238 uint32_t main_thread_scrolling_reasons; | 3234 uint32_t main_thread_scrolling_reasons; |
3239 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3235 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
3240 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3236 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
3241 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3237 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
3242 if (scroll_layer_impl == InnerViewportScrollLayer()) | |
3243 scroll_layer_impl = OuterViewportScrollLayer(); | |
tdresser
2016/09/23 15:59:58
I'm a bit confused by why this was here before, an
bokan
2016/09/23 19:57:01
I believe it's needed because the ScrollbarAnimati
| |
3244 if (scroll_on_main_thread || !scroll_layer_impl) | 3238 if (scroll_on_main_thread || !scroll_layer_impl) |
3245 return; | 3239 return; |
3246 | 3240 |
3247 ScrollbarAnimationController* animation_controller = | 3241 ScrollbarAnimationController* animation_controller = |
3248 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); | 3242 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); |
3249 if (!animation_controller) | 3243 if (!animation_controller) |
3250 return; | 3244 return; |
3251 | 3245 |
3252 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 3246 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
3253 for (ScrollbarLayerImplBase* scrollbar : | 3247 for (ScrollbarLayerImplBase* scrollbar : |
(...skipping 27 matching lines...) Expand all Loading... | |
3281 scroll_layer_id_when_mouse_over_scrollbar_); | 3275 scroll_layer_id_when_mouse_over_scrollbar_); |
3282 if (new_animation_controller) | 3276 if (new_animation_controller) |
3283 new_animation_controller->DidMouseMoveNear(0); | 3277 new_animation_controller->DidMouseMoveNear(0); |
3284 } | 3278 } |
3285 | 3279 |
3286 void LayerTreeHostImpl::PinchGestureBegin() { | 3280 void LayerTreeHostImpl::PinchGestureBegin() { |
3287 pinch_gesture_active_ = true; | 3281 pinch_gesture_active_ = true; |
3288 client_->RenewTreePriority(); | 3282 client_->RenewTreePriority(); |
3289 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); | 3283 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); |
3290 active_tree_->SetCurrentlyScrollingLayer( | 3284 active_tree_->SetCurrentlyScrollingLayer( |
3291 active_tree_->InnerViewportScrollLayer()); | 3285 active_tree_->OuterViewportScrollLayer()); |
3292 top_controls_manager_->PinchBegin(); | 3286 top_controls_manager_->PinchBegin(); |
3293 } | 3287 } |
3294 | 3288 |
3295 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 3289 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
3296 const gfx::Point& anchor) { | 3290 const gfx::Point& anchor) { |
3297 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 3291 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
3298 if (!InnerViewportScrollLayer()) | 3292 if (!InnerViewportScrollLayer()) |
3299 return; | 3293 return; |
3300 viewport()->PinchUpdate(magnify_delta, anchor); | 3294 viewport()->PinchUpdate(magnify_delta, anchor); |
3301 client_->SetNeedsCommitOnImplThread(); | 3295 client_->SetNeedsCommitOnImplThread(); |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4153 if (is_visible) { | 4147 if (is_visible) { |
4154 worker_context_visibility_ = | 4148 worker_context_visibility_ = |
4155 worker_context->CacheController()->ClientBecameVisible(); | 4149 worker_context->CacheController()->ClientBecameVisible(); |
4156 } else { | 4150 } else { |
4157 worker_context->CacheController()->ClientBecameNotVisible( | 4151 worker_context->CacheController()->ClientBecameNotVisible( |
4158 std::move(worker_context_visibility_)); | 4152 std::move(worker_context_visibility_)); |
4159 } | 4153 } |
4160 } | 4154 } |
4161 | 4155 |
4162 } // namespace cc | 4156 } // namespace cc |
OLD | NEW |