| 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 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 } | 2626 } |
| 2627 | 2627 |
| 2628 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 2628 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
| 2629 ScrollState* scroll_state, | 2629 ScrollState* scroll_state, |
| 2630 InputHandler::ScrollInputType type) { | 2630 InputHandler::ScrollInputType type) { |
| 2631 ScrollStatus scroll_status; | 2631 ScrollStatus scroll_status; |
| 2632 scroll_status.main_thread_scrolling_reasons = | 2632 scroll_status.main_thread_scrolling_reasons = |
| 2633 MainThreadScrollingReason::kNotScrollingOnMain; | 2633 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2634 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 2634 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
| 2635 | 2635 |
| 2636 ClearCurrentlyScrollingLayer(); | 2636 LayerImpl* scrolling_layer_impl = nullptr; |
| 2637 bool scroll_on_main_thread = false; |
| 2637 | 2638 |
| 2638 gfx::Point viewport_point(scroll_state->position_x(), | 2639 if (scroll_state->is_in_inertial_phase()) |
| 2639 scroll_state->position_y()); | 2640 scrolling_layer_impl = CurrentlyScrollingLayer(); |
| 2640 | 2641 |
| 2641 gfx::PointF device_viewport_point = gfx::ScalePoint( | 2642 if (!scrolling_layer_impl) { |
| 2642 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 2643 ClearCurrentlyScrollingLayer(); |
| 2643 LayerImpl* layer_impl = | |
| 2644 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | |
| 2645 | 2644 |
| 2646 if (layer_impl) { | 2645 gfx::Point viewport_point(scroll_state->position_x(), |
| 2647 LayerImpl* scroll_layer_impl = | 2646 scroll_state->position_y()); |
| 2648 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( | 2647 |
| 2649 device_viewport_point); | 2648 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 2650 if (scroll_layer_impl && | 2649 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 2651 !HasScrollAncestor(layer_impl, scroll_layer_impl)) { | 2650 LayerImpl* layer_impl = |
| 2652 scroll_status.thread = SCROLL_UNKNOWN; | 2651 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 2653 scroll_status.main_thread_scrolling_reasons = | 2652 |
| 2654 MainThreadScrollingReason::kFailedHitTest; | 2653 if (layer_impl) { |
| 2655 return scroll_status; | 2654 LayerImpl* scroll_layer_impl = |
| 2655 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( |
| 2656 device_viewport_point); |
| 2657 if (scroll_layer_impl && |
| 2658 !HasScrollAncestor(layer_impl, scroll_layer_impl)) { |
| 2659 scroll_status.thread = SCROLL_UNKNOWN; |
| 2660 scroll_status.main_thread_scrolling_reasons = |
| 2661 MainThreadScrollingReason::kFailedHitTest; |
| 2662 return scroll_status; |
| 2663 } |
| 2656 } | 2664 } |
| 2665 |
| 2666 scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 2667 device_viewport_point, type, layer_impl, &scroll_on_main_thread, |
| 2668 &scroll_status.main_thread_scrolling_reasons); |
| 2657 } | 2669 } |
| 2658 | |
| 2659 bool scroll_on_main_thread = false; | |
| 2660 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | |
| 2661 device_viewport_point, type, layer_impl, &scroll_on_main_thread, | |
| 2662 &scroll_status.main_thread_scrolling_reasons); | |
| 2663 | |
| 2664 if (scrolling_layer_impl) | 2670 if (scrolling_layer_impl) |
| 2665 scroll_affects_scroll_handler_ = | 2671 scroll_affects_scroll_handler_ = |
| 2666 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); | 2672 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); |
| 2667 | 2673 |
| 2668 if (scroll_on_main_thread) { | 2674 if (scroll_on_main_thread) { |
| 2669 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); | 2675 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); |
| 2670 | 2676 |
| 2671 scroll_status.thread = SCROLL_ON_MAIN_THREAD; | 2677 scroll_status.thread = SCROLL_ON_MAIN_THREAD; |
| 2672 return scroll_status; | 2678 return scroll_status; |
| 2673 } | 2679 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2702 // ScrollAnimated is used for animated wheel scrolls. We find the first layer | 2708 // ScrollAnimated is used for animated wheel scrolls. We find the first layer |
| 2703 // that can scroll and set up an animation of its scroll offset. Note that | 2709 // that can scroll and set up an animation of its scroll offset. Note that |
| 2704 // this does not currently go through the scroll customization machinery | 2710 // this does not currently go through the scroll customization machinery |
| 2705 // that ScrollBy uses for non-animated wheel scrolls. | 2711 // that ScrollBy uses for non-animated wheel scrolls. |
| 2706 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2712 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
| 2707 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2713 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2708 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2714 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2709 ScrollStateData scroll_state_end_data; | 2715 ScrollStateData scroll_state_end_data; |
| 2710 scroll_state_end_data.is_ending = true; | 2716 scroll_state_end_data.is_ending = true; |
| 2711 ScrollState scroll_state_end(scroll_state_end_data); | 2717 ScrollState scroll_state_end(scroll_state_end_data); |
| 2712 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | |
| 2713 // implemented, the current scrolling layer should not get cleared after | |
| 2714 // each animation (crbug.com/526463). | |
| 2715 ScrollEnd(&scroll_state_end); | 2718 ScrollEnd(&scroll_state_end); |
| 2716 ClearCurrentlyScrollingLayer(); | |
| 2717 } | 2719 } |
| 2718 return scroll_status; | 2720 return scroll_status; |
| 2719 } | 2721 } |
| 2720 | 2722 |
| 2721 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( | 2723 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( |
| 2722 ScrollNode* scroll_node, | 2724 ScrollNode* scroll_node, |
| 2723 const gfx::Vector2dF& delta) { | 2725 const gfx::Vector2dF& delta) { |
| 2724 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; | 2726 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; |
| 2725 float scale_factor = active_tree()->current_page_scale_factor(); | 2727 float scale_factor = active_tree()->current_page_scale_factor(); |
| 2726 | 2728 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2793 scroll_status.thread = SCROLL_IGNORED; | 2795 scroll_status.thread = SCROLL_IGNORED; |
| 2794 scroll_status.main_thread_scrolling_reasons = | 2796 scroll_status.main_thread_scrolling_reasons = |
| 2795 MainThreadScrollingReason::kNotScrollable; | 2797 MainThreadScrollingReason::kNotScrollable; |
| 2796 } | 2798 } |
| 2797 return scroll_status; | 2799 return scroll_status; |
| 2798 } | 2800 } |
| 2799 | 2801 |
| 2800 ScrollStateData scroll_state_data; | 2802 ScrollStateData scroll_state_data; |
| 2801 scroll_state_data.position_x = viewport_point.x(); | 2803 scroll_state_data.position_x = viewport_point.x(); |
| 2802 scroll_state_data.position_y = viewport_point.y(); | 2804 scroll_state_data.position_y = viewport_point.y(); |
| 2803 scroll_state_data.is_in_inertial_phase = true; | |
| 2804 ScrollState scroll_state(scroll_state_data); | 2805 ScrollState scroll_state(scroll_state_data); |
| 2805 | 2806 |
| 2806 // ScrollAnimated is used for animated wheel scrolls. We find the first layer | 2807 // ScrollAnimated is used for animated wheel scrolls. We find the first layer |
| 2807 // that can scroll and set up an animation of its scroll offset. Note that | 2808 // that can scroll and set up an animation of its scroll offset. Note that |
| 2808 // this does not currently go through the scroll customization machinery | 2809 // this does not currently go through the scroll customization machinery |
| 2809 // that ScrollBy uses for non-animated wheel scrolls. | 2810 // that ScrollBy uses for non-animated wheel scrolls. |
| 2810 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2811 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
| 2811 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2812 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2812 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2813 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2813 gfx::Vector2dF pending_delta = scroll_delta; | 2814 gfx::Vector2dF pending_delta = scroll_delta; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3165 scroll_affects_scroll_handler_ = false; | 3166 scroll_affects_scroll_handler_ = false; |
| 3166 accumulated_root_overscroll_ = gfx::Vector2dF(); | 3167 accumulated_root_overscroll_ = gfx::Vector2dF(); |
| 3167 } | 3168 } |
| 3168 | 3169 |
| 3169 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { | 3170 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { |
| 3170 DCHECK(scroll_state); | 3171 DCHECK(scroll_state); |
| 3171 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); | 3172 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); |
| 3172 | 3173 |
| 3173 DistributeScrollDelta(scroll_state); | 3174 DistributeScrollDelta(scroll_state); |
| 3174 browser_controls_offset_manager_->ScrollEnd(); | 3175 browser_controls_offset_manager_->ScrollEnd(); |
| 3175 ClearCurrentlyScrollingLayer(); | 3176 |
| 3177 if (!scroll_state->data()->may_precede_fling) { |
| 3178 // Only clear the currently scrolling layer if we know the scroll is done. |
| 3179 ClearCurrentlyScrollingLayer(); |
| 3180 } |
| 3176 } | 3181 } |
| 3177 | 3182 |
| 3178 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 3183 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
| 3179 InputHandler::ScrollStatus scroll_status; | 3184 InputHandler::ScrollStatus scroll_status; |
| 3180 scroll_status.main_thread_scrolling_reasons = | 3185 scroll_status.main_thread_scrolling_reasons = |
| 3181 MainThreadScrollingReason::kNotScrollingOnMain; | 3186 MainThreadScrollingReason::kNotScrollingOnMain; |
| 3182 if (!CurrentlyScrollingLayer()) { | 3187 if (!CurrentlyScrollingLayer()) { |
| 3183 scroll_status.thread = SCROLL_IGNORED; | 3188 scroll_status.thread = SCROLL_IGNORED; |
| 3184 scroll_status.main_thread_scrolling_reasons = | 3189 scroll_status.main_thread_scrolling_reasons = |
| 3185 MainThreadScrollingReason::kNoScrollingLayer; | 3190 MainThreadScrollingReason::kNoScrollingLayer; |
| (...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4074 worker_context_visibility_ = | 4079 worker_context_visibility_ = |
| 4075 worker_context->CacheController()->ClientBecameVisible(); | 4080 worker_context->CacheController()->ClientBecameVisible(); |
| 4076 } else { | 4081 } else { |
| 4077 worker_context->CacheController()->ClientBecameNotVisible( | 4082 worker_context->CacheController()->ClientBecameNotVisible( |
| 4078 std::move(worker_context_visibility_)); | 4083 std::move(worker_context_visibility_)); |
| 4079 } | 4084 } |
| 4080 } | 4085 } |
| 4081 } | 4086 } |
| 4082 | 4087 |
| 4083 } // namespace cc | 4088 } // namespace cc |
| OLD | NEW |