| 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 2729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( | 2740 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( |
| 2741 const gfx::Point& viewport_point) { | 2741 const gfx::Point& viewport_point) { |
| 2742 InputHandler::ScrollStatus scroll_status; | 2742 InputHandler::ScrollStatus scroll_status; |
| 2743 scroll_status.main_thread_scrolling_reasons = | 2743 scroll_status.main_thread_scrolling_reasons = |
| 2744 MainThreadScrollingReason::kNotScrollingOnMain; | 2744 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2745 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2745 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 2746 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2746 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2747 if (scroll_node) { | 2747 if (scroll_node) { |
| 2748 gfx::Vector2dF delta; | 2748 gfx::Vector2dF delta; |
| 2749 | 2749 |
| 2750 if (ScrollAnimationUpdateTarget(scroll_node, delta)) { | 2750 if (ScrollAnimationUpdateTarget(scroll_node, delta, base::TimeDelta())) { |
| 2751 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 2751 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
| 2752 } else { | 2752 } else { |
| 2753 scroll_status.thread = SCROLL_IGNORED; | 2753 scroll_status.thread = SCROLL_IGNORED; |
| 2754 scroll_status.main_thread_scrolling_reasons = | 2754 scroll_status.main_thread_scrolling_reasons = |
| 2755 MainThreadScrollingReason::kNotScrollable; | 2755 MainThreadScrollingReason::kNotScrollable; |
| 2756 } | 2756 } |
| 2757 return scroll_status; | 2757 return scroll_status; |
| 2758 } | 2758 } |
| 2759 ScrollStateData scroll_state_data; | 2759 ScrollStateData scroll_state_data; |
| 2760 scroll_state_data.position_x = viewport_point.x(); | 2760 scroll_state_data.position_x = viewport_point.x(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 gfx::ScrollOffset old_offset = | 2796 gfx::ScrollOffset old_offset = |
| 2797 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2797 scroll_tree.current_scroll_offset(scroll_node->owner_id); |
| 2798 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( | 2798 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( |
| 2799 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); | 2799 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); |
| 2800 | 2800 |
| 2801 gfx::ScrollOffset scrolled = new_offset - old_offset; | 2801 gfx::ScrollOffset scrolled = new_offset - old_offset; |
| 2802 return gfx::Vector2dF(scrolled.x(), scrolled.y()); | 2802 return gfx::Vector2dF(scrolled.x(), scrolled.y()); |
| 2803 } | 2803 } |
| 2804 | 2804 |
| 2805 bool LayerTreeHostImpl::ScrollAnimationCreate(ScrollNode* scroll_node, | 2805 bool LayerTreeHostImpl::ScrollAnimationCreate(ScrollNode* scroll_node, |
| 2806 const gfx::Vector2dF& delta) { | 2806 const gfx::Vector2dF& delta, |
| 2807 base::TimeDelta delayed_by) { |
| 2807 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2808 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 2808 | 2809 |
| 2809 const float kEpsilon = 0.1f; | 2810 const float kEpsilon = 0.1f; |
| 2810 bool scroll_animated = | 2811 bool scroll_animated = |
| 2811 (std::abs(delta.x()) > kEpsilon || std::abs(delta.y()) > kEpsilon); | 2812 (std::abs(delta.x()) > kEpsilon || std::abs(delta.y()) > kEpsilon); |
| 2812 if (!scroll_animated) { | 2813 if (!scroll_animated) { |
| 2813 scroll_tree.ScrollBy(scroll_node, delta, active_tree()); | 2814 scroll_tree.ScrollBy(scroll_node, delta, active_tree()); |
| 2814 return false; | 2815 return false; |
| 2815 } | 2816 } |
| 2816 | 2817 |
| 2817 scroll_tree.set_currently_scrolling_node(scroll_node->id); | 2818 scroll_tree.set_currently_scrolling_node(scroll_node->id); |
| 2818 | 2819 |
| 2819 gfx::ScrollOffset current_offset = | 2820 gfx::ScrollOffset current_offset = |
| 2820 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2821 scroll_tree.current_scroll_offset(scroll_node->owner_id); |
| 2821 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( | 2822 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( |
| 2822 current_offset + gfx::ScrollOffset(delta), scroll_node); | 2823 current_offset + gfx::ScrollOffset(delta), scroll_node); |
| 2823 DCHECK_EQ( | 2824 DCHECK_EQ( |
| 2824 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), | 2825 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), |
| 2825 scroll_node->element_id); | 2826 scroll_node->element_id); |
| 2826 | 2827 |
| 2827 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->element_id, | 2828 animation_host_->ImplOnlyScrollAnimationCreate( |
| 2828 target_offset, current_offset); | 2829 scroll_node->element_id, target_offset, current_offset, delayed_by); |
| 2829 | 2830 |
| 2830 SetNeedsOneBeginImplFrame(); | 2831 SetNeedsOneBeginImplFrame(); |
| 2831 | 2832 |
| 2832 return true; | 2833 return true; |
| 2833 } | 2834 } |
| 2834 | 2835 |
| 2835 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 2836 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
| 2836 const gfx::Point& viewport_point, | 2837 const gfx::Point& viewport_point, |
| 2837 const gfx::Vector2dF& scroll_delta) { | 2838 const gfx::Vector2dF& scroll_delta, |
| 2839 base::TimeDelta delayed_by) { |
| 2838 InputHandler::ScrollStatus scroll_status; | 2840 InputHandler::ScrollStatus scroll_status; |
| 2839 scroll_status.main_thread_scrolling_reasons = | 2841 scroll_status.main_thread_scrolling_reasons = |
| 2840 MainThreadScrollingReason::kNotScrollingOnMain; | 2842 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2841 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2843 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 2842 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2844 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2843 if (scroll_node) { | 2845 if (scroll_node) { |
| 2844 gfx::Vector2dF delta = scroll_delta; | 2846 gfx::Vector2dF delta = scroll_delta; |
| 2845 if (!scroll_node->user_scrollable_horizontal) | 2847 if (!scroll_node->user_scrollable_horizontal) |
| 2846 delta.set_x(0); | 2848 delta.set_x(0); |
| 2847 if (!scroll_node->user_scrollable_vertical) | 2849 if (!scroll_node->user_scrollable_vertical) |
| 2848 delta.set_y(0); | 2850 delta.set_y(0); |
| 2849 | 2851 |
| 2850 if (ScrollAnimationUpdateTarget(scroll_node, delta)) { | 2852 if (ScrollAnimationUpdateTarget(scroll_node, delta, delayed_by)) { |
| 2851 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 2853 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
| 2852 } else { | 2854 } else { |
| 2853 scroll_status.thread = SCROLL_IGNORED; | 2855 scroll_status.thread = SCROLL_IGNORED; |
| 2854 scroll_status.main_thread_scrolling_reasons = | 2856 scroll_status.main_thread_scrolling_reasons = |
| 2855 MainThreadScrollingReason::kNotScrollable; | 2857 MainThreadScrollingReason::kNotScrollable; |
| 2856 } | 2858 } |
| 2857 return scroll_status; | 2859 return scroll_status; |
| 2858 } | 2860 } |
| 2859 | 2861 |
| 2860 ScrollStateData scroll_state_data; | 2862 ScrollStateData scroll_state_data; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2871 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2873 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2872 gfx::Vector2dF pending_delta = scroll_delta; | 2874 gfx::Vector2dF pending_delta = scroll_delta; |
| 2873 if (scroll_node) { | 2875 if (scroll_node) { |
| 2874 for (; scroll_tree.parent(scroll_node); | 2876 for (; scroll_tree.parent(scroll_node); |
| 2875 scroll_node = scroll_tree.parent(scroll_node)) { | 2877 scroll_node = scroll_tree.parent(scroll_node)) { |
| 2876 if (!scroll_node->scrollable || | 2878 if (!scroll_node->scrollable || |
| 2877 scroll_node->is_outer_viewport_scroll_layer) | 2879 scroll_node->is_outer_viewport_scroll_layer) |
| 2878 continue; | 2880 continue; |
| 2879 | 2881 |
| 2880 if (scroll_node->is_inner_viewport_scroll_layer) { | 2882 if (scroll_node->is_inner_viewport_scroll_layer) { |
| 2881 gfx::Vector2dF scrolled = viewport()->ScrollAnimated(pending_delta); | 2883 gfx::Vector2dF scrolled = |
| 2884 viewport()->ScrollAnimated(pending_delta, delayed_by); |
| 2882 // Viewport::ScrollAnimated returns pending_delta as long as it | 2885 // Viewport::ScrollAnimated returns pending_delta as long as it |
| 2883 // starts an animation. | 2886 // starts an animation. |
| 2884 if (scrolled == pending_delta) | 2887 if (scrolled == pending_delta) |
| 2885 return scroll_status; | 2888 return scroll_status; |
| 2886 pending_delta -= scrolled; | 2889 pending_delta -= scrolled; |
| 2887 continue; | 2890 continue; |
| 2888 } | 2891 } |
| 2889 | 2892 |
| 2890 gfx::Vector2dF scroll_delta = | 2893 gfx::Vector2dF scroll_delta = |
| 2891 ComputeScrollDelta(scroll_node, pending_delta); | 2894 ComputeScrollDelta(scroll_node, pending_delta); |
| 2892 if (ScrollAnimationCreate(scroll_node, scroll_delta)) | 2895 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) |
| 2893 return scroll_status; | 2896 return scroll_status; |
| 2894 | 2897 |
| 2895 pending_delta -= scroll_delta; | 2898 pending_delta -= scroll_delta; |
| 2896 } | 2899 } |
| 2897 } | 2900 } |
| 2898 } | 2901 } |
| 2899 scroll_state.set_is_ending(true); | 2902 scroll_state.set_is_ending(true); |
| 2900 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is | 2903 // TODO(Sahel): Once the touchpad scroll latching for Non-mac devices is |
| 2901 // implemented, the current scrolling layer should not get cleared after | 2904 // implemented, the current scrolling layer should not get cleared after |
| 2902 // each animation (crbug.com/526463). | 2905 // each animation (crbug.com/526463). |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3903 active_tree_->min_page_scale_factor(), | 3906 active_tree_->min_page_scale_factor(), |
| 3904 active_tree_->max_page_scale_factor()); | 3907 active_tree_->max_page_scale_factor()); |
| 3905 } | 3908 } |
| 3906 | 3909 |
| 3907 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { | 3910 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { |
| 3908 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); | 3911 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); |
| 3909 } | 3912 } |
| 3910 | 3913 |
| 3911 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( | 3914 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( |
| 3912 ScrollNode* scroll_node, | 3915 ScrollNode* scroll_node, |
| 3913 const gfx::Vector2dF& scroll_delta) { | 3916 const gfx::Vector2dF& scroll_delta, |
| 3917 base::TimeDelta delayed_by) { |
| 3914 DCHECK_EQ( | 3918 DCHECK_EQ( |
| 3915 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), | 3919 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), |
| 3916 scroll_node->element_id); | 3920 scroll_node->element_id); |
| 3917 | 3921 |
| 3918 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( | 3922 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( |
| 3919 scroll_node->element_id, scroll_delta, | 3923 scroll_node->element_id, scroll_delta, |
| 3920 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( | 3924 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( |
| 3921 scroll_node->id), | 3925 scroll_node->id), |
| 3922 CurrentBeginFrameArgs().frame_time); | 3926 CurrentBeginFrameArgs().frame_time, delayed_by); |
| 3923 } | 3927 } |
| 3924 | 3928 |
| 3925 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, | 3929 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, |
| 3926 ElementListType list_type) const { | 3930 ElementListType list_type) const { |
| 3927 if (list_type == ElementListType::ACTIVE) { | 3931 if (list_type == ElementListType::ACTIVE) { |
| 3928 return active_tree() | 3932 return active_tree() |
| 3929 ? active_tree()->LayerByElementId(element_id) != nullptr | 3933 ? active_tree()->LayerByElementId(element_id) != nullptr |
| 3930 : false; | 3934 : false; |
| 3931 } else { | 3935 } else { |
| 3932 if (pending_tree() && pending_tree()->LayerByElementId(element_id)) | 3936 if (pending_tree() && pending_tree()->LayerByElementId(element_id)) |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4204 if (is_visible) { | 4208 if (is_visible) { |
| 4205 worker_context_visibility_ = | 4209 worker_context_visibility_ = |
| 4206 worker_context->CacheController()->ClientBecameVisible(); | 4210 worker_context->CacheController()->ClientBecameVisible(); |
| 4207 } else { | 4211 } else { |
| 4208 worker_context->CacheController()->ClientBecameNotVisible( | 4212 worker_context->CacheController()->ClientBecameNotVisible( |
| 4209 std::move(worker_context_visibility_)); | 4213 std::move(worker_context_visibility_)); |
| 4210 } | 4214 } |
| 4211 } | 4215 } |
| 4212 | 4216 |
| 4213 } // namespace cc | 4217 } // namespace cc |
| OLD | NEW |