| 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 674 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 675 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 675 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 676 status.main_thread_scrolling_reasons); | 676 status.main_thread_scrolling_reasons); |
| 677 | 677 |
| 678 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 678 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 679 InputHandler::WHEEL)); | 679 InputHandler::WHEEL)); |
| 680 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 680 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 681 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), | 681 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), |
| 682 InputHandler::WHEEL)); | 682 InputHandler::WHEEL)); |
| 683 host_impl_->ScrollEnd(EndState().get()); | 683 host_impl_->ScrollEnd(EndState().get()); |
| 684 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 685 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 684 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 686 InputHandler::WHEEL)); | 685 InputHandler::WHEEL)); |
| 687 EXPECT_TRUE(did_request_redraw_); | 686 EXPECT_TRUE(did_request_redraw_); |
| 688 EXPECT_TRUE(did_request_commit_); | 687 EXPECT_TRUE(did_request_commit_); |
| 689 } | 688 } |
| 690 | 689 |
| 691 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { | 690 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { |
| 692 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 691 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 693 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 692 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 694 | 693 |
| 695 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 694 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 696 DrawFrame(); | 695 DrawFrame(); |
| 697 | 696 |
| 698 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 697 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 699 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 698 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 700 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 699 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 701 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 700 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 702 status.main_thread_scrolling_reasons); | 701 status.main_thread_scrolling_reasons); |
| 703 | 702 |
| 704 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 703 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| 705 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 704 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 706 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); | 705 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); |
| 707 host_impl_->ScrollEnd(EndState().get()); | 706 host_impl_->ScrollEnd(EndState().get()); |
| 708 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 709 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 707 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| 710 } | 708 } |
| 711 | 709 |
| 712 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { | 710 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { |
| 713 // We should not crash when trying to scroll an empty layer tree. | 711 // We should not crash when trying to scroll an empty layer tree. |
| 714 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 712 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 715 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 713 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 716 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 714 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 717 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 715 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 718 status.main_thread_scrolling_reasons); | 716 status.main_thread_scrolling_reasons); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1023 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1026 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1024 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1027 status.main_thread_scrolling_reasons); | 1025 status.main_thread_scrolling_reasons); |
| 1028 | 1026 |
| 1029 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 1027 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1030 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1028 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1031 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1029 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 1032 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1030 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1033 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); | 1031 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); |
| 1034 host_impl_->ScrollEnd(EndState().get()); | 1032 host_impl_->ScrollEnd(EndState().get()); |
| 1035 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 1036 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1033 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1037 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1034 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1038 | 1035 |
| 1039 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), | 1036 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), |
| 1040 InputHandler::TOUCHSCREEN); | 1037 InputHandler::TOUCHSCREEN); |
| 1041 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1038 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1042 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1039 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1043 status.main_thread_scrolling_reasons); | 1040 status.main_thread_scrolling_reasons); |
| 1044 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 1041 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1045 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1042 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1046 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1043 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 1047 host_impl_->ScrollEnd(EndState().get()); | 1044 host_impl_->ScrollEnd(EndState().get()); |
| 1048 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 1049 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1045 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1050 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1046 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1051 } | 1047 } |
| 1052 | 1048 |
| 1053 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 1049 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
| 1054 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1050 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1055 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1051 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1056 | 1052 |
| 1057 LayerImpl* root = *host_impl_->active_tree()->begin(); | 1053 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1058 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1054 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1097 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1102 host_impl_->active_tree()->set_have_scroll_event_handlers(true); | 1098 host_impl_->active_tree()->set_have_scroll_event_handlers(true); |
| 1103 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1099 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1104 DrawFrame(); | 1100 DrawFrame(); |
| 1105 | 1101 |
| 1106 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1102 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1107 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1103 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1108 InputHandler::TOUCHSCREEN); | 1104 InputHandler::TOUCHSCREEN); |
| 1109 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); | 1105 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); |
| 1110 host_impl_->ScrollEnd(EndState().get()); | 1106 host_impl_->ScrollEnd(EndState().get()); |
| 1111 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 1112 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1107 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1113 } | 1108 } |
| 1114 | 1109 |
| 1115 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { | 1110 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { |
| 1116 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1111 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1117 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1112 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1118 | 1113 |
| 1119 DrawFrame(); | 1114 DrawFrame(); |
| 1120 | 1115 |
| 1121 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1116 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| (...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2772 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2767 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2773 InputHandler::WHEEL); | 2768 InputHandler::WHEEL); |
| 2774 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 2769 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
| 2775 EXPECT_FALSE(did_request_next_frame_); | 2770 EXPECT_FALSE(did_request_next_frame_); |
| 2776 EXPECT_TRUE(did_request_redraw_); | 2771 EXPECT_TRUE(did_request_redraw_); |
| 2777 did_request_redraw_ = false; | 2772 did_request_redraw_ = false; |
| 2778 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2773 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2779 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2774 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2780 | 2775 |
| 2781 host_impl_->ScrollEnd(EndState().get()); | 2776 host_impl_->ScrollEnd(EndState().get()); |
| 2782 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 2783 EXPECT_FALSE(did_request_next_frame_); | 2777 EXPECT_FALSE(did_request_next_frame_); |
| 2784 EXPECT_FALSE(did_request_redraw_); | 2778 EXPECT_FALSE(did_request_redraw_); |
| 2785 if (expecting_animations) { | 2779 if (expecting_animations) { |
| 2786 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 2780 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2787 requested_animation_delay_); | 2781 requested_animation_delay_); |
| 2788 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2782 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2789 } else { | 2783 } else { |
| 2790 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2784 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2791 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2785 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2792 } | 2786 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2866 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2860 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2867 InputHandler::WHEEL); | 2861 InputHandler::WHEEL); |
| 2868 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); | 2862 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); |
| 2869 EXPECT_FALSE(did_request_next_frame_); | 2863 EXPECT_FALSE(did_request_next_frame_); |
| 2870 EXPECT_TRUE(did_request_redraw_); | 2864 EXPECT_TRUE(did_request_redraw_); |
| 2871 did_request_redraw_ = false; | 2865 did_request_redraw_ = false; |
| 2872 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2866 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2873 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2867 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2874 | 2868 |
| 2875 host_impl_->ScrollEnd(EndState().get()); | 2869 host_impl_->ScrollEnd(EndState().get()); |
| 2876 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 2877 EXPECT_FALSE(did_request_next_frame_); | 2870 EXPECT_FALSE(did_request_next_frame_); |
| 2878 EXPECT_FALSE(did_request_redraw_); | 2871 EXPECT_FALSE(did_request_redraw_); |
| 2879 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2872 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2880 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2873 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2881 | 2874 |
| 2882 // Changing page scale triggers scrollbar animation. | 2875 // Changing page scale triggers scrollbar animation. |
| 2883 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 2876 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
| 2884 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); | 2877 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); |
| 2885 EXPECT_FALSE(did_request_next_frame_); | 2878 EXPECT_FALSE(did_request_next_frame_); |
| 2886 EXPECT_FALSE(did_request_redraw_); | 2879 EXPECT_FALSE(did_request_redraw_); |
| (...skipping 6713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9600 host_impl_->FlingScrollBegin().thread); | 9593 host_impl_->FlingScrollBegin().thread); |
| 9601 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9594 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9602 | 9595 |
| 9603 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 9596 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
| 9604 inner_viewport.height() / 2.f); | 9597 inner_viewport.height() / 2.f); |
| 9605 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9598 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9606 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9599 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9607 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9600 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9608 | 9601 |
| 9609 host_impl_->ScrollEnd(EndState().get()); | 9602 host_impl_->ScrollEnd(EndState().get()); |
| 9610 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9611 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9603 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 9612 | 9604 |
| 9613 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9605 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9614 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9606 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9615 | 9607 |
| 9616 // Fling past the inner viewport boundry, make sure outer viewport scrolls. | 9608 // Fling past the inner viewport boundry, make sure outer viewport scrolls. |
| 9617 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9609 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9618 host_impl_ | 9610 host_impl_ |
| 9619 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9611 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9620 InputHandler::TOUCHSCREEN) | 9612 InputHandler::TOUCHSCREEN) |
| 9621 .thread); | 9613 .thread); |
| 9622 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9614 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9623 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9615 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9624 host_impl_->FlingScrollBegin().thread); | 9616 host_impl_->FlingScrollBegin().thread); |
| 9625 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9617 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9626 | 9618 |
| 9627 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9619 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9628 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9620 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9629 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9621 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9630 | 9622 |
| 9631 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9623 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9632 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9624 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9633 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9625 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9634 | 9626 |
| 9635 host_impl_->ScrollEnd(EndState().get()); | 9627 host_impl_->ScrollEnd(EndState().get()); |
| 9636 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9637 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9628 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 9638 | 9629 |
| 9639 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9630 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9640 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9631 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9641 } | 9632 } |
| 9642 } | 9633 } |
| 9643 | 9634 |
| 9644 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9635 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9645 DiagonalScrollBubblesPerfectlyToInner) { | 9636 DiagonalScrollBubblesPerfectlyToInner) { |
| 9646 gfx::Size content_size = gfx::Size(200, 320); | 9637 gfx::Size content_size = gfx::Size(200, 320); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9684 // Now diagonal scroll across the outer viewport boundary in a single event. | 9675 // Now diagonal scroll across the outer viewport boundary in a single event. |
| 9685 // The entirety of the scroll should be consumed, as bubbling between inner | 9676 // The entirety of the scroll should be consumed, as bubbling between inner |
| 9686 // and outer viewport layers is perfect. | 9677 // and outer viewport layers is perfect. |
| 9687 host_impl_->ScrollBy( | 9678 host_impl_->ScrollBy( |
| 9688 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); | 9679 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); |
| 9689 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 9680 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9690 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9681 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9691 outer_expected += scroll_delta; | 9682 outer_expected += scroll_delta; |
| 9692 inner_expected += scroll_delta; | 9683 inner_expected += scroll_delta; |
| 9693 host_impl_->ScrollEnd(EndState().get()); | 9684 host_impl_->ScrollEnd(EndState().get()); |
| 9694 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9695 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9685 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9696 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9686 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9697 | 9687 |
| 9698 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9688 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9699 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9689 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9700 } | 9690 } |
| 9701 } | 9691 } |
| 9702 | 9692 |
| 9703 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9693 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9704 TouchFlingDoesntSwitchScrollingLayer) { | 9694 TouchFlingDoesntSwitchScrollingLayer) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9757 EXPECT_TRUE( | 9747 EXPECT_TRUE( |
| 9758 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 9748 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 9759 ExpectNone(*scroll_info, inner_scroll->id()); | 9749 ExpectNone(*scroll_info, inner_scroll->id()); |
| 9760 | 9750 |
| 9761 // As the locked layer is at its limit, no further scrolling can occur. | 9751 // As the locked layer is at its limit, no further scrolling can occur. |
| 9762 EXPECT_FALSE( | 9752 EXPECT_FALSE( |
| 9763 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9753 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 9764 .did_scroll); | 9754 .did_scroll); |
| 9765 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9755 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 9766 host_impl_->ScrollEnd(EndState().get()); | 9756 host_impl_->ScrollEnd(EndState().get()); |
| 9767 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9768 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9757 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9769 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9758 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9770 } | 9759 } |
| 9771 } | 9760 } |
| 9772 | 9761 |
| 9773 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9762 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9774 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 9763 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
| 9775 gfx::Size content_size = gfx::Size(100, 160); | 9764 gfx::Size content_size = gfx::Size(100, 160); |
| 9776 gfx::Size outer_viewport = gfx::Size(50, 80); | 9765 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 9777 gfx::Size inner_viewport = gfx::Size(25, 40); | 9766 gfx::Size inner_viewport = gfx::Size(25, 40); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10407 InputHandler::WHEEL) | 10396 InputHandler::WHEEL) |
| 10408 .thread); | 10397 .thread); |
| 10409 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 10398 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
| 10410 InputHandler::WHEEL)); | 10399 InputHandler::WHEEL)); |
| 10411 host_impl_->ScrollBy( | 10400 host_impl_->ScrollBy( |
| 10412 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 10401 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
| 10413 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 10402 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
| 10414 InputHandler::WHEEL)); | 10403 InputHandler::WHEEL)); |
| 10415 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 10404 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
| 10416 host_impl_->ScrollEnd(scroll_state_end.get()); | 10405 host_impl_->ScrollEnd(scroll_state_end.get()); |
| 10417 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 10418 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 10406 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 10419 InputHandler::WHEEL)); | 10407 InputHandler::WHEEL)); |
| 10420 | 10408 |
| 10421 // The instant scroll should have marked the smooth scroll animation as | 10409 // The instant scroll should have marked the smooth scroll animation as |
| 10422 // aborted. | 10410 // aborted. |
| 10423 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 10411 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 10424 scrolling_layer->element_id())); | 10412 scrolling_layer->element_id())); |
| 10425 | 10413 |
| 10426 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 10414 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 10427 scrolling_layer->CurrentScrollOffset()); | 10415 scrolling_layer->CurrentScrollOffset()); |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11638 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11626 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11639 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11627 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11640 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11628 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
| 11641 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11629 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
| 11642 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11630 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
| 11643 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11631 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11644 } | 11632 } |
| 11645 | 11633 |
| 11646 } // namespace | 11634 } // namespace |
| 11647 } // namespace cc | 11635 } // namespace cc |
| OLD | NEW |