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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 498 |
499 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { | 499 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { |
500 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 500 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
501 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 501 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
502 DrawFrame(); | 502 DrawFrame(); |
503 | 503 |
504 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 504 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
505 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 505 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
506 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 506 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
507 InputHandler::WHEEL)); | 507 InputHandler::WHEEL)); |
508 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 508 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 509 InputHandler::RAILS_MODE_FREE); |
509 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), | 510 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), |
510 InputHandler::WHEEL)); | 511 InputHandler::WHEEL)); |
511 host_impl_->ScrollEnd(); | 512 host_impl_->ScrollEnd(); |
512 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 513 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
513 InputHandler::WHEEL)); | 514 InputHandler::WHEEL)); |
514 EXPECT_TRUE(did_request_redraw_); | 515 EXPECT_TRUE(did_request_redraw_); |
515 EXPECT_TRUE(did_request_commit_); | 516 EXPECT_TRUE(did_request_commit_); |
516 } | 517 } |
517 | 518 |
518 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { | 519 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { |
519 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 520 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
520 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 521 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
521 DrawFrame(); | 522 DrawFrame(); |
522 | 523 |
523 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 524 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
524 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 525 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
525 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 526 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
526 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 527 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 528 InputHandler::RAILS_MODE_FREE); |
527 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); | 529 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); |
528 host_impl_->ScrollEnd(); | 530 host_impl_->ScrollEnd(); |
529 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 531 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
530 } | 532 } |
531 | 533 |
532 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { | 534 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { |
533 // We should not crash when trying to scroll an empty layer tree. | 535 // We should not crash when trying to scroll an empty layer tree. |
534 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 536 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
535 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 537 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
536 } | 538 } |
(...skipping 23 matching lines...) Expand all Loading... |
560 // We should not crash if the tree is replaced while we are scrolling. | 562 // We should not crash if the tree is replaced while we are scrolling. |
561 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 563 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
562 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 564 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
563 host_impl_->active_tree()->DetachLayerTree(); | 565 host_impl_->active_tree()->DetachLayerTree(); |
564 | 566 |
565 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 567 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
566 | 568 |
567 // We should still be scrolling, because the scrolled layer also exists in the | 569 // We should still be scrolling, because the scrolled layer also exists in the |
568 // new tree. | 570 // new tree. |
569 gfx::Vector2d scroll_delta(0, 10); | 571 gfx::Vector2d scroll_delta(0, 10); |
570 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 572 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 573 InputHandler::RAILS_MODE_FREE); |
571 host_impl_->ScrollEnd(); | 574 host_impl_->ScrollEnd(); |
572 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 575 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
573 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 576 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
574 } | 577 } |
575 | 578 |
576 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 579 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
577 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 580 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
578 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 581 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
579 DrawFrame(); | 582 DrawFrame(); |
580 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 583 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 835 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, |
833 host_impl_->ScrollBegin(gfx::Point(25, 25), InputHandler::GESTURE)); | 836 host_impl_->ScrollBegin(gfx::Point(25, 25), InputHandler::GESTURE)); |
834 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 837 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
835 InputHandler::GESTURE)); | 838 InputHandler::GESTURE)); |
836 | 839 |
837 // All scroll types outside this region should succeed. | 840 // All scroll types outside this region should succeed. |
838 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 841 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
839 host_impl_->ScrollBegin(gfx::Point(75, 75), InputHandler::WHEEL)); | 842 host_impl_->ScrollBegin(gfx::Point(75, 75), InputHandler::WHEEL)); |
840 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 843 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
841 InputHandler::GESTURE)); | 844 InputHandler::GESTURE)); |
842 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 845 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 846 InputHandler::RAILS_MODE_FREE); |
843 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 847 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
844 InputHandler::GESTURE)); | 848 InputHandler::GESTURE)); |
845 host_impl_->ScrollEnd(); | 849 host_impl_->ScrollEnd(); |
846 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 850 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
847 InputHandler::GESTURE)); | 851 InputHandler::GESTURE)); |
848 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 852 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
849 host_impl_->ScrollBegin(gfx::Point(75, 75), InputHandler::GESTURE)); | 853 host_impl_->ScrollBegin(gfx::Point(75, 75), InputHandler::GESTURE)); |
850 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 854 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
851 InputHandler::GESTURE)); | 855 InputHandler::GESTURE)); |
852 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 856 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 857 InputHandler::RAILS_MODE_FREE); |
853 host_impl_->ScrollEnd(); | 858 host_impl_->ScrollEnd(); |
854 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 859 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
855 InputHandler::GESTURE)); | 860 InputHandler::GESTURE)); |
856 } | 861 } |
857 | 862 |
858 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 863 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
859 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 864 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
860 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 865 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
861 | 866 |
862 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 867 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
863 root->SetContentsScale(2.f, 2.f); | 868 root->SetContentsScale(2.f, 2.f); |
864 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 869 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
865 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 870 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
866 | 871 |
867 DrawFrame(); | 872 DrawFrame(); |
868 | 873 |
869 // This point would fall into the non-fast scrollable region except that we've | 874 // This point would fall into the non-fast scrollable region except that we've |
870 // moved the layer down by 25 pixels. | 875 // moved the layer down by 25 pixels. |
871 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 876 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
872 host_impl_->ScrollBegin(gfx::Point(40, 10), InputHandler::WHEEL)); | 877 host_impl_->ScrollBegin(gfx::Point(40, 10), InputHandler::WHEEL)); |
873 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10), | 878 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10), |
874 InputHandler::WHEEL)); | 879 InputHandler::WHEEL)); |
875 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 1)); | 880 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 1), |
| 881 InputHandler::RAILS_MODE_FREE); |
876 host_impl_->ScrollEnd(); | 882 host_impl_->ScrollEnd(); |
877 | 883 |
878 // This point is still inside the non-fast region. | 884 // This point is still inside the non-fast region. |
879 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 885 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, |
880 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::WHEEL)); | 886 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::WHEEL)); |
881 } | 887 } |
882 | 888 |
883 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { | 889 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { |
884 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 890 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
885 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); | 891 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); |
(...skipping 23 matching lines...) Expand all Loading... |
909 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { | 915 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { |
910 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 916 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
911 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 917 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
912 | 918 |
913 DrawFrame(); | 919 DrawFrame(); |
914 | 920 |
915 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 921 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
916 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 922 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
917 | 923 |
918 // Trying to scroll to the left/top will not succeed. | 924 // Trying to scroll to the left/top will not succeed. |
919 EXPECT_FALSE( | 925 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0), |
920 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); | 926 InputHandler::RAILS_MODE_FREE).did_scroll); |
921 EXPECT_FALSE( | 927 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10), |
922 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll); | 928 InputHandler::RAILS_MODE_FREE).did_scroll); |
923 EXPECT_FALSE( | 929 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10), |
924 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll); | 930 InputHandler::RAILS_MODE_FREE).did_scroll); |
925 | 931 |
926 // Scrolling to the right/bottom will succeed. | 932 // Scrolling to the right/bottom will succeed. |
927 EXPECT_TRUE( | 933 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0), |
928 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)).did_scroll); | 934 InputHandler::RAILS_MODE_FREE).did_scroll); |
929 EXPECT_TRUE( | 935 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
930 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); | 936 InputHandler::RAILS_MODE_FREE).did_scroll); |
931 EXPECT_TRUE( | 937 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 10), |
932 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 10)).did_scroll); | 938 InputHandler::RAILS_MODE_FREE).did_scroll); |
933 | 939 |
934 // Scrolling to left/top will now succeed. | 940 // Scrolling to left/top will now succeed. |
935 EXPECT_TRUE( | 941 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0), |
936 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); | 942 InputHandler::RAILS_MODE_FREE).did_scroll); |
937 EXPECT_TRUE( | 943 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10), |
938 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll); | 944 InputHandler::RAILS_MODE_FREE).did_scroll); |
939 EXPECT_TRUE( | 945 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10), |
940 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll); | 946 InputHandler::RAILS_MODE_FREE).did_scroll); |
941 | 947 |
942 // Scrolling diagonally against an edge will succeed. | 948 // Scrolling diagonally against an edge will succeed. |
943 EXPECT_TRUE( | 949 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10), |
944 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10)).did_scroll); | 950 InputHandler::RAILS_MODE_FREE).did_scroll); |
945 EXPECT_TRUE( | 951 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0), |
946 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); | 952 InputHandler::RAILS_MODE_FREE).did_scroll); |
947 EXPECT_TRUE( | 953 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10), |
948 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10)).did_scroll); | 954 InputHandler::RAILS_MODE_FREE).did_scroll); |
949 | 955 |
950 // Trying to scroll more than the available space will also succeed. | 956 // Trying to scroll more than the available space will also succeed. |
951 EXPECT_TRUE( | 957 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000), |
952 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)).did_scroll); | 958 InputHandler::RAILS_MODE_FREE).did_scroll); |
| 959 } |
| 960 |
| 961 TEST_F(LayerTreeHostImplTest, ScrollByRespectsRails) { |
| 962 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 963 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 964 DrawFrame(); |
| 965 InputHandlerScrollResult result; |
| 966 |
| 967 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 968 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
| 969 |
| 970 // A free scroll. |
| 971 result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(1, 2), |
| 972 InputHandler::RAILS_MODE_FREE); |
| 973 EXPECT_TRUE(result.did_scroll); |
| 974 EXPECT_FALSE(result.did_overscroll_root); |
| 975 EXPECT_VECTOR_EQ(gfx::Vector2dF(1, 2), scroll_layer->CurrentScrollOffset()); |
| 976 |
| 977 // A vertically railed scroll. |
| 978 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(1, 2), |
| 979 InputHandler::RAILS_MODE_VERTICAL); |
| 980 EXPECT_TRUE(result.did_scroll); |
| 981 EXPECT_FALSE(result.did_overscroll_root); |
| 982 EXPECT_VECTOR_EQ(gfx::Vector2dF(1, 4), scroll_layer->CurrentScrollOffset()); |
| 983 |
| 984 // A horizontally railed scroll. |
| 985 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(1, 2), |
| 986 InputHandler::RAILS_MODE_HORIZONTAL); |
| 987 EXPECT_TRUE(result.did_scroll); |
| 988 EXPECT_FALSE(result.did_overscroll_root); |
| 989 EXPECT_VECTOR_EQ(gfx::Vector2dF(2, 4), scroll_layer->CurrentScrollOffset()); |
| 990 |
| 991 // A horizontally railed scroll which has no horizontal component. |
| 992 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 2), |
| 993 InputHandler::RAILS_MODE_HORIZONTAL); |
| 994 EXPECT_TRUE(result.did_scroll); |
| 995 EXPECT_FALSE(result.did_overscroll_root); |
| 996 EXPECT_VECTOR_EQ(gfx::Vector2dF(2, 4), scroll_layer->CurrentScrollOffset()); |
| 997 |
| 998 // A free scroll to return to the document's edge, so we can test overscroll. |
| 999 result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-2, -4), |
| 1000 InputHandler::RAILS_MODE_FREE); |
| 1001 EXPECT_TRUE(result.did_scroll); |
| 1002 EXPECT_FALSE(result.did_overscroll_root); |
| 1003 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1004 |
| 1005 // A horizontally railed overscroll with a vertical component in overscroll |
| 1006 // direction. |
| 1007 result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-1, -2), |
| 1008 InputHandler::RAILS_MODE_HORIZONTAL); |
| 1009 EXPECT_FALSE(result.did_scroll); |
| 1010 EXPECT_TRUE(result.did_overscroll_root); |
| 1011 EXPECT_EQ(gfx::Vector2dF(-1, 0), result.unused_scroll_delta); |
| 1012 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1013 |
| 1014 // A horizontally railed overscroll with a vertical component in scroll |
| 1015 // direction. |
| 1016 result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-1, 2), |
| 1017 InputHandler::RAILS_MODE_HORIZONTAL); |
| 1018 EXPECT_FALSE(result.did_scroll); |
| 1019 EXPECT_TRUE(result.did_overscroll_root); |
| 1020 EXPECT_EQ(gfx::Vector2dF(-1, 0), result.unused_scroll_delta); |
| 1021 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1022 |
| 1023 // A vertically railed scroll with a horizontal component in overscroll |
| 1024 // direction. |
| 1025 result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-1, 2), |
| 1026 InputHandler::RAILS_MODE_VERTICAL); |
| 1027 EXPECT_TRUE(result.did_scroll); |
| 1028 EXPECT_FALSE(result.did_overscroll_root); |
| 1029 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2), scroll_layer->CurrentScrollOffset()); |
953 } | 1030 } |
954 | 1031 |
955 TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) { | 1032 TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) { |
956 SetupScrollAndContentsLayers(gfx::Size(200, 2000)); | 1033 SetupScrollAndContentsLayers(gfx::Size(200, 2000)); |
957 host_impl_->SetViewportSize(gfx::Size(100, 1000)); | 1034 host_impl_->SetViewportSize(gfx::Size(100, 1000)); |
958 | 1035 |
959 DrawFrame(); | 1036 DrawFrame(); |
960 | 1037 |
961 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1038 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
962 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 1039 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1077 |
1001 DrawFrame(); | 1078 DrawFrame(); |
1002 gfx::Point scroll_position(10, 10); | 1079 gfx::Point scroll_position(10, 10); |
1003 | 1080 |
1004 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1081 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1005 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1082 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
1006 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1083 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1007 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); | 1084 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
1008 | 1085 |
1009 gfx::Vector2dF scroll_delta(10, 10); | 1086 gfx::Vector2dF scroll_delta(10, 10); |
1010 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1087 host_impl_->ScrollBy(scroll_position, scroll_delta, |
| 1088 InputHandler::RAILS_MODE_FREE); |
1011 host_impl_->ScrollEnd(); | 1089 host_impl_->ScrollEnd(); |
1012 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1090 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1013 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1091 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
1014 | 1092 |
1015 overflow->set_user_scrollable_horizontal(false); | 1093 overflow->set_user_scrollable_horizontal(false); |
1016 | 1094 |
1017 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1095 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1018 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1096 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
1019 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1097 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1020 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1098 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
1021 | 1099 |
1022 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1100 host_impl_->ScrollBy(scroll_position, scroll_delta, |
| 1101 InputHandler::RAILS_MODE_FREE); |
1023 host_impl_->ScrollEnd(); | 1102 host_impl_->ScrollEnd(); |
1024 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); | 1103 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
1025 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1104 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1026 | 1105 |
1027 overflow->set_user_scrollable_vertical(false); | 1106 overflow->set_user_scrollable_vertical(false); |
1028 | 1107 |
1029 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1108 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1030 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1109 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
1031 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); | 1110 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
1032 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1111 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1033 | 1112 |
1034 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1113 host_impl_->ScrollBy(scroll_position, scroll_delta, |
| 1114 InputHandler::RAILS_MODE_FREE); |
1035 host_impl_->ScrollEnd(); | 1115 host_impl_->ScrollEnd(); |
1036 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); | 1116 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); |
1037 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1117 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1038 } | 1118 } |
1039 | 1119 |
1040 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 1120 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
1041 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1121 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1042 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1122 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1043 DrawFrame(); | 1123 DrawFrame(); |
1044 | 1124 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 float page_scale_delta = 2.f; | 1167 float page_scale_delta = 2.f; |
1088 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 1168 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); |
1089 host_impl_->PinchGestureBegin(); | 1169 host_impl_->PinchGestureBegin(); |
1090 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1170 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
1091 host_impl_->PinchGestureEnd(); | 1171 host_impl_->PinchGestureEnd(); |
1092 host_impl_->ScrollEnd(); | 1172 host_impl_->ScrollEnd(); |
1093 | 1173 |
1094 gfx::Vector2d scroll_delta(0, 10); | 1174 gfx::Vector2d scroll_delta(0, 10); |
1095 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1175 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1096 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 1176 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
1097 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 1177 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 1178 InputHandler::RAILS_MODE_FREE); |
1098 host_impl_->ScrollEnd(); | 1179 host_impl_->ScrollEnd(); |
1099 | 1180 |
1100 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1181 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1101 host_impl_->ProcessScrollDeltas(); | 1182 host_impl_->ProcessScrollDeltas(); |
1102 ExpectContains(*scroll_info.get(), scroll_layer->id(), | 1183 ExpectContains(*scroll_info.get(), scroll_layer->id(), |
1103 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)); | 1184 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)); |
1104 } | 1185 } |
1105 } | 1186 } |
1106 | 1187 |
1107 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1188 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
1108 ui::LatencyInfo latency_info; | 1189 ui::LatencyInfo latency_info; |
1109 latency_info.trace_id = 1234; | 1190 latency_info.trace_id = 1234; |
1110 scoped_ptr<SwapPromise> swap_promise( | 1191 scoped_ptr<SwapPromise> swap_promise( |
1111 new LatencyInfoSwapPromise(latency_info)); | 1192 new LatencyInfoSwapPromise(latency_info)); |
1112 | 1193 |
1113 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1194 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1114 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1195 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1115 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 1196 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
1116 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1197 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 1198 InputHandler::RAILS_MODE_FREE); |
1117 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); | 1199 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); |
1118 host_impl_->ScrollEnd(); | 1200 host_impl_->ScrollEnd(); |
1119 | 1201 |
1120 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1202 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
1121 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 1203 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
1122 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); | 1204 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); |
1123 } | 1205 } |
1124 | 1206 |
1125 TEST_F(LayerTreeHostImplTest, PinchGesture) { | 1207 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
1126 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1208 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1303 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1222 max_page_scale); | 1304 max_page_scale); |
1223 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1305 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1224 scroll_layer->PullDeltaForMainThread(); | 1306 scroll_layer->PullDeltaForMainThread(); |
1225 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); | 1307 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
1226 | 1308 |
1227 float page_scale_delta = 1.f; | 1309 float page_scale_delta = 1.f; |
1228 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE); | 1310 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE); |
1229 host_impl_->PinchGestureBegin(); | 1311 host_impl_->PinchGestureBegin(); |
1230 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1312 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
1231 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 1313 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10), |
| 1314 InputHandler::RAILS_MODE_FREE); |
1232 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1315 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
1233 host_impl_->PinchGestureEnd(); | 1316 host_impl_->PinchGestureEnd(); |
1234 host_impl_->ScrollEnd(); | 1317 host_impl_->ScrollEnd(); |
1235 | 1318 |
1236 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1319 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1237 host_impl_->ProcessScrollDeltas(); | 1320 host_impl_->ProcessScrollDeltas(); |
1238 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1321 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
1239 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); | 1322 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); |
1240 } | 1323 } |
1241 | 1324 |
1242 // Two-finger panning should work when starting fully zoomed out. | 1325 // Two-finger panning should work when starting fully zoomed out. |
1243 { | 1326 { |
1244 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); | 1327 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); |
1245 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1328 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1246 scroll_layer->PullDeltaForMainThread(); | 1329 scroll_layer->PullDeltaForMainThread(); |
1247 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); | 1330 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); |
1248 | 1331 |
1249 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::GESTURE); | 1332 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::GESTURE); |
1250 host_impl_->PinchGestureBegin(); | 1333 host_impl_->PinchGestureBegin(); |
1251 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1334 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
1252 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); | 1335 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); |
1253 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); | 1336 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10), |
| 1337 InputHandler::RAILS_MODE_FREE); |
1254 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 1338 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
1255 host_impl_->PinchGestureEnd(); | 1339 host_impl_->PinchGestureEnd(); |
1256 host_impl_->ScrollEnd(); | 1340 host_impl_->ScrollEnd(); |
1257 | 1341 |
1258 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1342 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1259 host_impl_->ProcessScrollDeltas(); | 1343 host_impl_->ProcessScrollDeltas(); |
1260 EXPECT_EQ(scroll_info->page_scale_delta, 2.f); | 1344 EXPECT_EQ(scroll_info->page_scale_delta, 2.f); |
1261 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(20, 20)); | 1345 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(20, 20)); |
1262 } | 1346 } |
1263 } | 1347 } |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1717 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
1634 host_impl_->ScrollEnd(); | 1718 host_impl_->ScrollEnd(); |
1635 EXPECT_FALSE(did_request_animate_); | 1719 EXPECT_FALSE(did_request_animate_); |
1636 EXPECT_FALSE(did_request_redraw_); | 1720 EXPECT_FALSE(did_request_redraw_); |
1637 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 1721 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
1638 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 1722 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
1639 | 1723 |
1640 // After a scroll, a scrollbar animation should be scheduled about 20ms from | 1724 // After a scroll, a scrollbar animation should be scheduled about 20ms from |
1641 // now. | 1725 // now. |
1642 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1726 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
1643 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5)); | 1727 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5), |
| 1728 InputHandler::RAILS_MODE_FREE); |
1644 EXPECT_FALSE(did_request_animate_); | 1729 EXPECT_FALSE(did_request_animate_); |
1645 EXPECT_TRUE(did_request_redraw_); | 1730 EXPECT_TRUE(did_request_redraw_); |
1646 did_request_redraw_ = false; | 1731 did_request_redraw_ = false; |
1647 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 1732 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
1648 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 1733 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
1649 | 1734 |
1650 host_impl_->ScrollEnd(); | 1735 host_impl_->ScrollEnd(); |
1651 EXPECT_FALSE(did_request_animate_); | 1736 EXPECT_FALSE(did_request_animate_); |
1652 EXPECT_FALSE(did_request_redraw_); | 1737 EXPECT_FALSE(did_request_redraw_); |
1653 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 1738 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
(...skipping 24 matching lines...) Expand all Loading... |
1678 EXPECT_FALSE(did_request_animate_); | 1763 EXPECT_FALSE(did_request_animate_); |
1679 EXPECT_FALSE(did_request_redraw_); | 1764 EXPECT_FALSE(did_request_redraw_); |
1680 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 1765 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
1681 requested_animation_delay_); | 1766 requested_animation_delay_); |
1682 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 1767 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
1683 requested_animation_delay_ = base::TimeDelta(); | 1768 requested_animation_delay_ = base::TimeDelta(); |
1684 animation_task_ = base::Closure(); | 1769 animation_task_ = base::Closure(); |
1685 | 1770 |
1686 // Scrollbar animation is not triggered unnecessarily. | 1771 // Scrollbar animation is not triggered unnecessarily. |
1687 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1772 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
1688 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1773 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0), |
| 1774 InputHandler::RAILS_MODE_FREE); |
1689 EXPECT_FALSE(did_request_animate_); | 1775 EXPECT_FALSE(did_request_animate_); |
1690 EXPECT_TRUE(did_request_redraw_); | 1776 EXPECT_TRUE(did_request_redraw_); |
1691 did_request_redraw_ = false; | 1777 did_request_redraw_ = false; |
1692 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 1778 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
1693 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 1779 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
1694 | 1780 |
1695 host_impl_->ScrollEnd(); | 1781 host_impl_->ScrollEnd(); |
1696 EXPECT_FALSE(did_request_animate_); | 1782 EXPECT_FALSE(did_request_animate_); |
1697 EXPECT_FALSE(did_request_redraw_); | 1783 EXPECT_FALSE(did_request_redraw_); |
1698 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 1784 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 1912 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
1827 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 1913 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
1828 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 1914 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
1829 EXPECT_FALSE(metadata.root_overflow_x_hidden); | 1915 EXPECT_FALSE(metadata.root_overflow_x_hidden); |
1830 EXPECT_FALSE(metadata.root_overflow_y_hidden); | 1916 EXPECT_FALSE(metadata.root_overflow_y_hidden); |
1831 } | 1917 } |
1832 | 1918 |
1833 // Scrolling should update metadata immediately. | 1919 // Scrolling should update metadata immediately. |
1834 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1920 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1835 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 1921 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
1836 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1922 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 1923 InputHandler::RAILS_MODE_FREE); |
1837 { | 1924 { |
1838 CompositorFrameMetadata metadata = | 1925 CompositorFrameMetadata metadata = |
1839 host_impl_->MakeCompositorFrameMetadata(); | 1926 host_impl_->MakeCompositorFrameMetadata(); |
1840 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1927 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
1841 } | 1928 } |
1842 host_impl_->ScrollEnd(); | 1929 host_impl_->ScrollEnd(); |
1843 { | 1930 { |
1844 CompositorFrameMetadata metadata = | 1931 CompositorFrameMetadata metadata = |
1845 host_impl_->MakeCompositorFrameMetadata(); | 1932 host_impl_->MakeCompositorFrameMetadata(); |
1846 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1933 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2730 host_impl_->active_tree()->OuterViewportScrollLayer(); |
2644 LayerImpl *outer_container = | 2731 LayerImpl *outer_container = |
2645 host_impl_->active_tree()->OuterViewportContainerLayer(); | 2732 host_impl_->active_tree()->OuterViewportContainerLayer(); |
2646 | 2733 |
2647 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. | 2734 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
2648 outer_scroll->SetDrawsContent(true); | 2735 outer_scroll->SetDrawsContent(true); |
2649 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 2736 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
2650 | 2737 |
2651 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2738 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
2652 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2739 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
2653 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); | 2740 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f), |
| 2741 InputHandler::RAILS_MODE_FREE); |
2654 | 2742 |
2655 // The entire scroll delta should have been used to hide the top controls. | 2743 // The entire scroll delta should have been used to hide the top controls. |
2656 // The viewport layers should be resized back to their full sizes. | 2744 // The viewport layers should be resized back to their full sizes. |
2657 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 2745 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
2658 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 2746 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
2659 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 2747 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
2660 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 2748 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
2661 | 2749 |
2662 // The inner viewport should be scrollable by 50px * page_scale. | 2750 // The inner viewport should be scrollable by 50px * page_scale. |
2663 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); | 2751 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f), |
| 2752 InputHandler::RAILS_MODE_FREE); |
2664 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); | 2753 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
2665 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 2754 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
2666 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 2755 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
2667 | 2756 |
2668 host_impl_->ScrollEnd(); | 2757 host_impl_->ScrollEnd(); |
2669 | 2758 |
2670 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2759 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
2671 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2760 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
2672 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 2761 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
2673 | 2762 |
2674 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2763 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f), |
| 2764 InputHandler::RAILS_MODE_FREE); |
2675 | 2765 |
2676 // The entire scroll delta should have been used to show the top controls. | 2766 // The entire scroll delta should have been used to show the top controls. |
2677 // The outer viewport should be resized to accomodate and scrolled to the | 2767 // The outer viewport should be resized to accomodate and scrolled to the |
2678 // bottom of the document to keep the viewport in place. | 2768 // bottom of the document to keep the viewport in place. |
2679 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 2769 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
2680 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 2770 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
2681 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 2771 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
2682 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); | 2772 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
2683 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); | 2773 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
2684 | 2774 |
2685 // Now when we continue scrolling, make sure the outer viewport gets scrolled | 2775 // Now when we continue scrolling, make sure the outer viewport gets scrolled |
2686 // since it wasn't scrollable when the scroll began. | 2776 // since it wasn't scrollable when the scroll began. |
2687 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); | 2777 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f), |
| 2778 InputHandler::RAILS_MODE_FREE); |
2688 EXPECT_EQ(15.f, outer_scroll->CurrentScrollOffset().y()); | 2779 EXPECT_EQ(15.f, outer_scroll->CurrentScrollOffset().y()); |
2689 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); | 2780 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
2690 | 2781 |
2691 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f)); | 2782 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f), |
| 2783 InputHandler::RAILS_MODE_FREE); |
2692 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 2784 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
2693 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); | 2785 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
2694 | 2786 |
2695 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2787 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f), |
| 2788 InputHandler::RAILS_MODE_FREE); |
2696 host_impl_->ScrollEnd(); | 2789 host_impl_->ScrollEnd(); |
2697 | 2790 |
2698 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 2791 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
2699 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 2792 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
2700 } | 2793 } |
2701 | 2794 |
2702 // Test that the fixed position container delta is appropriately adjusted | 2795 // Test that the fixed position container delta is appropriately adjusted |
2703 // by the top controls showing/hiding and page scale doesn't affect it. | 2796 // by the top controls showing/hiding and page scale doesn't affect it. |
2704 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { | 2797 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { |
2705 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2798 SetupTopControlsAndScrollLayerWithVirtualViewport( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 | 2874 |
2782 // scroll child to limit | 2875 // scroll child to limit |
2783 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); | 2876 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); |
2784 child_clip->AddChild(child.Pass()); | 2877 child_clip->AddChild(child.Pass()); |
2785 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); | 2878 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); |
2786 | 2879 |
2787 // Scroll 25px to hide top controls | 2880 // Scroll 25px to hide top controls |
2788 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2881 gfx::Vector2dF scroll_delta(0.f, 25.f); |
2789 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2882 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
2790 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2883 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
2791 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2884 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 2885 InputHandler::RAILS_MODE_FREE); |
2792 host_impl_->ScrollEnd(); | 2886 host_impl_->ScrollEnd(); |
2793 | 2887 |
2794 // Top controls should be hidden | 2888 // Top controls should be hidden |
2795 EXPECT_EQ(scroll_delta.y(), | 2889 EXPECT_EQ(scroll_delta.y(), |
2796 top_controls_height_ - | 2890 top_controls_height_ - |
2797 host_impl_->top_controls_manager()->ContentTopOffset()); | 2891 host_impl_->top_controls_manager()->ContentTopOffset()); |
2798 } | 2892 } |
2799 | 2893 |
2800 // Ensure setting the top controls position explicitly using the setters on the | 2894 // Ensure setting the top controls position explicitly using the setters on the |
2801 // TreeImpl correctly affects the top controls manager and viewport bounds. | 2895 // TreeImpl correctly affects the top controls manager and viewport bounds. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 3024 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
2931 | 3025 |
2932 gfx::ScrollOffset viewport_offset = | 3026 gfx::ScrollOffset viewport_offset = |
2933 host_impl_->active_tree()->TotalScrollOffset(); | 3027 host_impl_->active_tree()->TotalScrollOffset(); |
2934 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 3028 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
2935 | 3029 |
2936 // Hide the top controls by 25px. | 3030 // Hide the top controls by 25px. |
2937 gfx::Vector2dF scroll_delta(0.f, 25.f); | 3031 gfx::Vector2dF scroll_delta(0.f, 25.f); |
2938 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3032 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
2939 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3033 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
2940 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3034 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3035 InputHandler::RAILS_MODE_FREE); |
2941 | 3036 |
2942 // scrolling down at the max extents no longer hides the top controls | 3037 // scrolling down at the max extents no longer hides the top controls |
2943 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 3038 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
2944 | 3039 |
2945 // forcefully hide the top controls by 25px | 3040 // forcefully hide the top controls by 25px |
2946 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); | 3041 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); |
2947 host_impl_->ScrollEnd(); | 3042 host_impl_->ScrollEnd(); |
2948 | 3043 |
2949 EXPECT_FLOAT_EQ(scroll_delta.y(), | 3044 EXPECT_FLOAT_EQ(scroll_delta.y(), |
2950 top_controls_height_ - | 3045 top_controls_height_ - |
2951 host_impl_->top_controls_manager()->ContentTopOffset()); | 3046 host_impl_->top_controls_manager()->ContentTopOffset()); |
2952 | 3047 |
2953 inner_scroll->ClampScrollToMaxScrollOffset(); | 3048 inner_scroll->ClampScrollToMaxScrollOffset(); |
2954 outer_scroll->ClampScrollToMaxScrollOffset(); | 3049 outer_scroll->ClampScrollToMaxScrollOffset(); |
2955 | 3050 |
2956 // We should still be fully scrolled. | 3051 // We should still be fully scrolled. |
2957 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 3052 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
2958 host_impl_->active_tree()->TotalScrollOffset()); | 3053 host_impl_->active_tree()->TotalScrollOffset()); |
2959 | 3054 |
2960 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 3055 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
2961 | 3056 |
2962 // Bring the top controls down by 25px. | 3057 // Bring the top controls down by 25px. |
2963 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 3058 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
2964 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3059 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
2965 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3060 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
2966 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3061 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3062 InputHandler::RAILS_MODE_FREE); |
2967 host_impl_->ScrollEnd(); | 3063 host_impl_->ScrollEnd(); |
2968 | 3064 |
2969 // The viewport offset shouldn't have changed. | 3065 // The viewport offset shouldn't have changed. |
2970 EXPECT_EQ(viewport_offset, | 3066 EXPECT_EQ(viewport_offset, |
2971 host_impl_->active_tree()->TotalScrollOffset()); | 3067 host_impl_->active_tree()->TotalScrollOffset()); |
2972 | 3068 |
2973 // Scroll the viewports to max scroll offset. | 3069 // Scroll the viewports to max scroll offset. |
2974 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 3070 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
2975 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 3071 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
2976 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 3072 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
2977 host_impl_->active_tree()->TotalScrollOffset()); | 3073 host_impl_->active_tree()->TotalScrollOffset()); |
2978 } | 3074 } |
2979 | 3075 |
2980 // Test that the top controls coming in and out maintains the same aspect ratio | 3076 // Test that the top controls coming in and out maintains the same aspect ratio |
2981 // between the inner and outer viewports. | 3077 // between the inner and outer viewports. |
2982 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { | 3078 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { |
2983 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3079 SetupTopControlsAndScrollLayerWithVirtualViewport( |
2984 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 3080 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
2985 DrawFrame(); | 3081 DrawFrame(); |
2986 | 3082 |
2987 EXPECT_FLOAT_EQ(top_controls_height_, | 3083 EXPECT_FLOAT_EQ(top_controls_height_, |
2988 host_impl_->top_controls_manager()->ContentTopOffset()); | 3084 host_impl_->top_controls_manager()->ContentTopOffset()); |
2989 | 3085 |
2990 gfx::Vector2dF scroll_delta(0.f, 25.f); | 3086 gfx::Vector2dF scroll_delta(0.f, 25.f); |
2991 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3087 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
2992 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3088 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
2993 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3089 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3090 InputHandler::RAILS_MODE_FREE); |
2994 host_impl_->ScrollEnd(); | 3091 host_impl_->ScrollEnd(); |
2995 | 3092 |
2996 EXPECT_FLOAT_EQ(scroll_delta.y(), | 3093 EXPECT_FLOAT_EQ(scroll_delta.y(), |
2997 top_controls_height_ - | 3094 top_controls_height_ - |
2998 host_impl_->top_controls_manager()->ContentTopOffset()); | 3095 host_impl_->top_controls_manager()->ContentTopOffset()); |
2999 | 3096 |
3000 // Top controls were hidden by 25px so the inner viewport should have expanded | 3097 // Top controls were hidden by 25px so the inner viewport should have expanded |
3001 // by that much. | 3098 // by that much. |
3002 LayerImpl* outer_container = | 3099 LayerImpl* outer_container = |
3003 host_impl_->active_tree()->OuterViewportContainerLayer(); | 3100 host_impl_->active_tree()->OuterViewportContainerLayer(); |
(...skipping 17 matching lines...) Expand all Loading... |
3021 DrawFrame(); | 3118 DrawFrame(); |
3022 | 3119 |
3023 EXPECT_EQ(top_controls_height_, | 3120 EXPECT_EQ(top_controls_height_, |
3024 host_impl_->top_controls_manager()->ContentTopOffset()); | 3121 host_impl_->top_controls_manager()->ContentTopOffset()); |
3025 | 3122 |
3026 // Send a gesture scroll that will scroll the outer viewport, make sure the | 3123 // Send a gesture scroll that will scroll the outer viewport, make sure the |
3027 // top controls get scrolled. | 3124 // top controls get scrolled. |
3028 gfx::Vector2dF scroll_delta(0.f, 15.f); | 3125 gfx::Vector2dF scroll_delta(0.f, 15.f); |
3029 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3126 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3030 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3127 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3031 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3128 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3129 InputHandler::RAILS_MODE_FREE); |
3032 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3130 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
3033 host_impl_->CurrentlyScrollingLayer()); | 3131 host_impl_->CurrentlyScrollingLayer()); |
3034 host_impl_->ScrollEnd(); | 3132 host_impl_->ScrollEnd(); |
3035 | 3133 |
3036 EXPECT_FLOAT_EQ(scroll_delta.y(), | 3134 EXPECT_FLOAT_EQ(scroll_delta.y(), |
3037 top_controls_height_ - | 3135 top_controls_height_ - |
3038 host_impl_->top_controls_manager()->ContentTopOffset()); | 3136 host_impl_->top_controls_manager()->ContentTopOffset()); |
3039 | 3137 |
3040 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 3138 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
3041 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3139 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3042 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3140 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3043 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3141 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3142 InputHandler::RAILS_MODE_FREE); |
3044 | 3143 |
3045 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 3144 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); |
3046 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3145 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
3047 host_impl_->CurrentlyScrollingLayer()); | 3146 host_impl_->CurrentlyScrollingLayer()); |
3048 | 3147 |
3049 host_impl_->ScrollEnd(); | 3148 host_impl_->ScrollEnd(); |
3050 | 3149 |
3051 // Position the viewports such that the inner viewport will be scrolled. | 3150 // Position the viewports such that the inner viewport will be scrolled. |
3052 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 3151 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
3053 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 3152 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
3054 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 3153 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
3055 | 3154 |
3056 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 3155 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
3057 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3156 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3058 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3157 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3059 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3158 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3159 InputHandler::RAILS_MODE_FREE); |
3060 | 3160 |
3061 EXPECT_EQ(top_controls_height_, | 3161 EXPECT_EQ(top_controls_height_, |
3062 host_impl_->top_controls_manager()->ContentTopOffset()); | 3162 host_impl_->top_controls_manager()->ContentTopOffset()); |
3063 EXPECT_FLOAT_EQ( | 3163 EXPECT_FLOAT_EQ( |
3064 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), | 3164 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
3065 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); | 3165 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); |
3066 | 3166 |
3067 host_impl_->ScrollEnd(); | 3167 host_impl_->ScrollEnd(); |
3068 } | 3168 } |
3069 | 3169 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3146 scroll_layer->AddChild(content_layer.Pass()); | 3246 scroll_layer->AddChild(content_layer.Pass()); |
3147 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 3247 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
3148 | 3248 |
3149 scroll_clip_layer->SetHasRenderSurface(true); | 3249 scroll_clip_layer->SetHasRenderSurface(true); |
3150 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 3250 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
3151 host_impl_->SetViewportSize(surface_size); | 3251 host_impl_->SetViewportSize(surface_size); |
3152 DrawFrame(); | 3252 DrawFrame(); |
3153 | 3253 |
3154 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3254 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3155 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3255 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3156 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3256 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 3257 InputHandler::RAILS_MODE_FREE); |
3157 host_impl_->ScrollEnd(); | 3258 host_impl_->ScrollEnd(); |
3158 EXPECT_TRUE(did_request_redraw_); | 3259 EXPECT_TRUE(did_request_redraw_); |
3159 EXPECT_TRUE(did_request_commit_); | 3260 EXPECT_TRUE(did_request_commit_); |
3160 } | 3261 } |
3161 | 3262 |
3162 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 3263 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
3163 gfx::Size surface_size(10, 10); | 3264 gfx::Size surface_size(10, 10); |
3164 gfx::Size contents_size(20, 20); | 3265 gfx::Size contents_size(20, 20); |
3165 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3266 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3166 root->SetBounds(surface_size); | 3267 root->SetBounds(surface_size); |
3167 root->SetContentBounds(contents_size); | 3268 root->SetContentBounds(contents_size); |
3168 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 3269 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
3169 root->SetHasRenderSurface(true); | 3270 root->SetHasRenderSurface(true); |
3170 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3271 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3171 host_impl_->SetViewportSize(surface_size); | 3272 host_impl_->SetViewportSize(surface_size); |
3172 DrawFrame(); | 3273 DrawFrame(); |
3173 | 3274 |
3174 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3275 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3175 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3276 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3176 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3277 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 3278 InputHandler::RAILS_MODE_FREE); |
3177 host_impl_->ScrollEnd(); | 3279 host_impl_->ScrollEnd(); |
3178 EXPECT_TRUE(did_request_redraw_); | 3280 EXPECT_TRUE(did_request_redraw_); |
3179 EXPECT_TRUE(did_request_commit_); | 3281 EXPECT_TRUE(did_request_commit_); |
3180 } | 3282 } |
3181 | 3283 |
3182 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 3284 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
3183 gfx::Size surface_size(10, 10); | 3285 gfx::Size surface_size(10, 10); |
3184 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3286 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3185 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 3287 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
3186 root->SetHasRenderSurface(true); | 3288 root->SetHasRenderSurface(true); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3273 | 3375 |
3274 LayerImpl* root_scroll = | 3376 LayerImpl* root_scroll = |
3275 host_impl_->active_tree()->InnerViewportScrollLayer(); | 3377 host_impl_->active_tree()->InnerViewportScrollLayer(); |
3276 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 3378 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
3277 | 3379 |
3278 gfx::Vector2d scroll_delta(0, 10); | 3380 gfx::Vector2d scroll_delta(0, 10); |
3279 gfx::Vector2d expected_scroll_delta = scroll_delta; | 3381 gfx::Vector2d expected_scroll_delta = scroll_delta; |
3280 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 3382 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
3281 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3383 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3282 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3384 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3283 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3385 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3386 InputHandler::RAILS_MODE_FREE); |
3284 host_impl_->ScrollEnd(); | 3387 host_impl_->ScrollEnd(); |
3285 | 3388 |
3286 // Set new page scale from main thread. | 3389 // Set new page scale from main thread. |
3287 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, page_scale, | 3390 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, page_scale, |
3288 page_scale); | 3391 page_scale); |
3289 | 3392 |
3290 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3393 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
3291 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); | 3394 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); |
3292 | 3395 |
3293 // The scroll range should also have been updated. | 3396 // The scroll range should also have been updated. |
(...skipping 30 matching lines...) Expand all Loading... |
3324 | 3427 |
3325 LayerImpl* root_scroll = | 3428 LayerImpl* root_scroll = |
3326 host_impl_->active_tree()->InnerViewportScrollLayer(); | 3429 host_impl_->active_tree()->InnerViewportScrollLayer(); |
3327 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 3430 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
3328 | 3431 |
3329 gfx::Vector2d scroll_delta(0, 10); | 3432 gfx::Vector2d scroll_delta(0, 10); |
3330 gfx::Vector2d expected_scroll_delta = scroll_delta; | 3433 gfx::Vector2d expected_scroll_delta = scroll_delta; |
3331 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 3434 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
3332 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3435 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3333 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3436 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3334 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3437 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3438 InputHandler::RAILS_MODE_FREE); |
3335 host_impl_->ScrollEnd(); | 3439 host_impl_->ScrollEnd(); |
3336 | 3440 |
3337 // Set new page scale on impl thread by pinching. | 3441 // Set new page scale on impl thread by pinching. |
3338 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 3442 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); |
3339 host_impl_->PinchGestureBegin(); | 3443 host_impl_->PinchGestureBegin(); |
3340 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 3444 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
3341 host_impl_->PinchGestureEnd(); | 3445 host_impl_->PinchGestureEnd(); |
3342 host_impl_->ScrollEnd(); | 3446 host_impl_->ScrollEnd(); |
3343 DrawOneFrame(); | 3447 DrawOneFrame(); |
3344 | 3448 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3435 Layer::INVALID_ID); | 3539 Layer::INVALID_ID); |
3436 host_impl_->active_tree()->DidBecomeActive(); | 3540 host_impl_->active_tree()->DidBecomeActive(); |
3437 host_impl_->SetViewportSize(surface_size); | 3541 host_impl_->SetViewportSize(surface_size); |
3438 DrawFrame(); | 3542 DrawFrame(); |
3439 | 3543 |
3440 gfx::Vector2d scroll_delta(0, 10); | 3544 gfx::Vector2d scroll_delta(0, 10); |
3441 gfx::Vector2d expected_scroll_delta(scroll_delta); | 3545 gfx::Vector2d expected_scroll_delta(scroll_delta); |
3442 gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset()); | 3546 gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset()); |
3443 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3547 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3444 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3548 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3445 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3549 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3550 InputHandler::RAILS_MODE_FREE); |
3446 host_impl_->ScrollEnd(); | 3551 host_impl_->ScrollEnd(); |
3447 | 3552 |
3448 float page_scale = 2.f; | 3553 float page_scale = 2.f; |
3449 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 3554 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
3450 page_scale); | 3555 page_scale); |
3451 | 3556 |
3452 DrawOneFrame(); | 3557 DrawOneFrame(); |
3453 | 3558 |
3454 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3559 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
3455 ExpectContains( | 3560 ExpectContains( |
(...skipping 30 matching lines...) Expand all Loading... |
3486 host_impl_->active_tree()->DidBecomeActive(); | 3591 host_impl_->active_tree()->DidBecomeActive(); |
3487 host_impl_->SetViewportSize(surface_size); | 3592 host_impl_->SetViewportSize(surface_size); |
3488 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); | 3593 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); |
3489 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); | 3594 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); |
3490 | 3595 |
3491 DrawFrame(); | 3596 DrawFrame(); |
3492 { | 3597 { |
3493 gfx::Vector2d scroll_delta(-8, -7); | 3598 gfx::Vector2d scroll_delta(-8, -7); |
3494 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3599 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3495 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3600 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
3496 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3601 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3602 InputHandler::RAILS_MODE_FREE); |
3497 host_impl_->ScrollEnd(); | 3603 host_impl_->ScrollEnd(); |
3498 | 3604 |
3499 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3605 scoped_ptr<ScrollAndScaleSet> scroll_info = |
3500 host_impl_->ProcessScrollDeltas(); | 3606 host_impl_->ProcessScrollDeltas(); |
3501 | 3607 |
3502 // The grand child should have scrolled up to its limit. | 3608 // The grand child should have scrolled up to its limit. |
3503 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 3609 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; |
3504 LayerImpl* grand_child = child->children()[0]; | 3610 LayerImpl* grand_child = child->children()[0]; |
3505 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5)); | 3611 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5)); |
3506 | 3612 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 | 3646 |
3541 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 3647 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
3542 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); | 3648 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
3543 | 3649 |
3544 DrawFrame(); | 3650 DrawFrame(); |
3545 { | 3651 { |
3546 gfx::Vector2d scroll_delta(0, -10); | 3652 gfx::Vector2d scroll_delta(0, -10); |
3547 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3653 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3548 host_impl_->ScrollBegin(gfx::Point(), | 3654 host_impl_->ScrollBegin(gfx::Point(), |
3549 InputHandler::NON_BUBBLING_GESTURE)); | 3655 InputHandler::NON_BUBBLING_GESTURE)); |
3550 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3656 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3657 InputHandler::RAILS_MODE_FREE); |
3551 host_impl_->ScrollEnd(); | 3658 host_impl_->ScrollEnd(); |
3552 | 3659 |
3553 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3660 scoped_ptr<ScrollAndScaleSet> scroll_info = |
3554 host_impl_->ProcessScrollDeltas(); | 3661 host_impl_->ProcessScrollDeltas(); |
3555 | 3662 |
3556 // The grand child should have scrolled up to its limit. | 3663 // The grand child should have scrolled up to its limit. |
3557 LayerImpl* child = | 3664 LayerImpl* child = |
3558 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 3665 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; |
3559 LayerImpl* grand_child = child->children()[0]; | 3666 LayerImpl* grand_child = child->children()[0]; |
3560 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); | 3667 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); |
3561 | 3668 |
3562 // The child should not have scrolled. | 3669 // The child should not have scrolled. |
3563 ExpectNone(*scroll_info.get(), child->id()); | 3670 ExpectNone(*scroll_info.get(), child->id()); |
3564 | 3671 |
3565 // The next time we scroll we should only scroll the parent. | 3672 // The next time we scroll we should only scroll the parent. |
3566 scroll_delta = gfx::Vector2d(0, -3); | 3673 scroll_delta = gfx::Vector2d(0, -3); |
3567 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3674 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3568 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3675 host_impl_->ScrollBegin(gfx::Point(5, 5), |
3569 InputHandler::NON_BUBBLING_GESTURE)); | 3676 InputHandler::NON_BUBBLING_GESTURE)); |
3570 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 3677 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
3571 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3678 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3679 InputHandler::RAILS_MODE_FREE); |
3572 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 3680 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
3573 host_impl_->ScrollEnd(); | 3681 host_impl_->ScrollEnd(); |
3574 | 3682 |
3575 scroll_info = host_impl_->ProcessScrollDeltas(); | 3683 scroll_info = host_impl_->ProcessScrollDeltas(); |
3576 | 3684 |
3577 // The child should have scrolled up to its limit. | 3685 // The child should have scrolled up to its limit. |
3578 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); | 3686 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); |
3579 | 3687 |
3580 // The grand child should not have scrolled. | 3688 // The grand child should not have scrolled. |
3581 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); | 3689 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); |
3582 | 3690 |
3583 // After scrolling the parent, another scroll on the opposite direction | 3691 // After scrolling the parent, another scroll on the opposite direction |
3584 // should still scroll the child. | 3692 // should still scroll the child. |
3585 scroll_delta = gfx::Vector2d(0, 7); | 3693 scroll_delta = gfx::Vector2d(0, 7); |
3586 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3694 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3587 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3695 host_impl_->ScrollBegin(gfx::Point(5, 5), |
3588 InputHandler::NON_BUBBLING_GESTURE)); | 3696 InputHandler::NON_BUBBLING_GESTURE)); |
3589 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 3697 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
3590 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3698 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3699 InputHandler::RAILS_MODE_FREE); |
3591 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 3700 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
3592 host_impl_->ScrollEnd(); | 3701 host_impl_->ScrollEnd(); |
3593 | 3702 |
3594 scroll_info = host_impl_->ProcessScrollDeltas(); | 3703 scroll_info = host_impl_->ProcessScrollDeltas(); |
3595 | 3704 |
3596 // The grand child should have scrolled. | 3705 // The grand child should have scrolled. |
3597 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 5)); | 3706 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 5)); |
3598 | 3707 |
3599 // The child should not have scrolled. | 3708 // The child should not have scrolled. |
3600 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); | 3709 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); |
3601 | 3710 |
3602 | 3711 |
3603 // Scrolling should be adjusted from viewport space. | 3712 // Scrolling should be adjusted from viewport space. |
3604 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); | 3713 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); |
3605 host_impl_->SetPageScaleOnActiveTree(2.f); | 3714 host_impl_->SetPageScaleOnActiveTree(2.f); |
3606 | 3715 |
3607 scroll_delta = gfx::Vector2d(0, -2); | 3716 scroll_delta = gfx::Vector2d(0, -2); |
3608 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3717 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3609 host_impl_->ScrollBegin(gfx::Point(1, 1), | 3718 host_impl_->ScrollBegin(gfx::Point(1, 1), |
3610 InputHandler::NON_BUBBLING_GESTURE)); | 3719 InputHandler::NON_BUBBLING_GESTURE)); |
3611 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); | 3720 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); |
3612 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3721 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3722 InputHandler::RAILS_MODE_FREE); |
3613 host_impl_->ScrollEnd(); | 3723 host_impl_->ScrollEnd(); |
3614 | 3724 |
3615 scroll_info = host_impl_->ProcessScrollDeltas(); | 3725 scroll_info = host_impl_->ProcessScrollDeltas(); |
3616 | 3726 |
3617 // Should have scrolled by half the amount in layer space (5 - 2/2) | 3727 // Should have scrolled by half the amount in layer space (5 - 2/2) |
3618 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 3728 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
3619 } | 3729 } |
3620 } | 3730 } |
3621 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 3731 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
3622 // When we try to scroll a non-scrollable child layer, the scroll delta | 3732 // When we try to scroll a non-scrollable child layer, the scroll delta |
(...skipping 19 matching lines...) Expand all Loading... |
3642 host_impl_->SetViewportSize(surface_size); | 3752 host_impl_->SetViewportSize(surface_size); |
3643 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3753 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
3644 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, | 3754 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, |
3645 Layer::INVALID_ID); | 3755 Layer::INVALID_ID); |
3646 host_impl_->active_tree()->DidBecomeActive(); | 3756 host_impl_->active_tree()->DidBecomeActive(); |
3647 DrawFrame(); | 3757 DrawFrame(); |
3648 { | 3758 { |
3649 gfx::Vector2d scroll_delta(0, 4); | 3759 gfx::Vector2d scroll_delta(0, 4); |
3650 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3760 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3651 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3761 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3652 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3762 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3763 InputHandler::RAILS_MODE_FREE); |
3653 host_impl_->ScrollEnd(); | 3764 host_impl_->ScrollEnd(); |
3654 | 3765 |
3655 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3766 scoped_ptr<ScrollAndScaleSet> scroll_info = |
3656 host_impl_->ProcessScrollDeltas(); | 3767 host_impl_->ProcessScrollDeltas(); |
3657 | 3768 |
3658 // Only the root scroll should have scrolled. | 3769 // Only the root scroll should have scrolled. |
3659 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 3770 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
3660 ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); | 3771 ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); |
3661 } | 3772 } |
3662 } | 3773 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3706 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); | 3817 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); |
3707 | 3818 |
3708 gfx::Size surface_size(50, 50); | 3819 gfx::Size surface_size(50, 50); |
3709 host_impl_->SetViewportSize(surface_size); | 3820 host_impl_->SetViewportSize(surface_size); |
3710 DrawFrame(); | 3821 DrawFrame(); |
3711 | 3822 |
3712 // Scroll to the right in screen coordinates with a gesture. | 3823 // Scroll to the right in screen coordinates with a gesture. |
3713 gfx::Vector2d gesture_scroll_delta(10, 0); | 3824 gfx::Vector2d gesture_scroll_delta(10, 0); |
3714 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3825 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3715 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3826 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3716 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3827 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta, |
| 3828 InputHandler::RAILS_MODE_FREE); |
3717 host_impl_->ScrollEnd(); | 3829 host_impl_->ScrollEnd(); |
3718 | 3830 |
3719 // The layer should have scrolled down in its local coordinates. | 3831 // The layer should have scrolled down in its local coordinates. |
3720 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3832 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
3721 ExpectContains(*scroll_info.get(), scroll_layer->id(), | 3833 ExpectContains(*scroll_info.get(), scroll_layer->id(), |
3722 gfx::Vector2d(0, gesture_scroll_delta.x())); | 3834 gfx::Vector2d(0, gesture_scroll_delta.x())); |
3723 | 3835 |
3724 // Reset and scroll down with the wheel. | 3836 // Reset and scroll down with the wheel. |
3725 scroll_layer->SetScrollDelta(gfx::Vector2dF()); | 3837 scroll_layer->SetScrollDelta(gfx::Vector2dF()); |
3726 gfx::Vector2d wheel_scroll_delta(0, 10); | 3838 gfx::Vector2d wheel_scroll_delta(0, 10); |
3727 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3839 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3728 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3840 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
3729 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); | 3841 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta, |
| 3842 InputHandler::RAILS_MODE_FREE); |
3730 host_impl_->ScrollEnd(); | 3843 host_impl_->ScrollEnd(); |
3731 | 3844 |
3732 // The layer should have scrolled down in its local coordinates. | 3845 // The layer should have scrolled down in its local coordinates. |
3733 scroll_info = host_impl_->ProcessScrollDeltas(); | 3846 scroll_info = host_impl_->ProcessScrollDeltas(); |
3734 ExpectContains(*scroll_info.get(), | 3847 ExpectContains(*scroll_info.get(), |
3735 scroll_layer->id(), | 3848 scroll_layer->id(), |
3736 wheel_scroll_delta); | 3849 wheel_scroll_delta); |
3737 } | 3850 } |
3738 | 3851 |
3739 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { | 3852 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { |
(...skipping 26 matching lines...) Expand all Loading... |
3766 scroll_layer->AddChild(clip_layer.Pass()); | 3879 scroll_layer->AddChild(clip_layer.Pass()); |
3767 | 3880 |
3768 gfx::Size surface_size(50, 50); | 3881 gfx::Size surface_size(50, 50); |
3769 host_impl_->SetViewportSize(surface_size); | 3882 host_impl_->SetViewportSize(surface_size); |
3770 DrawFrame(); | 3883 DrawFrame(); |
3771 { | 3884 { |
3772 // Scroll down in screen coordinates with a gesture. | 3885 // Scroll down in screen coordinates with a gesture. |
3773 gfx::Vector2d gesture_scroll_delta(0, 10); | 3886 gfx::Vector2d gesture_scroll_delta(0, 10); |
3774 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3887 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3775 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); | 3888 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); |
3776 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3889 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta, |
| 3890 InputHandler::RAILS_MODE_FREE); |
3777 host_impl_->ScrollEnd(); | 3891 host_impl_->ScrollEnd(); |
3778 | 3892 |
3779 // The child layer should have scrolled down in its local coordinates an | 3893 // The child layer should have scrolled down in its local coordinates an |
3780 // amount proportional to the angle between it and the input scroll delta. | 3894 // amount proportional to the angle between it and the input scroll delta. |
3781 gfx::Vector2d expected_scroll_delta( | 3895 gfx::Vector2d expected_scroll_delta( |
3782 0, gesture_scroll_delta.y() * | 3896 0, gesture_scroll_delta.y() * |
3783 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | 3897 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
3784 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3898 scoped_ptr<ScrollAndScaleSet> scroll_info = |
3785 host_impl_->ProcessScrollDeltas(); | 3899 host_impl_->ProcessScrollDeltas(); |
3786 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 3900 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
3787 | 3901 |
3788 // The root scroll layer should not have scrolled, because the input delta | 3902 // The root scroll layer should not have scrolled, because the input delta |
3789 // was close to the layer's axis of movement. | 3903 // was close to the layer's axis of movement. |
3790 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 3904 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
3791 } | 3905 } |
3792 { | 3906 { |
3793 // Now reset and scroll the same amount horizontally. | 3907 // Now reset and scroll the same amount horizontally. |
3794 child_ptr->SetScrollDelta(gfx::Vector2dF()); | 3908 child_ptr->SetScrollDelta(gfx::Vector2dF()); |
3795 gfx::Vector2d gesture_scroll_delta(10, 0); | 3909 gfx::Vector2d gesture_scroll_delta(10, 0); |
3796 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3910 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3797 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); | 3911 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); |
3798 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3912 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta, |
| 3913 InputHandler::RAILS_MODE_FREE); |
3799 host_impl_->ScrollEnd(); | 3914 host_impl_->ScrollEnd(); |
3800 | 3915 |
3801 // The child layer should have scrolled down in its local coordinates an | 3916 // The child layer should have scrolled down in its local coordinates an |
3802 // amount proportional to the angle between it and the input scroll delta. | 3917 // amount proportional to the angle between it and the input scroll delta. |
3803 gfx::Vector2d expected_scroll_delta( | 3918 gfx::Vector2d expected_scroll_delta( |
3804 0, -gesture_scroll_delta.x() * | 3919 0, -gesture_scroll_delta.x() * |
3805 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 3920 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
3806 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3921 scoped_ptr<ScrollAndScaleSet> scroll_info = |
3807 host_impl_->ProcessScrollDeltas(); | 3922 host_impl_->ProcessScrollDeltas(); |
3808 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 3923 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
(...skipping 21 matching lines...) Expand all Loading... |
3830 scroll_layer->SetTransform(scale_transform); | 3945 scroll_layer->SetTransform(scale_transform); |
3831 | 3946 |
3832 gfx::Size surface_size(50, 50); | 3947 gfx::Size surface_size(50, 50); |
3833 host_impl_->SetViewportSize(surface_size); | 3948 host_impl_->SetViewportSize(surface_size); |
3834 DrawFrame(); | 3949 DrawFrame(); |
3835 | 3950 |
3836 // Scroll down in screen coordinates with a gesture. | 3951 // Scroll down in screen coordinates with a gesture. |
3837 gfx::Vector2d scroll_delta(0, 10); | 3952 gfx::Vector2d scroll_delta(0, 10); |
3838 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3953 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3839 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3954 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3840 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3955 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 3956 InputHandler::RAILS_MODE_FREE); |
3841 host_impl_->ScrollEnd(); | 3957 host_impl_->ScrollEnd(); |
3842 | 3958 |
3843 // The layer should have scrolled down in its local coordinates, but half the | 3959 // The layer should have scrolled down in its local coordinates, but half the |
3844 // amount. | 3960 // amount. |
3845 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3961 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
3846 ExpectContains(*scroll_info.get(), | 3962 ExpectContains(*scroll_info.get(), |
3847 scroll_layer->id(), | 3963 scroll_layer->id(), |
3848 gfx::Vector2d(0, scroll_delta.y() / scale)); | 3964 gfx::Vector2d(0, scroll_delta.y() / scale)); |
3849 | 3965 |
3850 // Reset and scroll down with the wheel. | 3966 // Reset and scroll down with the wheel. |
3851 scroll_layer->SetScrollDelta(gfx::Vector2dF()); | 3967 scroll_layer->SetScrollDelta(gfx::Vector2dF()); |
3852 gfx::Vector2d wheel_scroll_delta(0, 10); | 3968 gfx::Vector2d wheel_scroll_delta(0, 10); |
3853 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3969 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3854 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3970 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
3855 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); | 3971 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta, |
| 3972 InputHandler::RAILS_MODE_FREE); |
3856 host_impl_->ScrollEnd(); | 3973 host_impl_->ScrollEnd(); |
3857 | 3974 |
3858 // It should apply the scale factor to the scroll delta for the wheel event. | 3975 // It should apply the scale factor to the scroll delta for the wheel event. |
3859 scroll_info = host_impl_->ProcessScrollDeltas(); | 3976 scroll_info = host_impl_->ProcessScrollDeltas(); |
3860 ExpectContains(*scroll_info.get(), | 3977 ExpectContains(*scroll_info.get(), |
3861 scroll_layer->id(), | 3978 scroll_layer->id(), |
3862 wheel_scroll_delta); | 3979 wheel_scroll_delta); |
3863 } | 3980 } |
3864 | 3981 |
3865 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { | 3982 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3998 host_impl_->ScrollEnd(); | 4115 host_impl_->ScrollEnd(); |
3999 | 4116 |
4000 // Scrolling should be relative to the offset as returned by the delegate. | 4117 // Scrolling should be relative to the offset as returned by the delegate. |
4001 gfx::Vector2dF scroll_delta(0.f, 10.f); | 4118 gfx::Vector2dF scroll_delta(0.f, 10.f); |
4002 gfx::ScrollOffset current_offset(7.f, 8.f); | 4119 gfx::ScrollOffset current_offset(7.f, 8.f); |
4003 | 4120 |
4004 scroll_delegate.set_getter_return_value(current_offset); | 4121 scroll_delegate.set_getter_return_value(current_offset); |
4005 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4122 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4006 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 4123 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
4007 | 4124 |
4008 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4125 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4126 InputHandler::RAILS_MODE_FREE); |
4009 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), | 4127 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), |
4010 scroll_delegate.last_set_scroll_offset()); | 4128 scroll_delegate.last_set_scroll_offset()); |
4011 | 4129 |
4012 current_offset = gfx::ScrollOffset(42.f, 41.f); | 4130 current_offset = gfx::ScrollOffset(42.f, 41.f); |
4013 scroll_delegate.set_getter_return_value(current_offset); | 4131 scroll_delegate.set_getter_return_value(current_offset); |
4014 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4132 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4133 InputHandler::RAILS_MODE_FREE); |
4015 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta), | 4134 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta), |
4016 scroll_delegate.last_set_scroll_offset()); | 4135 scroll_delegate.last_set_scroll_offset()); |
4017 host_impl_->ScrollEnd(); | 4136 host_impl_->ScrollEnd(); |
4018 scroll_delegate.set_getter_return_value(gfx::ScrollOffset()); | 4137 scroll_delegate.set_getter_return_value(gfx::ScrollOffset()); |
4019 | 4138 |
4020 // Forces a full tree synchronization and ensures that the scroll delegate | 4139 // Forces a full tree synchronization and ensures that the scroll delegate |
4021 // sees the correct size of the new tree. | 4140 // sees the correct size of the new tree. |
4022 gfx::Size new_size(42, 24); | 4141 gfx::Size new_size(42, 24); |
4023 host_impl_->CreatePendingTree(); | 4142 host_impl_->CreatePendingTree(); |
4024 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); | 4143 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4079 InputHandlerScrollResult scroll_result; | 4198 InputHandlerScrollResult scroll_result; |
4080 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 4199 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
4081 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 4200 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
4082 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 4201 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
4083 DrawFrame(); | 4202 DrawFrame(); |
4084 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4203 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4085 | 4204 |
4086 // In-bounds scrolling does not affect overscroll. | 4205 // In-bounds scrolling does not affect overscroll. |
4087 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4206 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4088 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 4207 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
4089 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4208 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 4209 InputHandler::RAILS_MODE_FREE); |
4090 EXPECT_TRUE(scroll_result.did_scroll); | 4210 EXPECT_TRUE(scroll_result.did_scroll); |
4091 EXPECT_FALSE(scroll_result.did_overscroll_root); | 4211 EXPECT_FALSE(scroll_result.did_overscroll_root); |
4092 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); | 4212 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
4093 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4213 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4094 | 4214 |
4095 // Overscroll events are reflected immediately. | 4215 // Overscroll events are reflected immediately. |
4096 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50)); | 4216 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50), |
| 4217 InputHandler::RAILS_MODE_FREE); |
4097 EXPECT_TRUE(scroll_result.did_scroll); | 4218 EXPECT_TRUE(scroll_result.did_scroll); |
4098 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4219 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4099 EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta); | 4220 EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta); |
4100 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 4221 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
4101 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4222 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4102 host_impl_->accumulated_root_overscroll()); | 4223 host_impl_->accumulated_root_overscroll()); |
4103 | 4224 |
4104 // In-bounds scrolling resets accumulated overscroll for the scrolled axes. | 4225 // In-bounds scrolling resets accumulated overscroll for the scrolled axes. |
4105 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50)); | 4226 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50), |
| 4227 InputHandler::RAILS_MODE_FREE); |
4106 EXPECT_TRUE(scroll_result.did_scroll); | 4228 EXPECT_TRUE(scroll_result.did_scroll); |
4107 EXPECT_FALSE(scroll_result.did_overscroll_root); | 4229 EXPECT_FALSE(scroll_result.did_overscroll_root); |
4108 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); | 4230 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
4109 EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll()); | 4231 EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll()); |
4110 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4232 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4111 host_impl_->accumulated_root_overscroll()); | 4233 host_impl_->accumulated_root_overscroll()); |
4112 | 4234 |
4113 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)); | 4235 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10), |
| 4236 InputHandler::RAILS_MODE_FREE); |
4114 EXPECT_FALSE(scroll_result.did_scroll); | 4237 EXPECT_FALSE(scroll_result.did_scroll); |
4115 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4238 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4116 EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); | 4239 EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); |
4117 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); | 4240 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
4118 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4241 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4119 host_impl_->accumulated_root_overscroll()); | 4242 host_impl_->accumulated_root_overscroll()); |
4120 | 4243 |
4121 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0)); | 4244 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, 0), |
| 4245 InputHandler::RAILS_MODE_FREE); |
4122 EXPECT_TRUE(scroll_result.did_scroll); | 4246 EXPECT_TRUE(scroll_result.did_scroll); |
4123 EXPECT_FALSE(scroll_result.did_overscroll_root); | 4247 EXPECT_FALSE(scroll_result.did_overscroll_root); |
4124 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta); | 4248 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta); |
4125 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); | 4249 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
4126 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4250 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4127 host_impl_->accumulated_root_overscroll()); | 4251 host_impl_->accumulated_root_overscroll()); |
4128 | 4252 |
4129 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-15, 0)); | 4253 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-15, 0), |
| 4254 InputHandler::RAILS_MODE_FREE); |
4130 EXPECT_TRUE(scroll_result.did_scroll); | 4255 EXPECT_TRUE(scroll_result.did_scroll); |
4131 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4256 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4132 EXPECT_EQ(gfx::Vector2dF(-5, 0), scroll_result.unused_scroll_delta); | 4257 EXPECT_EQ(gfx::Vector2dF(-5, 0), scroll_result.unused_scroll_delta); |
4133 EXPECT_EQ(gfx::Vector2dF(-5, -10), host_impl_->accumulated_root_overscroll()); | 4258 EXPECT_EQ(gfx::Vector2dF(-5, -10), host_impl_->accumulated_root_overscroll()); |
4134 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4259 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4135 host_impl_->accumulated_root_overscroll()); | 4260 host_impl_->accumulated_root_overscroll()); |
4136 | 4261 |
4137 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 60)); | 4262 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 60), |
| 4263 InputHandler::RAILS_MODE_FREE); |
4138 EXPECT_TRUE(scroll_result.did_scroll); | 4264 EXPECT_TRUE(scroll_result.did_scroll); |
4139 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4265 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4140 EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta); | 4266 EXPECT_EQ(gfx::Vector2dF(0, 10), scroll_result.unused_scroll_delta); |
4141 EXPECT_EQ(gfx::Vector2dF(-5, 10), host_impl_->accumulated_root_overscroll()); | 4267 EXPECT_EQ(gfx::Vector2dF(-5, 10), host_impl_->accumulated_root_overscroll()); |
4142 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4268 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4143 host_impl_->accumulated_root_overscroll()); | 4269 host_impl_->accumulated_root_overscroll()); |
4144 | 4270 |
4145 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -60)); | 4271 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(10, -60), |
| 4272 InputHandler::RAILS_MODE_FREE); |
4146 EXPECT_TRUE(scroll_result.did_scroll); | 4273 EXPECT_TRUE(scroll_result.did_scroll); |
4147 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4274 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4148 EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); | 4275 EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); |
4149 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); | 4276 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
4150 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4277 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4151 host_impl_->accumulated_root_overscroll()); | 4278 host_impl_->accumulated_root_overscroll()); |
4152 | 4279 |
4153 // Overscroll accumulates within the scope of ScrollBegin/ScrollEnd as long | 4280 // Overscroll accumulates within the scope of ScrollBegin/ScrollEnd as long |
4154 // as no scroll occurs. | 4281 // as no scroll occurs. |
4155 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); | 4282 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20), |
| 4283 InputHandler::RAILS_MODE_FREE); |
4156 EXPECT_FALSE(scroll_result.did_scroll); | 4284 EXPECT_FALSE(scroll_result.did_scroll); |
4157 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4285 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4158 EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta); | 4286 EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta); |
4159 EXPECT_EQ(gfx::Vector2dF(0, -30), host_impl_->accumulated_root_overscroll()); | 4287 EXPECT_EQ(gfx::Vector2dF(0, -30), host_impl_->accumulated_root_overscroll()); |
4160 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4288 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4161 host_impl_->accumulated_root_overscroll()); | 4289 host_impl_->accumulated_root_overscroll()); |
4162 | 4290 |
4163 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); | 4291 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20), |
| 4292 InputHandler::RAILS_MODE_FREE); |
4164 EXPECT_FALSE(scroll_result.did_scroll); | 4293 EXPECT_FALSE(scroll_result.did_scroll); |
4165 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4294 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4166 EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta); | 4295 EXPECT_EQ(gfx::Vector2dF(0, -20), scroll_result.unused_scroll_delta); |
4167 EXPECT_EQ(gfx::Vector2dF(0, -50), host_impl_->accumulated_root_overscroll()); | 4296 EXPECT_EQ(gfx::Vector2dF(0, -50), host_impl_->accumulated_root_overscroll()); |
4168 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4297 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4169 host_impl_->accumulated_root_overscroll()); | 4298 host_impl_->accumulated_root_overscroll()); |
4170 | 4299 |
4171 // Overscroll resets on valid scroll. | 4300 // Overscroll resets on valid scroll. |
4172 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4301 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 4302 InputHandler::RAILS_MODE_FREE); |
4173 EXPECT_TRUE(scroll_result.did_scroll); | 4303 EXPECT_TRUE(scroll_result.did_scroll); |
4174 EXPECT_FALSE(scroll_result.did_overscroll_root); | 4304 EXPECT_FALSE(scroll_result.did_overscroll_root); |
4175 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta); | 4305 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_result.unused_scroll_delta); |
4176 EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll()); | 4306 EXPECT_EQ(gfx::Vector2dF(0, 0), host_impl_->accumulated_root_overscroll()); |
4177 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4307 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4178 host_impl_->accumulated_root_overscroll()); | 4308 host_impl_->accumulated_root_overscroll()); |
4179 | 4309 |
4180 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20)); | 4310 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20), |
| 4311 InputHandler::RAILS_MODE_FREE); |
4181 EXPECT_TRUE(scroll_result.did_scroll); | 4312 EXPECT_TRUE(scroll_result.did_scroll); |
4182 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4313 EXPECT_TRUE(scroll_result.did_overscroll_root); |
4183 EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); | 4314 EXPECT_EQ(gfx::Vector2dF(0, -10), scroll_result.unused_scroll_delta); |
4184 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); | 4315 EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll()); |
4185 EXPECT_EQ(scroll_result.accumulated_root_overscroll, | 4316 EXPECT_EQ(scroll_result.accumulated_root_overscroll, |
4186 host_impl_->accumulated_root_overscroll()); | 4317 host_impl_->accumulated_root_overscroll()); |
4187 | 4318 |
4188 host_impl_->ScrollEnd(); | 4319 host_impl_->ScrollEnd(); |
4189 } | 4320 } |
4190 | 4321 |
(...skipping 24 matching lines...) Expand all Loading... |
4215 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 4346 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
4216 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4347 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
4217 host_impl_->active_tree()->DidBecomeActive(); | 4348 host_impl_->active_tree()->DidBecomeActive(); |
4218 host_impl_->SetViewportSize(surface_size); | 4349 host_impl_->SetViewportSize(surface_size); |
4219 DrawFrame(); | 4350 DrawFrame(); |
4220 { | 4351 { |
4221 gfx::Vector2d scroll_delta(0, -10); | 4352 gfx::Vector2d scroll_delta(0, -10); |
4222 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4353 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4223 host_impl_->ScrollBegin(gfx::Point(), | 4354 host_impl_->ScrollBegin(gfx::Point(), |
4224 InputHandler::NON_BUBBLING_GESTURE)); | 4355 InputHandler::NON_BUBBLING_GESTURE)); |
4225 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4356 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4357 InputHandler::RAILS_MODE_FREE); |
4226 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4358 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4227 host_impl_->ScrollEnd(); | 4359 host_impl_->ScrollEnd(); |
4228 | 4360 |
4229 // The next time we scroll we should only scroll the parent, but overscroll | 4361 // The next time we scroll we should only scroll the parent, but overscroll |
4230 // should still not reach the root layer. | 4362 // should still not reach the root layer. |
4231 scroll_delta = gfx::Vector2d(0, -30); | 4363 scroll_delta = gfx::Vector2d(0, -30); |
4232 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4364 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4233 host_impl_->ScrollBegin(gfx::Point(5, 5), | 4365 host_impl_->ScrollBegin(gfx::Point(5, 5), |
4234 InputHandler::NON_BUBBLING_GESTURE)); | 4366 InputHandler::NON_BUBBLING_GESTURE)); |
4235 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 4367 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
4236 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4368 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4237 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4369 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4370 InputHandler::RAILS_MODE_FREE); |
4238 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer); | 4371 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer); |
4239 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4372 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4240 host_impl_->ScrollEnd(); | 4373 host_impl_->ScrollEnd(); |
4241 | 4374 |
4242 // After scrolling the parent, another scroll on the opposite direction | 4375 // After scrolling the parent, another scroll on the opposite direction |
4243 // should scroll the child. | 4376 // should scroll the child. |
4244 scroll_delta = gfx::Vector2d(0, 70); | 4377 scroll_delta = gfx::Vector2d(0, 70); |
4245 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4378 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4246 host_impl_->ScrollBegin(gfx::Point(5, 5), | 4379 host_impl_->ScrollBegin(gfx::Point(5, 5), |
4247 InputHandler::NON_BUBBLING_GESTURE)); | 4380 InputHandler::NON_BUBBLING_GESTURE)); |
4248 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 4381 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
4249 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4382 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4383 InputHandler::RAILS_MODE_FREE); |
4250 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 4384 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
4251 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4385 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4252 host_impl_->ScrollEnd(); | 4386 host_impl_->ScrollEnd(); |
4253 } | 4387 } |
4254 } | 4388 } |
4255 | 4389 |
4256 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 4390 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
4257 // When we try to scroll a non-scrollable child layer, the scroll delta | 4391 // When we try to scroll a non-scrollable child layer, the scroll delta |
4258 // should be applied to one of its ancestors if possible. Overscroll should | 4392 // should be applied to one of its ancestors if possible. Overscroll should |
4259 // be reflected only when it has bubbled up to the root scrolling layer. | 4393 // be reflected only when it has bubbled up to the root scrolling layer. |
(...skipping 16 matching lines...) Expand all Loading... |
4276 host_impl_->SetViewportSize(surface_size); | 4410 host_impl_->SetViewportSize(surface_size); |
4277 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4411 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
4278 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 4412 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
4279 Layer::INVALID_ID); | 4413 Layer::INVALID_ID); |
4280 host_impl_->active_tree()->DidBecomeActive(); | 4414 host_impl_->active_tree()->DidBecomeActive(); |
4281 DrawFrame(); | 4415 DrawFrame(); |
4282 { | 4416 { |
4283 gfx::Vector2d scroll_delta(0, 8); | 4417 gfx::Vector2d scroll_delta(0, 8); |
4284 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4418 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4285 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4419 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4286 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4420 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4421 InputHandler::RAILS_MODE_FREE); |
4287 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4422 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4288 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4423 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4424 InputHandler::RAILS_MODE_FREE); |
4289 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); | 4425 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); |
4290 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4426 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 4427 InputHandler::RAILS_MODE_FREE); |
4291 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); | 4428 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); |
4292 host_impl_->ScrollEnd(); | 4429 host_impl_->ScrollEnd(); |
4293 } | 4430 } |
4294 } | 4431 } |
4295 | 4432 |
4296 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 4433 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
4297 LayerTreeSettings settings; | 4434 LayerTreeSettings settings; |
4298 CreateHostImpl(settings, CreateOutputSurface()); | 4435 CreateHostImpl(settings, CreateOutputSurface()); |
4299 | 4436 |
4300 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 4437 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
4301 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 4438 LayerImpl* clip_layer = scroll_layer->parent()->parent(); |
4302 clip_layer->SetBounds(gfx::Size(50, 50)); | 4439 clip_layer->SetBounds(gfx::Size(50, 50)); |
4303 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 4440 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
4304 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 4441 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
4305 DrawFrame(); | 4442 DrawFrame(); |
4306 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4443 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
4307 | 4444 |
4308 // Even though the layer can't scroll the overscroll still happens. | 4445 // Even though the layer can't scroll the overscroll still happens. |
4309 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4446 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4310 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 4447 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
4311 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4448 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
| 4449 InputHandler::RAILS_MODE_FREE); |
4312 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 4450 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
4313 } | 4451 } |
4314 | 4452 |
4315 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 4453 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
4316 gfx::Size surface_size(980, 1439); | 4454 gfx::Size surface_size(980, 1439); |
4317 gfx::Size content_size(980, 1438); | 4455 gfx::Size content_size(980, 1438); |
4318 float device_scale_factor = 1.5f; | 4456 float device_scale_factor = 1.5f; |
4319 scoped_ptr<LayerImpl> root_clip = | 4457 scoped_ptr<LayerImpl> root_clip = |
4320 LayerImpl::Create(host_impl_->active_tree(), 3); | 4458 LayerImpl::Create(host_impl_->active_tree(), 3); |
4321 root_clip->SetHasRenderSurface(true); | 4459 root_clip->SetHasRenderSurface(true); |
(...skipping 17 matching lines...) Expand all Loading... |
4339 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 4477 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
4340 Layer::INVALID_ID); | 4478 Layer::INVALID_ID); |
4341 host_impl_->active_tree()->DidBecomeActive(); | 4479 host_impl_->active_tree()->DidBecomeActive(); |
4342 DrawFrame(); | 4480 DrawFrame(); |
4343 { | 4481 { |
4344 // Horizontal & Vertical GlowEffect should not be applied when | 4482 // Horizontal & Vertical GlowEffect should not be applied when |
4345 // content size is less then view port size. For Example Horizontal & | 4483 // content size is less then view port size. For Example Horizontal & |
4346 // vertical GlowEffect should not be applied in about:blank page. | 4484 // vertical GlowEffect should not be applied in about:blank page. |
4347 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4485 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4348 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); | 4486 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); |
4349 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1)); | 4487 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1), |
| 4488 InputHandler::RAILS_MODE_FREE); |
4350 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4489 EXPECT_EQ(gfx::Vector2dF().ToString(), |
4351 host_impl_->accumulated_root_overscroll().ToString()); | 4490 host_impl_->accumulated_root_overscroll().ToString()); |
4352 | 4491 |
4353 host_impl_->ScrollEnd(); | 4492 host_impl_->ScrollEnd(); |
4354 } | 4493 } |
4355 } | 4494 } |
4356 | 4495 |
4357 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 4496 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
4358 gfx::Size surface_size(100, 100); | 4497 gfx::Size surface_size(100, 100); |
4359 gfx::Size content_size(200, 200); | 4498 gfx::Size content_size(200, 200); |
(...skipping 16 matching lines...) Expand all Loading... |
4376 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 4515 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
4377 Layer::INVALID_ID); | 4516 Layer::INVALID_ID); |
4378 host_impl_->active_tree()->DidBecomeActive(); | 4517 host_impl_->active_tree()->DidBecomeActive(); |
4379 DrawFrame(); | 4518 DrawFrame(); |
4380 { | 4519 { |
4381 // Edge glow effect should be applicable only upon reaching Edges | 4520 // Edge glow effect should be applicable only upon reaching Edges |
4382 // of the content. unnecessary glow effect calls shouldn't be | 4521 // of the content. unnecessary glow effect calls shouldn't be |
4383 // called while scrolling up without reaching the edge of the content. | 4522 // called while scrolling up without reaching the edge of the content. |
4384 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4523 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4385 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); | 4524 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); |
4386 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); | 4525 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100), |
| 4526 InputHandler::RAILS_MODE_FREE); |
4387 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4527 EXPECT_EQ(gfx::Vector2dF().ToString(), |
4388 host_impl_->accumulated_root_overscroll().ToString()); | 4528 host_impl_->accumulated_root_overscroll().ToString()); |
4389 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); | 4529 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f), |
| 4530 InputHandler::RAILS_MODE_FREE); |
4390 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4531 EXPECT_EQ(gfx::Vector2dF().ToString(), |
4391 host_impl_->accumulated_root_overscroll().ToString()); | 4532 host_impl_->accumulated_root_overscroll().ToString()); |
4392 host_impl_->ScrollEnd(); | 4533 host_impl_->ScrollEnd(); |
4393 // unusedrootDelta should be subtracted from applied delta so that | 4534 // unusedrootDelta should be subtracted from applied delta so that |
4394 // unwanted glow effect calls are not called. | 4535 // unwanted glow effect calls are not called. |
4395 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4536 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4396 host_impl_->ScrollBegin(gfx::Point(0, 0), | 4537 host_impl_->ScrollBegin(gfx::Point(0, 0), |
4397 InputHandler::NON_BUBBLING_GESTURE)); | 4538 InputHandler::NON_BUBBLING_GESTURE)); |
4398 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 4539 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
4399 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20)); | 4540 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20), |
| 4541 InputHandler::RAILS_MODE_FREE); |
4400 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), | 4542 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), |
4401 host_impl_->accumulated_root_overscroll().ToString()); | 4543 host_impl_->accumulated_root_overscroll().ToString()); |
4402 | 4544 |
4403 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)); | 4545 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f), |
| 4546 InputHandler::RAILS_MODE_FREE); |
4404 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), | 4547 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), |
4405 host_impl_->accumulated_root_overscroll().ToString()); | 4548 host_impl_->accumulated_root_overscroll().ToString()); |
4406 host_impl_->ScrollEnd(); | 4549 host_impl_->ScrollEnd(); |
4407 // TestCase to check kEpsilon, which prevents minute values to trigger | 4550 // TestCase to check kEpsilon, which prevents minute values to trigger |
4408 // gloweffect without reaching edge. | 4551 // gloweffect without reaching edge. |
4409 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4552 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4410 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); | 4553 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); |
4411 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)); | 4554 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f), |
| 4555 InputHandler::RAILS_MODE_FREE); |
4412 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4556 EXPECT_EQ(gfx::Vector2dF().ToString(), |
4413 host_impl_->accumulated_root_overscroll().ToString()); | 4557 host_impl_->accumulated_root_overscroll().ToString()); |
4414 host_impl_->ScrollEnd(); | 4558 host_impl_->ScrollEnd(); |
4415 } | 4559 } |
4416 } | 4560 } |
4417 | 4561 |
4418 class BlendStateCheckLayer : public LayerImpl { | 4562 class BlendStateCheckLayer : public LayerImpl { |
4419 public: | 4563 public: |
4420 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 4564 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
4421 int id, | 4565 int id, |
(...skipping 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6921 Layer::INVALID_ID); | 7065 Layer::INVALID_ID); |
6922 host_impl_->active_tree()->DidBecomeActive(); | 7066 host_impl_->active_tree()->DidBecomeActive(); |
6923 DrawFrame(); | 7067 DrawFrame(); |
6924 { | 7068 { |
6925 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7069 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
6926 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7070 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
6927 | 7071 |
6928 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7072 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
6929 | 7073 |
6930 gfx::Vector2d scroll_delta(0, 100); | 7074 gfx::Vector2d scroll_delta(0, 100); |
6931 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7075 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
6932 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7076 InputHandler::RAILS_MODE_FREE); |
| 7077 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 7078 InputHandler::RAILS_MODE_FREE); |
6933 | 7079 |
6934 host_impl_->ScrollEnd(); | 7080 host_impl_->ScrollEnd(); |
6935 | 7081 |
6936 scoped_ptr<ScrollAndScaleSet> scroll_info = | 7082 scoped_ptr<ScrollAndScaleSet> scroll_info = |
6937 host_impl_->ProcessScrollDeltas(); | 7083 host_impl_->ProcessScrollDeltas(); |
6938 | 7084 |
6939 // Only the child should have scrolled. | 7085 // Only the child should have scrolled. |
6940 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7086 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
6941 ExpectNone(*scroll_info.get(), root_id); | 7087 ExpectNone(*scroll_info.get(), root_id); |
6942 } | 7088 } |
(...skipping 25 matching lines...) Expand all Loading... |
6968 DrawFrame(); | 7114 DrawFrame(); |
6969 { | 7115 { |
6970 scoped_ptr<ScrollAndScaleSet> scroll_info; | 7116 scoped_ptr<ScrollAndScaleSet> scroll_info; |
6971 LayerImpl* child = | 7117 LayerImpl* child = |
6972 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 7118 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; |
6973 LayerImpl* grand_child = child->children()[0]; | 7119 LayerImpl* grand_child = child->children()[0]; |
6974 | 7120 |
6975 gfx::Vector2d scroll_delta(0, -2); | 7121 gfx::Vector2d scroll_delta(0, -2); |
6976 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7122 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
6977 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7123 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
6978 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7124 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 7125 InputHandler::RAILS_MODE_FREE).did_scroll); |
6979 | 7126 |
6980 // The grand child should have scrolled up to its limit. | 7127 // The grand child should have scrolled up to its limit. |
6981 scroll_info = host_impl_->ProcessScrollDeltas(); | 7128 scroll_info = host_impl_->ProcessScrollDeltas(); |
6982 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7129 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
6983 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); | 7130 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
6984 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 7131 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
6985 | 7132 |
6986 // The child should have received the bubbled delta, but the locked | 7133 // The child should have received the bubbled delta, but the locked |
6987 // scrolling layer should remain set as the grand child. | 7134 // scrolling layer should remain set as the grand child. |
6988 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7135 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 7136 InputHandler::RAILS_MODE_FREE).did_scroll); |
6989 scroll_info = host_impl_->ProcessScrollDeltas(); | 7137 scroll_info = host_impl_->ProcessScrollDeltas(); |
6990 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7138 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
6991 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); | 7139 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
6992 ExpectContains(*scroll_info, child->id(), scroll_delta); | 7140 ExpectContains(*scroll_info, child->id(), scroll_delta); |
6993 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 7141 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
6994 | 7142 |
6995 // The first |ScrollBy| after the fling should re-lock the scrolling | 7143 // The first |ScrollBy| after the fling should re-lock the scrolling |
6996 // layer to the first layer that scrolled, which is the child. | 7144 // layer to the first layer that scrolled, which is the child. |
6997 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7145 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
6998 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7146 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 7147 InputHandler::RAILS_MODE_FREE).did_scroll); |
6999 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 7148 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
7000 | 7149 |
7001 // The child should have scrolled up to its limit. | 7150 // The child should have scrolled up to its limit. |
7002 scroll_info = host_impl_->ProcessScrollDeltas(); | 7151 scroll_info = host_impl_->ProcessScrollDeltas(); |
7003 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7152 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
7004 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); | 7153 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
7005 ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta); | 7154 ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta); |
7006 | 7155 |
7007 // As the locked layer is at it's limit, no further scrolling can occur. | 7156 // As the locked layer is at it's limit, no further scrolling can occur. |
7008 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7157 EXPECT_FALSE( |
| 7158 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 7159 InputHandler::RAILS_MODE_FREE).did_scroll); |
7009 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 7160 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
7010 host_impl_->ScrollEnd(); | 7161 host_impl_->ScrollEnd(); |
7011 } | 7162 } |
7012 } | 7163 } |
7013 | 7164 |
7014 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 7165 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
7015 // When flinging via wheel, the root should eventually scroll (we should | 7166 // When flinging via wheel, the root should eventually scroll (we should |
7016 // bubble). | 7167 // bubble). |
7017 gfx::Size surface_size(10, 10); | 7168 gfx::Size surface_size(10, 10); |
7018 gfx::Size content_size(20, 20); | 7169 gfx::Size content_size(20, 20); |
(...skipping 13 matching lines...) Expand all Loading... |
7032 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 7183 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
7033 host_impl_->active_tree()->DidBecomeActive(); | 7184 host_impl_->active_tree()->DidBecomeActive(); |
7034 DrawFrame(); | 7185 DrawFrame(); |
7035 { | 7186 { |
7036 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7187 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7037 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7188 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
7038 | 7189 |
7039 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7190 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7040 | 7191 |
7041 gfx::Vector2d scroll_delta(0, 100); | 7192 gfx::Vector2d scroll_delta(0, 100); |
7042 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7193 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
7043 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7194 InputHandler::RAILS_MODE_FREE); |
| 7195 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 7196 InputHandler::RAILS_MODE_FREE); |
7044 | 7197 |
7045 host_impl_->ScrollEnd(); | 7198 host_impl_->ScrollEnd(); |
7046 | 7199 |
7047 scoped_ptr<ScrollAndScaleSet> scroll_info = | 7200 scoped_ptr<ScrollAndScaleSet> scroll_info = |
7048 host_impl_->ProcessScrollDeltas(); | 7201 host_impl_->ProcessScrollDeltas(); |
7049 | 7202 |
7050 // The root should have scrolled. | 7203 // The root should have scrolled. |
7051 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7204 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
7052 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); | 7205 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); |
7053 } | 7206 } |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7432 new SimpleSwapPromiseMonitor(NULL, | 7585 new SimpleSwapPromiseMonitor(NULL, |
7433 host_impl_.get(), | 7586 host_impl_.get(), |
7434 &set_needs_commit_count, | 7587 &set_needs_commit_count, |
7435 &set_needs_redraw_count, | 7588 &set_needs_redraw_count, |
7436 &forward_to_main_count)); | 7589 &forward_to_main_count)); |
7437 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7590 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
7438 | 7591 |
7439 // Scrolling normally should not trigger any forwarding. | 7592 // Scrolling normally should not trigger any forwarding. |
7440 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7593 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7441 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7594 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7442 EXPECT_TRUE( | 7595 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
7443 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); | 7596 InputHandler::RAILS_MODE_FREE).did_scroll); |
7444 host_impl_->ScrollEnd(); | 7597 host_impl_->ScrollEnd(); |
7445 | 7598 |
7446 EXPECT_EQ(0, set_needs_commit_count); | 7599 EXPECT_EQ(0, set_needs_commit_count); |
7447 EXPECT_EQ(1, set_needs_redraw_count); | 7600 EXPECT_EQ(1, set_needs_redraw_count); |
7448 EXPECT_EQ(0, forward_to_main_count); | 7601 EXPECT_EQ(0, forward_to_main_count); |
7449 | 7602 |
7450 // Scrolling with a scroll handler should defer the swap to the main | 7603 // Scrolling with a scroll handler should defer the swap to the main |
7451 // thread. | 7604 // thread. |
7452 scroll_layer->SetHaveScrollEventHandlers(true); | 7605 scroll_layer->SetHaveScrollEventHandlers(true); |
7453 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7606 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7454 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7607 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7455 EXPECT_TRUE( | 7608 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10), |
7456 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); | 7609 InputHandler::RAILS_MODE_FREE).did_scroll); |
7457 host_impl_->ScrollEnd(); | 7610 host_impl_->ScrollEnd(); |
7458 | 7611 |
7459 EXPECT_EQ(0, set_needs_commit_count); | 7612 EXPECT_EQ(0, set_needs_commit_count); |
7460 EXPECT_EQ(2, set_needs_redraw_count); | 7613 EXPECT_EQ(2, set_needs_redraw_count); |
7461 EXPECT_EQ(1, forward_to_main_count); | 7614 EXPECT_EQ(1, forward_to_main_count); |
7462 } | 7615 } |
7463 } | 7616 } |
7464 | 7617 |
7465 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 7618 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
7466 public: | 7619 public: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7527 | 7680 |
7528 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7681 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7529 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7682 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7530 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7683 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7531 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7684 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7532 scroll_layer->CurrentScrollOffset().ToString()); | 7685 scroll_layer->CurrentScrollOffset().ToString()); |
7533 | 7686 |
7534 // Scroll just the top controls and verify that the scroll succeeds. | 7687 // Scroll just the top controls and verify that the scroll succeeds. |
7535 const float residue = 10; | 7688 const float residue = 10; |
7536 float offset = top_controls_height_ - residue; | 7689 float offset = top_controls_height_ - residue; |
7537 EXPECT_TRUE( | 7690 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7538 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7691 InputHandler::RAILS_MODE_FREE).did_scroll); |
7539 EXPECT_FLOAT_EQ(-offset, | 7692 EXPECT_FLOAT_EQ(-offset, |
7540 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7693 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7541 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7694 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7542 scroll_layer->CurrentScrollOffset().ToString()); | 7695 scroll_layer->CurrentScrollOffset().ToString()); |
7543 | 7696 |
7544 // Scroll across the boundary | 7697 // Scroll across the boundary |
7545 const float content_scroll = 20; | 7698 const float content_scroll = 20; |
7546 offset = residue + content_scroll; | 7699 offset = residue + content_scroll; |
7547 EXPECT_TRUE( | 7700 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7548 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7701 InputHandler::RAILS_MODE_FREE).did_scroll); |
7549 EXPECT_EQ(-top_controls_height_, | 7702 EXPECT_EQ(-top_controls_height_, |
7550 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7703 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7551 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), | 7704 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), |
7552 scroll_layer->CurrentScrollOffset().ToString()); | 7705 scroll_layer->CurrentScrollOffset().ToString()); |
7553 | 7706 |
7554 // Now scroll back to the top of the content | 7707 // Now scroll back to the top of the content |
7555 offset = -content_scroll; | 7708 offset = -content_scroll; |
7556 EXPECT_TRUE( | 7709 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7557 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7710 InputHandler::RAILS_MODE_FREE).did_scroll); |
7558 EXPECT_EQ(-top_controls_height_, | 7711 EXPECT_EQ(-top_controls_height_, |
7559 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7712 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7560 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7713 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7561 scroll_layer->CurrentScrollOffset().ToString()); | 7714 scroll_layer->CurrentScrollOffset().ToString()); |
7562 | 7715 |
7563 // And scroll the top controls completely into view | 7716 // And scroll the top controls completely into view |
7564 offset = -top_controls_height_; | 7717 offset = -top_controls_height_; |
7565 EXPECT_TRUE( | 7718 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7566 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7719 InputHandler::RAILS_MODE_FREE).did_scroll); |
7567 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7720 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7568 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7721 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7569 scroll_layer->CurrentScrollOffset().ToString()); | 7722 scroll_layer->CurrentScrollOffset().ToString()); |
7570 | 7723 |
7571 // And attempt to scroll past the end | 7724 // And attempt to scroll past the end |
7572 EXPECT_FALSE( | 7725 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7573 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7726 InputHandler::RAILS_MODE_FREE).did_scroll); |
7574 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7727 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7575 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7728 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7576 scroll_layer->CurrentScrollOffset().ToString()); | 7729 scroll_layer->CurrentScrollOffset().ToString()); |
7577 | 7730 |
7578 host_impl_->ScrollEnd(); | 7731 host_impl_->ScrollEnd(); |
7579 } | 7732 } |
7580 | 7733 |
7581 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 7734 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
7582 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7735 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
7583 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 7736 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
7584 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7737 host_impl_->top_controls_manager()->UpdateTopControlsState( |
7585 BOTH, SHOWN, false); | 7738 BOTH, SHOWN, false); |
7586 DrawFrame(); | 7739 DrawFrame(); |
7587 | 7740 |
7588 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7741 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7589 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7742 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7590 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7743 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7591 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7744 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7592 scroll_layer->CurrentScrollOffset().ToString()); | 7745 scroll_layer->CurrentScrollOffset().ToString()); |
7593 | 7746 |
7594 // Scroll the top controls partially. | 7747 // Scroll the top controls partially. |
7595 const float residue = 35; | 7748 const float residue = 35; |
7596 float offset = top_controls_height_ - residue; | 7749 float offset = top_controls_height_ - residue; |
7597 EXPECT_TRUE( | 7750 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7598 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7751 InputHandler::RAILS_MODE_FREE).did_scroll); |
7599 EXPECT_FLOAT_EQ(-offset, | 7752 EXPECT_FLOAT_EQ(-offset, |
7600 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7753 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7601 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7754 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7602 scroll_layer->CurrentScrollOffset().ToString()); | 7755 scroll_layer->CurrentScrollOffset().ToString()); |
7603 | 7756 |
7604 did_request_redraw_ = false; | 7757 did_request_redraw_ = false; |
7605 did_request_animate_ = false; | 7758 did_request_animate_ = false; |
7606 did_request_commit_ = false; | 7759 did_request_commit_ = false; |
7607 | 7760 |
7608 // End the scroll while the controls are still offset from their limit. | 7761 // End the scroll while the controls are still offset from their limit. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7658 | 7811 |
7659 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7812 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7660 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7813 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7661 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7814 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7662 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7815 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
7663 scroll_layer->CurrentScrollOffset().ToString()); | 7816 scroll_layer->CurrentScrollOffset().ToString()); |
7664 | 7817 |
7665 // Scroll the top controls partially. | 7818 // Scroll the top controls partially. |
7666 const float residue = 15; | 7819 const float residue = 15; |
7667 float offset = top_controls_height_ - residue; | 7820 float offset = top_controls_height_ - residue; |
7668 EXPECT_TRUE( | 7821 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7669 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7822 InputHandler::RAILS_MODE_FREE).did_scroll); |
7670 EXPECT_FLOAT_EQ(-offset, | 7823 EXPECT_FLOAT_EQ(-offset, |
7671 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7824 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7672 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7825 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
7673 scroll_layer->CurrentScrollOffset().ToString()); | 7826 scroll_layer->CurrentScrollOffset().ToString()); |
7674 | 7827 |
7675 did_request_redraw_ = false; | 7828 did_request_redraw_ = false; |
7676 did_request_animate_ = false; | 7829 did_request_animate_ = false; |
7677 did_request_commit_ = false; | 7830 did_request_commit_ = false; |
7678 | 7831 |
7679 // End the scroll while the controls are still offset from the limit. | 7832 // End the scroll while the controls are still offset from the limit. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7722 | 7875 |
7723 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7876 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7724 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7877 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7725 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7878 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7726 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7879 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
7727 scroll_layer->CurrentScrollOffset().ToString()); | 7880 scroll_layer->CurrentScrollOffset().ToString()); |
7728 | 7881 |
7729 // Scroll the top controls partially. | 7882 // Scroll the top controls partially. |
7730 const float residue = 15; | 7883 const float residue = 15; |
7731 float offset = top_controls_height_ - residue; | 7884 float offset = top_controls_height_ - residue; |
7732 EXPECT_TRUE( | 7885 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7733 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7886 InputHandler::RAILS_MODE_FREE).did_scroll); |
7734 EXPECT_FLOAT_EQ(-offset, | 7887 EXPECT_FLOAT_EQ(-offset, |
7735 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7888 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7736 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7889 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
7737 scroll_layer->CurrentScrollOffset().ToString()); | 7890 scroll_layer->CurrentScrollOffset().ToString()); |
7738 | 7891 |
7739 did_request_redraw_ = false; | 7892 did_request_redraw_ = false; |
7740 did_request_animate_ = false; | 7893 did_request_animate_ = false; |
7741 did_request_commit_ = false; | 7894 did_request_commit_ = false; |
7742 | 7895 |
7743 // End the fling while the controls are still offset from the limit. | 7896 // End the fling while the controls are still offset from the limit. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7780 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7933 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
7781 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 7934 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
7782 false); | 7935 false); |
7783 DrawFrame(); | 7936 DrawFrame(); |
7784 | 7937 |
7785 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7938 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7786 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7939 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7787 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7940 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7788 | 7941 |
7789 float offset = 50; | 7942 float offset = 50; |
7790 EXPECT_TRUE( | 7943 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7791 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7944 InputHandler::RAILS_MODE_FREE).did_scroll); |
7792 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7945 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7793 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7946 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7794 scroll_layer->CurrentScrollOffset().ToString()); | 7947 scroll_layer->CurrentScrollOffset().ToString()); |
7795 | 7948 |
7796 EXPECT_TRUE( | 7949 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7797 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7950 InputHandler::RAILS_MODE_FREE).did_scroll); |
7798 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | 7951 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
7799 scroll_layer->CurrentScrollOffset().ToString()); | 7952 scroll_layer->CurrentScrollOffset().ToString()); |
7800 | 7953 |
7801 EXPECT_TRUE( | 7954 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset), |
7802 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7955 InputHandler::RAILS_MODE_FREE).did_scroll); |
7803 | 7956 |
7804 // Should have fully scrolled | 7957 // Should have fully scrolled |
7805 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), | 7958 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), |
7806 scroll_layer->CurrentScrollOffset().ToString()); | 7959 scroll_layer->CurrentScrollOffset().ToString()); |
7807 | 7960 |
7808 float overscrollamount = 10; | 7961 float overscrollamount = 10; |
7809 | 7962 |
7810 // Overscroll the content | 7963 // Overscroll the content |
7811 EXPECT_FALSE( | 7964 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), |
7812 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) | 7965 gfx::Vector2d(0, overscrollamount), |
7813 .did_scroll); | 7966 InputHandler::RAILS_MODE_FREE).did_scroll); |
7814 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), | 7967 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), |
7815 scroll_layer->CurrentScrollOffset().ToString()); | 7968 scroll_layer->CurrentScrollOffset().ToString()); |
7816 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | 7969 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
7817 host_impl_->accumulated_root_overscroll().ToString()); | 7970 host_impl_->accumulated_root_overscroll().ToString()); |
7818 | 7971 |
7819 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) | 7972 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset), |
7820 .did_scroll); | 7973 InputHandler::RAILS_MODE_FREE).did_scroll); |
7821 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 7974 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
7822 scroll_layer->CurrentScrollOffset().ToString()); | 7975 scroll_layer->CurrentScrollOffset().ToString()); |
7823 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7976 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7824 | 7977 |
7825 EXPECT_TRUE( | 7978 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset), |
7826 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); | 7979 InputHandler::RAILS_MODE_FREE).did_scroll); |
7827 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 7980 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
7828 scroll_layer->CurrentScrollOffset().ToString()); | 7981 scroll_layer->CurrentScrollOffset().ToString()); |
7829 | 7982 |
7830 // Top controls should be fully visible | 7983 // Top controls should be fully visible |
7831 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7984 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7832 | 7985 |
7833 host_impl_->ScrollEnd(); | 7986 host_impl_->ScrollEnd(); |
7834 } | 7987 } |
7835 | 7988 |
7836 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { | 7989 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7913 gfx::Vector2dF outer_expected; | 8066 gfx::Vector2dF outer_expected; |
7914 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8067 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7915 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8068 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7916 | 8069 |
7917 // Make sure the fling goes to the outer viewport first | 8070 // Make sure the fling goes to the outer viewport first |
7918 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8071 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7919 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 8072 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7920 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 8073 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7921 | 8074 |
7922 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 8075 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
7923 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8076 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8077 InputHandler::RAILS_MODE_FREE); |
7924 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 8078 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7925 | 8079 |
7926 host_impl_->ScrollEnd(); | 8080 host_impl_->ScrollEnd(); |
7927 | 8081 |
7928 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8082 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7929 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8083 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7930 | 8084 |
7931 // Fling past the outer viewport boundry, make sure inner viewport scrolls. | 8085 // Fling past the outer viewport boundry, make sure inner viewport scrolls. |
7932 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8086 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7933 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 8087 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7934 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 8088 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7935 | 8089 |
7936 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8090 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8091 InputHandler::RAILS_MODE_FREE); |
7937 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 8092 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7938 | 8093 |
7939 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8094 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8095 InputHandler::RAILS_MODE_FREE); |
7940 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 8096 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7941 | 8097 |
7942 host_impl_->ScrollEnd(); | 8098 host_impl_->ScrollEnd(); |
7943 | 8099 |
7944 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8100 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7945 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8101 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7946 } | 8102 } |
7947 } | 8103 } |
7948 | 8104 |
7949 TEST_F(LayerTreeHostImplVirtualViewportTest, | 8105 TEST_F(LayerTreeHostImplVirtualViewportTest, |
(...skipping 13 matching lines...) Expand all Loading... |
7963 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8119 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7964 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8120 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7965 | 8121 |
7966 // Make sure the scroll goes to the outer viewport first. | 8122 // Make sure the scroll goes to the outer viewport first. |
7967 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8123 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7968 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 8124 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
7969 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 8125 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7970 | 8126 |
7971 // Scroll near the edge of the outer viewport. | 8127 // Scroll near the edge of the outer viewport. |
7972 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 8128 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
7973 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8129 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8130 InputHandler::RAILS_MODE_FREE); |
7974 outer_expected += scroll_delta; | 8131 outer_expected += scroll_delta; |
7975 | 8132 |
7976 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8133 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7977 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8134 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7978 | 8135 |
7979 // Now diagonal scroll across the outer viewport boundary in a single event. | 8136 // Now diagonal scroll across the outer viewport boundary in a single event. |
7980 // The entirety of the scroll should be consumed, as bubbling between inner | 8137 // The entirety of the scroll should be consumed, as bubbling between inner |
7981 // and outer viewport layers is perfect. | 8138 // and outer viewport layers is perfect. |
7982 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); | 8139 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2), |
| 8140 InputHandler::RAILS_MODE_FREE); |
7983 outer_expected += scroll_delta; | 8141 outer_expected += scroll_delta; |
7984 inner_expected += scroll_delta; | 8142 inner_expected += scroll_delta; |
7985 host_impl_->ScrollEnd(); | 8143 host_impl_->ScrollEnd(); |
7986 | 8144 |
7987 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8145 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7988 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8146 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7989 } | 8147 } |
7990 } | 8148 } |
7991 | 8149 |
7992 TEST_F(LayerTreeHostImplVirtualViewportTest, | 8150 TEST_F(LayerTreeHostImplVirtualViewportTest, |
(...skipping 12 matching lines...) Expand all Loading... |
8005 LayerImpl* child_scroll = child.get(); | 8163 LayerImpl* child_scroll = child.get(); |
8006 outer_scroll->children()[0]->AddChild(child.Pass()); | 8164 outer_scroll->children()[0]->AddChild(child.Pass()); |
8007 | 8165 |
8008 DrawFrame(); | 8166 DrawFrame(); |
8009 { | 8167 { |
8010 scoped_ptr<ScrollAndScaleSet> scroll_info; | 8168 scoped_ptr<ScrollAndScaleSet> scroll_info; |
8011 | 8169 |
8012 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 8170 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
8013 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8171 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
8014 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 8172 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
8015 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 8173 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8174 InputHandler::RAILS_MODE_FREE).did_scroll); |
8016 | 8175 |
8017 // The child should have scrolled up to its limit. | 8176 // The child should have scrolled up to its limit. |
8018 scroll_info = host_impl_->ProcessScrollDeltas(); | 8177 scroll_info = host_impl_->ProcessScrollDeltas(); |
8019 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 8178 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
8020 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); | 8179 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); |
8021 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 8180 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
8022 | 8181 |
8023 // The first |ScrollBy| after the fling should re-lock the scrolling | 8182 // The first |ScrollBy| after the fling should re-lock the scrolling |
8024 // layer to the first layer that scrolled, the inner viewport scroll layer. | 8183 // layer to the first layer that scrolled, the inner viewport scroll layer. |
8025 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 8184 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
8026 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 8185 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8186 InputHandler::RAILS_MODE_FREE).did_scroll); |
8027 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 8187 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
8028 | 8188 |
8029 // The inner viewport should have scrolled up to its limit. | 8189 // The inner viewport should have scrolled up to its limit. |
8030 scroll_info = host_impl_->ProcessScrollDeltas(); | 8190 scroll_info = host_impl_->ProcessScrollDeltas(); |
8031 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 8191 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
8032 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); | 8192 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); |
8033 ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta); | 8193 ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta); |
8034 | 8194 |
8035 // As the locked layer is at its limit, no further scrolling can occur. | 8195 // As the locked layer is at its limit, no further scrolling can occur. |
8036 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 8196 EXPECT_FALSE( |
| 8197 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8198 InputHandler::RAILS_MODE_FREE).did_scroll); |
8037 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 8199 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
8038 host_impl_->ScrollEnd(); | 8200 host_impl_->ScrollEnd(); |
8039 } | 8201 } |
8040 } | 8202 } |
8041 | 8203 |
8042 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { | 8204 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { |
8043 public: | 8205 public: |
8044 void SetUp() override { | 8206 void SetUp() override { |
8045 LayerTreeSettings settings = DefaultSettings(); | 8207 LayerTreeSettings settings = DefaultSettings(); |
8046 settings.max_memory_for_prepaint_percentage = 50; | 8208 settings.max_memory_for_prepaint_percentage = 50; |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8468 host_impl_->PinchGestureBegin(); | 8630 host_impl_->PinchGestureBegin(); |
8469 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 8631 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
8470 host_impl_->PinchGestureEnd(); | 8632 host_impl_->PinchGestureEnd(); |
8471 host_impl_->ScrollEnd(); | 8633 host_impl_->ScrollEnd(); |
8472 | 8634 |
8473 gfx::Vector2dF scroll_delta(0, 5); | 8635 gfx::Vector2dF scroll_delta(0, 5); |
8474 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8636 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
8475 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 8637 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
8476 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 8638 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
8477 | 8639 |
8478 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8640 host_impl_->ScrollBy(gfx::Point(), scroll_delta, |
| 8641 InputHandler::RAILS_MODE_FREE); |
8479 host_impl_->ScrollEnd(); | 8642 host_impl_->ScrollEnd(); |
8480 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), | 8643 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
8481 scroll_layer->CurrentScrollOffset()); | 8644 scroll_layer->CurrentScrollOffset()); |
8482 } | 8645 } |
8483 } | 8646 } |
8484 | 8647 |
8485 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 8648 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
8486 public: | 8649 public: |
8487 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} | 8650 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} |
8488 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } | 8651 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } |
8489 | 8652 |
8490 protected: | 8653 protected: |
8491 int num_lost_surfaces_; | 8654 int num_lost_surfaces_; |
8492 }; | 8655 }; |
8493 | 8656 |
8494 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { | 8657 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { |
8495 // Really we just need at least one client notification each time | 8658 // Really we just need at least one client notification each time |
8496 // we go from having a valid output surface to not having a valid output | 8659 // we go from having a valid output surface to not having a valid output |
8497 // surface. | 8660 // surface. |
8498 EXPECT_EQ(0, num_lost_surfaces_); | 8661 EXPECT_EQ(0, num_lost_surfaces_); |
8499 host_impl_->DidLoseOutputSurface(); | 8662 host_impl_->DidLoseOutputSurface(); |
8500 EXPECT_EQ(1, num_lost_surfaces_); | 8663 EXPECT_EQ(1, num_lost_surfaces_); |
8501 host_impl_->DidLoseOutputSurface(); | 8664 host_impl_->DidLoseOutputSurface(); |
8502 EXPECT_LE(1, num_lost_surfaces_); | 8665 EXPECT_LE(1, num_lost_surfaces_); |
8503 } | 8666 } |
8504 | 8667 |
8505 } // namespace | 8668 } // namespace |
8506 } // namespace cc | 8669 } // namespace cc |
OLD | NEW |