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

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

Issue 2422353002: Iframe/div MD scrollbars get idle when mouse leaves the nested elements. (Closed)
Patch Set: Unittest passes asan build bot. Created 4 years, 1 month 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 3211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3222 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar());
3223 3223
3224 host_impl_->MouseMoveAt(gfx::Point(116, 100)); 3224 host_impl_->MouseMoveAt(gfx::Point(116, 100));
3225 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3225 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_near_scrollbar());
3226 3226
3227 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f); 3227 scrollbar_animation_controller->set_mouse_move_distance_for_test(102.f);
3228 host_impl_->MouseMoveAt(gfx::Point(116, 100)); 3228 host_impl_->MouseMoveAt(gfx::Point(116, 100));
3229 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar()); 3229 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_near_scrollbar());
3230 3230
3231 did_request_redraw_ = false; 3231 did_request_redraw_ = false;
3232 EXPECT_EQ(Layer::INVALID_ID, 3232 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar());
3233 host_impl_->scroll_layer_id_when_mouse_over_scrollbar());
3234 host_impl_->MouseMoveAt(gfx::Point(10, 100)); 3233 host_impl_->MouseMoveAt(gfx::Point(10, 100));
3235 EXPECT_EQ(117, host_impl_->scroll_layer_id_when_mouse_over_scrollbar()); 3234 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar());
3236 host_impl_->MouseMoveAt(gfx::Point(10, 120)); 3235 host_impl_->MouseMoveAt(gfx::Point(10, 120));
3237 EXPECT_EQ(117, host_impl_->scroll_layer_id_when_mouse_over_scrollbar()); 3236 EXPECT_TRUE(scrollbar_animation_controller->mouse_is_over_scrollbar());
3238 host_impl_->MouseMoveAt(gfx::Point(150, 120)); 3237 host_impl_->MouseMoveAt(gfx::Point(150, 120));
3239 EXPECT_EQ(Layer::INVALID_ID, 3238 EXPECT_FALSE(scrollbar_animation_controller->mouse_is_over_scrollbar());
3240 host_impl_->scroll_layer_id_when_mouse_over_scrollbar());
3241 } 3239 }
3242 3240
3243 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { 3241 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
3244 SetupMouseMoveAtWithDeviceScale(1.f); 3242 SetupMouseMoveAtWithDeviceScale(1.f);
3245 } 3243 }
3246 3244
3247 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3245 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3248 SetupMouseMoveAtWithDeviceScale(2.f); 3246 SetupMouseMoveAtWithDeviceScale(2.f);
3249 } 3247 }
3250 3248
(...skipping 8220 matching lines...) Expand 10 before | Expand all | Expand 10 after
11471 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); 11469 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create());
11472 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); 11470 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get());
11473 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11471 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11474 11472
11475 // Re-initialize with a software output surface. 11473 // Re-initialize with a software output surface.
11476 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); 11474 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware();
11477 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 11475 host_impl_->InitializeRenderer(compositor_frame_sink_.get());
11478 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11476 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11479 } 11477 }
11480 11478
11479 TEST_F(LayerTreeHostImplTest, LayerTreeHostImplTestScrollbarStates) {
11480 LayerTreeSettings settings = DefaultSettings();
11481 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500);
11482 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300);
11483 settings.scrollbar_animator = LayerTreeSettings::THINNING;
11484
11485 gfx::Size viewport_size(300, 200);
11486 gfx::Size content_size(1000, 1000);
11487 gfx::Size child_layer_size(250, 150);
11488 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height()));
11489 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height()));
11490
11491 const int scrollbar_1_id = 10;
11492 const int scrollbar_2_id = 11;
11493 const int child_clip_id = 12;
11494 const int child_scroll_id = 13;
11495
11496 CreateHostImpl(settings, CreateCompositorFrameSink());
11497 host_impl_->active_tree()->SetDeviceScaleFactor(1);
11498 host_impl_->SetViewportSize(viewport_size);
11499 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
11500 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
11501 viewport_size);
11502 LayerImpl* root_scroll =
11503 host_impl_->active_tree()->OuterViewportScrollLayer();
11504
11505 // scrollbar_1 on root scroll.
11506 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 =
11507 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
11508 scrollbar_1_id, VERTICAL, 5, 5, true,
11509 true);
11510 scrollbar_1->SetScrollLayerId(root_scroll->id());
11511 scrollbar_1->SetDrawsContent(true);
11512 scrollbar_1->SetBounds(scrollbar_size_1);
11513 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1));
11514 host_impl_->active_tree()
11515 ->InnerViewportContainerLayer()
11516 ->test_properties()
11517 ->AddChild(std::move(scrollbar_1));
11518
11519 host_impl_->active_tree()->BuildPropertyTreesForTesting();
11520 host_impl_->active_tree()->DidBecomeActive();
11521
11522 DrawFrame();
11523 host_impl_->active_tree()->UpdateDrawProperties(false);
11524
11525 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller =
11526 static_cast<ScrollbarAnimationControllerThinning*>(
11527 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
11528 EXPECT_TRUE(scrollbar_1_animation_controller);
11529 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f);
11530
11531 // Mouse moves close to the scrollbar, goes over the scrollbar, and
11532 // moves back to where it was.
11533 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11534 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11535 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11536 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11537 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11538 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11539 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11540 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11541 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11542 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11543 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11544 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11545 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11546 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11547 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11548
11549 // scrollbar_2 on child.
11550 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 =
11551 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
11552 scrollbar_2_id, VERTICAL, 5, 5, true,
11553 true);
11554 std::unique_ptr<LayerImpl> child_clip =
11555 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
11556 std::unique_ptr<LayerImpl> child =
11557 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
11558 child->SetPosition(gfx::PointF(50, 50));
11559 child->SetBounds(child_layer_size);
11560 child->SetDrawsContent(true);
11561 child->SetScrollClipLayer(child_clip_id);
11562
11563 scrollbar_2->SetScrollLayerId(child_scroll_id);
11564 scrollbar_2->SetDrawsContent(true);
11565 scrollbar_2->SetBounds(scrollbar_size_2);
11566
11567 child->test_properties()->AddChild(std::move(scrollbar_2));
11568 child_clip->test_properties()->AddChild(std::move(child));
11569 root_scroll->test_properties()->AddChild(std::move(child_clip));
11570
11571 host_impl_->active_tree()->BuildPropertyTreesForTesting();
11572 host_impl_->active_tree()->DidBecomeActive();
11573
11574 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller =
11575 static_cast<ScrollbarAnimationControllerThinning*>(
11576 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
11577 EXPECT_TRUE(scrollbar_2_animation_controller);
11578 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f);
11579
11580 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to
11581 // scrollbar_1, goes over scrollbar_1.
11582 host_impl_->MouseMoveAt(gfx::Point(60, 150));
11583 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11584 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11585 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11586 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11587 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11588 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11589 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11590 EXPECT_TRUE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11591 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11592 host_impl_->MouseMoveAt(gfx::Point(40, 150));
11593 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11594 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11595 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11596 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11597 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11598 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11599 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11600 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11601 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11602 }
11603
11481 } // namespace 11604 } // namespace
11482 } // namespace cc 11605 } // 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