| 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> |
| (...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2937 host_impl_->active_tree()->LayerById(400); | 2937 host_impl_->active_tree()->LayerById(400); |
| 2938 | 2938 |
| 2939 EffectNode* active_tree_node = | 2939 EffectNode* active_tree_node = |
| 2940 host_impl_->active_tree()->property_trees()->effect_tree.Node( | 2940 host_impl_->active_tree()->property_trees()->effect_tree.Node( |
| 2941 active_scrollbar_layer->effect_tree_index()); | 2941 active_scrollbar_layer->effect_tree_index()); |
| 2942 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), | 2942 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), |
| 2943 active_tree_node->opacity); | 2943 active_tree_node->opacity); |
| 2944 | 2944 |
| 2945 if (expecting_animations) { | 2945 if (expecting_animations) { |
| 2946 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) | 2946 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) |
| 2947 ->DidMouseMoveNear(0); | 2947 ->DidMouseMoveNear(VERTICAL, 0); |
| 2948 } else { | 2948 } else { |
| 2949 EXPECT_EQ(nullptr, | 2949 EXPECT_EQ(nullptr, |
| 2950 host_impl_->ScrollbarAnimationControllerForId(scroll->id())); | 2950 host_impl_->ScrollbarAnimationControllerForId(scroll->id())); |
| 2951 } | 2951 } |
| 2952 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2952 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2953 InputHandler::WHEEL); | 2953 InputHandler::WHEEL); |
| 2954 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 2954 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
| 2955 host_impl_->ScrollEnd(EndState().get()); | 2955 host_impl_->ScrollEnd(EndState().get()); |
| 2956 host_impl_->CreatePendingTree(); | 2956 host_impl_->CreatePendingTree(); |
| 2957 // To test the case where the effect tree index of scrollbar layer changes, | 2957 // To test the case where the effect tree index of scrollbar layer changes, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 | 3197 |
| 3198 DrawFrame(); | 3198 DrawFrame(); |
| 3199 host_impl_->active_tree()->UpdateDrawProperties(false); | 3199 host_impl_->active_tree()->UpdateDrawProperties(false); |
| 3200 | 3200 |
| 3201 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 3201 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |
| 3202 static_cast<ScrollbarAnimationControllerThinning*>( | 3202 static_cast<ScrollbarAnimationControllerThinning*>( |
| 3203 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 3203 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
| 3204 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | 3204 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); |
| 3205 | 3205 |
| 3206 host_impl_->MouseMoveAt(gfx::Point(200, 1)); | 3206 host_impl_->MouseMoveAt(gfx::Point(200, 1)); |
| 3207 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); | 3207 EXPECT_FALSE( |
| 3208 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3208 | 3209 |
| 3209 host_impl_->MouseMoveAt(gfx::Point(100, 50)); | 3210 host_impl_->MouseMoveAt(gfx::Point(100, 50)); |
| 3210 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); | 3211 EXPECT_TRUE( |
| 3212 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3211 | 3213 |
| 3212 host_impl_->MouseMoveAt(gfx::Point(116, 100)); | 3214 host_impl_->MouseMoveAt(gfx::Point(116, 100)); |
| 3213 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); | 3215 EXPECT_FALSE( |
| 3216 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3214 | 3217 |
| 3215 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f); | 3218 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f); |
| 3216 host_impl_->MouseMoveAt(gfx::Point(116, 100)); | 3219 host_impl_->MouseMoveAt(gfx::Point(116, 100)); |
| 3217 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); | 3220 EXPECT_TRUE( |
| 3221 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 3218 | 3222 |
| 3219 did_request_redraw_ = false; | 3223 did_request_redraw_ = false; |
| 3220 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar()); | 3224 EXPECT_FALSE( |
| 3225 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3221 host_impl_->MouseMoveAt(gfx::Point(10, 100)); | 3226 host_impl_->MouseMoveAt(gfx::Point(10, 100)); |
| 3222 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar()); | 3227 EXPECT_TRUE( |
| 3228 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3223 host_impl_->MouseMoveAt(gfx::Point(10, 120)); | 3229 host_impl_->MouseMoveAt(gfx::Point(10, 120)); |
| 3224 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar()); | 3230 EXPECT_TRUE( |
| 3231 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3225 host_impl_->MouseMoveAt(gfx::Point(150, 120)); | 3232 host_impl_->MouseMoveAt(gfx::Point(150, 120)); |
| 3226 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar()); | 3233 EXPECT_FALSE( |
| 3234 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 3227 } | 3235 } |
| 3228 | 3236 |
| 3229 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { | 3237 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { |
| 3230 SetupMouseMoveAtWithDeviceScale(1.f); | 3238 SetupMouseMoveAtWithDeviceScale(1.f); |
| 3231 } | 3239 } |
| 3232 | 3240 |
| 3233 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { | 3241 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { |
| 3234 SetupMouseMoveAtWithDeviceScale(2.f); | 3242 SetupMouseMoveAtWithDeviceScale(2.f); |
| 3235 } | 3243 } |
| 3236 | 3244 |
| (...skipping 8419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11656 | 11664 |
| 11657 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller = | 11665 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller = |
| 11658 static_cast<ScrollbarAnimationControllerThinning*>( | 11666 static_cast<ScrollbarAnimationControllerThinning*>( |
| 11659 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 11667 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
| 11660 EXPECT_TRUE(scrollbar_1_animation_controller); | 11668 EXPECT_TRUE(scrollbar_1_animation_controller); |
| 11661 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f); | 11669 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f); |
| 11662 | 11670 |
| 11663 // Mouse moves close to the scrollbar, goes over the scrollbar, and | 11671 // Mouse moves close to the scrollbar, goes over the scrollbar, and |
| 11664 // moves back to where it was. | 11672 // moves back to where it was. |
| 11665 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 11673 host_impl_->MouseMoveAt(gfx::Point(100, 150)); |
| 11666 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11674 EXPECT_FALSE( |
| 11667 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11675 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11676 EXPECT_FALSE( |
| 11677 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11668 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 11678 host_impl_->MouseMoveAt(gfx::Point(40, 150)); |
| 11669 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11679 EXPECT_TRUE( |
| 11670 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11680 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11681 EXPECT_FALSE( |
| 11682 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11671 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11683 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11672 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11684 EXPECT_TRUE( |
| 11673 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11685 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11686 EXPECT_TRUE( |
| 11687 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11674 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 11688 host_impl_->MouseMoveAt(gfx::Point(40, 150)); |
| 11675 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11689 EXPECT_TRUE( |
| 11676 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11690 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11691 EXPECT_FALSE( |
| 11692 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11677 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 11693 host_impl_->MouseMoveAt(gfx::Point(100, 150)); |
| 11678 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11694 EXPECT_FALSE( |
| 11679 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11695 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11696 EXPECT_FALSE( |
| 11697 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11680 | 11698 |
| 11681 // scrollbar_2 on child. | 11699 // scrollbar_2 on child. |
| 11682 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = | 11700 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = |
| 11683 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), | 11701 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), |
| 11684 scrollbar_2_id, VERTICAL, 5, 5, true, | 11702 scrollbar_2_id, VERTICAL, 5, 5, true, |
| 11685 true); | 11703 true); |
| 11686 std::unique_ptr<LayerImpl> child_clip = | 11704 std::unique_ptr<LayerImpl> child_clip = |
| 11687 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 11705 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); |
| 11688 std::unique_ptr<LayerImpl> child = | 11706 std::unique_ptr<LayerImpl> child = |
| 11689 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); | 11707 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 11710 | 11728 |
| 11711 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller = | 11729 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller = |
| 11712 static_cast<ScrollbarAnimationControllerThinning*>( | 11730 static_cast<ScrollbarAnimationControllerThinning*>( |
| 11713 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); | 11731 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); |
| 11714 EXPECT_TRUE(scrollbar_2_animation_controller); | 11732 EXPECT_TRUE(scrollbar_2_animation_controller); |
| 11715 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f); | 11733 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f); |
| 11716 | 11734 |
| 11717 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to | 11735 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to |
| 11718 // scrollbar_1, goes over scrollbar_1. | 11736 // scrollbar_1, goes over scrollbar_1. |
| 11719 host_impl_->MouseMoveAt(gfx::Point(60, 150)); | 11737 host_impl_->MouseMoveAt(gfx::Point(60, 150)); |
| 11720 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11738 EXPECT_FALSE( |
| 11721 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11739 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11722 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11740 EXPECT_FALSE( |
| 11723 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11741 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11742 EXPECT_TRUE( |
| 11743 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11744 EXPECT_TRUE( |
| 11745 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11724 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 11746 host_impl_->MouseMoveAt(gfx::Point(100, 150)); |
| 11725 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11747 EXPECT_FALSE( |
| 11726 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11748 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11727 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11749 EXPECT_FALSE( |
| 11728 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11750 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11751 EXPECT_TRUE( |
| 11752 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11753 EXPECT_FALSE( |
| 11754 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11729 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 11755 host_impl_->MouseMoveAt(gfx::Point(40, 150)); |
| 11730 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11756 EXPECT_TRUE( |
| 11731 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11757 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11732 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11758 EXPECT_FALSE( |
| 11733 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11759 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11760 EXPECT_FALSE( |
| 11761 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11762 EXPECT_FALSE( |
| 11763 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11734 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11764 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11735 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11765 EXPECT_TRUE( |
| 11736 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11766 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11737 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11767 EXPECT_TRUE( |
| 11738 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11768 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11769 EXPECT_FALSE( |
| 11770 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL)); |
| 11771 EXPECT_FALSE( |
| 11772 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL)); |
| 11739 } | 11773 } |
| 11740 | 11774 |
| 11741 TEST_F(LayerTreeHostImplTest, | 11775 TEST_F(LayerTreeHostImplTest, |
| 11742 LayerTreeHostImplTestScrollbarStatesInMainThreadScorlling) { | 11776 LayerTreeHostImplTestScrollbarStatesInMainThreadScorlling) { |
| 11743 SetupMouseMoveAtTestScrollbarStates(true); | 11777 SetupMouseMoveAtTestScrollbarStates(true); |
| 11744 } | 11778 } |
| 11745 | 11779 |
| 11746 TEST_F(LayerTreeHostImplTest, | 11780 TEST_F(LayerTreeHostImplTest, |
| 11747 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { | 11781 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { |
| 11748 SetupMouseMoveAtTestScrollbarStates(false); | 11782 SetupMouseMoveAtTestScrollbarStates(false); |
| 11749 } | 11783 } |
| 11750 | 11784 |
| 11751 } // namespace | 11785 } // namespace |
| 11752 } // namespace cc | 11786 } // namespace cc |
| OLD | NEW |