| 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 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 } | 2694 } |
| 2695 | 2695 |
| 2696 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 2696 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
| 2697 ScrollState* scroll_state, | 2697 ScrollState* scroll_state, |
| 2698 InputHandler::ScrollInputType type) { | 2698 InputHandler::ScrollInputType type) { |
| 2699 ScrollStatus scroll_status; | 2699 ScrollStatus scroll_status; |
| 2700 scroll_status.main_thread_scrolling_reasons = | 2700 scroll_status.main_thread_scrolling_reasons = |
| 2701 MainThreadScrollingReason::kNotScrollingOnMain; | 2701 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2702 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 2702 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
| 2703 | 2703 |
| 2704 // On Mac a scroll begin with |inertial_phase| = true happens to handle a | |
| 2705 // fling. | |
| 2706 if (scroll_state->is_in_inertial_phase()) | |
| 2707 return FlingScrollBegin(); | |
| 2708 | |
| 2709 ClearCurrentlyScrollingLayer(); | 2704 ClearCurrentlyScrollingLayer(); |
| 2710 | 2705 |
| 2711 gfx::Point viewport_point(scroll_state->position_x(), | 2706 gfx::Point viewport_point(scroll_state->position_x(), |
| 2712 scroll_state->position_y()); | 2707 scroll_state->position_y()); |
| 2713 | 2708 |
| 2714 gfx::PointF device_viewport_point = gfx::ScalePoint( | 2709 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 2715 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 2710 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 2716 LayerImpl* layer_impl = | 2711 LayerImpl* layer_impl = |
| 2717 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 2712 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 2718 | 2713 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2861 scroll_status.thread = SCROLL_IGNORED; | 2856 scroll_status.thread = SCROLL_IGNORED; |
| 2862 scroll_status.main_thread_scrolling_reasons = | 2857 scroll_status.main_thread_scrolling_reasons = |
| 2863 MainThreadScrollingReason::kNotScrollable; | 2858 MainThreadScrollingReason::kNotScrollable; |
| 2864 } | 2859 } |
| 2865 return scroll_status; | 2860 return scroll_status; |
| 2866 } | 2861 } |
| 2867 | 2862 |
| 2868 ScrollStateData scroll_state_data; | 2863 ScrollStateData scroll_state_data; |
| 2869 scroll_state_data.position_x = viewport_point.x(); | 2864 scroll_state_data.position_x = viewport_point.x(); |
| 2870 scroll_state_data.position_y = viewport_point.y(); | 2865 scroll_state_data.position_y = viewport_point.y(); |
| 2871 scroll_state_data.is_in_inertial_phase = false; | 2866 scroll_state_data.is_in_inertial_phase = true; |
| 2872 ScrollState scroll_state(scroll_state_data); | 2867 ScrollState scroll_state(scroll_state_data); |
| 2873 | 2868 |
| 2874 // ScrollAnimated is used for animated wheel scrolls. We find the first layer | 2869 // ScrollAnimated is used for animated wheel scrolls. We find the first layer |
| 2875 // that can scroll and set up an animation of its scroll offset. Note that | 2870 // that can scroll and set up an animation of its scroll offset. Note that |
| 2876 // this does not currently go through the scroll customization machinery | 2871 // this does not currently go through the scroll customization machinery |
| 2877 // that ScrollBy uses for non-animated wheel scrolls. | 2872 // that ScrollBy uses for non-animated wheel scrolls. |
| 2878 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2873 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
| 2879 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2874 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2880 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2875 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2881 gfx::Vector2dF pending_delta = scroll_delta; | 2876 gfx::Vector2dF pending_delta = scroll_delta; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2899 gfx::Vector2dF scroll_delta = | 2894 gfx::Vector2dF scroll_delta = |
| 2900 ComputeScrollDelta(scroll_node, pending_delta); | 2895 ComputeScrollDelta(scroll_node, pending_delta); |
| 2901 if (ScrollAnimationCreate(scroll_node, scroll_delta)) | 2896 if (ScrollAnimationCreate(scroll_node, scroll_delta)) |
| 2902 return scroll_status; | 2897 return scroll_status; |
| 2903 | 2898 |
| 2904 pending_delta -= scroll_delta; | 2899 pending_delta -= scroll_delta; |
| 2905 } | 2900 } |
| 2906 } | 2901 } |
| 2907 } | 2902 } |
| 2908 scroll_state.set_is_ending(true); | 2903 scroll_state.set_is_ending(true); |
| 2909 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | |
| 2910 // impelemented, the current scrolling layer should not get cleared after | |
| 2911 // each animation (crbug.com/526463). | |
| 2912 ScrollEnd(&scroll_state); | 2904 ScrollEnd(&scroll_state); |
| 2913 ClearCurrentlyScrollingLayer(); | |
| 2914 | |
| 2915 return scroll_status; | 2905 return scroll_status; |
| 2916 } | 2906 } |
| 2917 | 2907 |
| 2918 gfx::Vector2dF LayerTreeHostImpl::ScrollNodeWithViewportSpaceDelta( | 2908 gfx::Vector2dF LayerTreeHostImpl::ScrollNodeWithViewportSpaceDelta( |
| 2919 ScrollNode* scroll_node, | 2909 ScrollNode* scroll_node, |
| 2920 const gfx::PointF& viewport_point, | 2910 const gfx::PointF& viewport_point, |
| 2921 const gfx::Vector2dF& viewport_delta, | 2911 const gfx::Vector2dF& viewport_delta, |
| 2922 ScrollTree* scroll_tree) { | 2912 ScrollTree* scroll_tree) { |
| 2923 // Layers with non-invertible screen space transforms should not have passed | 2913 // Layers with non-invertible screen space transforms should not have passed |
| 2924 // the scroll hit test in the first place. | 2914 // the scroll hit test in the first place. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3258 scroll_affects_scroll_handler_ = false; | 3248 scroll_affects_scroll_handler_ = false; |
| 3259 accumulated_root_overscroll_ = gfx::Vector2dF(); | 3249 accumulated_root_overscroll_ = gfx::Vector2dF(); |
| 3260 } | 3250 } |
| 3261 | 3251 |
| 3262 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { | 3252 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { |
| 3263 DCHECK(scroll_state); | 3253 DCHECK(scroll_state); |
| 3264 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); | 3254 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); |
| 3265 | 3255 |
| 3266 DistributeScrollDelta(scroll_state); | 3256 DistributeScrollDelta(scroll_state); |
| 3267 top_controls_manager_->ScrollEnd(); | 3257 top_controls_manager_->ScrollEnd(); |
| 3268 | 3258 ClearCurrentlyScrollingLayer(); |
| 3269 if (scroll_state->is_in_inertial_phase()) { | |
| 3270 // Only clear the currently scrolling layer if we know the scroll is done. | |
| 3271 // A non-inertial scroll end could be followed by an inertial scroll. | |
| 3272 ClearCurrentlyScrollingLayer(); | |
| 3273 } | |
| 3274 } | 3259 } |
| 3275 | 3260 |
| 3276 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 3261 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
| 3277 InputHandler::ScrollStatus scroll_status; | 3262 InputHandler::ScrollStatus scroll_status; |
| 3278 scroll_status.main_thread_scrolling_reasons = | 3263 scroll_status.main_thread_scrolling_reasons = |
| 3279 MainThreadScrollingReason::kNotScrollingOnMain; | 3264 MainThreadScrollingReason::kNotScrollingOnMain; |
| 3280 if (!CurrentlyScrollingLayer()) { | 3265 if (!CurrentlyScrollingLayer()) { |
| 3281 scroll_status.thread = SCROLL_IGNORED; | 3266 scroll_status.thread = SCROLL_IGNORED; |
| 3282 scroll_status.main_thread_scrolling_reasons = | 3267 scroll_status.main_thread_scrolling_reasons = |
| 3283 MainThreadScrollingReason::kNoScrollingLayer; | 3268 MainThreadScrollingReason::kNoScrollingLayer; |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4135 layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); | 4120 layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); |
| 4136 break; | 4121 break; |
| 4137 } | 4122 } |
| 4138 } | 4123 } |
| 4139 } | 4124 } |
| 4140 | 4125 |
| 4141 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { | 4126 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { |
| 4142 // TODO(majidvp): We should pass in the original starting scroll position here | 4127 // TODO(majidvp): We should pass in the original starting scroll position here |
| 4143 ScrollStateData scroll_state_data; | 4128 ScrollStateData scroll_state_data; |
| 4144 ScrollState scroll_state(scroll_state_data); | 4129 ScrollState scroll_state(scroll_state_data); |
| 4145 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | |
| 4146 // impelemented, the current scrolling layer should not get cleared after | |
| 4147 // each animation (crbug.com/526463). | |
| 4148 ScrollEnd(&scroll_state); | 4130 ScrollEnd(&scroll_state); |
| 4149 ClearCurrentlyScrollingLayer(); | |
| 4150 } | 4131 } |
| 4151 | 4132 |
| 4152 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( | 4133 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( |
| 4153 ElementId element_id) const { | 4134 ElementId element_id) const { |
| 4154 if (active_tree()) { | 4135 if (active_tree()) { |
| 4155 LayerImpl* layer = active_tree()->LayerByElementId(element_id); | 4136 LayerImpl* layer = active_tree()->LayerByElementId(element_id); |
| 4156 if (layer) | 4137 if (layer) |
| 4157 return layer->ScrollOffsetForAnimation(); | 4138 return layer->ScrollOffsetForAnimation(); |
| 4158 } | 4139 } |
| 4159 | 4140 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4208 if (is_visible) { | 4189 if (is_visible) { |
| 4209 worker_context_visibility_ = | 4190 worker_context_visibility_ = |
| 4210 worker_context->CacheController()->ClientBecameVisible(); | 4191 worker_context->CacheController()->ClientBecameVisible(); |
| 4211 } else { | 4192 } else { |
| 4212 worker_context->CacheController()->ClientBecameNotVisible( | 4193 worker_context->CacheController()->ClientBecameNotVisible( |
| 4213 std::move(worker_context_visibility_)); | 4194 std::move(worker_context_visibility_)); |
| 4214 } | 4195 } |
| 4215 } | 4196 } |
| 4216 | 4197 |
| 4217 } // namespace cc | 4198 } // namespace cc |
| OLD | NEW |