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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "cc/tiles/picture_layer_tiling.h" | 75 #include "cc/tiles/picture_layer_tiling.h" |
76 #include "cc/tiles/raster_tile_priority_queue.h" | 76 #include "cc/tiles/raster_tile_priority_queue.h" |
77 #include "cc/tiles/software_image_decode_controller.h" | 77 #include "cc/tiles/software_image_decode_controller.h" |
78 #include "cc/tiles/tile_task_manager.h" | 78 #include "cc/tiles/tile_task_manager.h" |
79 #include "cc/trees/damage_tracker.h" | 79 #include "cc/trees/damage_tracker.h" |
80 #include "cc/trees/draw_property_utils.h" | 80 #include "cc/trees/draw_property_utils.h" |
81 #include "cc/trees/latency_info_swap_promise_monitor.h" | 81 #include "cc/trees/latency_info_swap_promise_monitor.h" |
82 #include "cc/trees/layer_tree_host.h" | 82 #include "cc/trees/layer_tree_host.h" |
83 #include "cc/trees/layer_tree_host_common.h" | 83 #include "cc/trees/layer_tree_host_common.h" |
84 #include "cc/trees/layer_tree_impl.h" | 84 #include "cc/trees/layer_tree_impl.h" |
| 85 #include "cc/trees/scroll_node.h" |
85 #include "cc/trees/single_thread_proxy.h" | 86 #include "cc/trees/single_thread_proxy.h" |
86 #include "cc/trees/tree_synchronizer.h" | 87 #include "cc/trees/tree_synchronizer.h" |
87 #include "gpu/GLES2/gl2extchromium.h" | 88 #include "gpu/GLES2/gl2extchromium.h" |
88 #include "gpu/command_buffer/client/gles2_interface.h" | 89 #include "gpu/command_buffer/client/gles2_interface.h" |
89 #include "ui/gfx/geometry/point_conversions.h" | 90 #include "ui/gfx/geometry/point_conversions.h" |
90 #include "ui/gfx/geometry/rect_conversions.h" | 91 #include "ui/gfx/geometry/rect_conversions.h" |
91 #include "ui/gfx/geometry/scroll_offset.h" | 92 #include "ui/gfx/geometry/scroll_offset.h" |
92 #include "ui/gfx/geometry/size_conversions.h" | 93 #include "ui/gfx/geometry/size_conversions.h" |
93 #include "ui/gfx/geometry/vector2d_conversions.h" | 94 #include "ui/gfx/geometry/vector2d_conversions.h" |
94 | 95 |
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 } | 2451 } |
2451 | 2452 |
2452 InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll( | 2453 InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll( |
2453 const gfx::PointF& screen_space_point, | 2454 const gfx::PointF& screen_space_point, |
2454 InputHandler::ScrollInputType type, | 2455 InputHandler::ScrollInputType type, |
2455 const ScrollTree& scroll_tree, | 2456 const ScrollTree& scroll_tree, |
2456 ScrollNode* scroll_node) const { | 2457 ScrollNode* scroll_node) const { |
2457 InputHandler::ScrollStatus scroll_status; | 2458 InputHandler::ScrollStatus scroll_status; |
2458 scroll_status.main_thread_scrolling_reasons = | 2459 scroll_status.main_thread_scrolling_reasons = |
2459 MainThreadScrollingReason::kNotScrollingOnMain; | 2460 MainThreadScrollingReason::kNotScrollingOnMain; |
2460 if (!!scroll_node->data.main_thread_scrolling_reasons) { | 2461 if (!!scroll_node->main_thread_scrolling_reasons) { |
2461 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); | 2462 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); |
2462 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | 2463 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; |
2463 scroll_status.main_thread_scrolling_reasons = | 2464 scroll_status.main_thread_scrolling_reasons = |
2464 scroll_node->data.main_thread_scrolling_reasons; | 2465 scroll_node->main_thread_scrolling_reasons; |
2465 return scroll_status; | 2466 return scroll_status; |
2466 } | 2467 } |
2467 | 2468 |
2468 gfx::Transform screen_space_transform = | 2469 gfx::Transform screen_space_transform = |
2469 scroll_tree.ScreenSpaceTransform(scroll_node->id); | 2470 scroll_tree.ScreenSpaceTransform(scroll_node->id); |
2470 if (!screen_space_transform.IsInvertible()) { | 2471 if (!screen_space_transform.IsInvertible()) { |
2471 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); | 2472 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); |
2472 scroll_status.thread = InputHandler::SCROLL_IGNORED; | 2473 scroll_status.thread = InputHandler::SCROLL_IGNORED; |
2473 scroll_status.main_thread_scrolling_reasons = | 2474 scroll_status.main_thread_scrolling_reasons = |
2474 MainThreadScrollingReason::kNonInvertibleTransform; | 2475 MainThreadScrollingReason::kNonInvertibleTransform; |
2475 return scroll_status; | 2476 return scroll_status; |
2476 } | 2477 } |
2477 | 2478 |
2478 if (scroll_node->data.contains_non_fast_scrollable_region) { | 2479 if (scroll_node->contains_non_fast_scrollable_region) { |
2479 bool clipped = false; | 2480 bool clipped = false; |
2480 gfx::Transform inverse_screen_space_transform( | 2481 gfx::Transform inverse_screen_space_transform( |
2481 gfx::Transform::kSkipInitialization); | 2482 gfx::Transform::kSkipInitialization); |
2482 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) { | 2483 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) { |
2483 // TODO(shawnsingh): We shouldn't be applying a projection if screen space | 2484 // TODO(shawnsingh): We shouldn't be applying a projection if screen space |
2484 // transform is uninvertible here. Perhaps we should be returning | 2485 // transform is uninvertible here. Perhaps we should be returning |
2485 // SCROLL_ON_MAIN_THREAD in this case? | 2486 // SCROLL_ON_MAIN_THREAD in this case? |
2486 } | 2487 } |
2487 | 2488 |
2488 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint( | 2489 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint( |
2489 inverse_screen_space_transform, screen_space_point, &clipped); | 2490 inverse_screen_space_transform, screen_space_point, &clipped); |
2490 if (!clipped && | 2491 if (!clipped && |
2491 active_tree() | 2492 active_tree() |
2492 ->LayerById(scroll_node->owner_id) | 2493 ->LayerById(scroll_node->owner_id) |
2493 ->non_fast_scrollable_region() | 2494 ->non_fast_scrollable_region() |
2494 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { | 2495 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { |
2495 TRACE_EVENT0("cc", | 2496 TRACE_EVENT0("cc", |
2496 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); | 2497 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); |
2497 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | 2498 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; |
2498 scroll_status.main_thread_scrolling_reasons = | 2499 scroll_status.main_thread_scrolling_reasons = |
2499 MainThreadScrollingReason::kNonFastScrollableRegion; | 2500 MainThreadScrollingReason::kNonFastScrollableRegion; |
2500 return scroll_status; | 2501 return scroll_status; |
2501 } | 2502 } |
2502 } | 2503 } |
2503 | 2504 |
2504 if (!scroll_node->data.scrollable) { | 2505 if (!scroll_node->scrollable) { |
2505 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); | 2506 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); |
2506 scroll_status.thread = InputHandler::SCROLL_IGNORED; | 2507 scroll_status.thread = InputHandler::SCROLL_IGNORED; |
2507 scroll_status.main_thread_scrolling_reasons = | 2508 scroll_status.main_thread_scrolling_reasons = |
2508 MainThreadScrollingReason::kNotScrollable; | 2509 MainThreadScrollingReason::kNotScrollable; |
2509 return scroll_status; | 2510 return scroll_status; |
2510 } | 2511 } |
2511 | 2512 |
2512 gfx::ScrollOffset max_scroll_offset = | 2513 gfx::ScrollOffset max_scroll_offset = |
2513 scroll_tree.MaxScrollOffset(scroll_node->id); | 2514 scroll_tree.MaxScrollOffset(scroll_node->id); |
2514 if (max_scroll_offset.x() <= 0 && max_scroll_offset.y() <= 0) { | 2515 if (max_scroll_offset.x() <= 0 && max_scroll_offset.y() <= 0) { |
2515 TRACE_EVENT0("cc", | 2516 TRACE_EVENT0("cc", |
2516 "LayerImpl::tryScroll: Ignored. Technically scrollable," | 2517 "LayerImpl::tryScroll: Ignored. Technically scrollable," |
2517 " but has no affordance in either direction."); | 2518 " but has no affordance in either direction."); |
2518 scroll_status.thread = InputHandler::SCROLL_IGNORED; | 2519 scroll_status.thread = InputHandler::SCROLL_IGNORED; |
2519 scroll_status.main_thread_scrolling_reasons = | 2520 scroll_status.main_thread_scrolling_reasons = |
2520 MainThreadScrollingReason::kNotScrollable; | 2521 MainThreadScrollingReason::kNotScrollable; |
2521 return scroll_status; | 2522 return scroll_status; |
2522 } | 2523 } |
2523 | 2524 |
2524 scroll_status.thread = InputHandler::SCROLL_ON_IMPL_THREAD; | 2525 scroll_status.thread = InputHandler::SCROLL_ON_IMPL_THREAD; |
2525 return scroll_status; | 2526 return scroll_status; |
2526 } | 2527 } |
2527 | 2528 |
2528 static bool IsMainThreadScrolling(const InputHandler::ScrollStatus& status, | 2529 static bool IsMainThreadScrolling(const InputHandler::ScrollStatus& status, |
2529 const ScrollNode* scroll_node) { | 2530 const ScrollNode* scroll_node) { |
2530 if (status.thread == InputHandler::SCROLL_ON_MAIN_THREAD) { | 2531 if (status.thread == InputHandler::SCROLL_ON_MAIN_THREAD) { |
2531 if (!!scroll_node->data.main_thread_scrolling_reasons) { | 2532 if (!!scroll_node->main_thread_scrolling_reasons) { |
2532 DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons( | 2533 DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons( |
2533 status.main_thread_scrolling_reasons)); | 2534 status.main_thread_scrolling_reasons)); |
2534 } else { | 2535 } else { |
2535 DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons( | 2536 DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons( |
2536 status.main_thread_scrolling_reasons)); | 2537 status.main_thread_scrolling_reasons)); |
2537 } | 2538 } |
2538 return true; | 2539 return true; |
2539 } | 2540 } |
2540 return false; | 2541 return false; |
2541 } | 2542 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. | 2606 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. |
2606 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | 2607 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { |
2607 DCHECK(scroll_ancestor); | 2608 DCHECK(scroll_ancestor); |
2608 if (!child) | 2609 if (!child) |
2609 return false; | 2610 return false; |
2610 ScrollTree& scroll_tree = | 2611 ScrollTree& scroll_tree = |
2611 child->layer_tree_impl()->property_trees()->scroll_tree; | 2612 child->layer_tree_impl()->property_trees()->scroll_tree; |
2612 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | 2613 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
2613 for (; scroll_tree.parent(scroll_node); | 2614 for (; scroll_tree.parent(scroll_node); |
2614 scroll_node = scroll_tree.parent(scroll_node)) { | 2615 scroll_node = scroll_tree.parent(scroll_node)) { |
2615 if (scroll_node->data.scrollable) | 2616 if (scroll_node->scrollable) |
2616 return scroll_node->owner_id == scroll_ancestor->id(); | 2617 return scroll_node->owner_id == scroll_ancestor->id(); |
2617 } | 2618 } |
2618 return false; | 2619 return false; |
2619 } | 2620 } |
2620 | 2621 |
2621 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( | 2622 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( |
2622 ScrollState* scroll_state, | 2623 ScrollState* scroll_state, |
2623 LayerImpl* scrolling_layer_impl, | 2624 LayerImpl* scrolling_layer_impl, |
2624 InputHandler::ScrollInputType type) { | 2625 InputHandler::ScrollInputType type) { |
2625 DCHECK(scroll_state); | 2626 DCHECK(scroll_state); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2755 } | 2756 } |
2756 | 2757 |
2757 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( | 2758 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( |
2758 ScrollNode* scroll_node, | 2759 ScrollNode* scroll_node, |
2759 const gfx::Vector2dF& delta) { | 2760 const gfx::Vector2dF& delta) { |
2760 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; | 2761 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; |
2761 float scale_factor = active_tree()->current_page_scale_factor(); | 2762 float scale_factor = active_tree()->current_page_scale_factor(); |
2762 | 2763 |
2763 gfx::Vector2dF adjusted_scroll(delta); | 2764 gfx::Vector2dF adjusted_scroll(delta); |
2764 adjusted_scroll.Scale(1.f / scale_factor); | 2765 adjusted_scroll.Scale(1.f / scale_factor); |
2765 if (!scroll_node->data.user_scrollable_horizontal) | 2766 if (!scroll_node->user_scrollable_horizontal) |
2766 adjusted_scroll.set_x(0); | 2767 adjusted_scroll.set_x(0); |
2767 if (!scroll_node->data.user_scrollable_vertical) | 2768 if (!scroll_node->user_scrollable_vertical) |
2768 adjusted_scroll.set_y(0); | 2769 adjusted_scroll.set_y(0); |
2769 | 2770 |
2770 gfx::ScrollOffset old_offset = | 2771 gfx::ScrollOffset old_offset = |
2771 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2772 scroll_tree.current_scroll_offset(scroll_node->owner_id); |
2772 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( | 2773 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( |
2773 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); | 2774 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); |
2774 | 2775 |
2775 gfx::ScrollOffset scrolled = new_offset - old_offset; | 2776 gfx::ScrollOffset scrolled = new_offset - old_offset; |
2776 return gfx::Vector2dF(scrolled.x(), scrolled.y()); | 2777 return gfx::Vector2dF(scrolled.x(), scrolled.y()); |
2777 } | 2778 } |
(...skipping 11 matching lines...) Expand all Loading... |
2789 } | 2790 } |
2790 | 2791 |
2791 scroll_tree.set_currently_scrolling_node(scroll_node->id); | 2792 scroll_tree.set_currently_scrolling_node(scroll_node->id); |
2792 | 2793 |
2793 gfx::ScrollOffset current_offset = | 2794 gfx::ScrollOffset current_offset = |
2794 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2795 scroll_tree.current_scroll_offset(scroll_node->owner_id); |
2795 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( | 2796 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( |
2796 current_offset + gfx::ScrollOffset(delta), scroll_node); | 2797 current_offset + gfx::ScrollOffset(delta), scroll_node); |
2797 DCHECK_EQ( | 2798 DCHECK_EQ( |
2798 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), | 2799 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), |
2799 scroll_node->data.element_id); | 2800 scroll_node->element_id); |
2800 | 2801 |
2801 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->data.element_id, | 2802 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->element_id, |
2802 target_offset, current_offset); | 2803 target_offset, current_offset); |
2803 | 2804 |
2804 SetNeedsOneBeginImplFrame(); | 2805 SetNeedsOneBeginImplFrame(); |
2805 | 2806 |
2806 return true; | 2807 return true; |
2807 } | 2808 } |
2808 | 2809 |
2809 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 2810 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
2810 const gfx::Point& viewport_point, | 2811 const gfx::Point& viewport_point, |
2811 const gfx::Vector2dF& scroll_delta) { | 2812 const gfx::Vector2dF& scroll_delta) { |
2812 InputHandler::ScrollStatus scroll_status; | 2813 InputHandler::ScrollStatus scroll_status; |
2813 scroll_status.main_thread_scrolling_reasons = | 2814 scroll_status.main_thread_scrolling_reasons = |
2814 MainThreadScrollingReason::kNotScrollingOnMain; | 2815 MainThreadScrollingReason::kNotScrollingOnMain; |
2815 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2816 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
2816 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2817 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
2817 if (scroll_node) { | 2818 if (scroll_node) { |
2818 gfx::Vector2dF delta = scroll_delta; | 2819 gfx::Vector2dF delta = scroll_delta; |
2819 if (!scroll_node->data.user_scrollable_horizontal) | 2820 if (!scroll_node->user_scrollable_horizontal) |
2820 delta.set_x(0); | 2821 delta.set_x(0); |
2821 if (!scroll_node->data.user_scrollable_vertical) | 2822 if (!scroll_node->user_scrollable_vertical) |
2822 delta.set_y(0); | 2823 delta.set_y(0); |
2823 | 2824 |
2824 if (ScrollAnimationUpdateTarget(scroll_node, delta)) { | 2825 if (ScrollAnimationUpdateTarget(scroll_node, delta)) { |
2825 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 2826 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
2826 } else { | 2827 } else { |
2827 scroll_status.thread = SCROLL_IGNORED; | 2828 scroll_status.thread = SCROLL_IGNORED; |
2828 scroll_status.main_thread_scrolling_reasons = | 2829 scroll_status.main_thread_scrolling_reasons = |
2829 MainThreadScrollingReason::kNotScrollable; | 2830 MainThreadScrollingReason::kNotScrollable; |
2830 } | 2831 } |
2831 return scroll_status; | 2832 return scroll_status; |
2832 } | 2833 } |
2833 | 2834 |
2834 ScrollStateData scroll_state_data; | 2835 ScrollStateData scroll_state_data; |
2835 scroll_state_data.position_x = viewport_point.x(); | 2836 scroll_state_data.position_x = viewport_point.x(); |
2836 scroll_state_data.position_y = viewport_point.y(); | 2837 scroll_state_data.position_y = viewport_point.y(); |
2837 scroll_state_data.is_in_inertial_phase = true; | 2838 scroll_state_data.is_in_inertial_phase = true; |
2838 ScrollState scroll_state(scroll_state_data); | 2839 ScrollState scroll_state(scroll_state_data); |
2839 | 2840 |
2840 // ScrollAnimated is used for animated wheel scrolls. We find the first layer | 2841 // ScrollAnimated is used for animated wheel scrolls. We find the first layer |
2841 // that can scroll and set up an animation of its scroll offset. Note that | 2842 // that can scroll and set up an animation of its scroll offset. Note that |
2842 // this does not currently go through the scroll customization machinery | 2843 // this does not currently go through the scroll customization machinery |
2843 // that ScrollBy uses for non-animated wheel scrolls. | 2844 // that ScrollBy uses for non-animated wheel scrolls. |
2844 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2845 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
2845 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2846 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
2846 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2847 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
2847 gfx::Vector2dF pending_delta = scroll_delta; | 2848 gfx::Vector2dF pending_delta = scroll_delta; |
2848 if (scroll_node) { | 2849 if (scroll_node) { |
2849 for (; scroll_tree.parent(scroll_node); | 2850 for (; scroll_tree.parent(scroll_node); |
2850 scroll_node = scroll_tree.parent(scroll_node)) { | 2851 scroll_node = scroll_tree.parent(scroll_node)) { |
2851 if (!scroll_node->data.scrollable || | 2852 if (!scroll_node->scrollable || |
2852 scroll_node->data.is_outer_viewport_scroll_layer) | 2853 scroll_node->is_outer_viewport_scroll_layer) |
2853 continue; | 2854 continue; |
2854 | 2855 |
2855 if (scroll_node->data.is_inner_viewport_scroll_layer) { | 2856 if (scroll_node->is_inner_viewport_scroll_layer) { |
2856 gfx::Vector2dF scrolled = viewport()->ScrollAnimated(pending_delta); | 2857 gfx::Vector2dF scrolled = viewport()->ScrollAnimated(pending_delta); |
2857 // Viewport::ScrollAnimated returns pending_delta as long as it | 2858 // Viewport::ScrollAnimated returns pending_delta as long as it |
2858 // starts an animation. | 2859 // starts an animation. |
2859 if (scrolled == pending_delta) | 2860 if (scrolled == pending_delta) |
2860 return scroll_status; | 2861 return scroll_status; |
2861 pending_delta -= scrolled; | 2862 pending_delta -= scrolled; |
2862 continue; | 2863 continue; |
2863 } | 2864 } |
2864 | 2865 |
2865 gfx::Vector2dF scroll_delta = | 2866 gfx::Vector2dF scroll_delta = |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 ScrollState* scroll_state) { | 2996 ScrollState* scroll_state) { |
2996 DCHECK(scroll_state); | 2997 DCHECK(scroll_state); |
2997 gfx::Point viewport_point(scroll_state->position_x(), | 2998 gfx::Point viewport_point(scroll_state->position_x(), |
2998 scroll_state->position_y()); | 2999 scroll_state->position_y()); |
2999 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); | 3000 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); |
3000 gfx::Vector2dF applied_delta; | 3001 gfx::Vector2dF applied_delta; |
3001 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for | 3002 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for |
3002 // details. | 3003 // details. |
3003 const float kEpsilon = 0.1f; | 3004 const float kEpsilon = 0.1f; |
3004 | 3005 |
3005 if (scroll_node->data.is_inner_viewport_scroll_layer) { | 3006 if (scroll_node->is_inner_viewport_scroll_layer) { |
3006 bool affect_top_controls = !wheel_scrolling_; | 3007 bool affect_top_controls = !wheel_scrolling_; |
3007 Viewport::ScrollResult result = viewport()->ScrollBy( | 3008 Viewport::ScrollResult result = viewport()->ScrollBy( |
3008 delta, viewport_point, scroll_state->is_direct_manipulation(), | 3009 delta, viewport_point, scroll_state->is_direct_manipulation(), |
3009 affect_top_controls); | 3010 affect_top_controls); |
3010 applied_delta = result.consumed_delta; | 3011 applied_delta = result.consumed_delta; |
3011 scroll_state->set_caused_scroll( | 3012 scroll_state->set_caused_scroll( |
3012 std::abs(result.content_scrolled_delta.x()) > kEpsilon, | 3013 std::abs(result.content_scrolled_delta.x()) > kEpsilon, |
3013 std::abs(result.content_scrolled_delta.y()) > kEpsilon); | 3014 std::abs(result.content_scrolled_delta.y()) > kEpsilon); |
3014 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); | 3015 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); |
3015 } else { | 3016 } else { |
3016 applied_delta = ScrollSingleNode( | 3017 applied_delta = ScrollSingleNode( |
3017 scroll_node, delta, viewport_point, | 3018 scroll_node, delta, viewport_point, |
3018 scroll_state->is_direct_manipulation(), | 3019 scroll_state->is_direct_manipulation(), |
3019 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); | 3020 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); |
3020 } | 3021 } |
3021 | 3022 |
3022 // If the layer wasn't able to move, try the next one in the hierarchy. | 3023 // If the layer wasn't able to move, try the next one in the hierarchy. |
3023 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; | 3024 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; |
3024 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; | 3025 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; |
3025 | 3026 |
3026 if (scrolled && !scroll_node->data.is_inner_viewport_scroll_layer) { | 3027 if (scrolled && !scroll_node->is_inner_viewport_scroll_layer) { |
3027 // If the applied delta is within 45 degrees of the input | 3028 // If the applied delta is within 45 degrees of the input |
3028 // delta, bail out to make it easier to scroll just one layer | 3029 // delta, bail out to make it easier to scroll just one layer |
3029 // in one direction without affecting any of its parents. | 3030 // in one direction without affecting any of its parents. |
3030 float angle_threshold = 45; | 3031 float angle_threshold = 45; |
3031 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < | 3032 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < |
3032 angle_threshold) { | 3033 angle_threshold) { |
3033 applied_delta = delta; | 3034 applied_delta = delta; |
3034 } else { | 3035 } else { |
3035 // Allow further movement only on an axis perpendicular to the direction | 3036 // Allow further movement only on an axis perpendicular to the direction |
3036 // in which the layer moved. | 3037 // in which the layer moved. |
(...skipping 17 matching lines...) Expand all Loading... |
3054 // crbug.com/526462) | 3055 // crbug.com/526462) |
3055 std::list<const ScrollNode*> current_scroll_chain; | 3056 std::list<const ScrollNode*> current_scroll_chain; |
3056 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3057 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3057 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3058 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3058 if (scroll_node) { | 3059 if (scroll_node) { |
3059 for (; scroll_tree.parent(scroll_node); | 3060 for (; scroll_tree.parent(scroll_node); |
3060 scroll_node = scroll_tree.parent(scroll_node)) { | 3061 scroll_node = scroll_tree.parent(scroll_node)) { |
3061 // Skip the outer viewport scroll layer so that we try to scroll the | 3062 // Skip the outer viewport scroll layer so that we try to scroll the |
3062 // viewport only once. i.e. The inner viewport layer represents the | 3063 // viewport only once. i.e. The inner viewport layer represents the |
3063 // viewport. | 3064 // viewport. |
3064 if (!scroll_node->data.scrollable || | 3065 if (!scroll_node->scrollable || |
3065 scroll_node->data.is_outer_viewport_scroll_layer) | 3066 scroll_node->is_outer_viewport_scroll_layer) |
3066 continue; | 3067 continue; |
3067 current_scroll_chain.push_front(scroll_node); | 3068 current_scroll_chain.push_front(scroll_node); |
3068 } | 3069 } |
3069 } | 3070 } |
3070 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, | 3071 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, |
3071 active_tree()); | 3072 active_tree()); |
3072 scroll_state->DistributeToScrollChainDescendant(); | 3073 scroll_state->DistributeToScrollChainDescendant(); |
3073 } | 3074 } |
3074 | 3075 |
3075 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( | 3076 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 3156 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
3156 ScrollDirection direction) { | 3157 ScrollDirection direction) { |
3157 DCHECK(wheel_scrolling_); | 3158 DCHECK(wheel_scrolling_); |
3158 | 3159 |
3159 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3160 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3160 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3161 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3161 if (scroll_node) { | 3162 if (scroll_node) { |
3162 for (; scroll_tree.parent(scroll_node); | 3163 for (; scroll_tree.parent(scroll_node); |
3163 scroll_node = scroll_tree.parent(scroll_node)) { | 3164 scroll_node = scroll_tree.parent(scroll_node)) { |
3164 // The inner viewport layer represents the viewport. | 3165 // The inner viewport layer represents the viewport. |
3165 if (!scroll_node->data.scrollable || | 3166 if (!scroll_node->scrollable || |
3166 scroll_node->data.is_outer_viewport_scroll_layer) | 3167 scroll_node->is_outer_viewport_scroll_layer) |
3167 continue; | 3168 continue; |
3168 | 3169 |
3169 float height = | 3170 float height = |
3170 scroll_tree.scroll_clip_layer_bounds(scroll_node->id).height(); | 3171 scroll_tree.scroll_clip_layer_bounds(scroll_node->id).height(); |
3171 | 3172 |
3172 // These magical values match WebKit and are designed to scroll nearly the | 3173 // These magical values match WebKit and are designed to scroll nearly the |
3173 // entire visible content height but leave a bit of overlap. | 3174 // entire visible content height but leave a bit of overlap. |
3174 float page = std::max(height * 0.875f, 1.f); | 3175 float page = std::max(height * 0.875f, 1.f); |
3175 if (direction == SCROLL_BACKWARD) | 3176 if (direction == SCROLL_BACKWARD) |
3176 page = -page; | 3177 page = -page; |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3812 | 3813 |
3813 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { | 3814 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { |
3814 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); | 3815 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); |
3815 } | 3816 } |
3816 | 3817 |
3817 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( | 3818 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( |
3818 ScrollNode* scroll_node, | 3819 ScrollNode* scroll_node, |
3819 const gfx::Vector2dF& scroll_delta) { | 3820 const gfx::Vector2dF& scroll_delta) { |
3820 DCHECK_EQ( | 3821 DCHECK_EQ( |
3821 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), | 3822 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), |
3822 scroll_node->data.element_id); | 3823 scroll_node->element_id); |
3823 | 3824 |
3824 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( | 3825 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( |
3825 scroll_node->data.element_id, scroll_delta, | 3826 scroll_node->element_id, scroll_delta, |
3826 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( | 3827 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( |
3827 scroll_node->id), | 3828 scroll_node->id), |
3828 CurrentBeginFrameArgs().frame_time); | 3829 CurrentBeginFrameArgs().frame_time); |
3829 } | 3830 } |
3830 | 3831 |
3831 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, | 3832 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, |
3832 ElementListType list_type) const { | 3833 ElementListType list_type) const { |
3833 if (list_type == ElementListType::ACTIVE) { | 3834 if (list_type == ElementListType::ACTIVE) { |
3834 return active_tree() | 3835 return active_tree() |
3835 ? active_tree()->LayerByElementId(element_id) != nullptr | 3836 ? active_tree()->LayerByElementId(element_id) != nullptr |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4025 return task_runner_provider_->HasImplThread(); | 4026 return task_runner_provider_->HasImplThread(); |
4026 } | 4027 } |
4027 | 4028 |
4028 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4029 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4029 // In single threaded mode we skip the pending tree and commit directly to the | 4030 // In single threaded mode we skip the pending tree and commit directly to the |
4030 // active tree. | 4031 // active tree. |
4031 return !task_runner_provider_->HasImplThread(); | 4032 return !task_runner_provider_->HasImplThread(); |
4032 } | 4033 } |
4033 | 4034 |
4034 } // namespace cc | 4035 } // namespace cc |
OLD | NEW |