Chromium Code Reviews| 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 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2781 } else { | 2781 } else { |
| 2782 scroll_status.thread = SCROLL_IGNORED; | 2782 scroll_status.thread = SCROLL_IGNORED; |
| 2783 scroll_status.main_thread_scrolling_reasons = | 2783 scroll_status.main_thread_scrolling_reasons = |
| 2784 MainThreadScrollingReason::kNotScrollable; | 2784 MainThreadScrollingReason::kNotScrollable; |
| 2785 } | 2785 } |
| 2786 return scroll_status; | 2786 return scroll_status; |
| 2787 } | 2787 } |
| 2788 ScrollStateData scroll_state_data; | 2788 ScrollStateData scroll_state_data; |
| 2789 scroll_state_data.position_x = viewport_point.x(); | 2789 scroll_state_data.position_x = viewport_point.x(); |
| 2790 scroll_state_data.position_y = viewport_point.y(); | 2790 scroll_state_data.position_y = viewport_point.y(); |
| 2791 scroll_state_data.is_in_inertial_phase = true; | 2791 scroll_state_data.is_in_inertial_phase = false; |
|
ericrk
2016/08/31 18:29:42
nit: This is already the default value of is_in_in
sahel
2016/08/31 19:16:46
Done.
| |
| 2792 ScrollState scroll_state(scroll_state_data); | 2792 ScrollState scroll_state(scroll_state_data); |
| 2793 | 2793 |
| 2794 // ScrollAnimated is used for animated wheel scrolls. We find the first layer | 2794 // ScrollAnimated is used for animated wheel scrolls. We find the first layer |
| 2795 // that can scroll and set up an animation of its scroll offset. Note that | 2795 // that can scroll and set up an animation of its scroll offset. Note that |
| 2796 // this does not currently go through the scroll customization machinery | 2796 // this does not currently go through the scroll customization machinery |
| 2797 // that ScrollBy uses for non-animated wheel scrolls. | 2797 // that ScrollBy uses for non-animated wheel scrolls. |
| 2798 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2798 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
| 2799 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2799 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2800 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2800 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2801 ScrollStateData scroll_state_end_data; | 2801 ScrollStateData scroll_state_end_data; |
| 2802 scroll_state_end_data.is_ending = true; | 2802 scroll_state_end_data.is_ending = true; |
| 2803 ScrollState scroll_state_end(scroll_state_end_data); | 2803 ScrollState scroll_state_end(scroll_state_end_data); |
| 2804 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | |
| 2805 // implemented, the current scrolling layer should not get cleared after | |
| 2806 // each animation (crbug.com/526463). | |
| 2804 ScrollEnd(&scroll_state_end); | 2807 ScrollEnd(&scroll_state_end); |
| 2808 ClearCurrentlyScrollingLayer(); | |
| 2805 } | 2809 } |
| 2806 return scroll_status; | 2810 return scroll_status; |
| 2807 } | 2811 } |
| 2808 | 2812 |
| 2809 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( | 2813 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( |
| 2810 ScrollNode* scroll_node, | 2814 ScrollNode* scroll_node, |
| 2811 const gfx::Vector2dF& delta) { | 2815 const gfx::Vector2dF& delta) { |
| 2812 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; | 2816 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; |
| 2813 float scale_factor = active_tree()->current_page_scale_factor(); | 2817 float scale_factor = active_tree()->current_page_scale_factor(); |
| 2814 | 2818 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2918 ComputeScrollDelta(scroll_node, pending_delta); | 2922 ComputeScrollDelta(scroll_node, pending_delta); |
| 2919 if (ScrollAnimationCreate(scroll_node, scroll_delta)) | 2923 if (ScrollAnimationCreate(scroll_node, scroll_delta)) |
| 2920 return scroll_status; | 2924 return scroll_status; |
| 2921 | 2925 |
| 2922 pending_delta -= scroll_delta; | 2926 pending_delta -= scroll_delta; |
| 2923 } | 2927 } |
| 2924 } | 2928 } |
| 2925 } | 2929 } |
| 2926 scroll_state.set_is_ending(true); | 2930 scroll_state.set_is_ending(true); |
| 2927 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | 2931 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is |
| 2928 // impelemented, the current scrolling layer should not get cleared after | 2932 // implemented, the current scrolling layer should not get cleared after |
| 2929 // each animation (crbug.com/526463). | 2933 // each animation (crbug.com/526463). |
| 2930 ScrollEnd(&scroll_state); | 2934 ScrollEnd(&scroll_state); |
| 2931 ClearCurrentlyScrollingLayer(); | 2935 ClearCurrentlyScrollingLayer(); |
| 2932 | 2936 |
| 2933 return scroll_status; | 2937 return scroll_status; |
| 2934 } | 2938 } |
| 2935 | 2939 |
| 2936 gfx::Vector2dF LayerTreeHostImpl::ScrollNodeWithViewportSpaceDelta( | 2940 gfx::Vector2dF LayerTreeHostImpl::ScrollNodeWithViewportSpaceDelta( |
| 2937 ScrollNode* scroll_node, | 2941 ScrollNode* scroll_node, |
| 2938 const gfx::PointF& viewport_point, | 2942 const gfx::PointF& viewport_point, |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4159 break; | 4163 break; |
| 4160 } | 4164 } |
| 4161 } | 4165 } |
| 4162 } | 4166 } |
| 4163 | 4167 |
| 4164 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { | 4168 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { |
| 4165 // TODO(majidvp): We should pass in the original starting scroll position here | 4169 // TODO(majidvp): We should pass in the original starting scroll position here |
| 4166 ScrollStateData scroll_state_data; | 4170 ScrollStateData scroll_state_data; |
| 4167 ScrollState scroll_state(scroll_state_data); | 4171 ScrollState scroll_state(scroll_state_data); |
| 4168 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | 4172 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is |
| 4169 // impelemented, the current scrolling layer should not get cleared after | 4173 // implemented, the current scrolling layer should not get cleared after |
| 4170 // each animation (crbug.com/526463). | 4174 // each animation (crbug.com/526463). |
| 4171 ScrollEnd(&scroll_state); | 4175 ScrollEnd(&scroll_state); |
| 4172 ClearCurrentlyScrollingLayer(); | 4176 ClearCurrentlyScrollingLayer(); |
| 4173 } | 4177 } |
| 4174 | 4178 |
| 4175 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( | 4179 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( |
| 4176 ElementId element_id) const { | 4180 ElementId element_id) const { |
| 4177 if (active_tree()) { | 4181 if (active_tree()) { |
| 4178 LayerImpl* layer = active_tree()->LayerByElementId(element_id); | 4182 LayerImpl* layer = active_tree()->LayerByElementId(element_id); |
| 4179 if (layer) | 4183 if (layer) |
| 4180 return layer->ScrollOffsetForAnimation(); | 4184 return layer->ScrollOffsetForAnimation(); |
| 4181 } | 4185 } |
| 4182 | 4186 |
| 4183 return gfx::ScrollOffset(); | 4187 return gfx::ScrollOffset(); |
| 4184 } | 4188 } |
| 4185 | 4189 |
| 4186 bool LayerTreeHostImpl::SupportsImplScrolling() const { | 4190 bool LayerTreeHostImpl::SupportsImplScrolling() const { |
| 4187 // Supported in threaded mode. | 4191 // Supported in threaded mode. |
| 4188 return task_runner_provider_->HasImplThread(); | 4192 return task_runner_provider_->HasImplThread(); |
| 4189 } | 4193 } |
| 4190 | 4194 |
| 4191 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4195 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 4192 // In single threaded mode we skip the pending tree and commit directly to the | 4196 // In single threaded mode we skip the pending tree and commit directly to the |
| 4193 // active tree. | 4197 // active tree. |
| 4194 return !task_runner_provider_->HasImplThread(); | 4198 return !task_runner_provider_->HasImplThread(); |
| 4195 } | 4199 } |
| 4196 | 4200 |
| 4197 } // namespace cc | 4201 } // namespace cc |
| OLD | NEW |