| 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 680 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 681 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 681 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 682 status.main_thread_scrolling_reasons); | 682 status.main_thread_scrolling_reasons); |
| 683 | 683 |
| 684 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 684 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 685 InputHandler::WHEEL)); | 685 InputHandler::WHEEL)); |
| 686 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 686 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 687 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), | 687 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), |
| 688 InputHandler::WHEEL)); | 688 InputHandler::WHEEL)); |
| 689 host_impl_->ScrollEnd(EndState().get()); | 689 host_impl_->ScrollEnd(EndState().get()); |
| 690 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 691 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 690 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 692 InputHandler::WHEEL)); | 691 InputHandler::WHEEL)); |
| 693 EXPECT_TRUE(did_request_redraw_); | 692 EXPECT_TRUE(did_request_redraw_); |
| 694 EXPECT_TRUE(did_request_commit_); | 693 EXPECT_TRUE(did_request_commit_); |
| 695 } | 694 } |
| 696 | 695 |
| 697 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { | 696 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { |
| 698 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 697 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 699 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 698 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 700 | 699 |
| 701 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 700 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 702 DrawFrame(); | 701 DrawFrame(); |
| 703 | 702 |
| 704 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 703 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 705 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 704 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 706 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 705 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 707 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 706 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 708 status.main_thread_scrolling_reasons); | 707 status.main_thread_scrolling_reasons); |
| 709 | 708 |
| 710 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 709 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| 711 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 710 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 712 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); | 711 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); |
| 713 host_impl_->ScrollEnd(EndState().get()); | 712 host_impl_->ScrollEnd(EndState().get()); |
| 714 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 715 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 713 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| 716 } | 714 } |
| 717 | 715 |
| 718 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { | 716 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { |
| 719 // We should not crash when trying to scroll an empty layer tree. | 717 // We should not crash when trying to scroll an empty layer tree. |
| 720 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 718 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 721 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 719 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 722 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 720 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 723 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 721 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 724 status.main_thread_scrolling_reasons); | 722 status.main_thread_scrolling_reasons); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1029 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1032 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1030 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1033 status.main_thread_scrolling_reasons); | 1031 status.main_thread_scrolling_reasons); |
| 1034 | 1032 |
| 1035 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 1033 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1036 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1034 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1037 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1035 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 1038 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1036 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1039 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); | 1037 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); |
| 1040 host_impl_->ScrollEnd(EndState().get()); | 1038 host_impl_->ScrollEnd(EndState().get()); |
| 1041 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 1042 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1039 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1043 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1040 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1044 | 1041 |
| 1045 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), | 1042 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), |
| 1046 InputHandler::TOUCHSCREEN); | 1043 InputHandler::TOUCHSCREEN); |
| 1047 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1044 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1048 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1045 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1049 status.main_thread_scrolling_reasons); | 1046 status.main_thread_scrolling_reasons); |
| 1050 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 1047 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1051 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1048 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1052 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1049 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 1053 host_impl_->ScrollEnd(EndState().get()); | 1050 host_impl_->ScrollEnd(EndState().get()); |
| 1054 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 1055 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1051 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1056 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1052 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1057 } | 1053 } |
| 1058 | 1054 |
| 1059 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 1055 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
| 1060 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1056 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1061 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1057 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1062 | 1058 |
| 1063 LayerImpl* root = *host_impl_->active_tree()->begin(); | 1059 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1064 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1060 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1103 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1108 host_impl_->active_tree()->set_have_scroll_event_handlers(true); | 1104 host_impl_->active_tree()->set_have_scroll_event_handlers(true); |
| 1109 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1105 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1110 DrawFrame(); | 1106 DrawFrame(); |
| 1111 | 1107 |
| 1112 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1108 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1113 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1109 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1114 InputHandler::TOUCHSCREEN); | 1110 InputHandler::TOUCHSCREEN); |
| 1115 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); | 1111 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); |
| 1116 host_impl_->ScrollEnd(EndState().get()); | 1112 host_impl_->ScrollEnd(EndState().get()); |
| 1117 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 1118 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1113 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1119 } | 1114 } |
| 1120 | 1115 |
| 1121 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { | 1116 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { |
| 1122 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1117 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1123 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1118 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1124 | 1119 |
| 1125 DrawFrame(); | 1120 DrawFrame(); |
| 1126 | 1121 |
| 1127 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1122 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| (...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2781 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2776 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2782 InputHandler::WHEEL); | 2777 InputHandler::WHEEL); |
| 2783 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 2778 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
| 2784 EXPECT_FALSE(did_request_next_frame_); | 2779 EXPECT_FALSE(did_request_next_frame_); |
| 2785 EXPECT_TRUE(did_request_redraw_); | 2780 EXPECT_TRUE(did_request_redraw_); |
| 2786 did_request_redraw_ = false; | 2781 did_request_redraw_ = false; |
| 2787 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2782 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2788 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2783 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2789 | 2784 |
| 2790 host_impl_->ScrollEnd(EndState().get()); | 2785 host_impl_->ScrollEnd(EndState().get()); |
| 2791 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 2792 EXPECT_FALSE(did_request_next_frame_); | 2786 EXPECT_FALSE(did_request_next_frame_); |
| 2793 EXPECT_FALSE(did_request_redraw_); | 2787 EXPECT_FALSE(did_request_redraw_); |
| 2794 if (expecting_animations) { | 2788 if (expecting_animations) { |
| 2795 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 2789 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2796 requested_animation_delay_); | 2790 requested_animation_delay_); |
| 2797 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2791 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2798 } else { | 2792 } else { |
| 2799 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2793 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2800 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2794 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2801 } | 2795 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2875 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2869 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2876 InputHandler::WHEEL); | 2870 InputHandler::WHEEL); |
| 2877 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); | 2871 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); |
| 2878 EXPECT_FALSE(did_request_next_frame_); | 2872 EXPECT_FALSE(did_request_next_frame_); |
| 2879 EXPECT_TRUE(did_request_redraw_); | 2873 EXPECT_TRUE(did_request_redraw_); |
| 2880 did_request_redraw_ = false; | 2874 did_request_redraw_ = false; |
| 2881 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2875 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2882 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2876 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2883 | 2877 |
| 2884 host_impl_->ScrollEnd(EndState().get()); | 2878 host_impl_->ScrollEnd(EndState().get()); |
| 2885 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 2886 EXPECT_FALSE(did_request_next_frame_); | 2879 EXPECT_FALSE(did_request_next_frame_); |
| 2887 EXPECT_FALSE(did_request_redraw_); | 2880 EXPECT_FALSE(did_request_redraw_); |
| 2888 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2881 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2889 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2882 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2890 | 2883 |
| 2891 // Changing page scale triggers scrollbar animation. | 2884 // Changing page scale triggers scrollbar animation. |
| 2892 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 2885 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
| 2893 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); | 2886 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); |
| 2894 EXPECT_FALSE(did_request_next_frame_); | 2887 EXPECT_FALSE(did_request_next_frame_); |
| 2895 EXPECT_FALSE(did_request_redraw_); | 2888 EXPECT_FALSE(did_request_redraw_); |
| (...skipping 6472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9368 host_impl_->FlingScrollBegin().thread); | 9361 host_impl_->FlingScrollBegin().thread); |
| 9369 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 9362 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9370 | 9363 |
| 9371 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 9364 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
| 9372 inner_viewport.height() / 2.f); | 9365 inner_viewport.height() / 2.f); |
| 9373 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9366 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9374 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9367 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9375 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 9368 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9376 | 9369 |
| 9377 host_impl_->ScrollEnd(EndState().get()); | 9370 host_impl_->ScrollEnd(EndState().get()); |
| 9378 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9379 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9371 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 9380 | 9372 |
| 9381 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9373 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9382 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9374 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9383 | 9375 |
| 9384 // Fling past the inner viewport boundry, make sure outer viewport scrolls. | 9376 // Fling past the inner viewport boundry, make sure outer viewport scrolls. |
| 9385 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9377 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9386 host_impl_ | 9378 host_impl_ |
| 9387 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9379 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9388 InputHandler::TOUCHSCREEN) | 9380 InputHandler::TOUCHSCREEN) |
| 9389 .thread); | 9381 .thread); |
| 9390 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 9382 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9391 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9383 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9392 host_impl_->FlingScrollBegin().thread); | 9384 host_impl_->FlingScrollBegin().thread); |
| 9393 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 9385 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9394 | 9386 |
| 9395 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9387 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9396 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9388 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9397 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 9389 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9398 | 9390 |
| 9399 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9391 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9400 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9392 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9401 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 9393 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 9402 | 9394 |
| 9403 host_impl_->ScrollEnd(EndState().get()); | 9395 host_impl_->ScrollEnd(EndState().get()); |
| 9404 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9405 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9396 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 9406 | 9397 |
| 9407 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9398 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9408 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9399 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9409 } | 9400 } |
| 9410 } | 9401 } |
| 9411 | 9402 |
| 9412 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9403 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9413 DiagonalScrollBubblesPerfectlyToInner) { | 9404 DiagonalScrollBubblesPerfectlyToInner) { |
| 9414 gfx::Size content_size = gfx::Size(200, 320); | 9405 gfx::Size content_size = gfx::Size(200, 320); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9452 // Now diagonal scroll across the outer viewport boundary in a single event. | 9443 // Now diagonal scroll across the outer viewport boundary in a single event. |
| 9453 // The entirety of the scroll should be consumed, as bubbling between inner | 9444 // The entirety of the scroll should be consumed, as bubbling between inner |
| 9454 // and outer viewport layers is perfect. | 9445 // and outer viewport layers is perfect. |
| 9455 host_impl_->ScrollBy( | 9446 host_impl_->ScrollBy( |
| 9456 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); | 9447 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); |
| 9457 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 9448 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9458 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9449 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9459 outer_expected += scroll_delta; | 9450 outer_expected += scroll_delta; |
| 9460 inner_expected += scroll_delta; | 9451 inner_expected += scroll_delta; |
| 9461 host_impl_->ScrollEnd(EndState().get()); | 9452 host_impl_->ScrollEnd(EndState().get()); |
| 9462 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9463 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9453 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9464 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9454 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9465 | 9455 |
| 9466 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9456 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9467 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9457 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9468 } | 9458 } |
| 9469 } | 9459 } |
| 9470 | 9460 |
| 9471 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9461 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9472 TouchFlingDoesntSwitchScrollingLayer) { | 9462 TouchFlingDoesntSwitchScrollingLayer) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9525 EXPECT_TRUE( | 9515 EXPECT_TRUE( |
| 9526 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 9516 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 9527 ExpectNone(*scroll_info, inner_scroll->id()); | 9517 ExpectNone(*scroll_info, inner_scroll->id()); |
| 9528 | 9518 |
| 9529 // As the locked layer is at its limit, no further scrolling can occur. | 9519 // As the locked layer is at its limit, no further scrolling can occur. |
| 9530 EXPECT_FALSE( | 9520 EXPECT_FALSE( |
| 9531 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9521 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 9532 .did_scroll); | 9522 .did_scroll); |
| 9533 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9523 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 9534 host_impl_->ScrollEnd(EndState().get()); | 9524 host_impl_->ScrollEnd(EndState().get()); |
| 9535 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 9536 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9525 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9537 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9526 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9538 } | 9527 } |
| 9539 } | 9528 } |
| 9540 | 9529 |
| 9541 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9530 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9542 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 9531 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
| 9543 gfx::Size content_size = gfx::Size(100, 160); | 9532 gfx::Size content_size = gfx::Size(100, 160); |
| 9544 gfx::Size outer_viewport = gfx::Size(50, 80); | 9533 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 9545 gfx::Size inner_viewport = gfx::Size(25, 40); | 9534 gfx::Size inner_viewport = gfx::Size(25, 40); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10175 InputHandler::WHEEL) | 10164 InputHandler::WHEEL) |
| 10176 .thread); | 10165 .thread); |
| 10177 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 10166 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
| 10178 InputHandler::WHEEL)); | 10167 InputHandler::WHEEL)); |
| 10179 host_impl_->ScrollBy( | 10168 host_impl_->ScrollBy( |
| 10180 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 10169 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
| 10181 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 10170 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
| 10182 InputHandler::WHEEL)); | 10171 InputHandler::WHEEL)); |
| 10183 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 10172 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
| 10184 host_impl_->ScrollEnd(scroll_state_end.get()); | 10173 host_impl_->ScrollEnd(scroll_state_end.get()); |
| 10185 host_impl_->ClearCurrentlyScrollingLayerForTesting(); | |
| 10186 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 10174 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 10187 InputHandler::WHEEL)); | 10175 InputHandler::WHEEL)); |
| 10188 | 10176 |
| 10189 // The instant scroll should have marked the smooth scroll animation as | 10177 // The instant scroll should have marked the smooth scroll animation as |
| 10190 // aborted. | 10178 // aborted. |
| 10191 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 10179 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 10192 scrolling_layer->element_id())); | 10180 scrolling_layer->element_id())); |
| 10193 | 10181 |
| 10194 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 10182 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 10195 scrolling_layer->CurrentScrollOffset()); | 10183 scrolling_layer->CurrentScrollOffset()); |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11210 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11198 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11211 | 11199 |
| 11212 // Re-initialize with a software output surface. | 11200 // Re-initialize with a software output surface. |
| 11213 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11201 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11214 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11202 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11215 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11203 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11216 } | 11204 } |
| 11217 | 11205 |
| 11218 } // namespace | 11206 } // namespace |
| 11219 } // namespace cc | 11207 } // namespace cc |
| OLD | NEW |