| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 | 1046 |
| 1047 overflow->set_user_scrollable_horizontal(false); | 1047 overflow->set_user_scrollable_horizontal(false); |
| 1048 | 1048 |
| 1049 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1049 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 1050 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1050 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
| 1051 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1051 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1052 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1052 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1053 | 1053 |
| 1054 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1054 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 1055 host_impl_->ScrollEnd(); | 1055 host_impl_->ScrollEnd(); |
| 1056 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); | 1056 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1057 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1057 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1058 | 1058 |
| 1059 overflow->set_user_scrollable_vertical(false); | 1059 overflow->set_user_scrollable_vertical(false); |
| 1060 | 1060 |
| 1061 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1061 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 1062 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1062 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
| 1063 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); | 1063 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1064 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1064 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1065 | 1065 |
| 1066 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1066 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 1067 host_impl_->ScrollEnd(); | 1067 host_impl_->ScrollEnd(); |
| 1068 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); | 1068 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); |
| 1069 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1069 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1072 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
| 1073 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1073 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1074 | 1074 |
| 1075 host_impl_->CreatePendingTree(); | 1075 host_impl_->CreatePendingTree(); |
| 1076 host_impl_->pending_tree()->SetRootLayer( | 1076 host_impl_->pending_tree()->SetRootLayer( |
| 1077 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1077 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
| 1078 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1078 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 1501 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 1502 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1502 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 1503 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); | 1503 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); |
| 1504 host_impl_->ScrollEnd(); | 1504 host_impl_->ScrollEnd(); |
| 1505 | 1505 |
| 1506 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1506 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 1507 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 1507 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
| 1508 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); | 1508 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 // Test that scrolls targeting a layer with a non-null scroll_parent() bubble | 1511 // Test that scrolls targeting a layer with a non-null scroll_parent() don't |
| 1512 // up to the scroll_parent, rather than the stacking parent. | 1512 // bubble up. |
| 1513 TEST_F(LayerTreeHostImplTest, ScrollBubblesToScrollParent) { | 1513 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { |
| 1514 LayerImpl* viewport_scroll = | 1514 LayerImpl* viewport_scroll = |
| 1515 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1515 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1516 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1516 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1517 | 1517 |
| 1518 // Set up two scrolling children of the root, one of which is a scroll parent | 1518 // Set up two scrolling children of the root, one of which is a scroll parent |
| 1519 // to the other. Scrolls bubbling from the child should bubble to the parent, | 1519 // to the other. Scrolls shouldn't bubbling from the child. |
| 1520 // not the viewport. | |
| 1521 LayerImpl *parent; | 1520 LayerImpl *parent; |
| 1522 LayerImpl *child; | 1521 LayerImpl *child; |
| 1523 LayerImpl *child_clip; | 1522 LayerImpl *child_clip; |
| 1524 | 1523 |
| 1525 scoped_ptr<LayerImpl> scroll_parent_clip = | 1524 scoped_ptr<LayerImpl> scroll_parent_clip = |
| 1526 LayerImpl::Create(host_impl_->active_tree(), 6); | 1525 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 1527 scoped_ptr<LayerImpl> scroll_parent = CreateScrollableLayer( | 1526 scoped_ptr<LayerImpl> scroll_parent = CreateScrollableLayer( |
| 1528 7, gfx::Size(10, 10), scroll_parent_clip.get()); | 1527 7, gfx::Size(10, 10), scroll_parent_clip.get()); |
| 1529 parent = scroll_parent.get(); | 1528 parent = scroll_parent.get(); |
| 1530 scroll_parent_clip->AddChild(scroll_parent.Pass()); | 1529 scroll_parent_clip->AddChild(scroll_parent.Pass()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1542 child_clip = scroll_child_clip.get(); | 1541 child_clip = scroll_child_clip.get(); |
| 1543 viewport_scroll->AddChild(scroll_child_clip.Pass()); | 1542 viewport_scroll->AddChild(scroll_child_clip.Pass()); |
| 1544 | 1543 |
| 1545 child_clip->SetScrollParent(parent); | 1544 child_clip->SetScrollParent(parent); |
| 1546 | 1545 |
| 1547 DrawFrame(); | 1546 DrawFrame(); |
| 1548 | 1547 |
| 1549 { | 1548 { |
| 1550 host_impl_->ScrollBegin(gfx::Point(21, 21), InputHandler::GESTURE); | 1549 host_impl_->ScrollBegin(gfx::Point(21, 21), InputHandler::GESTURE); |
| 1551 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(5, 5)); | 1550 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(5, 5)); |
| 1552 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(2, 1)); | 1551 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(100, 100)); |
| 1553 host_impl_->ScrollEnd(); | 1552 host_impl_->ScrollEnd(); |
| 1554 | 1553 |
| 1555 // The child should be fully scrolled by the first ScrollBy. | 1554 // The child should be fully scrolled by the first ScrollBy. |
| 1556 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 5), child->CurrentScrollOffset()); | 1555 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 5), child->CurrentScrollOffset()); |
| 1557 | 1556 |
| 1558 // The scroll_parent should receive the bubbled up second ScrollBy. | 1557 // The scroll_parent shouldn't receive the second ScrollBy. |
| 1559 EXPECT_VECTOR_EQ(gfx::Vector2dF(2, 1), parent->CurrentScrollOffset()); | 1558 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), parent->CurrentScrollOffset()); |
| 1560 | 1559 |
| 1561 // The viewport shouldn't have been scrolled at all. | 1560 // The viewport shouldn't have been scrolled at all. |
| 1562 EXPECT_VECTOR_EQ( | 1561 EXPECT_VECTOR_EQ( |
| 1563 gfx::Vector2dF(0, 0), | 1562 gfx::Vector2dF(0, 0), |
| 1564 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1563 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1565 EXPECT_VECTOR_EQ( | 1564 EXPECT_VECTOR_EQ( |
| 1566 gfx::Vector2dF(0, 0), | 1565 gfx::Vector2dF(0, 0), |
| 1567 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); | 1566 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); |
| 1568 } | 1567 } |
| 1569 | 1568 |
| 1570 { | 1569 { |
| 1571 host_impl_->ScrollBegin(gfx::Point(21, 21), InputHandler::GESTURE); | 1570 host_impl_->ScrollBegin(gfx::Point(21, 21), InputHandler::GESTURE); |
| 1572 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(3, 4)); | 1571 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(3, 4)); |
| 1573 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(2, 1)); | 1572 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(2, 1)); |
| 1573 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(2, 1)); |
| 1574 host_impl_->ScrollBy(gfx::Point(21, 21), gfx::Vector2d(2, 1)); |
| 1574 host_impl_->ScrollEnd(); | 1575 host_impl_->ScrollEnd(); |
| 1575 | 1576 |
| 1576 // The first ScrollBy should scroll the parent to its extent. | 1577 // The ScrollBy's should scroll the parent to its extent. |
| 1577 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 5), parent->CurrentScrollOffset()); | 1578 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 5), parent->CurrentScrollOffset()); |
| 1578 | 1579 |
| 1579 // The viewport should now be next in bubbling order. | 1580 // The viewport shouldn't receive any scroll delta. |
| 1580 EXPECT_VECTOR_EQ( | 1581 EXPECT_VECTOR_EQ( |
| 1581 gfx::Vector2dF(2, 1), | 1582 gfx::Vector2dF(0, 0), |
| 1582 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1583 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1583 EXPECT_VECTOR_EQ( | 1584 EXPECT_VECTOR_EQ( |
| 1584 gfx::Vector2dF(0, 0), | 1585 gfx::Vector2dF(0, 0), |
| 1585 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); | 1586 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); |
| 1586 } | 1587 } |
| 1587 } | 1588 } |
| 1588 | 1589 |
| 1589 | 1590 |
| 1590 TEST_F(LayerTreeHostImplTest, PinchGesture) { | 1591 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
| 1591 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1592 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 | 3600 |
| 3600 EXPECT_EQ(top_controls_height_, | 3601 EXPECT_EQ(top_controls_height_, |
| 3601 host_impl_->top_controls_manager()->ContentTopOffset()); | 3602 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3602 | 3603 |
| 3603 // Send a gesture scroll that will scroll the outer viewport, make sure the | 3604 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 3604 // top controls get scrolled. | 3605 // top controls get scrolled. |
| 3605 gfx::Vector2dF scroll_delta(0.f, 15.f); | 3606 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 3606 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3607 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 3607 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3608 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 3608 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3609 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3609 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3610 |
| 3611 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), |
| 3610 host_impl_->CurrentlyScrollingLayer()); | 3612 host_impl_->CurrentlyScrollingLayer()); |
| 3611 host_impl_->ScrollEnd(); | 3613 host_impl_->ScrollEnd(); |
| 3612 | 3614 |
| 3613 EXPECT_FLOAT_EQ(scroll_delta.y(), | 3615 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 3614 top_controls_height_ - | 3616 top_controls_height_ - |
| 3615 host_impl_->top_controls_manager()->ContentTopOffset()); | 3617 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3616 | 3618 |
| 3617 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 3619 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 3618 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3620 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 3619 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3621 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 3620 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3622 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3621 | 3623 |
| 3622 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 3624 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3623 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3625 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), |
| 3624 host_impl_->CurrentlyScrollingLayer()); | 3626 host_impl_->CurrentlyScrollingLayer()); |
| 3625 | 3627 |
| 3626 host_impl_->ScrollEnd(); | 3628 host_impl_->ScrollEnd(); |
| 3627 | 3629 |
| 3628 // Position the viewports such that the inner viewport will be scrolled. | 3630 // Position the viewports such that the inner viewport will be scrolled. |
| 3629 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 3631 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 3630 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 3632 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 3631 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 3633 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
| 3632 | 3634 |
| 3633 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 3635 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3993 // The scroll range should not have changed. | 3995 // The scroll range should not have changed. |
| 3994 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); | 3996 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); |
| 3995 | 3997 |
| 3996 // The page scale delta remains constant because the impl thread did not | 3998 // The page scale delta remains constant because the impl thread did not |
| 3997 // scale. | 3999 // scale. |
| 3998 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 4000 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
| 3999 } | 4001 } |
| 4000 | 4002 |
| 4001 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 4003 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
| 4002 // Scroll a child layer beyond its maximum scroll range and make sure the | 4004 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 4003 // parent layer is scrolled on the axis on which the child was unable to | 4005 // parent layer isn't scrolled. |
| 4004 // scroll. | |
| 4005 gfx::Size surface_size(10, 10); | 4006 gfx::Size surface_size(10, 10); |
| 4006 gfx::Size content_size(20, 20); | 4007 gfx::Size content_size(20, 20); |
| 4007 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4008 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4008 root->SetBounds(surface_size); | 4009 root->SetBounds(surface_size); |
| 4009 root->SetHasRenderSurface(true); | 4010 root->SetHasRenderSurface(true); |
| 4010 scoped_ptr<LayerImpl> grand_child = | 4011 scoped_ptr<LayerImpl> grand_child = |
| 4011 CreateScrollableLayer(3, content_size, root.get()); | 4012 CreateScrollableLayer(3, content_size, root.get()); |
| 4012 | 4013 |
| 4013 scoped_ptr<LayerImpl> child = | 4014 scoped_ptr<LayerImpl> child = |
| 4014 CreateScrollableLayer(2, content_size, root.get()); | 4015 CreateScrollableLayer(2, content_size, root.get()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4033 | 4034 |
| 4034 scoped_ptr<ScrollAndScaleSet> scroll_info = | 4035 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 4035 host_impl_->ProcessScrollDeltas(); | 4036 host_impl_->ProcessScrollDeltas(); |
| 4036 | 4037 |
| 4037 // The grand child should have scrolled up to its limit. | 4038 // The grand child should have scrolled up to its limit. |
| 4038 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 4039 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; |
| 4039 LayerImpl* grand_child = child->children()[0]; | 4040 LayerImpl* grand_child = child->children()[0]; |
| 4040 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 4041 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 4041 gfx::Vector2d(0, -5))); | 4042 gfx::Vector2d(0, -5))); |
| 4042 | 4043 |
| 4043 // The child should have only scrolled on the other axis. | 4044 // The child should not have scrolled. |
| 4044 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 4045 ExpectNone(*scroll_info.get(), child->id()); |
| 4045 gfx::Vector2d(-3, 0))); | |
| 4046 } | 4046 } |
| 4047 } | 4047 } |
| 4048 | 4048 |
| 4049 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 4049 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 4050 // Scroll a child layer beyond its maximum scroll range and make sure the | 4050 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 4051 // the scroll doesn't bubble up to the parent layer. | 4051 // the scroll doesn't bubble up to the parent layer. |
| 4052 gfx::Size surface_size(20, 20); | 4052 gfx::Size surface_size(20, 20); |
| 4053 gfx::Size viewport_size(10, 10); | 4053 gfx::Size viewport_size(10, 10); |
| 4054 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4054 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4055 root->SetHasRenderSurface(true); | 4055 root->SetHasRenderSurface(true); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4334 } | 4334 } |
| 4335 { | 4335 { |
| 4336 // Now reset and scroll the same amount horizontally. | 4336 // Now reset and scroll the same amount horizontally. |
| 4337 child_ptr->SetScrollDelta(gfx::Vector2dF()); | 4337 child_ptr->SetScrollDelta(gfx::Vector2dF()); |
| 4338 gfx::Vector2d gesture_scroll_delta(10, 0); | 4338 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 4339 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4339 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 4340 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); | 4340 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); |
| 4341 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 4341 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 4342 host_impl_->ScrollEnd(); | 4342 host_impl_->ScrollEnd(); |
| 4343 | 4343 |
| 4344 // The child layer should have scrolled down in its local coordinates an | 4344 // The child layer shouldn't have scrolled. |
| 4345 // amount proportional to the angle between it and the input scroll delta. | |
| 4346 gfx::Vector2d expected_scroll_delta( | 4345 gfx::Vector2d expected_scroll_delta( |
| 4347 0, -gesture_scroll_delta.x() * | 4346 0, -gesture_scroll_delta.x() * |
| 4348 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 4347 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
| 4349 scoped_ptr<ScrollAndScaleSet> scroll_info = | 4348 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 4350 host_impl_->ProcessScrollDeltas(); | 4349 host_impl_->ProcessScrollDeltas(); |
| 4351 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 4350 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
| 4352 expected_scroll_delta)); | 4351 expected_scroll_delta)); |
| 4353 | 4352 |
| 4354 // The root scroll layer should have scrolled more, since the input scroll | 4353 // The root scroll layer shouldn't have scrolled. |
| 4355 // delta was mostly orthogonal to the child layer's vertical scroll axis. | 4354 ExpectNone(*scroll_info.get(), scroll_layer->id()); |
| 4356 gfx::Vector2d expected_root_scroll_delta( | |
| 4357 gesture_scroll_delta.x() * | |
| 4358 std::pow(std::cos(MathUtil::Deg2Rad(child_layer_angle)), 2), | |
| 4359 0); | |
| 4360 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | |
| 4361 expected_root_scroll_delta)); | |
| 4362 } | 4355 } |
| 4363 } | 4356 } |
| 4364 | 4357 |
| 4365 TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) { | 4358 TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) { |
| 4366 // When scrolling an element with perspective, the distance scrolled | 4359 // When scrolling an element with perspective, the distance scrolled |
| 4367 // depends on the point at which the scroll begins. | 4360 // depends on the point at which the scroll begins. |
| 4368 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 4361 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 4369 int child_clip_layer_id = 6; | 4362 int child_clip_layer_id = 6; |
| 4370 int child_layer_id = 7; | 4363 int child_layer_id = 7; |
| 4371 | 4364 |
| (...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6642 | 6635 |
| 6643 scoped_ptr<ScrollAndScaleSet> scroll_info = | 6636 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 6644 host_impl_->ProcessScrollDeltas(); | 6637 host_impl_->ProcessScrollDeltas(); |
| 6645 | 6638 |
| 6646 // Only the child should have scrolled. | 6639 // Only the child should have scrolled. |
| 6647 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6640 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6648 ExpectNone(*scroll_info.get(), root_id); | 6641 ExpectNone(*scroll_info.get(), root_id); |
| 6649 } | 6642 } |
| 6650 } | 6643 } |
| 6651 | 6644 |
| 6652 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 6645 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
| 6653 // Scroll a child layer beyond its maximum scroll range and make sure the | 6646 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 6654 // the scroll doesn't bubble up to the parent layer. | 6647 // the scroll doesn't bubble up to the parent layer. |
| 6655 gfx::Size surface_size(10, 10); | 6648 gfx::Size surface_size(10, 10); |
| 6656 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6649 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6657 root->SetHasRenderSurface(true); | 6650 root->SetHasRenderSurface(true); |
| 6658 scoped_ptr<LayerImpl> root_scrolling = | 6651 scoped_ptr<LayerImpl> root_scrolling = |
| 6659 CreateScrollableLayer(2, surface_size, root.get()); | 6652 CreateScrollableLayer(2, surface_size, root.get()); |
| 6660 | 6653 |
| 6661 scoped_ptr<LayerImpl> grand_child = | 6654 scoped_ptr<LayerImpl> grand_child = |
| 6662 CreateScrollableLayer(4, surface_size, root.get()); | 6655 CreateScrollableLayer(4, surface_size, root.get()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6684 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 6677 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 6685 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6678 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6686 | 6679 |
| 6687 // The grand child should have scrolled up to its limit. | 6680 // The grand child should have scrolled up to its limit. |
| 6688 scroll_info = host_impl_->ProcessScrollDeltas(); | 6681 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6689 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6682 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6690 EXPECT_TRUE( | 6683 EXPECT_TRUE( |
| 6691 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 6684 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| 6692 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 6685 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 6693 | 6686 |
| 6694 // The child should have received the bubbled delta, but the locked | 6687 // The locked scrolling layer should remain set as the grand child. |
| 6695 // scrolling layer should remain set as the grand child. | 6688 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6696 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | |
| 6697 scroll_info = host_impl_->ProcessScrollDeltas(); | 6689 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6698 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 6690 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6699 EXPECT_TRUE( | 6691 EXPECT_TRUE( |
| 6700 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 6692 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| 6701 EXPECT_TRUE(ScrollInfoContains(*scroll_info, child->id(), scroll_delta)); | 6693 ExpectNone(*scroll_info, child->id()); |
| 6702 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 6694 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 6703 | 6695 |
| 6704 // The first |ScrollBy| after the fling should re-lock the scrolling | |
| 6705 // layer to the first layer that scrolled, which is the child. | |
| 6706 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 6696 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
| 6707 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6697 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6708 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 6698 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 6709 | 6699 |
| 6710 // The child should have scrolled up to its limit. | 6700 // The child should not have scrolled. |
| 6711 scroll_info = host_impl_->ProcessScrollDeltas(); | 6701 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6712 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 6702 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6713 EXPECT_TRUE( | 6703 EXPECT_TRUE( |
| 6714 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 6704 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| 6715 EXPECT_TRUE(ScrollInfoContains(*scroll_info, child->id(), | 6705 ExpectNone(*scroll_info, child->id()); |
| 6716 scroll_delta + scroll_delta)); | |
| 6717 | 6706 |
| 6718 // As the locked layer is at it's limit, no further scrolling can occur. | 6707 // As the locked layer is at it's limit, no further scrolling can occur. |
| 6719 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6708 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6720 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 6709 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 6721 host_impl_->ScrollEnd(); | 6710 host_impl_->ScrollEnd(); |
| 6722 } | 6711 } |
| 6723 } | 6712 } |
| 6724 | 6713 |
| 6725 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 6714 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { |
| 6726 // When flinging via wheel, the root should eventually scroll (we should | 6715 // When flinging via wheel, we shouldn't bubble. |
| 6727 // bubble). | |
| 6728 gfx::Size surface_size(10, 10); | 6716 gfx::Size surface_size(10, 10); |
| 6729 gfx::Size content_size(20, 20); | 6717 gfx::Size content_size(20, 20); |
| 6730 scoped_ptr<LayerImpl> root_clip = | 6718 scoped_ptr<LayerImpl> root_clip = |
| 6731 LayerImpl::Create(host_impl_->active_tree(), 3); | 6719 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6732 root_clip->SetHasRenderSurface(true); | 6720 root_clip->SetHasRenderSurface(true); |
| 6733 scoped_ptr<LayerImpl> root_scroll = | 6721 scoped_ptr<LayerImpl> root_scroll = |
| 6734 CreateScrollableLayer(1, content_size, root_clip.get()); | 6722 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 6735 int root_scroll_id = root_scroll->id(); | 6723 int root_scroll_id = root_scroll->id(); |
| 6736 scoped_ptr<LayerImpl> child = | 6724 scoped_ptr<LayerImpl> child = |
| 6737 CreateScrollableLayer(2, content_size, root_clip.get()); | 6725 CreateScrollableLayer(2, content_size, root_clip.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6751 | 6739 |
| 6752 gfx::Vector2d scroll_delta(0, 100); | 6740 gfx::Vector2d scroll_delta(0, 100); |
| 6753 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 6741 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 6754 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 6742 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 6755 | 6743 |
| 6756 host_impl_->ScrollEnd(); | 6744 host_impl_->ScrollEnd(); |
| 6757 | 6745 |
| 6758 scoped_ptr<ScrollAndScaleSet> scroll_info = | 6746 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 6759 host_impl_->ProcessScrollDeltas(); | 6747 host_impl_->ProcessScrollDeltas(); |
| 6760 | 6748 |
| 6761 // The root should have scrolled. | 6749 // The root shouldn't have scrolled. |
| 6762 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 6750 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6763 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), root_scroll_id, | 6751 ExpectNone(*scroll_info.get(), root_scroll_id); |
| 6764 gfx::Vector2d(0, 10))); | |
| 6765 } | 6752 } |
| 6766 } | 6753 } |
| 6767 | 6754 |
| 6768 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { | 6755 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { |
| 6769 // If we ray cast a scroller that is not on the first layer's ancestor chain, | 6756 // If we ray cast a scroller that is not on the first layer's ancestor chain, |
| 6770 // we should return SCROLL_UNKNOWN. | 6757 // we should return SCROLL_UNKNOWN. |
| 6771 gfx::Size content_size(100, 100); | 6758 gfx::Size content_size(100, 100); |
| 6772 SetupScrollAndContentsLayers(content_size); | 6759 SetupScrollAndContentsLayers(content_size); |
| 6773 | 6760 |
| 6774 int scroll_layer_id = 2; | 6761 int scroll_layer_id = 2; |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7694 DrawFrame(); | 7681 DrawFrame(); |
| 7695 { | 7682 { |
| 7696 gfx::Vector2dF inner_expected; | 7683 gfx::Vector2dF inner_expected; |
| 7697 gfx::Vector2dF outer_expected; | 7684 gfx::Vector2dF outer_expected; |
| 7698 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7685 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7699 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7686 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7700 | 7687 |
| 7701 // Make sure the fling goes to the outer viewport first | 7688 // Make sure the fling goes to the outer viewport first |
| 7702 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7689 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 7703 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7690 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 7704 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7691 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7705 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7692 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
| 7706 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7693 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7707 | 7694 |
| 7708 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7695 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
| 7709 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7696 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7710 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7697 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7711 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), outer_scroll); | 7698 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7712 | 7699 |
| 7713 host_impl_->ScrollEnd(); | 7700 host_impl_->ScrollEnd(); |
| 7714 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 7701 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 7715 | 7702 |
| 7716 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7703 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7717 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7704 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7718 | 7705 |
| 7719 // Fling past the outer viewport boundry, make sure inner viewport scrolls. | 7706 // Fling past the outer viewport boundry, make sure inner viewport scrolls. |
| 7720 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7707 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 7721 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7708 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 7722 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7709 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7723 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7710 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
| 7724 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7711 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7725 | 7712 |
| 7726 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7713 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7727 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7714 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7728 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7715 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7729 | 7716 |
| 7730 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7717 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7731 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7718 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7732 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 7719 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 7733 | 7720 |
| 7734 host_impl_->ScrollEnd(); | 7721 host_impl_->ScrollEnd(); |
| 7735 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 7722 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 7736 | 7723 |
| 7737 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7724 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7738 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7725 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7739 } | 7726 } |
| 7740 } | 7727 } |
| 7741 | 7728 |
| 7742 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7729 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7784 host_impl_->ScrollEnd(); | 7771 host_impl_->ScrollEnd(); |
| 7785 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 7772 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 7786 gfx::Point(), InputHandler::GESTURE)); | 7773 gfx::Point(), InputHandler::GESTURE)); |
| 7787 | 7774 |
| 7788 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7775 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7789 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7776 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7790 } | 7777 } |
| 7791 } | 7778 } |
| 7792 | 7779 |
| 7793 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7780 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 7794 TouchFlingCanLockToViewportLayerAfterBubbling) { | 7781 TouchFlingDoesntSwitchScrollingLayer) { |
| 7795 gfx::Size content_size = gfx::Size(100, 160); | 7782 gfx::Size content_size = gfx::Size(100, 160); |
| 7796 gfx::Size outer_viewport = gfx::Size(50, 80); | 7783 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 7797 gfx::Size inner_viewport = gfx::Size(25, 40); | 7784 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 7798 | 7785 |
| 7799 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7786 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 7800 | 7787 |
| 7801 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7788 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 7802 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7789 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 7803 | 7790 |
| 7804 scoped_ptr<LayerImpl> child = | 7791 scoped_ptr<LayerImpl> child = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7817 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 7804 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 7818 InputHandler::GESTURE)); | 7805 InputHandler::GESTURE)); |
| 7819 | 7806 |
| 7820 // The child should have scrolled up to its limit. | 7807 // The child should have scrolled up to its limit. |
| 7821 scroll_info = host_impl_->ProcessScrollDeltas(); | 7808 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 7822 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7809 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 7823 EXPECT_TRUE( | 7810 EXPECT_TRUE( |
| 7824 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 7811 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 7825 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 7812 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 7826 | 7813 |
| 7827 // The first |ScrollBy| after the fling should re-lock the scrolling | 7814 // The fling have no effect on the currently scrolling layer. |
| 7828 // layer to the first layer that scrolled, the inner viewport scroll layer. | |
| 7829 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7815 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
| 7830 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7816 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 7831 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 7817 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 7832 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 7818 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 7833 InputHandler::GESTURE)); | 7819 InputHandler::GESTURE)); |
| 7834 | 7820 |
| 7835 // The inner viewport should have scrolled up to its limit. | 7821 // The inner viewport shouldn't have scrolled. |
| 7836 scroll_info = host_impl_->ProcessScrollDeltas(); | 7822 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 7837 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7823 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 7838 EXPECT_TRUE( | 7824 EXPECT_TRUE( |
| 7839 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 7825 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 7840 EXPECT_TRUE( | 7826 ExpectNone(*scroll_info, inner_scroll->id()); |
| 7841 ScrollInfoContains(*scroll_info, inner_scroll->id(), scroll_delta)); | |
| 7842 | 7827 |
| 7843 // As the locked layer is at its limit, no further scrolling can occur. | 7828 // As the locked layer is at its limit, no further scrolling can occur. |
| 7844 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7829 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 7845 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 7830 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 7846 host_impl_->ScrollEnd(); | 7831 host_impl_->ScrollEnd(); |
| 7847 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 7832 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 7848 gfx::Point(), InputHandler::GESTURE)); | 7833 gfx::Point(), InputHandler::GESTURE)); |
| 7849 } | 7834 } |
| 7850 } | 7835 } |
| 7851 | 7836 |
| 7852 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7837 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 7853 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 7838 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
| 7854 gfx::Size content_size = gfx::Size(100, 160); | 7839 gfx::Size content_size = gfx::Size(100, 160); |
| 7855 gfx::Size outer_viewport = gfx::Size(50, 80); | 7840 gfx::Size outer_viewport = gfx::Size(50, 80); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8504 // Hold an unowned pointer to the output surface to use for mock expectations. | 8489 // Hold an unowned pointer to the output surface to use for mock expectations. |
| 8505 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 8490 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
| 8506 | 8491 |
| 8507 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 8492 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 8508 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 8493 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
| 8509 host_impl_->BeginCommit(); | 8494 host_impl_->BeginCommit(); |
| 8510 } | 8495 } |
| 8511 | 8496 |
| 8512 } // namespace | 8497 } // namespace |
| 8513 } // namespace cc | 8498 } // namespace cc |
| OLD | NEW |