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 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3164 host_impl_->CreatePendingTree(); | 3164 host_impl_->CreatePendingTree(); |
3165 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); | 3165 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
3166 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 3166 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
3167 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 3167 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
3168 VERTICAL, 10, 0, false, true); | 3168 VERTICAL, 10, 0, false, true); |
3169 scrollbar->test_properties()->opacity = 0.f; | 3169 scrollbar->test_properties()->opacity = 0.f; |
3170 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 3170 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
3171 LayerImpl* container = | 3171 LayerImpl* container = |
3172 host_impl_->pending_tree()->InnerViewportContainerLayer(); | 3172 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
3173 scrollbar->SetScrollElementId(scroll->element_id()); | 3173 scrollbar->SetScrollElementId(scroll->element_id()); |
| 3174 scrollbar->SetBounds(gfx::Size(10, 100)); |
| 3175 scrollbar->SetPosition(gfx::PointF(90, 0)); |
3174 container->test_properties()->AddChild(std::move(scrollbar)); | 3176 container->test_properties()->AddChild(std::move(scrollbar)); |
3175 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3177 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
3176 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 3178 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
3177 host_impl_->ActivateSyncTree(); | 3179 host_impl_->ActivateSyncTree(); |
3178 | 3180 |
3179 LayerImpl* active_scrollbar_layer = | 3181 LayerImpl* active_scrollbar_layer = |
3180 host_impl_->active_tree()->LayerById(400); | 3182 host_impl_->active_tree()->LayerById(400); |
3181 | 3183 |
3182 EffectNode* active_tree_node = | 3184 EffectNode* active_tree_node = |
3183 host_impl_->active_tree()->property_trees()->effect_tree.Node( | 3185 host_impl_->active_tree()->property_trees()->effect_tree.Node( |
3184 active_scrollbar_layer->effect_tree_index()); | 3186 active_scrollbar_layer->effect_tree_index()); |
3185 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), | 3187 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), |
3186 active_tree_node->opacity); | 3188 active_tree_node->opacity); |
3187 | 3189 |
3188 if (expecting_animations) { | 3190 if (expecting_animations) { |
3189 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id()) | 3191 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id()) |
3190 ->DidMouseMoveNear(VERTICAL, 0); | 3192 ->DidMouseMove(gfx::PointF(0, 90)); |
3191 } else { | 3193 } else { |
3192 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( | 3194 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( |
3193 scroll->element_id())); | 3195 scroll->element_id())); |
3194 } | 3196 } |
3195 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3197 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
3196 InputHandler::WHEEL); | 3198 InputHandler::WHEEL); |
3197 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 3199 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
3198 host_impl_->ScrollEnd(EndState().get()); | 3200 host_impl_->ScrollEnd(EndState().get()); |
3199 host_impl_->CreatePendingTree(); | 3201 host_impl_->CreatePendingTree(); |
3200 // To test the case where the effect tree index of scrollbar layer changes, | 3202 // 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 Loading... |
3258 host_impl_->CreatePendingTree(); | 3260 host_impl_->CreatePendingTree(); |
3259 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); | 3261 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
3260 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 3262 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
3261 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 3263 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
3262 VERTICAL, 10, 0, false, true); | 3264 VERTICAL, 10, 0, false, true); |
3263 scrollbar->test_properties()->opacity = 0.f; | 3265 scrollbar->test_properties()->opacity = 0.f; |
3264 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 3266 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
3265 LayerImpl* container = | 3267 LayerImpl* container = |
3266 host_impl_->pending_tree()->InnerViewportContainerLayer(); | 3268 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
3267 scrollbar->SetScrollElementId(scroll->element_id()); | 3269 scrollbar->SetScrollElementId(scroll->element_id()); |
| 3270 scrollbar->SetBounds(gfx::Size(10, 100)); |
| 3271 scrollbar->SetPosition(gfx::PointF(90, 0)); |
3268 container->test_properties()->AddChild(std::move(scrollbar)); | 3272 container->test_properties()->AddChild(std::move(scrollbar)); |
3269 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3273 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
3270 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 3274 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
3271 host_impl_->ActivateSyncTree(); | 3275 host_impl_->ActivateSyncTree(); |
3272 | 3276 |
3273 ScrollbarAnimationController* scrollbar_controller = | 3277 ScrollbarAnimationController* scrollbar_controller = |
3274 host_impl_->ScrollbarAnimationControllerForElementId( | 3278 host_impl_->ScrollbarAnimationControllerForElementId( |
3275 scroll->element_id()); | 3279 scroll->element_id()); |
3276 | 3280 |
3277 // Scrollbars will flash shown but we should have a fade out animation | 3281 // Scrollbars will flash shown but we should have a fade out animation |
3278 // queued. Run it and fade out the scrollbars. | 3282 // queued. Run it and fade out the scrollbars. |
3279 { | 3283 { |
3280 ASSERT_FALSE(animation_task_.Equals(base::Closure())); | 3284 ASSERT_FALSE(animation_task_.Equals(base::Closure())); |
3281 ASSERT_FALSE(animation_task_.IsCancelled()); | 3285 ASSERT_FALSE(animation_task_.IsCancelled()); |
3282 animation_task_.Run(); | 3286 animation_task_.Run(); |
3283 | 3287 |
3284 base::TimeTicks fake_now = base::TimeTicks::Now(); | 3288 base::TimeTicks fake_now = base::TimeTicks::Now(); |
3285 scrollbar_controller->Animate(fake_now); | 3289 scrollbar_controller->Animate(fake_now); |
3286 fake_now += settings.scrollbar_fade_delay; | 3290 fake_now += settings.scrollbar_fade_delay; |
3287 scrollbar_controller->Animate(fake_now); | 3291 scrollbar_controller->Animate(fake_now); |
3288 | 3292 |
3289 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); | 3293 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); |
3290 } | 3294 } |
3291 | 3295 |
3292 // Move the mouse over the scrollbar region. This should post a delayed fade | 3296 // Move the mouse over the scrollbar region. This should post a delayed fade |
3293 // in task. Execute it to show the scrollbars. | 3297 // in task. Execute it to fade in the scrollbars. |
3294 { | 3298 { |
3295 animation_task_ = base::Closure(); | 3299 animation_task_ = base::Closure(); |
3296 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0); | 3300 scrollbar_controller->DidMouseMove(gfx::PointF(90, 0)); |
3297 ASSERT_FALSE(animation_task_.Equals(base::Closure())); | 3301 ASSERT_FALSE(animation_task_.Equals(base::Closure())); |
3298 ASSERT_FALSE(animation_task_.IsCancelled()); | 3302 ASSERT_FALSE(animation_task_.IsCancelled()); |
3299 } | 3303 } |
3300 | 3304 |
3301 // The fade in task should cause the scrollbars to show. Ensure that we | 3305 // The fade in task should cause the scrollbars to show. Ensure that we |
3302 // requested a redraw and a commit. | 3306 // requested a redraw and a commit. |
3303 { | 3307 { |
3304 did_request_redraw_ = false; | 3308 did_request_redraw_ = false; |
3305 did_request_commit_ = false; | 3309 did_request_commit_ = false; |
3306 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); | 3310 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3498 host_impl_->SetViewportSize(device_viewport_size); | 3502 host_impl_->SetViewportSize(device_viewport_size); |
3499 | 3503 |
3500 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 3504 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
3501 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 3505 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
3502 viewport_size); | 3506 viewport_size); |
3503 LayerImpl* root_scroll = | 3507 LayerImpl* root_scroll = |
3504 host_impl_->active_tree()->OuterViewportScrollLayer(); | 3508 host_impl_->active_tree()->OuterViewportScrollLayer(); |
3505 // The scrollbar is on the left side. | 3509 // The scrollbar is on the left side. |
3506 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 3510 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
3507 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, | 3511 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, |
3508 VERTICAL, 5, 5, true, true); | 3512 VERTICAL, 15, 0, true, true); |
3509 scrollbar->SetScrollElementId(root_scroll->element_id()); | 3513 scrollbar->SetScrollElementId(root_scroll->element_id()); |
3510 scrollbar->SetDrawsContent(true); | 3514 scrollbar->SetDrawsContent(true); |
3511 scrollbar->SetBounds(scrollbar_size); | 3515 scrollbar->SetBounds(scrollbar_size); |
3512 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); | 3516 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); |
3513 host_impl_->active_tree() | 3517 host_impl_->active_tree() |
3514 ->InnerViewportContainerLayer() | 3518 ->InnerViewportContainerLayer() |
3515 ->test_properties() | 3519 ->test_properties() |
3516 ->AddChild(std::move(scrollbar)); | 3520 ->AddChild(std::move(scrollbar)); |
3517 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3521 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
3518 host_impl_->active_tree()->DidBecomeActive(); | 3522 host_impl_->active_tree()->DidBecomeActive(); |
3519 | 3523 |
3520 DrawFrame(); | 3524 DrawFrame(); |
3521 host_impl_->active_tree()->UpdateDrawProperties(false); | 3525 host_impl_->active_tree()->UpdateDrawProperties(false); |
3522 | 3526 |
3523 ScrollbarAnimationController* scrollbar_animation_controller = | 3527 ScrollbarAnimationController* scrollbar_animation_controller = |
3524 host_impl_->ScrollbarAnimationControllerForElementId( | 3528 host_impl_->ScrollbarAnimationControllerForElementId( |
3525 root_scroll->element_id()); | 3529 root_scroll->element_id()); |
3526 | 3530 |
3527 const float kMouseDistanceToTriggerAnimation = | 3531 const float kMouseMoveDistanceToTriggerFadeIn = |
| 3532 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn; |
| 3533 |
| 3534 const float kMouseMoveDistanceToTriggerExpand = |
3528 SingleScrollbarAnimationControllerThinning:: | 3535 SingleScrollbarAnimationControllerThinning:: |
3529 kDefaultMouseMoveDistanceToTriggerAnimation; | 3536 kMouseMoveDistanceToTriggerExpand; |
3530 | 3537 |
3531 host_impl_->MouseMoveAt( | 3538 host_impl_->MouseMoveAt( |
3532 gfx::Point(15 + kMouseDistanceToTriggerAnimation * 2, 1)); | 3539 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 1)); |
3533 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 3540 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 3541 EXPECT_FALSE( |
| 3542 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
3534 | 3543 |
3535 host_impl_->MouseMoveAt( | 3544 host_impl_->MouseMoveAt( |
3536 gfx::Point(15 + kMouseDistanceToTriggerAnimation - 1, 50)); | 3545 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand - 1, 10)); |
3537 EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 3546 EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 3547 EXPECT_TRUE( |
| 3548 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
3538 | 3549 |
3539 host_impl_->MouseMoveAt( | 3550 host_impl_->MouseMoveAt( |
3540 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 100)); | 3551 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 100)); |
3541 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 3552 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 3553 EXPECT_FALSE( |
| 3554 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
3542 | 3555 |
3543 did_request_redraw_ = false; | 3556 did_request_redraw_ = false; |
3544 EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 3557 EXPECT_FALSE( |
3545 host_impl_->MouseMoveAt(gfx::Point(10, 100)); | 3558 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
3546 EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 3559 host_impl_->MouseMoveAt(gfx::Point(10, 10)); |
3547 host_impl_->MouseMoveAt(gfx::Point(10, 120)); | 3560 EXPECT_TRUE( |
3548 EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 3561 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 3562 host_impl_->MouseMoveAt(gfx::Point(10, 0)); |
| 3563 EXPECT_TRUE( |
| 3564 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
3549 host_impl_->MouseMoveAt(gfx::Point(150, 120)); | 3565 host_impl_->MouseMoveAt(gfx::Point(150, 120)); |
3550 EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 3566 EXPECT_FALSE( |
| 3567 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
3551 } | 3568 } |
3552 | 3569 |
3553 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { | 3570 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { |
3554 SetupMouseMoveAtWithDeviceScale(1.f); | 3571 SetupMouseMoveAtWithDeviceScale(1.f); |
3555 } | 3572 } |
3556 | 3573 |
3557 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { | 3574 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { |
3558 SetupMouseMoveAtWithDeviceScale(2.f); | 3575 SetupMouseMoveAtWithDeviceScale(2.f); |
3559 } | 3576 } |
3560 | 3577 |
(...skipping 8547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12108 host_impl_->active_tree()->OuterViewportScrollLayer(); | 12125 host_impl_->active_tree()->OuterViewportScrollLayer(); |
12109 | 12126 |
12110 if (main_thread_scrolling) { | 12127 if (main_thread_scrolling) { |
12111 root_scroll->set_main_thread_scrolling_reasons( | 12128 root_scroll->set_main_thread_scrolling_reasons( |
12112 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 12129 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
12113 } | 12130 } |
12114 | 12131 |
12115 // scrollbar_1 on root scroll. | 12132 // scrollbar_1 on root scroll. |
12116 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 = | 12133 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 = |
12117 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), | 12134 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), |
12118 scrollbar_1_id, VERTICAL, 5, 5, true, | 12135 scrollbar_1_id, VERTICAL, 15, 0, |
12119 true); | 12136 true, true); |
12120 scrollbar_1->SetScrollElementId(root_scroll->element_id()); | 12137 scrollbar_1->SetScrollElementId(root_scroll->element_id()); |
12121 scrollbar_1->SetDrawsContent(true); | 12138 scrollbar_1->SetDrawsContent(true); |
12122 scrollbar_1->SetBounds(scrollbar_size_1); | 12139 scrollbar_1->SetBounds(scrollbar_size_1); |
12123 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1)); | 12140 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1)); |
| 12141 scrollbar_1->SetCurrentPos(0); |
| 12142 scrollbar_1->SetPosition(gfx::PointF(0, 0)); |
12124 host_impl_->active_tree() | 12143 host_impl_->active_tree() |
12125 ->InnerViewportContainerLayer() | 12144 ->InnerViewportContainerLayer() |
12126 ->test_properties() | 12145 ->test_properties() |
12127 ->AddChild(std::move(scrollbar_1)); | 12146 ->AddChild(std::move(scrollbar_1)); |
12128 | 12147 |
12129 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 12148 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
12130 host_impl_->active_tree()->DidBecomeActive(); | 12149 host_impl_->active_tree()->DidBecomeActive(); |
12131 | 12150 |
12132 DrawFrame(); | 12151 DrawFrame(); |
12133 host_impl_->active_tree()->UpdateDrawProperties(false); | 12152 host_impl_->active_tree()->UpdateDrawProperties(false); |
12134 | 12153 |
12135 ScrollbarAnimationController* scrollbar_1_animation_controller = | 12154 ScrollbarAnimationController* scrollbar_1_animation_controller = |
12136 host_impl_->ScrollbarAnimationControllerForElementId( | 12155 host_impl_->ScrollbarAnimationControllerForElementId( |
12137 root_scroll->element_id()); | 12156 root_scroll->element_id()); |
12138 EXPECT_TRUE(scrollbar_1_animation_controller); | 12157 EXPECT_TRUE(scrollbar_1_animation_controller); |
12139 | 12158 |
12140 const float kMouseDistanceToTriggerAnimation = | 12159 const float kMouseMoveDistanceToTriggerFadeIn = |
| 12160 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn; |
| 12161 |
| 12162 const float kMouseMoveDistanceToTriggerExpand = |
12141 SingleScrollbarAnimationControllerThinning:: | 12163 SingleScrollbarAnimationControllerThinning:: |
12142 kDefaultMouseMoveDistanceToTriggerAnimation; | 12164 kMouseMoveDistanceToTriggerExpand; |
12143 | 12165 |
12144 // Mouse moves close to the scrollbar, goes over the scrollbar, and | 12166 // Mouse moves close to the scrollbar, goes over the scrollbar, and |
12145 // moves back to where it was. | 12167 // moves back to where it was. |
12146 host_impl_->MouseMoveAt( | 12168 host_impl_->MouseMoveAt( |
12147 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); | 12169 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 0)); |
12148 EXPECT_FALSE( | 12170 EXPECT_FALSE( |
12149 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12171 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12150 EXPECT_FALSE( | 12172 EXPECT_FALSE( |
12151 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12173 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12174 EXPECT_FALSE( |
| 12175 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12176 |
12152 host_impl_->MouseMoveAt( | 12177 host_impl_->MouseMoveAt( |
12153 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); | 12178 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand, 0)); |
12154 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12179 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12155 EXPECT_FALSE( | 12180 EXPECT_FALSE( |
12156 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12181 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
12157 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 12182 EXPECT_FALSE( |
| 12183 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12184 |
| 12185 host_impl_->MouseMoveAt( |
| 12186 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0)); |
12158 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12187 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12159 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12188 EXPECT_TRUE( |
| 12189 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12190 EXPECT_FALSE( |
| 12191 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12192 |
| 12193 host_impl_->MouseMoveAt(gfx::Point(10, 0)); |
| 12194 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 12195 EXPECT_TRUE( |
| 12196 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12197 EXPECT_TRUE( |
| 12198 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12199 |
12160 host_impl_->MouseMoveAt( | 12200 host_impl_->MouseMoveAt( |
12161 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); | 12201 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0)); |
| 12202 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 12203 EXPECT_TRUE( |
| 12204 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12205 EXPECT_FALSE( |
| 12206 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12207 |
| 12208 host_impl_->MouseMoveAt( |
| 12209 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand, 0)); |
12162 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12210 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12163 EXPECT_FALSE( | 12211 EXPECT_FALSE( |
12164 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12212 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12213 EXPECT_FALSE( |
| 12214 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12215 |
12165 host_impl_->MouseMoveAt( | 12216 host_impl_->MouseMoveAt( |
12166 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); | 12217 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 0)); |
12167 EXPECT_FALSE( | 12218 EXPECT_FALSE( |
12168 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12219 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12169 EXPECT_FALSE( | 12220 EXPECT_FALSE( |
12170 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12221 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12222 EXPECT_FALSE( |
| 12223 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12171 | 12224 |
12172 // scrollbar_2 on child. | 12225 // scrollbar_2 on child. |
12173 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = | 12226 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = |
12174 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), | 12227 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), |
12175 scrollbar_2_id, VERTICAL, 5, 5, true, | 12228 scrollbar_2_id, VERTICAL, 15, 0, |
12176 true); | 12229 true, true); |
12177 std::unique_ptr<LayerImpl> child_clip = | 12230 std::unique_ptr<LayerImpl> child_clip = |
12178 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 12231 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); |
12179 std::unique_ptr<LayerImpl> child = | 12232 std::unique_ptr<LayerImpl> child = |
12180 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); | 12233 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); |
12181 child->SetPosition(gfx::PointF(50, 50)); | 12234 child->SetPosition(gfx::PointF(50, 50)); |
12182 child->SetBounds(child_layer_size); | 12235 child->SetBounds(child_layer_size); |
12183 child->SetDrawsContent(true); | 12236 child->SetDrawsContent(true); |
12184 child->SetScrollClipLayer(child_clip_id); | 12237 child->SetScrollClipLayer(child_clip_id); |
12185 child->SetElementId(LayerIdToElementIdForTesting(child->id())); | 12238 child->SetElementId(LayerIdToElementIdForTesting(child->id())); |
12186 ElementId child_element_id = child->element_id(); | 12239 ElementId child_element_id = child->element_id(); |
12187 | 12240 |
12188 if (main_thread_scrolling) { | 12241 if (main_thread_scrolling) { |
12189 child->set_main_thread_scrolling_reasons( | 12242 child->set_main_thread_scrolling_reasons( |
12190 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 12243 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
12191 } | 12244 } |
12192 | 12245 |
12193 scrollbar_2->SetScrollElementId(child_element_id); | 12246 scrollbar_2->SetScrollElementId(child_element_id); |
12194 scrollbar_2->SetDrawsContent(true); | 12247 scrollbar_2->SetDrawsContent(true); |
12195 scrollbar_2->SetBounds(scrollbar_size_2); | 12248 scrollbar_2->SetBounds(scrollbar_size_2); |
| 12249 scrollbar_2->SetCurrentPos(0); |
| 12250 scrollbar_2->SetPosition(gfx::PointF(0, 0)); |
12196 | 12251 |
12197 child->test_properties()->AddChild(std::move(scrollbar_2)); | 12252 child->test_properties()->AddChild(std::move(scrollbar_2)); |
12198 child_clip->test_properties()->AddChild(std::move(child)); | 12253 child_clip->test_properties()->AddChild(std::move(child)); |
12199 root_scroll->test_properties()->AddChild(std::move(child_clip)); | 12254 root_scroll->test_properties()->AddChild(std::move(child_clip)); |
12200 | 12255 |
12201 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 12256 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
12202 host_impl_->active_tree()->DidBecomeActive(); | 12257 host_impl_->active_tree()->DidBecomeActive(); |
12203 | 12258 |
12204 ScrollbarAnimationController* scrollbar_2_animation_controller = | 12259 ScrollbarAnimationController* scrollbar_2_animation_controller = |
12205 host_impl_->ScrollbarAnimationControllerForElementId(child_element_id); | 12260 host_impl_->ScrollbarAnimationControllerForElementId(child_element_id); |
12206 EXPECT_TRUE(scrollbar_2_animation_controller); | 12261 EXPECT_TRUE(scrollbar_2_animation_controller); |
12207 | 12262 |
12208 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to | 12263 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to |
12209 // scrollbar_1, goes over scrollbar_1. | 12264 // scrollbar_1, goes over scrollbar_1. |
12210 host_impl_->MouseMoveAt(gfx::Point(60, 150)); | 12265 host_impl_->MouseMoveAt(gfx::Point(60, 60)); |
12211 EXPECT_FALSE( | 12266 EXPECT_FALSE( |
12212 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12267 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12213 EXPECT_FALSE( | 12268 EXPECT_FALSE( |
12214 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12269 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12270 EXPECT_FALSE( |
| 12271 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12215 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12272 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12216 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12273 EXPECT_TRUE( |
| 12274 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12275 EXPECT_TRUE( |
| 12276 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12277 |
12217 host_impl_->MouseMoveAt( | 12278 host_impl_->MouseMoveAt( |
12218 gfx::Point(64 + kMouseDistanceToTriggerAnimation, 150)); | 12279 gfx::Point(64 + kMouseMoveDistanceToTriggerExpand, 50)); |
12219 EXPECT_FALSE( | 12280 EXPECT_FALSE( |
12220 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12281 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12221 EXPECT_FALSE( | 12282 EXPECT_FALSE( |
12222 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12283 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12284 EXPECT_FALSE( |
| 12285 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12223 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12286 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 12287 EXPECT_TRUE( |
| 12288 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
12224 EXPECT_FALSE( | 12289 EXPECT_FALSE( |
12225 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12290 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12226 host_impl_->MouseMoveAt( | 12291 host_impl_->MouseMoveAt( |
12227 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); | 12292 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0)); |
12228 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12293 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
| 12294 EXPECT_TRUE( |
| 12295 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
12229 EXPECT_FALSE( | 12296 EXPECT_FALSE( |
12230 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12297 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12231 EXPECT_FALSE( | 12298 EXPECT_FALSE( |
12232 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12299 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12233 EXPECT_FALSE( | 12300 EXPECT_FALSE( |
12234 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12301 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
12235 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 12302 EXPECT_FALSE( |
| 12303 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
| 12304 host_impl_->MouseMoveAt(gfx::Point(10, 0)); |
12236 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12305 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12237 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12306 EXPECT_TRUE( |
| 12307 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12308 EXPECT_TRUE( |
| 12309 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12238 EXPECT_FALSE( | 12310 EXPECT_FALSE( |
12239 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); | 12311 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); |
12240 EXPECT_FALSE( | 12312 EXPECT_FALSE( |
12241 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); | 12313 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL)); |
| 12314 EXPECT_FALSE( |
| 12315 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL)); |
12242 | 12316 |
12243 // Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an | 12317 // Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an |
12244 // event to fade out scrollbar_1. | 12318 // event to fade out scrollbar_1. |
12245 animation_task_ = base::Closure(); | 12319 animation_task_ = base::Closure(); |
12246 | 12320 |
12247 host_impl_->MouseDown(); | 12321 host_impl_->MouseDown(); |
12248 host_impl_->MouseMoveAt(gfx::Point(100, 150)); | 12322 host_impl_->MouseMoveAt(gfx::Point(60, 50)); |
12249 host_impl_->MouseUp(); | 12323 host_impl_->MouseUp(); |
12250 | 12324 |
12251 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 12325 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
12252 | 12326 |
12253 // Near scrollbar_1, then mouse down and up, should not post an event to fade | 12327 // Near scrollbar_1, then mouse down and up, should not post an event to fade |
12254 // out scrollbar_1. | 12328 // out scrollbar_1. |
12255 host_impl_->MouseMoveAt(gfx::Point(40, 150)); | 12329 host_impl_->MouseMoveAt(gfx::Point(40, 150)); |
12256 animation_task_ = base::Closure(); | 12330 animation_task_ = base::Closure(); |
12257 | 12331 |
12258 host_impl_->MouseDown(); | 12332 host_impl_->MouseDown(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12347 else | 12421 else |
12348 EXPECT_FALSE(tile->HasRasterTask()); | 12422 EXPECT_FALSE(tile->HasRasterTask()); |
12349 } | 12423 } |
12350 Region expected_invalidation( | 12424 Region expected_invalidation( |
12351 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12425 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
12352 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12426 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12353 } | 12427 } |
12354 | 12428 |
12355 } // namespace | 12429 } // namespace |
12356 } // namespace cc | 12430 } // namespace cc |
OLD | NEW |