| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "cc/animation/animation_host.h" | 18 #include "cc/animation/animation_host.h" |
| 19 #include "cc/animation/animation_id_provider.h" | 19 #include "cc/animation/animation_id_provider.h" |
| 20 #include "cc/animation/transform_operations.h" | 20 #include "cc/animation/transform_operations.h" |
| 21 #include "cc/base/math_util.h" | 21 #include "cc/base/math_util.h" |
| 22 #include "cc/input/browser_controls_offset_manager.h" | 22 #include "cc/input/browser_controls_offset_manager.h" |
| 23 #include "cc/input/main_thread_scrolling_reason.h" | 23 #include "cc/input/main_thread_scrolling_reason.h" |
| 24 #include "cc/input/page_scale_animation.h" | 24 #include "cc/input/page_scale_animation.h" |
| 25 #include "cc/input/scrollbar_animation_controller_thinning.h" | |
| 26 #include "cc/layers/append_quads_data.h" | 25 #include "cc/layers/append_quads_data.h" |
| 27 #include "cc/layers/heads_up_display_layer_impl.h" | 26 #include "cc/layers/heads_up_display_layer_impl.h" |
| 28 #include "cc/layers/layer_impl.h" | 27 #include "cc/layers/layer_impl.h" |
| 29 #include "cc/layers/painted_scrollbar_layer_impl.h" | 28 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 30 #include "cc/layers/render_surface_impl.h" | 29 #include "cc/layers/render_surface_impl.h" |
| 31 #include "cc/layers/solid_color_layer_impl.h" | 30 #include "cc/layers/solid_color_layer_impl.h" |
| 32 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 31 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 33 #include "cc/layers/texture_layer_impl.h" | 32 #include "cc/layers/texture_layer_impl.h" |
| 34 #include "cc/layers/video_layer_impl.h" | 33 #include "cc/layers/video_layer_impl.h" |
| 35 #include "cc/layers/viewport.h" | 34 #include "cc/layers/viewport.h" |
| (...skipping 2846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2882 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2881 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2883 requested_animation_delay_ = base::TimeDelta(); | 2882 requested_animation_delay_ = base::TimeDelta(); |
| 2884 animation_task_ = base::Closure(); | 2883 animation_task_ = base::Closure(); |
| 2885 } else { | 2884 } else { |
| 2886 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2885 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2887 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2886 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2888 } | 2887 } |
| 2889 } | 2888 } |
| 2890 }; | 2889 }; |
| 2891 | 2890 |
| 2892 TEST_F(LayerTreeHostImplTestScrollbarAnimation, LinearFade) { | 2891 TEST_F(LayerTreeHostImplTestScrollbarAnimation, Android) { |
| 2893 RunTest(LayerTreeSettings::LINEAR_FADE); | 2892 RunTest(LayerTreeSettings::ANDROID_OVERLAY); |
| 2894 } | 2893 } |
| 2895 | 2894 |
| 2896 TEST_F(LayerTreeHostImplTestScrollbarAnimation, Thinning) { | 2895 TEST_F(LayerTreeHostImplTestScrollbarAnimation, AuraOverlay) { |
| 2897 RunTest(LayerTreeSettings::THINNING); | 2896 RunTest(LayerTreeSettings::AURA_OVERLAY); |
| 2898 } | 2897 } |
| 2899 | 2898 |
| 2900 TEST_F(LayerTreeHostImplTestScrollbarAnimation, NoAnimator) { | 2899 TEST_F(LayerTreeHostImplTestScrollbarAnimation, NoAnimator) { |
| 2901 RunTest(LayerTreeSettings::NO_ANIMATOR); | 2900 RunTest(LayerTreeSettings::NO_ANIMATOR); |
| 2902 } | 2901 } |
| 2903 | 2902 |
| 2904 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { | 2903 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { |
| 2905 protected: | 2904 protected: |
| 2906 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2905 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 2907 LayerTreeSettings settings = DefaultSettings(); | 2906 LayerTreeSettings settings = DefaultSettings(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 if (expecting_animations) { | 2980 if (expecting_animations) { |
| 2982 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); | 2981 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); |
| 2983 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); | 2982 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); |
| 2984 } else { | 2983 } else { |
| 2985 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity); | 2984 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity); |
| 2986 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity()); | 2985 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity()); |
| 2987 } | 2986 } |
| 2988 } | 2987 } |
| 2989 }; | 2988 }; |
| 2990 | 2989 |
| 2991 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) { | 2990 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Android) { |
| 2992 RunTest(LayerTreeSettings::LINEAR_FADE); | 2991 RunTest(LayerTreeSettings::ANDROID_OVERLAY); |
| 2993 } | 2992 } |
| 2994 | 2993 |
| 2995 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { | 2994 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) { |
| 2996 RunTest(LayerTreeSettings::THINNING); | 2995 RunTest(LayerTreeSettings::AURA_OVERLAY); |
| 2997 } | 2996 } |
| 2998 | 2997 |
| 2999 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { | 2998 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { |
| 3000 RunTest(LayerTreeSettings::NO_ANIMATOR); | 2999 RunTest(LayerTreeSettings::NO_ANIMATOR); |
| 3001 } | 3000 } |
| 3002 | 3001 |
| 3003 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { | 3002 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { |
| 3004 LayerTreeSettings settings = DefaultSettings(); | 3003 LayerTreeSettings settings = DefaultSettings(); |
| 3005 CreateHostImpl(settings, CreateCompositorFrameSink()); | 3004 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3006 | 3005 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3029 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 3028 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); |
| 3030 child->SetBounds(inner_viewport_size); | 3029 child->SetBounds(inner_viewport_size); |
| 3031 | 3030 |
| 3032 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); | 3031 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); |
| 3033 | 3032 |
| 3034 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); | 3033 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); |
| 3035 } | 3034 } |
| 3036 | 3035 |
| 3037 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { | 3036 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { |
| 3038 LayerTreeSettings settings = DefaultSettings(); | 3037 LayerTreeSettings settings = DefaultSettings(); |
| 3039 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; | 3038 settings.scrollbar_animator = LayerTreeSettings::ANDROID_OVERLAY; |
| 3040 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); | 3039 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); |
| 3041 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); | 3040 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); |
| 3042 CreateHostImpl(settings, CreateCompositorFrameSink()); | 3041 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3043 | 3042 |
| 3044 gfx::Size viewport_size(300, 200); | 3043 gfx::Size viewport_size(300, 200); |
| 3045 gfx::Size content_size(1000, 1000); | 3044 gfx::Size content_size(1000, 1000); |
| 3046 | 3045 |
| 3047 const int vert_1_id = 10; | 3046 const int vert_1_id = 10; |
| 3048 const int horiz_1_id = 11; | 3047 const int horiz_1_id = 11; |
| 3049 const int vert_2_id = 12; | 3048 const int vert_2_id = 12; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3152 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 3151 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 3153 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20)); | 3152 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20)); |
| 3154 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 3153 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 3155 } | 3154 } |
| 3156 | 3155 |
| 3157 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( | 3156 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( |
| 3158 float device_scale_factor) { | 3157 float device_scale_factor) { |
| 3159 LayerTreeSettings settings = DefaultSettings(); | 3158 LayerTreeSettings settings = DefaultSettings(); |
| 3160 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); | 3159 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); |
| 3161 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); | 3160 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); |
| 3162 settings.scrollbar_animator = LayerTreeSettings::THINNING; | 3161 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; |
| 3163 | 3162 |
| 3164 gfx::Size viewport_size(300, 200); | 3163 gfx::Size viewport_size(300, 200); |
| 3165 gfx::Size device_viewport_size = | 3164 gfx::Size device_viewport_size = |
| 3166 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor); | 3165 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor); |
| 3167 gfx::Size content_size(1000, 1000); | 3166 gfx::Size content_size(1000, 1000); |
| 3168 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height())); | 3167 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height())); |
| 3169 | 3168 |
| 3170 CreateHostImpl(settings, CreateCompositorFrameSink()); | 3169 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3171 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); | 3170 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 3172 host_impl_->SetViewportSize(device_viewport_size); | 3171 host_impl_->SetViewportSize(device_viewport_size); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3187 host_impl_->active_tree() | 3186 host_impl_->active_tree() |
| 3188 ->InnerViewportContainerLayer() | 3187 ->InnerViewportContainerLayer() |
| 3189 ->test_properties() | 3188 ->test_properties() |
| 3190 ->AddChild(std::move(scrollbar)); | 3189 ->AddChild(std::move(scrollbar)); |
| 3191 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3190 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3192 host_impl_->active_tree()->DidBecomeActive(); | 3191 host_impl_->active_tree()->DidBecomeActive(); |
| 3193 | 3192 |
| 3194 DrawFrame(); | 3193 DrawFrame(); |
| 3195 host_impl_->active_tree()->UpdateDrawProperties(false); | 3194 host_impl_->active_tree()->UpdateDrawProperties(false); |
| 3196 | 3195 |
| 3197 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 3196 ScrollbarAnimationController* scrollbar_animation_controller = |
| 3198 static_cast<ScrollbarAnimationControllerThinning*>( | 3197 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()); |
| 3199 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | |
| 3200 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | |
| 3201 | 3198 |
| 3202 host_impl_->MouseMoveAt(gfx::Point(200, 1)); | 3199 const float kMouseDistanceToTriggerAnimation = |
| 3200 SingleScrollbarAnimationControllerThinning:: |
| 3201 kDefaultMouseMoveDistanceToTriggerAnimation; |
| 3202 |
| 3203 host_impl_->MouseMoveAt( |
| 3204 gfx::Point(15 + kMouseDistanceToTriggerAnimation * 2, 1)); |
| 3203 EXPECT_FALSE( | 3205 EXPECT_FALSE( |
| 3204 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 3206 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3205 | 3207 |
| 3206 host_impl_->MouseMoveAt(gfx::Point(100, 50)); | 3208 host_impl_->MouseMoveAt( |
| 3209 gfx::Point(15 + kMouseDistanceToTriggerAnimation - 1, 50)); |
| 3207 EXPECT_TRUE( | 3210 EXPECT_TRUE( |
| 3208 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 3211 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3209 | 3212 |
| 3210 host_impl_->MouseMoveAt(gfx::Point(116, 100)); | 3213 host_impl_->MouseMoveAt( |
| 3214 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 100)); |
| 3211 EXPECT_FALSE( | 3215 EXPECT_FALSE( |
| 3212 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 3216 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3213 | 3217 |
| 3214 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f); | |
| 3215 host_impl_->MouseMoveAt(gfx::Point(116, 100)); | |
| 3216 EXPECT_TRUE( | |
| 3217 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | |
| 3218 | |
| 3219 did_request_redraw_ = false; | 3218 did_request_redraw_ = false; |
| 3220 EXPECT_FALSE( | 3219 EXPECT_FALSE( |
| 3221 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 3220 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3222 host_impl_->MouseMoveAt(gfx::Point(10, 100)); | 3221 host_impl_->MouseMoveAt(gfx::Point(10, 100)); |
| 3223 EXPECT_TRUE( | 3222 EXPECT_TRUE( |
| 3224 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 3223 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3225 host_impl_->MouseMoveAt(gfx::Point(10, 120)); | 3224 host_impl_->MouseMoveAt(gfx::Point(10, 120)); |
| 3226 EXPECT_TRUE( | 3225 EXPECT_TRUE( |
| 3227 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 3226 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3228 host_impl_->MouseMoveAt(gfx::Point(150, 120)); | 3227 host_impl_->MouseMoveAt(gfx::Point(150, 120)); |
| (...skipping 8326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11555 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11554 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11556 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11555 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11557 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11556 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11558 } | 11557 } |
| 11559 | 11558 |
| 11560 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates( | 11559 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates( |
| 11561 bool main_thread_scrolling) { | 11560 bool main_thread_scrolling) { |
| 11562 LayerTreeSettings settings = DefaultSettings(); | 11561 LayerTreeSettings settings = DefaultSettings(); |
| 11563 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); | 11562 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); |
| 11564 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); | 11563 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); |
| 11565 settings.scrollbar_animator = LayerTreeSettings::THINNING; | 11564 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; |
| 11566 | 11565 |
| 11567 gfx::Size viewport_size(300, 200); | 11566 gfx::Size viewport_size(300, 200); |
| 11568 gfx::Size content_size(1000, 1000); | 11567 gfx::Size content_size(1000, 1000); |
| 11569 gfx::Size child_layer_size(250, 150); | 11568 gfx::Size child_layer_size(250, 150); |
| 11570 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height())); | 11569 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height())); |
| 11571 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height())); | 11570 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height())); |
| 11572 | 11571 |
| 11573 const int scrollbar_1_id = 10; | 11572 const int scrollbar_1_id = 10; |
| 11574 const int scrollbar_2_id = 11; | 11573 const int scrollbar_2_id = 11; |
| 11575 const int child_clip_id = 12; | 11574 const int child_clip_id = 12; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11602 ->InnerViewportContainerLayer() | 11601 ->InnerViewportContainerLayer() |
| 11603 ->test_properties() | 11602 ->test_properties() |
| 11604 ->AddChild(std::move(scrollbar_1)); | 11603 ->AddChild(std::move(scrollbar_1)); |
| 11605 | 11604 |
| 11606 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 11605 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 11607 host_impl_->active_tree()->DidBecomeActive(); | 11606 host_impl_->active_tree()->DidBecomeActive(); |
| 11608 | 11607 |
| 11609 DrawFrame(); | 11608 DrawFrame(); |
| 11610 host_impl_->active_tree()->UpdateDrawProperties(false); | 11609 host_impl_->active_tree()->UpdateDrawProperties(false); |
| 11611 | 11610 |
| 11612 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller = | 11611 ScrollbarAnimationController* scrollbar_1_animation_controller = |
| 11613 static_cast<ScrollbarAnimationControllerThinning*>( | 11612 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()); |
| 11614 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | |
| 11615 EXPECT_TRUE(scrollbar_1_animation_controller); | 11613 EXPECT_TRUE(scrollbar_1_animation_controller); |
| 11616 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f); | 11614 |
| 11615 const float kMouseDistanceToTriggerAnimation = |
| 11616 SingleScrollbarAnimationControllerThinning:: |
| 11617 kDefaultMouseMoveDistanceToTriggerAnimation; |
| 11617 | 11618 |
| 11618 // Mouse moves close to the scrollbar, goes over the scrollbar, and | 11619 // Mouse moves close to the scrollbar, goes over the scrollbar, and |
| 11619 // moves back to where it was. | 11620 // moves back to where it was. |
| 11620 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 11621 host_impl_->MouseMoveAt( |
| 11622 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); |
| 11621 EXPECT_FALSE( | 11623 EXPECT_FALSE( |
| 11622 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11624 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11623 EXPECT_FALSE( | 11625 EXPECT_FALSE( |
| 11624 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11626 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11625 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 11627 host_impl_->MouseMoveAt( |
| 11628 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); |
| 11626 EXPECT_TRUE( | 11629 EXPECT_TRUE( |
| 11627 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11630 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11628 EXPECT_FALSE( | 11631 EXPECT_FALSE( |
| 11629 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11632 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11630 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11633 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11631 EXPECT_TRUE( | 11634 EXPECT_TRUE( |
| 11632 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11635 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11633 EXPECT_TRUE( | 11636 EXPECT_TRUE( |
| 11634 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11637 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11635 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 11638 host_impl_->MouseMoveAt( |
| 11639 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); |
| 11636 EXPECT_TRUE( | 11640 EXPECT_TRUE( |
| 11637 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11641 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11638 EXPECT_FALSE( | 11642 EXPECT_FALSE( |
| 11639 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11643 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11640 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 11644 host_impl_->MouseMoveAt( |
| 11645 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); |
| 11641 EXPECT_FALSE( | 11646 EXPECT_FALSE( |
| 11642 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11647 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11643 EXPECT_FALSE( | 11648 EXPECT_FALSE( |
| 11644 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11649 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11645 | 11650 |
| 11646 // scrollbar_2 on child. | 11651 // scrollbar_2 on child. |
| 11647 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = | 11652 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = |
| 11648 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), | 11653 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), |
| 11649 scrollbar_2_id, VERTICAL, 5, 5, true, | 11654 scrollbar_2_id, VERTICAL, 5, 5, true, |
| 11650 true); | 11655 true); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 11666 scrollbar_2->SetDrawsContent(true); | 11671 scrollbar_2->SetDrawsContent(true); |
| 11667 scrollbar_2->SetBounds(scrollbar_size_2); | 11672 scrollbar_2->SetBounds(scrollbar_size_2); |
| 11668 | 11673 |
| 11669 child->test_properties()->AddChild(std::move(scrollbar_2)); | 11674 child->test_properties()->AddChild(std::move(scrollbar_2)); |
| 11670 child_clip->test_properties()->AddChild(std::move(child)); | 11675 child_clip->test_properties()->AddChild(std::move(child)); |
| 11671 root_scroll->test_properties()->AddChild(std::move(child_clip)); | 11676 root_scroll->test_properties()->AddChild(std::move(child_clip)); |
| 11672 | 11677 |
| 11673 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 11678 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 11674 host_impl_->active_tree()->DidBecomeActive(); | 11679 host_impl_->active_tree()->DidBecomeActive(); |
| 11675 | 11680 |
| 11676 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller = | 11681 ScrollbarAnimationController* scrollbar_2_animation_controller = |
| 11677 static_cast<ScrollbarAnimationControllerThinning*>( | 11682 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id); |
| 11678 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); | |
| 11679 EXPECT_TRUE(scrollbar_2_animation_controller); | 11683 EXPECT_TRUE(scrollbar_2_animation_controller); |
| 11680 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f); | |
| 11681 | 11684 |
| 11682 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to | 11685 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to |
| 11683 // scrollbar_1, goes over scrollbar_1. | 11686 // scrollbar_1, goes over scrollbar_1. |
| 11684 host_impl_->MouseMoveAt(gfx::Point(60, 150)); | 11687 host_impl_->MouseMoveAt(gfx::Point(60, 150)); |
| 11685 EXPECT_FALSE( | 11688 EXPECT_FALSE( |
| 11686 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11689 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11687 EXPECT_FALSE( | 11690 EXPECT_FALSE( |
| 11688 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11691 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11689 EXPECT_TRUE( | 11692 EXPECT_TRUE( |
| 11690 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11693 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11691 EXPECT_TRUE( | 11694 EXPECT_TRUE( |
| 11692 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11695 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11693 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 11696 host_impl_->MouseMoveAt( |
| 11697 gfx::Point(64 + kMouseDistanceToTriggerAnimation, 150)); |
| 11694 EXPECT_FALSE( | 11698 EXPECT_FALSE( |
| 11695 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11699 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11696 EXPECT_FALSE( | 11700 EXPECT_FALSE( |
| 11697 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11701 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11698 EXPECT_TRUE( | 11702 EXPECT_TRUE( |
| 11699 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11703 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11700 EXPECT_FALSE( | 11704 EXPECT_FALSE( |
| 11701 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11705 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11702 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 11706 host_impl_->MouseMoveAt( |
| 11707 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); |
| 11703 EXPECT_TRUE( | 11708 EXPECT_TRUE( |
| 11704 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11709 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11705 EXPECT_FALSE( | 11710 EXPECT_FALSE( |
| 11706 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11711 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11707 EXPECT_FALSE( | 11712 EXPECT_FALSE( |
| 11708 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); | 11713 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11709 EXPECT_FALSE( | 11714 EXPECT_FALSE( |
| 11710 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); | 11715 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11711 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11716 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11712 EXPECT_TRUE( | 11717 EXPECT_TRUE( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 11734 SetupMouseMoveAtTestScrollbarStates(true); | 11739 SetupMouseMoveAtTestScrollbarStates(true); |
| 11735 } | 11740 } |
| 11736 | 11741 |
| 11737 TEST_F(LayerTreeHostImplTest, | 11742 TEST_F(LayerTreeHostImplTest, |
| 11738 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { | 11743 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { |
| 11739 SetupMouseMoveAtTestScrollbarStates(false); | 11744 SetupMouseMoveAtTestScrollbarStates(false); |
| 11740 } | 11745 } |
| 11741 | 11746 |
| 11742 } // namespace | 11747 } // namespace |
| 11743 } // namespace cc | 11748 } // namespace cc |
| OLD | NEW |