| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // ancestor along the scroll tree. | 158 // ancestor along the scroll tree. |
| 159 bool IsScrolledBy(LayerImpl* child, LayerImpl* ancestor) { | 159 bool IsScrolledBy(LayerImpl* child, LayerImpl* ancestor) { |
| 160 DCHECK(ancestor && ancestor->scrollable()); | 160 DCHECK(ancestor && ancestor->scrollable()); |
| 161 if (!child) | 161 if (!child) |
| 162 return false; | 162 return false; |
| 163 | 163 |
| 164 ScrollTree& scroll_tree = | 164 ScrollTree& scroll_tree = |
| 165 child->layer_tree_impl()->property_trees()->scroll_tree; | 165 child->layer_tree_impl()->property_trees()->scroll_tree; |
| 166 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | 166 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
| 167 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { | 167 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { |
| 168 if (scroll_node->owner_id == ancestor->id()) | 168 if (scroll_node->owning_layer_id == ancestor->id()) |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 return false; | 171 return false; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace | 174 } // namespace |
| 175 | 175 |
| 176 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, | 176 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, |
| 177 "Scheduling.%s.PendingTreeDuration"); | 177 "Scheduling.%s.PendingTreeDuration"); |
| 178 | 178 |
| (...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2456 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) { | 2456 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) { |
| 2457 // TODO(shawnsingh): We shouldn't be applying a projection if screen space | 2457 // TODO(shawnsingh): We shouldn't be applying a projection if screen space |
| 2458 // transform is uninvertible here. Perhaps we should be returning | 2458 // transform is uninvertible here. Perhaps we should be returning |
| 2459 // SCROLL_ON_MAIN_THREAD in this case? | 2459 // SCROLL_ON_MAIN_THREAD in this case? |
| 2460 } | 2460 } |
| 2461 | 2461 |
| 2462 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint( | 2462 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint( |
| 2463 inverse_screen_space_transform, screen_space_point, &clipped); | 2463 inverse_screen_space_transform, screen_space_point, &clipped); |
| 2464 if (!clipped && | 2464 if (!clipped && |
| 2465 active_tree() | 2465 active_tree() |
| 2466 ->LayerById(scroll_node->owner_id) | 2466 ->LayerById(scroll_node->owning_layer_id) |
| 2467 ->non_fast_scrollable_region() | 2467 ->non_fast_scrollable_region() |
| 2468 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { | 2468 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { |
| 2469 TRACE_EVENT0("cc", | 2469 TRACE_EVENT0("cc", |
| 2470 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); | 2470 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); |
| 2471 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | 2471 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; |
| 2472 scroll_status.main_thread_scrolling_reasons = | 2472 scroll_status.main_thread_scrolling_reasons = |
| 2473 MainThreadScrollingReason::kNonFastScrollableRegion; | 2473 MainThreadScrollingReason::kNonFastScrollableRegion; |
| 2474 return scroll_status; | 2474 return scroll_status; |
| 2475 } | 2475 } |
| 2476 } | 2476 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); | 2538 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); |
| 2539 if (IsMainThreadScrolling(status, scroll_node)) { | 2539 if (IsMainThreadScrolling(status, scroll_node)) { |
| 2540 *scroll_on_main_thread = true; | 2540 *scroll_on_main_thread = true; |
| 2541 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2541 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
| 2542 return NULL; | 2542 return NULL; |
| 2543 } | 2543 } |
| 2544 | 2544 |
| 2545 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && | 2545 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && |
| 2546 !potentially_scrolling_layer_impl) { | 2546 !potentially_scrolling_layer_impl) { |
| 2547 potentially_scrolling_layer_impl = | 2547 potentially_scrolling_layer_impl = |
| 2548 active_tree_->LayerById(scroll_node->owner_id); | 2548 active_tree_->LayerById(scroll_node->owning_layer_id); |
| 2549 } | 2549 } |
| 2550 } | 2550 } |
| 2551 } | 2551 } |
| 2552 | 2552 |
| 2553 // Falling back to the viewport layer ensures generation of root overscroll | 2553 // Falling back to the viewport layer ensures generation of root overscroll |
| 2554 // notifications. We use the viewport's main scroll layer to represent the | 2554 // notifications. We use the viewport's main scroll layer to represent the |
| 2555 // viewport in scrolling code. | 2555 // viewport in scrolling code. |
| 2556 if (!potentially_scrolling_layer_impl || | 2556 if (!potentially_scrolling_layer_impl || |
| 2557 potentially_scrolling_layer_impl == OuterViewportScrollLayer() || | 2557 potentially_scrolling_layer_impl == OuterViewportScrollLayer() || |
| 2558 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) { | 2558 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2579 LayerImpl* scroll_ancestor) { | 2579 LayerImpl* scroll_ancestor) { |
| 2580 DCHECK(scroll_ancestor); | 2580 DCHECK(scroll_ancestor); |
| 2581 if (!child) | 2581 if (!child) |
| 2582 return false; | 2582 return false; |
| 2583 ScrollTree& scroll_tree = | 2583 ScrollTree& scroll_tree = |
| 2584 child->layer_tree_impl()->property_trees()->scroll_tree; | 2584 child->layer_tree_impl()->property_trees()->scroll_tree; |
| 2585 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | 2585 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
| 2586 for (; scroll_tree.parent(scroll_node); | 2586 for (; scroll_tree.parent(scroll_node); |
| 2587 scroll_node = scroll_tree.parent(scroll_node)) { | 2587 scroll_node = scroll_tree.parent(scroll_node)) { |
| 2588 if (scroll_node->scrollable) | 2588 if (scroll_node->scrollable) |
| 2589 return scroll_node->owner_id == scroll_ancestor->id(); | 2589 return scroll_node->owning_layer_id == scroll_ancestor->id(); |
| 2590 } | 2590 } |
| 2591 return false; | 2591 return false; |
| 2592 } | 2592 } |
| 2593 | 2593 |
| 2594 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( | 2594 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( |
| 2595 ScrollState* scroll_state, | 2595 ScrollState* scroll_state, |
| 2596 LayerImpl* scrolling_layer_impl, | 2596 LayerImpl* scrolling_layer_impl, |
| 2597 InputHandler::ScrollInputType type) { | 2597 InputHandler::ScrollInputType type) { |
| 2598 DCHECK(scroll_state); | 2598 DCHECK(scroll_state); |
| 2599 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); | 2599 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 float scale_factor = active_tree()->current_page_scale_factor(); | 2740 float scale_factor = active_tree()->current_page_scale_factor(); |
| 2741 | 2741 |
| 2742 gfx::Vector2dF adjusted_scroll(delta); | 2742 gfx::Vector2dF adjusted_scroll(delta); |
| 2743 adjusted_scroll.Scale(1.f / scale_factor); | 2743 adjusted_scroll.Scale(1.f / scale_factor); |
| 2744 if (!scroll_node->user_scrollable_horizontal) | 2744 if (!scroll_node->user_scrollable_horizontal) |
| 2745 adjusted_scroll.set_x(0); | 2745 adjusted_scroll.set_x(0); |
| 2746 if (!scroll_node->user_scrollable_vertical) | 2746 if (!scroll_node->user_scrollable_vertical) |
| 2747 adjusted_scroll.set_y(0); | 2747 adjusted_scroll.set_y(0); |
| 2748 | 2748 |
| 2749 gfx::ScrollOffset old_offset = | 2749 gfx::ScrollOffset old_offset = |
| 2750 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2750 scroll_tree.current_scroll_offset(scroll_node->owning_layer_id); |
| 2751 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( | 2751 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( |
| 2752 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); | 2752 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); |
| 2753 | 2753 |
| 2754 gfx::ScrollOffset scrolled = new_offset - old_offset; | 2754 gfx::ScrollOffset scrolled = new_offset - old_offset; |
| 2755 return gfx::Vector2dF(scrolled.x(), scrolled.y()); | 2755 return gfx::Vector2dF(scrolled.x(), scrolled.y()); |
| 2756 } | 2756 } |
| 2757 | 2757 |
| 2758 bool LayerTreeHostImpl::ScrollAnimationCreate(ScrollNode* scroll_node, | 2758 bool LayerTreeHostImpl::ScrollAnimationCreate(ScrollNode* scroll_node, |
| 2759 const gfx::Vector2dF& delta, | 2759 const gfx::Vector2dF& delta, |
| 2760 base::TimeDelta delayed_by) { | 2760 base::TimeDelta delayed_by) { |
| 2761 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2761 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 2762 | 2762 |
| 2763 const float kEpsilon = 0.1f; | 2763 const float kEpsilon = 0.1f; |
| 2764 bool scroll_animated = | 2764 bool scroll_animated = |
| 2765 (std::abs(delta.x()) > kEpsilon || std::abs(delta.y()) > kEpsilon); | 2765 (std::abs(delta.x()) > kEpsilon || std::abs(delta.y()) > kEpsilon); |
| 2766 if (!scroll_animated) { | 2766 if (!scroll_animated) { |
| 2767 scroll_tree.ScrollBy(scroll_node, delta, active_tree()); | 2767 scroll_tree.ScrollBy(scroll_node, delta, active_tree()); |
| 2768 return false; | 2768 return false; |
| 2769 } | 2769 } |
| 2770 | 2770 |
| 2771 scroll_tree.set_currently_scrolling_node(scroll_node->id); | 2771 scroll_tree.set_currently_scrolling_node(scroll_node->id); |
| 2772 | 2772 |
| 2773 gfx::ScrollOffset current_offset = | 2773 gfx::ScrollOffset current_offset = |
| 2774 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2774 scroll_tree.current_scroll_offset(scroll_node->owning_layer_id); |
| 2775 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( | 2775 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( |
| 2776 current_offset + gfx::ScrollOffset(delta), scroll_node); | 2776 current_offset + gfx::ScrollOffset(delta), scroll_node); |
| 2777 DCHECK_EQ( | 2777 DCHECK_EQ( |
| 2778 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), | 2778 ElementId( |
| 2779 active_tree()->LayerById(scroll_node->owning_layer_id)->element_id()), |
| 2779 scroll_node->element_id); | 2780 scroll_node->element_id); |
| 2780 | 2781 |
| 2781 mutator_host_->ImplOnlyScrollAnimationCreate( | 2782 mutator_host_->ImplOnlyScrollAnimationCreate( |
| 2782 scroll_node->element_id, target_offset, current_offset, delayed_by); | 2783 scroll_node->element_id, target_offset, current_offset, delayed_by); |
| 2783 | 2784 |
| 2784 SetNeedsOneBeginImplFrame(); | 2785 SetNeedsOneBeginImplFrame(); |
| 2785 | 2786 |
| 2786 return true; | 2787 return true; |
| 2787 } | 2788 } |
| 2788 | 2789 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2826 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2826 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2827 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2827 gfx::Vector2dF pending_delta = scroll_delta; | 2828 gfx::Vector2dF pending_delta = scroll_delta; |
| 2828 if (scroll_node) { | 2829 if (scroll_node) { |
| 2829 for (; scroll_tree.parent(scroll_node); | 2830 for (; scroll_tree.parent(scroll_node); |
| 2830 scroll_node = scroll_tree.parent(scroll_node)) { | 2831 scroll_node = scroll_tree.parent(scroll_node)) { |
| 2831 if (!scroll_node->scrollable) | 2832 if (!scroll_node->scrollable) |
| 2832 continue; | 2833 continue; |
| 2833 | 2834 |
| 2834 if (viewport()->MainScrollLayer() && | 2835 if (viewport()->MainScrollLayer() && |
| 2835 scroll_node->owner_id == viewport()->MainScrollLayer()->id()) { | 2836 scroll_node->owning_layer_id == |
| 2837 viewport()->MainScrollLayer()->id()) { |
| 2836 gfx::Vector2dF scrolled = | 2838 gfx::Vector2dF scrolled = |
| 2837 viewport()->ScrollAnimated(pending_delta, delayed_by); | 2839 viewport()->ScrollAnimated(pending_delta, delayed_by); |
| 2838 // Viewport::ScrollAnimated returns pending_delta as long as it | 2840 // Viewport::ScrollAnimated returns pending_delta as long as it |
| 2839 // starts an animation. | 2841 // starts an animation. |
| 2840 if (scrolled == pending_delta) | 2842 if (scrolled == pending_delta) |
| 2841 return scroll_status; | 2843 return scroll_status; |
| 2842 break; | 2844 break; |
| 2843 } | 2845 } |
| 2844 | 2846 |
| 2845 gfx::Vector2dF scroll_delta = | 2847 gfx::Vector2dF scroll_delta = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2892 inverse_screen_space_transform, screen_space_end_point, &end_clipped); | 2894 inverse_screen_space_transform, screen_space_end_point, &end_clipped); |
| 2893 | 2895 |
| 2894 // In general scroll point coordinates should not get clipped. | 2896 // In general scroll point coordinates should not get clipped. |
| 2895 DCHECK(!start_clipped); | 2897 DCHECK(!start_clipped); |
| 2896 DCHECK(!end_clipped); | 2898 DCHECK(!end_clipped); |
| 2897 if (start_clipped || end_clipped) | 2899 if (start_clipped || end_clipped) |
| 2898 return gfx::Vector2dF(); | 2900 return gfx::Vector2dF(); |
| 2899 | 2901 |
| 2900 // Apply the scroll delta. | 2902 // Apply the scroll delta. |
| 2901 gfx::ScrollOffset previous_offset = | 2903 gfx::ScrollOffset previous_offset = |
| 2902 scroll_tree->current_scroll_offset(scroll_node->owner_id); | 2904 scroll_tree->current_scroll_offset(scroll_node->owning_layer_id); |
| 2903 scroll_tree->ScrollBy(scroll_node, local_end_point - local_start_point, | 2905 scroll_tree->ScrollBy(scroll_node, local_end_point - local_start_point, |
| 2904 active_tree()); | 2906 active_tree()); |
| 2905 gfx::ScrollOffset scrolled = | 2907 gfx::ScrollOffset scrolled = |
| 2906 scroll_tree->current_scroll_offset(scroll_node->owner_id) - | 2908 scroll_tree->current_scroll_offset(scroll_node->owning_layer_id) - |
| 2907 previous_offset; | 2909 previous_offset; |
| 2908 | 2910 |
| 2909 // Get the end point in the layer's content space so we can apply its | 2911 // Get the end point in the layer's content space so we can apply its |
| 2910 // ScreenSpaceTransform. | 2912 // ScreenSpaceTransform. |
| 2911 gfx::PointF actual_local_end_point = | 2913 gfx::PointF actual_local_end_point = |
| 2912 local_start_point + gfx::Vector2dF(scrolled.x(), scrolled.y()); | 2914 local_start_point + gfx::Vector2dF(scrolled.x(), scrolled.y()); |
| 2913 | 2915 |
| 2914 // Calculate the applied scroll delta in viewport space coordinates. | 2916 // Calculate the applied scroll delta in viewport space coordinates. |
| 2915 gfx::PointF actual_screen_space_end_point = MathUtil::MapPoint( | 2917 gfx::PointF actual_screen_space_end_point = MathUtil::MapPoint( |
| 2916 screen_space_transform, actual_local_end_point, &end_clipped); | 2918 screen_space_transform, actual_local_end_point, &end_clipped); |
| 2917 DCHECK(!end_clipped); | 2919 DCHECK(!end_clipped); |
| 2918 if (end_clipped) | 2920 if (end_clipped) |
| 2919 return gfx::Vector2dF(); | 2921 return gfx::Vector2dF(); |
| 2920 gfx::PointF actual_viewport_end_point = gfx::ScalePoint( | 2922 gfx::PointF actual_viewport_end_point = gfx::ScalePoint( |
| 2921 actual_screen_space_end_point, 1.f / scale_from_viewport_to_screen_space); | 2923 actual_screen_space_end_point, 1.f / scale_from_viewport_to_screen_space); |
| 2922 return actual_viewport_end_point - viewport_point; | 2924 return actual_viewport_end_point - viewport_point; |
| 2923 } | 2925 } |
| 2924 | 2926 |
| 2925 static gfx::Vector2dF ScrollNodeWithLocalDelta( | 2927 static gfx::Vector2dF ScrollNodeWithLocalDelta( |
| 2926 ScrollNode* scroll_node, | 2928 ScrollNode* scroll_node, |
| 2927 const gfx::Vector2dF& local_delta, | 2929 const gfx::Vector2dF& local_delta, |
| 2928 float page_scale_factor, | 2930 float page_scale_factor, |
| 2929 LayerTreeImpl* layer_tree_impl) { | 2931 LayerTreeImpl* layer_tree_impl) { |
| 2930 ScrollTree& scroll_tree = layer_tree_impl->property_trees()->scroll_tree; | 2932 ScrollTree& scroll_tree = layer_tree_impl->property_trees()->scroll_tree; |
| 2931 gfx::ScrollOffset previous_offset = | 2933 gfx::ScrollOffset previous_offset = |
| 2932 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2934 scroll_tree.current_scroll_offset(scroll_node->owning_layer_id); |
| 2933 gfx::Vector2dF delta = local_delta; | 2935 gfx::Vector2dF delta = local_delta; |
| 2934 delta.Scale(1.f / page_scale_factor); | 2936 delta.Scale(1.f / page_scale_factor); |
| 2935 scroll_tree.ScrollBy(scroll_node, delta, layer_tree_impl); | 2937 scroll_tree.ScrollBy(scroll_node, delta, layer_tree_impl); |
| 2936 gfx::ScrollOffset scrolled = | 2938 gfx::ScrollOffset scrolled = |
| 2937 scroll_tree.current_scroll_offset(scroll_node->owner_id) - | 2939 scroll_tree.current_scroll_offset(scroll_node->owning_layer_id) - |
| 2938 previous_offset; | 2940 previous_offset; |
| 2939 gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y()); | 2941 gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y()); |
| 2940 consumed_scroll.Scale(page_scale_factor); | 2942 consumed_scroll.Scale(page_scale_factor); |
| 2941 | 2943 |
| 2942 return consumed_scroll; | 2944 return consumed_scroll; |
| 2943 } | 2945 } |
| 2944 | 2946 |
| 2945 // TODO(danakj): Make this into two functions, one with delta, one with | 2947 // TODO(danakj): Make this into two functions, one with delta, one with |
| 2946 // viewport_point, no bool required. | 2948 // viewport_point, no bool required. |
| 2947 gfx::Vector2dF LayerTreeHostImpl::ScrollSingleNode( | 2949 gfx::Vector2dF LayerTreeHostImpl::ScrollSingleNode( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2973 scroll_state->position_y()); | 2975 scroll_state->position_y()); |
| 2974 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); | 2976 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); |
| 2975 gfx::Vector2dF applied_delta; | 2977 gfx::Vector2dF applied_delta; |
| 2976 gfx::Vector2dF delta_applied_to_content; | 2978 gfx::Vector2dF delta_applied_to_content; |
| 2977 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for | 2979 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for |
| 2978 // details. | 2980 // details. |
| 2979 const float kEpsilon = 0.1f; | 2981 const float kEpsilon = 0.1f; |
| 2980 | 2982 |
| 2981 bool is_viewport_scroll_layer = | 2983 bool is_viewport_scroll_layer = |
| 2982 viewport()->MainScrollLayer() && | 2984 viewport()->MainScrollLayer() && |
| 2983 scroll_node->owner_id == viewport()->MainScrollLayer()->id(); | 2985 scroll_node->owning_layer_id == viewport()->MainScrollLayer()->id(); |
| 2984 | 2986 |
| 2985 // This is needed if the scroll chains up to the viewport without going | 2987 // This is needed if the scroll chains up to the viewport without going |
| 2986 // through the outer viewport scroll layer. This can happen if we scroll an | 2988 // through the outer viewport scroll layer. This can happen if we scroll an |
| 2987 // element that's not a descendant of the document.rootScroller. In that case | 2989 // element that's not a descendant of the document.rootScroller. In that case |
| 2988 // we want to scroll the inner viewport -- to allow panning while zoomed -- | 2990 // we want to scroll the inner viewport -- to allow panning while zoomed -- |
| 2989 // but also move browser controls if needed. | 2991 // but also move browser controls if needed. |
| 2990 bool is_inner_viewport_scroll_layer = | 2992 bool is_inner_viewport_scroll_layer = |
| 2991 scroll_node->owner_id == InnerViewportScrollLayer()->id(); | 2993 scroll_node->owning_layer_id == InnerViewportScrollLayer()->id(); |
| 2992 | 2994 |
| 2993 if (is_viewport_scroll_layer || is_inner_viewport_scroll_layer) { | 2995 if (is_viewport_scroll_layer || is_inner_viewport_scroll_layer) { |
| 2994 Viewport::ScrollResult result = viewport()->ScrollBy( | 2996 Viewport::ScrollResult result = viewport()->ScrollBy( |
| 2995 delta, viewport_point, scroll_state->is_direct_manipulation(), | 2997 delta, viewport_point, scroll_state->is_direct_manipulation(), |
| 2996 !wheel_scrolling_, is_viewport_scroll_layer); | 2998 !wheel_scrolling_, is_viewport_scroll_layer); |
| 2997 | 2999 |
| 2998 applied_delta = result.consumed_delta; | 3000 applied_delta = result.consumed_delta; |
| 2999 delta_applied_to_content = result.content_scrolled_delta; | 3001 delta_applied_to_content = result.content_scrolled_delta; |
| 3000 } else { | 3002 } else { |
| 3001 applied_delta = ScrollSingleNode( | 3003 applied_delta = ScrollSingleNode( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 | 3092 |
| 3091 scroll_state->set_delta_consumed_for_scroll_sequence( | 3093 scroll_state->set_delta_consumed_for_scroll_sequence( |
| 3092 did_lock_scrolling_layer_); | 3094 did_lock_scrolling_layer_); |
| 3093 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); | 3095 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); |
| 3094 scroll_state->set_current_native_scrolling_node( | 3096 scroll_state->set_current_native_scrolling_node( |
| 3095 active_tree()->property_trees()->scroll_tree.CurrentlyScrollingNode()); | 3097 active_tree()->property_trees()->scroll_tree.CurrentlyScrollingNode()); |
| 3096 | 3098 |
| 3097 DistributeScrollDelta(scroll_state); | 3099 DistributeScrollDelta(scroll_state); |
| 3098 | 3100 |
| 3099 active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( | 3101 active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( |
| 3100 scroll_state->current_native_scrolling_node()->owner_id)); | 3102 scroll_state->current_native_scrolling_node()->owning_layer_id)); |
| 3101 did_lock_scrolling_layer_ = | 3103 did_lock_scrolling_layer_ = |
| 3102 scroll_state->delta_consumed_for_scroll_sequence(); | 3104 scroll_state->delta_consumed_for_scroll_sequence(); |
| 3103 | 3105 |
| 3104 bool did_scroll_x = scroll_state->caused_scroll_x(); | 3106 bool did_scroll_x = scroll_state->caused_scroll_x(); |
| 3105 bool did_scroll_y = scroll_state->caused_scroll_y(); | 3107 bool did_scroll_y = scroll_state->caused_scroll_y(); |
| 3106 bool did_scroll_content = did_scroll_x || did_scroll_y; | 3108 bool did_scroll_content = did_scroll_x || did_scroll_y; |
| 3107 if (did_scroll_content) { | 3109 if (did_scroll_content) { |
| 3108 // If we are scrolling with an active scroll handler, forward latency | 3110 // If we are scrolling with an active scroll handler, forward latency |
| 3109 // tracking information to the main thread so the delay introduced by the | 3111 // tracking information to the main thread so the delay introduced by the |
| 3110 // handler is accounted for. | 3112 // handler is accounted for. |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3846 | 3848 |
| 3847 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { | 3849 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { |
| 3848 return mutator_host_->ScrollAnimationAbort(false /* needs_completion */); | 3850 return mutator_host_->ScrollAnimationAbort(false /* needs_completion */); |
| 3849 } | 3851 } |
| 3850 | 3852 |
| 3851 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( | 3853 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( |
| 3852 ScrollNode* scroll_node, | 3854 ScrollNode* scroll_node, |
| 3853 const gfx::Vector2dF& scroll_delta, | 3855 const gfx::Vector2dF& scroll_delta, |
| 3854 base::TimeDelta delayed_by) { | 3856 base::TimeDelta delayed_by) { |
| 3855 DCHECK_EQ( | 3857 DCHECK_EQ( |
| 3856 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), | 3858 ElementId( |
| 3859 active_tree()->LayerById(scroll_node->owning_layer_id)->element_id()), |
| 3857 scroll_node->element_id); | 3860 scroll_node->element_id); |
| 3858 | 3861 |
| 3859 return mutator_host_->ImplOnlyScrollAnimationUpdateTarget( | 3862 return mutator_host_->ImplOnlyScrollAnimationUpdateTarget( |
| 3860 scroll_node->element_id, scroll_delta, | 3863 scroll_node->element_id, scroll_delta, |
| 3861 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( | 3864 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( |
| 3862 scroll_node->id), | 3865 scroll_node->id), |
| 3863 CurrentBeginFrameArgs().frame_time, delayed_by); | 3866 CurrentBeginFrameArgs().frame_time, delayed_by); |
| 3864 } | 3867 } |
| 3865 | 3868 |
| 3866 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, | 3869 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4088 worker_context_visibility_ = | 4091 worker_context_visibility_ = |
| 4089 worker_context->CacheController()->ClientBecameVisible(); | 4092 worker_context->CacheController()->ClientBecameVisible(); |
| 4090 } else { | 4093 } else { |
| 4091 worker_context->CacheController()->ClientBecameNotVisible( | 4094 worker_context->CacheController()->ClientBecameNotVisible( |
| 4092 std::move(worker_context_visibility_)); | 4095 std::move(worker_context_visibility_)); |
| 4093 } | 4096 } |
| 4094 } | 4097 } |
| 4095 } | 4098 } |
| 4096 | 4099 |
| 4097 } // namespace cc | 4100 } // namespace cc |
| OLD | NEW |