Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into fix-669677 Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after
2794 host_impl_->ScrollEnd(EndState().get()); 2794 host_impl_->ScrollEnd(EndState().get());
2795 EXPECT_FALSE(did_request_next_frame_); 2795 EXPECT_FALSE(did_request_next_frame_);
2796 EXPECT_FALSE(did_request_redraw_); 2796 EXPECT_FALSE(did_request_redraw_);
2797 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2797 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2798 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2798 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2799 2799
2800 // Before the scrollbar animation exists, we should not get redraws. 2800 // Before the scrollbar animation exists, we should not get redraws.
2801 BeginFrameArgs begin_frame_args = 2801 BeginFrameArgs begin_frame_args =
2802 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); 2802 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now);
2803 host_impl_->WillBeginImplFrame(begin_frame_args); 2803 host_impl_->WillBeginImplFrame(begin_frame_args);
2804 host_impl_->Animate(); 2804 host_impl_->Animate(); // All Animate will check need fade out?
bokan 2017/01/06 20:17:57 I don't understand what this comment is saying.
chaopeng 2017/01/10 20:49:50 It just a note I forgot to remove...
2805 EXPECT_FALSE(did_request_next_frame_); 2805 EXPECT_FALSE(did_request_next_frame_);
2806 did_request_next_frame_ = false; 2806 did_request_next_frame_ = false;
2807 EXPECT_FALSE(did_request_redraw_); 2807 EXPECT_FALSE(did_request_redraw_);
2808 did_request_redraw_ = false; 2808 did_request_redraw_ = false;
2809 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2809 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2810 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2810 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2811 host_impl_->DidFinishImplFrame(); 2811 host_impl_->DidFinishImplFrame();
2812 2812
2813 // After a scroll, a scrollbar animation should be scheduled about 20ms from 2813 // After a scroll, a scrollbar animation should be scheduled about 20ms from
2814 // now. 2814 // now.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 host_impl_->active_tree()->LayerById(400); 2982 host_impl_->active_tree()->LayerById(400);
2983 2983
2984 EffectNode* active_tree_node = 2984 EffectNode* active_tree_node =
2985 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2985 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2986 active_scrollbar_layer->effect_tree_index()); 2986 active_scrollbar_layer->effect_tree_index());
2987 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2987 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
2988 active_tree_node->opacity); 2988 active_tree_node->opacity);
2989 2989
2990 if (expecting_animations) { 2990 if (expecting_animations) {
2991 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) 2991 host_impl_->ScrollbarAnimationControllerForId(scroll->id())
2992 ->DidMouseMoveNear(0); 2992 ->DidMouseMoveNear(VERTICAL, 0);
2993 } else { 2993 } else {
2994 EXPECT_EQ(nullptr, 2994 EXPECT_EQ(nullptr,
2995 host_impl_->ScrollbarAnimationControllerForId(scroll->id())); 2995 host_impl_->ScrollbarAnimationControllerForId(scroll->id()));
2996 } 2996 }
2997 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2997 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2998 InputHandler::WHEEL); 2998 InputHandler::WHEEL);
2999 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 2999 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
3000 host_impl_->ScrollEnd(EndState().get()); 3000 host_impl_->ScrollEnd(EndState().get());
3001 host_impl_->CreatePendingTree(); 3001 host_impl_->CreatePendingTree();
3002 // To test the case where the effect tree index of scrollbar layer changes, 3002 // 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
3242 3242
3243 DrawFrame(); 3243 DrawFrame();
3244 host_impl_->active_tree()->UpdateDrawProperties(false); 3244 host_impl_->active_tree()->UpdateDrawProperties(false);
3245 3245
3246 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = 3246 ScrollbarAnimationControllerThinning* scrollbar_animation_controller =
3247 static_cast<ScrollbarAnimationControllerThinning*>( 3247 static_cast<ScrollbarAnimationControllerThinning*>(
3248 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 3248 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
3249 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); 3249 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f);
3250 3250
3251 host_impl_->MouseMoveAt(gfx::Point(200, 1)); 3251 host_impl_->MouseMoveAt(gfx::Point(200, 1));
3252 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3252 EXPECT_FALSE(
3253 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3253 3254
3254 host_impl_->MouseMoveAt(gfx::Point(100, 50)); 3255 host_impl_->MouseMoveAt(gfx::Point(100, 50));
3255 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3256 EXPECT_TRUE(
3257 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3256 3258
3257 host_impl_->MouseMoveAt(gfx::Point(116, 100)); 3259 host_impl_->MouseMoveAt(gfx::Point(116, 100));
3258 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3260 EXPECT_FALSE(
3261 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3259 3262
3260 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f); 3263 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f);
3261 host_impl_->MouseMoveAt(gfx::Point(116, 100)); 3264 host_impl_->MouseMoveAt(gfx::Point(116, 100));
3262 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3265 EXPECT_TRUE(
3266 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3263 3267
3264 did_request_redraw_ = false; 3268 did_request_redraw_ = false;
3265 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3269 EXPECT_FALSE(
3270 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3266 host_impl_->MouseMoveAt(gfx::Point(10, 100)); 3271 host_impl_->MouseMoveAt(gfx::Point(10, 100));
3267 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3272 EXPECT_TRUE(
3273 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3268 host_impl_->MouseMoveAt(gfx::Point(10, 120)); 3274 host_impl_->MouseMoveAt(gfx::Point(10, 120));
3269 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3275 EXPECT_TRUE(
3276 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3270 host_impl_->MouseMoveAt(gfx::Point(150, 120)); 3277 host_impl_->MouseMoveAt(gfx::Point(150, 120));
3271 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar()); 3278 EXPECT_FALSE(
3279 scrollbar_animation_controller->mouse_is_over_scrollbar(VERTICAL));
3272 } 3280 }
3273 3281
3274 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { 3282 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
3275 SetupMouseMoveAtWithDeviceScale(1.f); 3283 SetupMouseMoveAtWithDeviceScale(1.f);
3276 } 3284 }
3277 3285
3278 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3286 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3279 SetupMouseMoveAtWithDeviceScale(2.f); 3287 SetupMouseMoveAtWithDeviceScale(2.f);
3280 } 3288 }
3281 3289
(...skipping 8413 matching lines...) Expand 10 before | Expand all | Expand 10 after
11695 11703
11696 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller = 11704 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller =
11697 static_cast<ScrollbarAnimationControllerThinning*>( 11705 static_cast<ScrollbarAnimationControllerThinning*>(
11698 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 11706 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
11699 EXPECT_TRUE(scrollbar_1_animation_controller); 11707 EXPECT_TRUE(scrollbar_1_animation_controller);
11700 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f); 11708 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f);
11701 11709
11702 // Mouse moves close to the scrollbar, goes over the scrollbar, and 11710 // Mouse moves close to the scrollbar, goes over the scrollbar, and
11703 // moves back to where it was. 11711 // moves back to where it was.
11704 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11712 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11705 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11713 EXPECT_FALSE(
11706 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11714 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11715 EXPECT_FALSE(
11716 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11707 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 11717 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11708 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11718 EXPECT_TRUE(
11709 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11719 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11720 EXPECT_FALSE(
11721 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11710 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11722 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11711 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11723 EXPECT_TRUE(
11712 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11724 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11725 EXPECT_TRUE(
11726 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11713 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 11727 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11714 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11728 EXPECT_TRUE(
11715 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11729 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11730 EXPECT_FALSE(
11731 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11716 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11732 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11717 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11733 EXPECT_FALSE(
11718 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11734 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11735 EXPECT_FALSE(
11736 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11719 11737
11720 // scrollbar_2 on child. 11738 // scrollbar_2 on child.
11721 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = 11739 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 =
11722 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 11740 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
11723 scrollbar_2_id, VERTICAL, 5, 5, true, 11741 scrollbar_2_id, VERTICAL, 5, 5, true,
11724 true); 11742 true);
11725 std::unique_ptr<LayerImpl> child_clip = 11743 std::unique_ptr<LayerImpl> child_clip =
11726 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 11744 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
11727 std::unique_ptr<LayerImpl> child = 11745 std::unique_ptr<LayerImpl> child =
11728 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 11746 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
(...skipping 15 matching lines...) Expand all
11744 11762
11745 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller = 11763 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller =
11746 static_cast<ScrollbarAnimationControllerThinning*>( 11764 static_cast<ScrollbarAnimationControllerThinning*>(
11747 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); 11765 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
11748 EXPECT_TRUE(scrollbar_2_animation_controller); 11766 EXPECT_TRUE(scrollbar_2_animation_controller);
11749 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f); 11767 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f);
11750 11768
11751 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to 11769 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to
11752 // scrollbar_1, goes over scrollbar_1. 11770 // scrollbar_1, goes over scrollbar_1.
11753 host_impl_->MouseMoveAt(gfx::Point(60, 150)); 11771 host_impl_->MouseMoveAt(gfx::Point(60, 150));
11754 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11772 EXPECT_FALSE(
11755 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11773 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11756 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11774 EXPECT_FALSE(
11757 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11775 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11776 EXPECT_TRUE(
11777 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11778 EXPECT_TRUE(
11779 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11758 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11780 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11759 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11781 EXPECT_FALSE(
11760 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11782 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11761 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11783 EXPECT_FALSE(
11762 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11784 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11785 EXPECT_TRUE(
11786 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11787 EXPECT_FALSE(
11788 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11763 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 11789 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11764 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11790 EXPECT_TRUE(
11765 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11791 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11766 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11792 EXPECT_FALSE(
11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11793 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11794 EXPECT_FALSE(
11795 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11796 EXPECT_FALSE(
11797 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11768 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11798 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11769 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11799 EXPECT_TRUE(
11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11800 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11771 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11801 EXPECT_TRUE(
11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11802 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11803 EXPECT_FALSE(
11804 scrollbar_2_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11805 EXPECT_FALSE(
11806 scrollbar_2_animation_controller->mouse_is_over_scrollbar(VERTICAL));
11773 } 11807 }
11774 11808
11775 } // namespace 11809 } // namespace
11776 } // namespace cc 11810 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698