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

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

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: weiliangc comment addressed Created 3 years, 7 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 host_impl_->CreatePendingTree(); 3116 host_impl_->CreatePendingTree();
3117 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 3117 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
3118 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3118 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3119 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 3119 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
3120 VERTICAL, 10, 0, false, true); 3120 VERTICAL, 10, 0, false, true);
3121 scrollbar->test_properties()->opacity = 0.f; 3121 scrollbar->test_properties()->opacity = 0.f;
3122 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 3122 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
3123 LayerImpl* container = 3123 LayerImpl* container =
3124 host_impl_->pending_tree()->InnerViewportContainerLayer(); 3124 host_impl_->pending_tree()->InnerViewportContainerLayer();
3125 scrollbar->SetScrollElementId(scroll->element_id()); 3125 scrollbar->SetScrollElementId(scroll->element_id());
3126 scrollbar->SetBounds(gfx::Size(10, 100));
3127 scrollbar->SetPosition(gfx::PointF(90, 0));
3126 container->test_properties()->AddChild(std::move(scrollbar)); 3128 container->test_properties()->AddChild(std::move(scrollbar));
3127 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3129 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3128 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3130 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3129 host_impl_->ActivateSyncTree(); 3131 host_impl_->ActivateSyncTree();
3130 3132
3131 LayerImpl* active_scrollbar_layer = 3133 LayerImpl* active_scrollbar_layer =
3132 host_impl_->active_tree()->LayerById(400); 3134 host_impl_->active_tree()->LayerById(400);
3133 3135
3134 EffectNode* active_tree_node = 3136 EffectNode* active_tree_node =
3135 host_impl_->active_tree()->property_trees()->effect_tree.Node( 3137 host_impl_->active_tree()->property_trees()->effect_tree.Node(
3136 active_scrollbar_layer->effect_tree_index()); 3138 active_scrollbar_layer->effect_tree_index());
3137 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 3139 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
3138 active_tree_node->opacity); 3140 active_tree_node->opacity);
3139 3141
3140 if (expecting_animations) { 3142 if (expecting_animations) {
3141 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id()) 3143 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id())
3142 ->DidMouseMoveNear(VERTICAL, 0); 3144 ->DidMouseMove(gfx::PointF(0, 90));
3143 } else { 3145 } else {
3144 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3146 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3145 scroll->element_id())); 3147 scroll->element_id()));
3146 } 3148 }
3147 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 3149 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
3148 InputHandler::WHEEL); 3150 InputHandler::WHEEL);
3149 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 3151 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
3150 host_impl_->ScrollEnd(EndState().get()); 3152 host_impl_->ScrollEnd(EndState().get());
3151 host_impl_->CreatePendingTree(); 3153 host_impl_->CreatePendingTree();
3152 // To test the case where the effect tree index of scrollbar layer changes, 3154 // To test the case where the effect tree index of scrollbar layer changes,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 host_impl_->CreatePendingTree(); 3212 host_impl_->CreatePendingTree();
3211 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 3213 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
3212 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3214 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3213 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 3215 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
3214 VERTICAL, 10, 0, false, true); 3216 VERTICAL, 10, 0, false, true);
3215 scrollbar->test_properties()->opacity = 0.f; 3217 scrollbar->test_properties()->opacity = 0.f;
3216 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 3218 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
3217 LayerImpl* container = 3219 LayerImpl* container =
3218 host_impl_->pending_tree()->InnerViewportContainerLayer(); 3220 host_impl_->pending_tree()->InnerViewportContainerLayer();
3219 scrollbar->SetScrollElementId(scroll->element_id()); 3221 scrollbar->SetScrollElementId(scroll->element_id());
3222 scrollbar->SetBounds(gfx::Size(10, 100));
3223 scrollbar->SetPosition(gfx::PointF(90, 0));
3220 container->test_properties()->AddChild(std::move(scrollbar)); 3224 container->test_properties()->AddChild(std::move(scrollbar));
3221 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3225 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3222 scroll->set_needs_show_scrollbars(true); 3226 scroll->set_needs_show_scrollbars(true);
3223 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3227 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3224 host_impl_->ActivateSyncTree(); 3228 host_impl_->ActivateSyncTree();
3225 3229
3226 ScrollbarAnimationController* scrollbar_controller = 3230 ScrollbarAnimationController* scrollbar_controller =
3227 host_impl_->ScrollbarAnimationControllerForElementId( 3231 host_impl_->ScrollbarAnimationControllerForElementId(
3228 scroll->element_id()); 3232 scroll->element_id());
3229 3233
3230 // Scrollbars will flash shown but we should have a fade out animation 3234 // Scrollbars will flash shown but we should have a fade out animation
3231 // queued. Run it and fade out the scrollbars. 3235 // queued. Run it and fade out the scrollbars.
3232 { 3236 {
3233 ASSERT_FALSE(animation_task_.Equals(base::Closure())); 3237 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3234 ASSERT_FALSE(animation_task_.IsCancelled()); 3238 ASSERT_FALSE(animation_task_.IsCancelled());
3235 animation_task_.Run(); 3239 animation_task_.Run();
3236 3240
3237 base::TimeTicks fake_now = base::TimeTicks::Now(); 3241 base::TimeTicks fake_now = base::TimeTicks::Now();
3238 scrollbar_controller->Animate(fake_now); 3242 scrollbar_controller->Animate(fake_now);
3239 fake_now += settings.scrollbar_fade_delay; 3243 fake_now += settings.scrollbar_fade_delay;
3240 scrollbar_controller->Animate(fake_now); 3244 scrollbar_controller->Animate(fake_now);
3241 3245
3242 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); 3246 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
3243 } 3247 }
3244 3248
3245 // Move the mouse over the scrollbar region. This should post a delayed fade 3249 // Move the mouse over the scrollbar region. This should post a delayed fade
3246 // in task. Execute it to show the scrollbars. 3250 // in task. Execute it to fade in the scrollbars.
3247 { 3251 {
3248 animation_task_ = base::Closure(); 3252 animation_task_ = base::Closure();
3249 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0); 3253 scrollbar_controller->DidMouseMove(gfx::PointF(90, 0));
3250 ASSERT_FALSE(animation_task_.Equals(base::Closure())); 3254 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3251 ASSERT_FALSE(animation_task_.IsCancelled()); 3255 ASSERT_FALSE(animation_task_.IsCancelled());
3252 } 3256 }
3253 3257
3254 // The fade in task should cause the scrollbars to show. Ensure that we 3258 // The fade in task should cause the scrollbars to show. Ensure that we
3255 // requested a redraw and a commit. 3259 // requested a redraw and a commit.
3256 { 3260 {
3257 did_request_redraw_ = false; 3261 did_request_redraw_ = false;
3258 did_request_commit_ = false; 3262 did_request_commit_ = false;
3259 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); 3263 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3441 host_impl_->SetViewportSize(device_viewport_size); 3445 host_impl_->SetViewportSize(device_viewport_size);
3442 3446
3443 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 3447 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
3444 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( 3448 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
3445 viewport_size); 3449 viewport_size);
3446 LayerImpl* root_scroll = 3450 LayerImpl* root_scroll =
3447 host_impl_->active_tree()->OuterViewportScrollLayer(); 3451 host_impl_->active_tree()->OuterViewportScrollLayer();
3448 // The scrollbar is on the left side. 3452 // The scrollbar is on the left side.
3449 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3453 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3450 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, 3454 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6,
3451 VERTICAL, 5, 5, true, true); 3455 VERTICAL, 15, 0, true, true);
3452 scrollbar->SetScrollElementId(root_scroll->element_id()); 3456 scrollbar->SetScrollElementId(root_scroll->element_id());
3453 scrollbar->SetDrawsContent(true); 3457 scrollbar->SetDrawsContent(true);
3454 scrollbar->SetBounds(scrollbar_size); 3458 scrollbar->SetBounds(scrollbar_size);
3455 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); 3459 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size));
3456 host_impl_->active_tree() 3460 host_impl_->active_tree()
3457 ->InnerViewportContainerLayer() 3461 ->InnerViewportContainerLayer()
3458 ->test_properties() 3462 ->test_properties()
3459 ->AddChild(std::move(scrollbar)); 3463 ->AddChild(std::move(scrollbar));
3460 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3464 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3461 host_impl_->active_tree()->DidBecomeActive(); 3465 host_impl_->active_tree()->DidBecomeActive();
3462 3466
3463 DrawFrame(); 3467 DrawFrame();
3464 host_impl_->active_tree()->UpdateDrawProperties(false); 3468 host_impl_->active_tree()->UpdateDrawProperties(false);
3465 3469
3466 ScrollbarAnimationController* scrollbar_animation_controller = 3470 ScrollbarAnimationController* scrollbar_animation_controller =
3467 host_impl_->ScrollbarAnimationControllerForElementId( 3471 host_impl_->ScrollbarAnimationControllerForElementId(
3468 root_scroll->element_id()); 3472 root_scroll->element_id());
3469 3473
3470 const float kMouseDistanceToTriggerAnimation = 3474 const float kMouseMoveDistanceToTriggerFadeIn =
3475 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
3476
3477 const float kMouseMoveDistanceToTriggerExpand =
3471 SingleScrollbarAnimationControllerThinning:: 3478 SingleScrollbarAnimationControllerThinning::
3472 kDefaultMouseMoveDistanceToTriggerAnimation; 3479 kMouseMoveDistanceToTriggerExpand;
3473 3480
3474 host_impl_->MouseMoveAt( 3481 host_impl_->MouseMoveAt(
3475 gfx::Point(15 + kMouseDistanceToTriggerAnimation * 2, 1)); 3482 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 1));
3476 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); 3483 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));
3484 EXPECT_FALSE(
3485 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
3477 3486
3478 host_impl_->MouseMoveAt( 3487 host_impl_->MouseMoveAt(
3479 gfx::Point(15 + kMouseDistanceToTriggerAnimation - 1, 50)); 3488 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand - 1, 10));
3480 EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); 3489 EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));
3490 EXPECT_TRUE(
3491 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
3481 3492
3482 host_impl_->MouseMoveAt( 3493 host_impl_->MouseMoveAt(
3483 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 100)); 3494 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 100));
3484 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); 3495 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));
3496 EXPECT_FALSE(
3497 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
3485 3498
3486 did_request_redraw_ = false; 3499 did_request_redraw_ = false;
3487 EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3500 EXPECT_FALSE(
3488 host_impl_->MouseMoveAt(gfx::Point(10, 100)); 3501 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3489 EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3502 host_impl_->MouseMoveAt(gfx::Point(10, 10));
3490 host_impl_->MouseMoveAt(gfx::Point(10, 120)); 3503 EXPECT_TRUE(
3491 EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3504 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3505 host_impl_->MouseMoveAt(gfx::Point(10, 0));
3506 EXPECT_TRUE(
3507 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3492 host_impl_->MouseMoveAt(gfx::Point(150, 120)); 3508 host_impl_->MouseMoveAt(gfx::Point(150, 120));
3493 EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3509 EXPECT_FALSE(
3510 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3494 } 3511 }
3495 3512
3496 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { 3513 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
3497 SetupMouseMoveAtWithDeviceScale(1.f); 3514 SetupMouseMoveAtWithDeviceScale(1.f);
3498 } 3515 }
3499 3516
3500 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3517 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3501 SetupMouseMoveAtWithDeviceScale(2.f); 3518 SetupMouseMoveAtWithDeviceScale(2.f);
3502 } 3519 }
3503 3520
(...skipping 8547 matching lines...) Expand 10 before | Expand all | Expand 10 after
12051 host_impl_->active_tree()->OuterViewportScrollLayer(); 12068 host_impl_->active_tree()->OuterViewportScrollLayer();
12052 12069
12053 if (main_thread_scrolling) { 12070 if (main_thread_scrolling) {
12054 root_scroll->set_main_thread_scrolling_reasons( 12071 root_scroll->set_main_thread_scrolling_reasons(
12055 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 12072 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
12056 } 12073 }
12057 12074
12058 // scrollbar_1 on root scroll. 12075 // scrollbar_1 on root scroll.
12059 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 = 12076 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 =
12060 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 12077 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
12061 scrollbar_1_id, VERTICAL, 5, 5, true, 12078 scrollbar_1_id, VERTICAL, 15, 0,
12062 true); 12079 true, true);
12063 scrollbar_1->SetScrollElementId(root_scroll->element_id()); 12080 scrollbar_1->SetScrollElementId(root_scroll->element_id());
12064 scrollbar_1->SetDrawsContent(true); 12081 scrollbar_1->SetDrawsContent(true);
12065 scrollbar_1->SetBounds(scrollbar_size_1); 12082 scrollbar_1->SetBounds(scrollbar_size_1);
12066 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1)); 12083 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1));
12084 scrollbar_1->SetCurrentPos(0);
12085 scrollbar_1->SetPosition(gfx::PointF(0, 0));
12067 host_impl_->active_tree() 12086 host_impl_->active_tree()
12068 ->InnerViewportContainerLayer() 12087 ->InnerViewportContainerLayer()
12069 ->test_properties() 12088 ->test_properties()
12070 ->AddChild(std::move(scrollbar_1)); 12089 ->AddChild(std::move(scrollbar_1));
12071 12090
12072 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 12091 host_impl_->active_tree()->BuildPropertyTreesForTesting();
12073 host_impl_->active_tree()->DidBecomeActive(); 12092 host_impl_->active_tree()->DidBecomeActive();
12074 12093
12075 DrawFrame(); 12094 DrawFrame();
12076 host_impl_->active_tree()->UpdateDrawProperties(false); 12095 host_impl_->active_tree()->UpdateDrawProperties(false);
12077 12096
12078 ScrollbarAnimationController* scrollbar_1_animation_controller = 12097 ScrollbarAnimationController* scrollbar_1_animation_controller =
12079 host_impl_->ScrollbarAnimationControllerForElementId( 12098 host_impl_->ScrollbarAnimationControllerForElementId(
12080 root_scroll->element_id()); 12099 root_scroll->element_id());
12081 EXPECT_TRUE(scrollbar_1_animation_controller); 12100 EXPECT_TRUE(scrollbar_1_animation_controller);
12082 12101
12083 const float kMouseDistanceToTriggerAnimation = 12102 const float kMouseMoveDistanceToTriggerFadeIn =
12103 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
12104
12105 const float kMouseMoveDistanceToTriggerExpand =
12084 SingleScrollbarAnimationControllerThinning:: 12106 SingleScrollbarAnimationControllerThinning::
12085 kDefaultMouseMoveDistanceToTriggerAnimation; 12107 kMouseMoveDistanceToTriggerExpand;
12086 12108
12087 // Mouse moves close to the scrollbar, goes over the scrollbar, and 12109 // Mouse moves close to the scrollbar, goes over the scrollbar, and
12088 // moves back to where it was. 12110 // moves back to where it was.
12089 host_impl_->MouseMoveAt( 12111 host_impl_->MouseMoveAt(
12090 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); 12112 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 0));
12091 EXPECT_FALSE( 12113 EXPECT_FALSE(
12092 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12114 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12093 EXPECT_FALSE( 12115 EXPECT_FALSE(
12094 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12116 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12117 EXPECT_FALSE(
12118 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12119
12095 host_impl_->MouseMoveAt( 12120 host_impl_->MouseMoveAt(
12096 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); 12121 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand, 0));
12097 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12122 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12098 EXPECT_FALSE( 12123 EXPECT_FALSE(
12099 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12124 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12100 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 12125 EXPECT_FALSE(
12126 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12127
12128 host_impl_->MouseMoveAt(
12129 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0));
12101 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12130 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12102 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12131 EXPECT_TRUE(
12132 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12133 EXPECT_FALSE(
12134 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12135
12136 host_impl_->MouseMoveAt(gfx::Point(10, 0));
12137 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12138 EXPECT_TRUE(
12139 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12140 EXPECT_TRUE(
12141 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12142
12103 host_impl_->MouseMoveAt( 12143 host_impl_->MouseMoveAt(
12104 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); 12144 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0));
12145 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12146 EXPECT_TRUE(
12147 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12148 EXPECT_FALSE(
12149 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12150
12151 host_impl_->MouseMoveAt(
12152 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand, 0));
12105 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12153 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12106 EXPECT_FALSE( 12154 EXPECT_FALSE(
12107 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12155 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12156 EXPECT_FALSE(
12157 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12158
12108 host_impl_->MouseMoveAt( 12159 host_impl_->MouseMoveAt(
12109 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); 12160 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 0));
12110 EXPECT_FALSE( 12161 EXPECT_FALSE(
12111 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12162 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12112 EXPECT_FALSE( 12163 EXPECT_FALSE(
12113 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12164 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12165 EXPECT_FALSE(
12166 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12114 12167
12115 // scrollbar_2 on child. 12168 // scrollbar_2 on child.
12116 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = 12169 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 =
12117 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 12170 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
12118 scrollbar_2_id, VERTICAL, 5, 5, true, 12171 scrollbar_2_id, VERTICAL, 15, 0,
12119 true); 12172 true, true);
12120 std::unique_ptr<LayerImpl> child_clip = 12173 std::unique_ptr<LayerImpl> child_clip =
12121 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 12174 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
12122 std::unique_ptr<LayerImpl> child = 12175 std::unique_ptr<LayerImpl> child =
12123 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 12176 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
12124 child->SetPosition(gfx::PointF(50, 50)); 12177 child->SetPosition(gfx::PointF(50, 50));
12125 child->SetBounds(child_layer_size); 12178 child->SetBounds(child_layer_size);
12126 child->SetDrawsContent(true); 12179 child->SetDrawsContent(true);
12127 child->SetScrollClipLayer(child_clip_id); 12180 child->SetScrollClipLayer(child_clip_id);
12128 child->SetElementId(LayerIdToElementIdForTesting(child->id())); 12181 child->SetElementId(LayerIdToElementIdForTesting(child->id()));
12129 ElementId child_element_id = child->element_id(); 12182 ElementId child_element_id = child->element_id();
12130 12183
12131 if (main_thread_scrolling) { 12184 if (main_thread_scrolling) {
12132 child->set_main_thread_scrolling_reasons( 12185 child->set_main_thread_scrolling_reasons(
12133 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 12186 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
12134 } 12187 }
12135 12188
12136 scrollbar_2->SetScrollElementId(child_element_id); 12189 scrollbar_2->SetScrollElementId(child_element_id);
12137 scrollbar_2->SetDrawsContent(true); 12190 scrollbar_2->SetDrawsContent(true);
12138 scrollbar_2->SetBounds(scrollbar_size_2); 12191 scrollbar_2->SetBounds(scrollbar_size_2);
12192 scrollbar_2->SetCurrentPos(0);
12193 scrollbar_2->SetPosition(gfx::PointF(0, 0));
12139 12194
12140 child->test_properties()->AddChild(std::move(scrollbar_2)); 12195 child->test_properties()->AddChild(std::move(scrollbar_2));
12141 child_clip->test_properties()->AddChild(std::move(child)); 12196 child_clip->test_properties()->AddChild(std::move(child));
12142 root_scroll->test_properties()->AddChild(std::move(child_clip)); 12197 root_scroll->test_properties()->AddChild(std::move(child_clip));
12143 12198
12144 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 12199 host_impl_->active_tree()->BuildPropertyTreesForTesting();
12145 host_impl_->active_tree()->DidBecomeActive(); 12200 host_impl_->active_tree()->DidBecomeActive();
12146 12201
12147 ScrollbarAnimationController* scrollbar_2_animation_controller = 12202 ScrollbarAnimationController* scrollbar_2_animation_controller =
12148 host_impl_->ScrollbarAnimationControllerForElementId(child_element_id); 12203 host_impl_->ScrollbarAnimationControllerForElementId(child_element_id);
12149 EXPECT_TRUE(scrollbar_2_animation_controller); 12204 EXPECT_TRUE(scrollbar_2_animation_controller);
12150 12205
12151 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to 12206 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to
12152 // scrollbar_1, goes over scrollbar_1. 12207 // scrollbar_1, goes over scrollbar_1.
12153 host_impl_->MouseMoveAt(gfx::Point(60, 150)); 12208 host_impl_->MouseMoveAt(gfx::Point(60, 60));
12154 EXPECT_FALSE( 12209 EXPECT_FALSE(
12155 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12210 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12156 EXPECT_FALSE( 12211 EXPECT_FALSE(
12157 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12212 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12213 EXPECT_FALSE(
12214 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12158 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12215 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12159 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12216 EXPECT_TRUE(
12217 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12218 EXPECT_TRUE(
12219 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12220
12160 host_impl_->MouseMoveAt( 12221 host_impl_->MouseMoveAt(
12161 gfx::Point(64 + kMouseDistanceToTriggerAnimation, 150)); 12222 gfx::Point(64 + kMouseMoveDistanceToTriggerExpand, 50));
12162 EXPECT_FALSE( 12223 EXPECT_FALSE(
12163 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12224 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12164 EXPECT_FALSE( 12225 EXPECT_FALSE(
12165 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12226 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12227 EXPECT_FALSE(
12228 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12166 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12229 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12230 EXPECT_TRUE(
12231 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12167 EXPECT_FALSE( 12232 EXPECT_FALSE(
12168 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12233 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12169 host_impl_->MouseMoveAt( 12234 host_impl_->MouseMoveAt(
12170 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); 12235 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0));
12171 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12236 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12237 EXPECT_TRUE(
12238 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12172 EXPECT_FALSE( 12239 EXPECT_FALSE(
12173 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12240 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12174 EXPECT_FALSE( 12241 EXPECT_FALSE(
12175 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12242 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12176 EXPECT_FALSE( 12243 EXPECT_FALSE(
12177 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12244 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12178 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 12245 EXPECT_FALSE(
12246 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12247 host_impl_->MouseMoveAt(gfx::Point(10, 0));
12179 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12248 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12180 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12249 EXPECT_TRUE(
12250 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12251 EXPECT_TRUE(
12252 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12181 EXPECT_FALSE( 12253 EXPECT_FALSE(
12182 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12254 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12183 EXPECT_FALSE( 12255 EXPECT_FALSE(
12184 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12256 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12257 EXPECT_FALSE(
12258 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12185 12259
12186 // Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an 12260 // Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an
12187 // event to fade out scrollbar_1. 12261 // event to fade out scrollbar_1.
12188 scrollbar_1_animation_controller->DidScrollUpdate(); 12262 scrollbar_1_animation_controller->DidScrollUpdate();
12189 animation_task_ = base::Closure(); 12263 animation_task_ = base::Closure();
12190 12264
12191 host_impl_->MouseDown(); 12265 host_impl_->MouseDown();
12192 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 12266 host_impl_->MouseMoveAt(gfx::Point(60, 50));
12193 host_impl_->MouseUp(); 12267 host_impl_->MouseUp();
12194 12268
12195 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 12269 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
12196 12270
12197 // Near scrollbar_1, then mouse down and up, should not post an event to fade 12271 // Near scrollbar_1, then mouse down and up, should not post an event to fade
12198 // out scrollbar_1. 12272 // out scrollbar_1.
12199 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 12273 host_impl_->MouseMoveAt(gfx::Point(40, 150));
12200 animation_task_ = base::Closure(); 12274 animation_task_ = base::Closure();
12201 12275
12202 host_impl_->MouseDown(); 12276 host_impl_->MouseDown();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
12291 else 12365 else
12292 EXPECT_FALSE(tile->HasRasterTask()); 12366 EXPECT_FALSE(tile->HasRasterTask());
12293 } 12367 }
12294 Region expected_invalidation( 12368 Region expected_invalidation(
12295 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12369 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12296 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12370 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12297 } 12371 }
12298 12372
12299 } // namespace 12373 } // namespace
12300 } // namespace cc 12374 } // namespace cc
OLDNEW
« no previous file with comments | « 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