| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 EventListenerClass::kMouseWheel, | 743 EventListenerClass::kMouseWheel, |
| 744 EventListenerProperties::kBlockingAndPassive); | 744 EventListenerProperties::kBlockingAndPassive); |
| 745 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 745 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 746 InputHandler::WHEEL); | 746 InputHandler::WHEEL); |
| 747 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 747 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 748 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, | 748 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, |
| 749 status.main_thread_scrolling_reasons); | 749 status.main_thread_scrolling_reasons); |
| 750 | 750 |
| 751 // But gesture scrolls can still be handled. | 751 // But gesture scrolls can still be handled. |
| 752 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 752 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 753 InputHandler::GESTURE); | 753 InputHandler::TOUCHSCREEN); |
| 754 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 754 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 755 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 755 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 756 status.main_thread_scrolling_reasons); | 756 status.main_thread_scrolling_reasons); |
| 757 host_impl_->ScrollEnd(EndState().get()); | 757 host_impl_->ScrollEnd(EndState().get()); |
| 758 | 758 |
| 759 // And if the handlers go away, wheel scrolls can again be processed | 759 // And if the handlers go away, wheel scrolls can again be processed |
| 760 // on impl. | 760 // on impl. |
| 761 host_impl_->active_tree()->set_event_listener_properties( | 761 host_impl_->active_tree()->set_event_listener_properties( |
| 762 EventListenerClass::kMouseWheel, EventListenerProperties::kNone); | 762 EventListenerClass::kMouseWheel, EventListenerProperties::kNone); |
| 763 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 763 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 786 SetNeedsRebuildPropertyTrees(); | 786 SetNeedsRebuildPropertyTrees(); |
| 787 RebuildPropertyTrees(); | 787 RebuildPropertyTrees(); |
| 788 } | 788 } |
| 789 | 789 |
| 790 // Touch handler regions determine whether touch events block scroll. | 790 // Touch handler regions determine whether touch events block scroll. |
| 791 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 791 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| 792 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 792 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
| 793 | 793 |
| 794 // But they don't influence the actual handling of the scroll gestures. | 794 // But they don't influence the actual handling of the scroll gestures. |
| 795 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 795 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 796 BeginState(gfx::Point()).get(), InputHandler::GESTURE); | 796 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 797 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 797 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 798 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 798 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 799 status.main_thread_scrolling_reasons); | 799 status.main_thread_scrolling_reasons); |
| 800 host_impl_->ScrollEnd(EndState().get()); | 800 host_impl_->ScrollEnd(EndState().get()); |
| 801 | 801 |
| 802 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 802 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 803 root->SetTouchEventHandlerRegion(gfx::Rect()); | 803 root->SetTouchEventHandlerRegion(gfx::Rect()); |
| 804 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 804 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 805 child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); | 805 child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); |
| 806 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 806 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 807 } | 807 } |
| 808 | 808 |
| 809 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { | 809 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { |
| 810 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 810 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 811 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 811 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 812 DrawFrame(); | 812 DrawFrame(); |
| 813 | 813 |
| 814 // Ignore the fling since no layer is being scrolled | 814 // Ignore the fling since no layer is being scrolled |
| 815 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin(); | 815 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin(); |
| 816 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 816 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 817 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 817 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 818 status.main_thread_scrolling_reasons); | 818 status.main_thread_scrolling_reasons); |
| 819 | 819 |
| 820 // Start scrolling a layer | 820 // Start scrolling a layer |
| 821 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 821 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 822 InputHandler::GESTURE); | 822 InputHandler::TOUCHSCREEN); |
| 823 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 823 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 824 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 824 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 825 status.main_thread_scrolling_reasons); | 825 status.main_thread_scrolling_reasons); |
| 826 | 826 |
| 827 // Now the fling should go ahead since we've started scrolling a layer | 827 // Now the fling should go ahead since we've started scrolling a layer |
| 828 status = host_impl_->FlingScrollBegin(); | 828 status = host_impl_->FlingScrollBegin(); |
| 829 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 829 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 830 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 830 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 831 status.main_thread_scrolling_reasons); | 831 status.main_thread_scrolling_reasons); |
| 832 } | 832 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 862 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 862 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 863 | 863 |
| 864 root->set_main_thread_scrolling_reasons( | 864 root->set_main_thread_scrolling_reasons( |
| 865 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 865 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 866 | 866 |
| 867 SetNeedsRebuildPropertyTrees(); | 867 SetNeedsRebuildPropertyTrees(); |
| 868 DrawFrame(); | 868 DrawFrame(); |
| 869 | 869 |
| 870 // Start scrolling a layer | 870 // Start scrolling a layer |
| 871 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 871 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 872 BeginState(gfx::Point()).get(), InputHandler::GESTURE); | 872 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 873 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 873 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 874 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 874 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
| 875 status.main_thread_scrolling_reasons); | 875 status.main_thread_scrolling_reasons); |
| 876 | 876 |
| 877 // The fling should be ignored since there's no layer being scrolled impl-side | 877 // The fling should be ignored since there's no layer being scrolled impl-side |
| 878 status = host_impl_->FlingScrollBegin(); | 878 status = host_impl_->FlingScrollBegin(); |
| 879 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 879 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 880 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 880 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 881 status.main_thread_scrolling_reasons); | 881 status.main_thread_scrolling_reasons); |
| 882 } | 882 } |
| 883 | 883 |
| 884 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { | 884 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { |
| 885 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 885 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 886 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 886 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 887 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 887 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 888 | 888 |
| 889 root->set_main_thread_scrolling_reasons( | 889 root->set_main_thread_scrolling_reasons( |
| 890 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 890 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 891 SetNeedsRebuildPropertyTrees(); | 891 SetNeedsRebuildPropertyTrees(); |
| 892 DrawFrame(); | 892 DrawFrame(); |
| 893 | 893 |
| 894 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 894 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 895 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 895 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 896 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 896 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 897 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 897 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
| 898 status.main_thread_scrolling_reasons); | 898 status.main_thread_scrolling_reasons); |
| 899 | 899 |
| 900 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 900 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 901 InputHandler::GESTURE); | 901 InputHandler::TOUCHSCREEN); |
| 902 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 902 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 903 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 903 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
| 904 status.main_thread_scrolling_reasons); | 904 status.main_thread_scrolling_reasons); |
| 905 } | 905 } |
| 906 | 906 |
| 907 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 907 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
| 908 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 908 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 909 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 909 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 910 | 910 |
| 911 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 911 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 912 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 912 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 913 | 913 |
| 914 SetNeedsRebuildPropertyTrees(); | 914 SetNeedsRebuildPropertyTrees(); |
| 915 DrawFrame(); | 915 DrawFrame(); |
| 916 | 916 |
| 917 // All scroll types inside the non-fast scrollable region should fail. | 917 // All scroll types inside the non-fast scrollable region should fail. |
| 918 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 918 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 919 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); | 919 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); |
| 920 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 920 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 921 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, | 921 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, |
| 922 status.main_thread_scrolling_reasons); | 922 status.main_thread_scrolling_reasons); |
| 923 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 923 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
| 924 InputHandler::WHEEL)); | 924 InputHandler::WHEEL)); |
| 925 | 925 |
| 926 status = host_impl_->ScrollBegin(BeginState(gfx::Point(25, 25)).get(), | 926 status = host_impl_->ScrollBegin(BeginState(gfx::Point(25, 25)).get(), |
| 927 InputHandler::GESTURE); | 927 InputHandler::TOUCHSCREEN); |
| 928 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 928 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 929 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, | 929 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, |
| 930 status.main_thread_scrolling_reasons); | 930 status.main_thread_scrolling_reasons); |
| 931 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 931 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 932 InputHandler::GESTURE)); | 932 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); |
| 933 | 933 |
| 934 // All scroll types outside this region should succeed. | 934 // All scroll types outside this region should succeed. |
| 935 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), | 935 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), |
| 936 InputHandler::WHEEL); | 936 InputHandler::WHEEL); |
| 937 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 937 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 938 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 938 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 939 status.main_thread_scrolling_reasons); | 939 status.main_thread_scrolling_reasons); |
| 940 | 940 |
| 941 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 941 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 942 InputHandler::GESTURE)); | 942 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 943 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 943 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 944 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 944 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 945 InputHandler::GESTURE)); | 945 gfx::Point(25, 25), InputHandler::TOUCHSCREEN)); |
| 946 host_impl_->ScrollEnd(EndState().get()); | 946 host_impl_->ScrollEnd(EndState().get()); |
| 947 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 947 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 948 InputHandler::GESTURE)); | 948 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 949 | 949 |
| 950 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), | 950 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), |
| 951 InputHandler::GESTURE); | 951 InputHandler::TOUCHSCREEN); |
| 952 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 952 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 953 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 953 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 954 status.main_thread_scrolling_reasons); | 954 status.main_thread_scrolling_reasons); |
| 955 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 955 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 956 InputHandler::GESTURE)); | 956 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 957 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 957 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 958 host_impl_->ScrollEnd(EndState().get()); | 958 host_impl_->ScrollEnd(EndState().get()); |
| 959 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 959 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 960 InputHandler::GESTURE)); | 960 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 961 } | 961 } |
| 962 | 962 |
| 963 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 963 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
| 964 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 964 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 965 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 965 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 966 | 966 |
| 967 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 967 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 968 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 968 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 969 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 969 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
| 970 root->SetDrawsContent(true); | 970 root->SetDrawsContent(true); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 994 } | 994 } |
| 995 | 995 |
| 996 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { | 996 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { |
| 997 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 997 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 998 EXPECT_FALSE(host_impl_->active_tree()->have_scroll_event_handlers()); | 998 EXPECT_FALSE(host_impl_->active_tree()->have_scroll_event_handlers()); |
| 999 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 999 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1000 DrawFrame(); | 1000 DrawFrame(); |
| 1001 | 1001 |
| 1002 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1002 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1003 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1003 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1004 InputHandler::GESTURE); | 1004 InputHandler::TOUCHSCREEN); |
| 1005 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1005 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1006 host_impl_->ScrollEnd(EndState().get()); | 1006 host_impl_->ScrollEnd(EndState().get()); |
| 1007 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1007 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) { | 1010 TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) { |
| 1011 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1011 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1012 host_impl_->active_tree()->set_have_scroll_event_handlers(true); | 1012 host_impl_->active_tree()->set_have_scroll_event_handlers(true); |
| 1013 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1013 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1014 DrawFrame(); | 1014 DrawFrame(); |
| 1015 | 1015 |
| 1016 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1016 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1017 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1017 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1018 InputHandler::GESTURE); | 1018 InputHandler::TOUCHSCREEN); |
| 1019 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); | 1019 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); |
| 1020 host_impl_->ScrollEnd(EndState().get()); | 1020 host_impl_->ScrollEnd(EndState().get()); |
| 1021 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 1021 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { | 1024 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { |
| 1025 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1025 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1026 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1026 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1027 | 1027 |
| 1028 DrawFrame(); | 1028 DrawFrame(); |
| 1029 | 1029 |
| 1030 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1030 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 1031 BeginState(gfx::Point()).get(), InputHandler::GESTURE); | 1031 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 1032 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1032 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1033 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1033 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1034 status.main_thread_scrolling_reasons); | 1034 status.main_thread_scrolling_reasons); |
| 1035 | 1035 |
| 1036 // Trying to scroll to the left/top will not succeed. | 1036 // Trying to scroll to the left/top will not succeed. |
| 1037 EXPECT_FALSE( | 1037 EXPECT_FALSE( |
| 1038 host_impl_->ScrollBy( | 1038 host_impl_->ScrollBy( |
| 1039 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1039 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
| 1040 .did_scroll); | 1040 .did_scroll); |
| 1041 EXPECT_FALSE( | 1041 EXPECT_FALSE( |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 // The impl-based pinch zoom should adjust the max scroll position. | 1476 // The impl-based pinch zoom should adjust the max scroll position. |
| 1477 { | 1477 { |
| 1478 host_impl_->active_tree()->PushPageScaleFromMainThread( | 1478 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 1479 page_scale_factor, min_page_scale, max_page_scale); | 1479 page_scale_factor, min_page_scale, max_page_scale); |
| 1480 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1480 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1481 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1481 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1482 | 1482 |
| 1483 float page_scale_delta = 2.f; | 1483 float page_scale_delta = 2.f; |
| 1484 | 1484 |
| 1485 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), | 1485 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), |
| 1486 InputHandler::GESTURE); | 1486 InputHandler::TOUCHSCREEN); |
| 1487 host_impl_->PinchGestureBegin(); | 1487 host_impl_->PinchGestureBegin(); |
| 1488 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 1488 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 1489 host_impl_->PinchGestureEnd(); | 1489 host_impl_->PinchGestureEnd(); |
| 1490 host_impl_->ScrollEnd(EndState().get()); | 1490 host_impl_->ScrollEnd(EndState().get()); |
| 1491 EXPECT_FALSE(did_request_next_frame_); | 1491 EXPECT_FALSE(did_request_next_frame_); |
| 1492 EXPECT_TRUE(did_request_redraw_); | 1492 EXPECT_TRUE(did_request_redraw_); |
| 1493 EXPECT_TRUE(did_request_commit_); | 1493 EXPECT_TRUE(did_request_commit_); |
| 1494 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 1494 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
| 1495 | 1495 |
| 1496 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1496 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1497 host_impl_->ProcessScrollDeltas(); | 1497 host_impl_->ProcessScrollDeltas(); |
| 1498 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1498 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1499 | 1499 |
| 1500 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), | 1500 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), |
| 1501 scroll_layer->MaxScrollOffset().ToString()); | 1501 scroll_layer->MaxScrollOffset().ToString()); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 // Scrolling after a pinch gesture should always be in local space. The | 1504 // Scrolling after a pinch gesture should always be in local space. The |
| 1505 // scroll deltas have the page scale factor applied. | 1505 // scroll deltas have the page scale factor applied. |
| 1506 { | 1506 { |
| 1507 host_impl_->active_tree()->PushPageScaleFromMainThread( | 1507 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 1508 page_scale_factor, min_page_scale, max_page_scale); | 1508 page_scale_factor, min_page_scale, max_page_scale); |
| 1509 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1509 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1510 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1510 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1511 | 1511 |
| 1512 float page_scale_delta = 2.f; | 1512 float page_scale_delta = 2.f; |
| 1513 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1513 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1514 InputHandler::GESTURE); | 1514 InputHandler::TOUCHSCREEN); |
| 1515 host_impl_->PinchGestureBegin(); | 1515 host_impl_->PinchGestureBegin(); |
| 1516 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1516 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 1517 host_impl_->PinchGestureEnd(); | 1517 host_impl_->PinchGestureEnd(); |
| 1518 host_impl_->ScrollEnd(EndState().get()); | 1518 host_impl_->ScrollEnd(EndState().get()); |
| 1519 | 1519 |
| 1520 gfx::Vector2d scroll_delta(0, 10); | 1520 gfx::Vector2d scroll_delta(0, 10); |
| 1521 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1521 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1522 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 1522 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 1523 InputHandler::WHEEL) | 1523 InputHandler::WHEEL) |
| 1524 .thread); | 1524 .thread); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1547 outer_scroll_layer->SetDrawsContent(true); | 1547 outer_scroll_layer->SetDrawsContent(true); |
| 1548 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1548 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1549 inner_scroll_layer->SetDrawsContent(true); | 1549 inner_scroll_layer->SetDrawsContent(true); |
| 1550 | 1550 |
| 1551 EXPECT_VECTOR_EQ( | 1551 EXPECT_VECTOR_EQ( |
| 1552 gfx::Vector2dF(500, 500), | 1552 gfx::Vector2dF(500, 500), |
| 1553 outer_scroll_layer->MaxScrollOffset()); | 1553 outer_scroll_layer->MaxScrollOffset()); |
| 1554 | 1554 |
| 1555 RebuildPropertyTrees(); | 1555 RebuildPropertyTrees(); |
| 1556 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1556 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1557 InputHandler::GESTURE); | 1557 InputHandler::TOUCHSCREEN); |
| 1558 host_impl_->PinchGestureBegin(); | 1558 host_impl_->PinchGestureBegin(); |
| 1559 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1559 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
| 1560 host_impl_->PinchGestureEnd(); | 1560 host_impl_->PinchGestureEnd(); |
| 1561 host_impl_->ScrollEnd(EndState().get()); | 1561 host_impl_->ScrollEnd(EndState().get()); |
| 1562 | 1562 |
| 1563 // Sanity check - we're zoomed in, starting from the origin. | 1563 // Sanity check - we're zoomed in, starting from the origin. |
| 1564 EXPECT_VECTOR_EQ( | 1564 EXPECT_VECTOR_EQ( |
| 1565 gfx::Vector2dF(0, 0), | 1565 gfx::Vector2dF(0, 0), |
| 1566 outer_scroll_layer->CurrentScrollOffset()); | 1566 outer_scroll_layer->CurrentScrollOffset()); |
| 1567 EXPECT_VECTOR_EQ( | 1567 EXPECT_VECTOR_EQ( |
| 1568 gfx::Vector2dF(0, 0), | 1568 gfx::Vector2dF(0, 0), |
| 1569 inner_scroll_layer->CurrentScrollOffset()); | 1569 inner_scroll_layer->CurrentScrollOffset()); |
| 1570 | 1570 |
| 1571 // Scroll down - only the inner viewport should scroll. | 1571 // Scroll down - only the inner viewport should scroll. |
| 1572 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1572 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1573 InputHandler::GESTURE); | 1573 InputHandler::TOUCHSCREEN); |
| 1574 host_impl_->ScrollBy( | 1574 host_impl_->ScrollBy( |
| 1575 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); | 1575 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); |
| 1576 host_impl_->ScrollEnd(EndState().get()); | 1576 host_impl_->ScrollEnd(EndState().get()); |
| 1577 | 1577 |
| 1578 EXPECT_VECTOR_EQ( | 1578 EXPECT_VECTOR_EQ( |
| 1579 gfx::Vector2dF(50, 50), | 1579 gfx::Vector2dF(50, 50), |
| 1580 inner_scroll_layer->CurrentScrollOffset()); | 1580 inner_scroll_layer->CurrentScrollOffset()); |
| 1581 EXPECT_VECTOR_EQ( | 1581 EXPECT_VECTOR_EQ( |
| 1582 gfx::Vector2dF(0, 0), | 1582 gfx::Vector2dF(0, 0), |
| 1583 outer_scroll_layer->CurrentScrollOffset()); | 1583 outer_scroll_layer->CurrentScrollOffset()); |
| 1584 | 1584 |
| 1585 // Scroll down - outer viewport should start scrolling after the inner is at | 1585 // Scroll down - outer viewport should start scrolling after the inner is at |
| 1586 // its maximum. | 1586 // its maximum. |
| 1587 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1587 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1588 InputHandler::GESTURE); | 1588 InputHandler::TOUCHSCREEN); |
| 1589 host_impl_->ScrollBy( | 1589 host_impl_->ScrollBy( |
| 1590 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); | 1590 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); |
| 1591 host_impl_->ScrollEnd(EndState().get()); | 1591 host_impl_->ScrollEnd(EndState().get()); |
| 1592 | 1592 |
| 1593 EXPECT_VECTOR_EQ( | 1593 EXPECT_VECTOR_EQ( |
| 1594 gfx::Vector2dF(250, 250), | 1594 gfx::Vector2dF(250, 250), |
| 1595 inner_scroll_layer->CurrentScrollOffset()); | 1595 inner_scroll_layer->CurrentScrollOffset()); |
| 1596 EXPECT_VECTOR_EQ( | 1596 EXPECT_VECTOR_EQ( |
| 1597 gfx::Vector2dF(300, 300), | 1597 gfx::Vector2dF(300, 300), |
| 1598 outer_scroll_layer->CurrentScrollOffset()); | 1598 outer_scroll_layer->CurrentScrollOffset()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1618 EXPECT_VECTOR_EQ( | 1618 EXPECT_VECTOR_EQ( |
| 1619 gfx::Vector2dF(500, 500), | 1619 gfx::Vector2dF(500, 500), |
| 1620 outer_scroll_layer->MaxScrollOffset()); | 1620 outer_scroll_layer->MaxScrollOffset()); |
| 1621 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 1621 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 1622 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); | 1622 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); |
| 1623 | 1623 |
| 1624 RebuildPropertyTrees(); | 1624 RebuildPropertyTrees(); |
| 1625 | 1625 |
| 1626 // Scroll only the layout viewport. | 1626 // Scroll only the layout viewport. |
| 1627 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1627 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1628 InputHandler::GESTURE); | 1628 InputHandler::TOUCHSCREEN); |
| 1629 host_impl_->ScrollBy( | 1629 host_impl_->ScrollBy( |
| 1630 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); | 1630 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); |
| 1631 EXPECT_VECTOR2DF_EQ( | 1631 EXPECT_VECTOR2DF_EQ( |
| 1632 gfx::Vector2dF(0.125f, 0.125f), | 1632 gfx::Vector2dF(0.125f, 0.125f), |
| 1633 outer_scroll_layer->CurrentScrollOffset()); | 1633 outer_scroll_layer->CurrentScrollOffset()); |
| 1634 EXPECT_VECTOR2DF_EQ( | 1634 EXPECT_VECTOR2DF_EQ( |
| 1635 gfx::Vector2dF(0, 0), | 1635 gfx::Vector2dF(0, 0), |
| 1636 inner_scroll_layer->CurrentScrollOffset()); | 1636 inner_scroll_layer->CurrentScrollOffset()); |
| 1637 host_impl_->ScrollEnd(EndState().get()); | 1637 host_impl_->ScrollEnd(EndState().get()); |
| 1638 | 1638 |
| 1639 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 1639 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 1640 | 1640 |
| 1641 // Now that we zoomed in, the scroll should be applied to the inner viewport. | 1641 // Now that we zoomed in, the scroll should be applied to the inner viewport. |
| 1642 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1642 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1643 InputHandler::GESTURE); | 1643 InputHandler::TOUCHSCREEN); |
| 1644 host_impl_->ScrollBy( | 1644 host_impl_->ScrollBy( |
| 1645 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); | 1645 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); |
| 1646 EXPECT_VECTOR2DF_EQ( | 1646 EXPECT_VECTOR2DF_EQ( |
| 1647 gfx::Vector2dF(0.125f, 0.125f), | 1647 gfx::Vector2dF(0.125f, 0.125f), |
| 1648 outer_scroll_layer->CurrentScrollOffset()); | 1648 outer_scroll_layer->CurrentScrollOffset()); |
| 1649 EXPECT_VECTOR2DF_EQ( | 1649 EXPECT_VECTOR2DF_EQ( |
| 1650 gfx::Vector2dF(0.25f, 0.25f), | 1650 gfx::Vector2dF(0.25f, 0.25f), |
| 1651 inner_scroll_layer->CurrentScrollOffset()); | 1651 inner_scroll_layer->CurrentScrollOffset()); |
| 1652 host_impl_->ScrollEnd(EndState().get()); | 1652 host_impl_->ScrollEnd(EndState().get()); |
| 1653 } | 1653 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1669 outer_scroll_layer->SetDrawsContent(true); | 1669 outer_scroll_layer->SetDrawsContent(true); |
| 1670 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1670 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1671 inner_scroll_layer->SetDrawsContent(true); | 1671 inner_scroll_layer->SetDrawsContent(true); |
| 1672 | 1672 |
| 1673 EXPECT_VECTOR_EQ( | 1673 EXPECT_VECTOR_EQ( |
| 1674 gfx::Vector2dF(500, 500), | 1674 gfx::Vector2dF(500, 500), |
| 1675 outer_scroll_layer->MaxScrollOffset()); | 1675 outer_scroll_layer->MaxScrollOffset()); |
| 1676 | 1676 |
| 1677 RebuildPropertyTrees(); | 1677 RebuildPropertyTrees(); |
| 1678 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1678 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1679 InputHandler::GESTURE); | 1679 InputHandler::TOUCHSCREEN); |
| 1680 host_impl_->PinchGestureBegin(); | 1680 host_impl_->PinchGestureBegin(); |
| 1681 | 1681 |
| 1682 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); | 1682 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); |
| 1683 EXPECT_VECTOR_EQ( | 1683 EXPECT_VECTOR_EQ( |
| 1684 gfx::Vector2dF(0, 0), | 1684 gfx::Vector2dF(0, 0), |
| 1685 outer_scroll_layer->CurrentScrollOffset()); | 1685 outer_scroll_layer->CurrentScrollOffset()); |
| 1686 EXPECT_VECTOR_EQ( | 1686 EXPECT_VECTOR_EQ( |
| 1687 gfx::Vector2dF(125, 125), | 1687 gfx::Vector2dF(125, 125), |
| 1688 inner_scroll_layer->CurrentScrollOffset()); | 1688 inner_scroll_layer->CurrentScrollOffset()); |
| 1689 | 1689 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 const gfx::Size viewport_size(500, 500); | 1727 const gfx::Size viewport_size(500, 500); |
| 1728 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1728 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1729 | 1729 |
| 1730 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; | 1730 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; |
| 1731 gfx::Point anchor(viewport_size.width() - offsetFromEdge, | 1731 gfx::Point anchor(viewport_size.width() - offsetFromEdge, |
| 1732 viewport_size.height() - offsetFromEdge); | 1732 viewport_size.height() - offsetFromEdge); |
| 1733 | 1733 |
| 1734 // Pinch in within the margins. The scroll should stay exactly locked to the | 1734 // Pinch in within the margins. The scroll should stay exactly locked to the |
| 1735 // bottom and right. | 1735 // bottom and right. |
| 1736 RebuildPropertyTrees(); | 1736 RebuildPropertyTrees(); |
| 1737 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); | 1737 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::TOUCHSCREEN); |
| 1738 host_impl_->PinchGestureBegin(); | 1738 host_impl_->PinchGestureBegin(); |
| 1739 host_impl_->PinchGestureUpdate(2, anchor); | 1739 host_impl_->PinchGestureUpdate(2, anchor); |
| 1740 host_impl_->PinchGestureEnd(); | 1740 host_impl_->PinchGestureEnd(); |
| 1741 host_impl_->ScrollEnd(EndState().get()); | 1741 host_impl_->ScrollEnd(EndState().get()); |
| 1742 | 1742 |
| 1743 EXPECT_VECTOR_EQ( | 1743 EXPECT_VECTOR_EQ( |
| 1744 gfx::Vector2dF(250, 250), | 1744 gfx::Vector2dF(250, 250), |
| 1745 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1745 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1746 | 1746 |
| 1747 // Reset. | 1747 // Reset. |
| 1748 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); | 1748 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); |
| 1749 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); | 1749 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); |
| 1750 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); | 1750 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); |
| 1751 | 1751 |
| 1752 // Pinch in within the margins. The scroll should stay exactly locked to the | 1752 // Pinch in within the margins. The scroll should stay exactly locked to the |
| 1753 // top and left. | 1753 // top and left. |
| 1754 anchor = gfx::Point(offsetFromEdge, offsetFromEdge); | 1754 anchor = gfx::Point(offsetFromEdge, offsetFromEdge); |
| 1755 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); | 1755 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::TOUCHSCREEN); |
| 1756 host_impl_->PinchGestureBegin(); | 1756 host_impl_->PinchGestureBegin(); |
| 1757 host_impl_->PinchGestureUpdate(2, anchor); | 1757 host_impl_->PinchGestureUpdate(2, anchor); |
| 1758 host_impl_->PinchGestureEnd(); | 1758 host_impl_->PinchGestureEnd(); |
| 1759 host_impl_->ScrollEnd(EndState().get()); | 1759 host_impl_->ScrollEnd(EndState().get()); |
| 1760 | 1760 |
| 1761 EXPECT_VECTOR_EQ( | 1761 EXPECT_VECTOR_EQ( |
| 1762 gfx::Vector2dF(0, 0), | 1762 gfx::Vector2dF(0, 0), |
| 1763 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1763 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1764 | 1764 |
| 1765 // Reset. | 1765 // Reset. |
| 1766 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); | 1766 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); |
| 1767 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); | 1767 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); |
| 1768 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); | 1768 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); |
| 1769 | 1769 |
| 1770 // Pinch in just outside the margin. There should be no snapping. | 1770 // Pinch in just outside the margin. There should be no snapping. |
| 1771 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips; | 1771 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips; |
| 1772 anchor = gfx::Point(offsetFromEdge, offsetFromEdge); | 1772 anchor = gfx::Point(offsetFromEdge, offsetFromEdge); |
| 1773 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); | 1773 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::TOUCHSCREEN); |
| 1774 host_impl_->PinchGestureBegin(); | 1774 host_impl_->PinchGestureBegin(); |
| 1775 host_impl_->PinchGestureUpdate(2, anchor); | 1775 host_impl_->PinchGestureUpdate(2, anchor); |
| 1776 host_impl_->PinchGestureEnd(); | 1776 host_impl_->PinchGestureEnd(); |
| 1777 host_impl_->ScrollEnd(EndState().get()); | 1777 host_impl_->ScrollEnd(EndState().get()); |
| 1778 | 1778 |
| 1779 EXPECT_VECTOR_EQ( | 1779 EXPECT_VECTOR_EQ( |
| 1780 gfx::Vector2dF(50, 50), | 1780 gfx::Vector2dF(50, 50), |
| 1781 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1781 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1782 | 1782 |
| 1783 // Reset. | 1783 // Reset. |
| 1784 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); | 1784 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.f); |
| 1785 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); | 1785 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); |
| 1786 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); | 1786 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2d()); |
| 1787 | 1787 |
| 1788 // Pinch in just outside the margin. There should be no snapping. | 1788 // Pinch in just outside the margin. There should be no snapping. |
| 1789 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips; | 1789 offsetFromEdge = Viewport::kPinchZoomSnapMarginDips; |
| 1790 anchor = gfx::Point(viewport_size.width() - offsetFromEdge, | 1790 anchor = gfx::Point(viewport_size.width() - offsetFromEdge, |
| 1791 viewport_size.height() - offsetFromEdge); | 1791 viewport_size.height() - offsetFromEdge); |
| 1792 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::GESTURE); | 1792 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::TOUCHSCREEN); |
| 1793 host_impl_->PinchGestureBegin(); | 1793 host_impl_->PinchGestureBegin(); |
| 1794 host_impl_->PinchGestureUpdate(2, anchor); | 1794 host_impl_->PinchGestureUpdate(2, anchor); |
| 1795 host_impl_->PinchGestureEnd(); | 1795 host_impl_->PinchGestureEnd(); |
| 1796 host_impl_->ScrollEnd(EndState().get()); | 1796 host_impl_->ScrollEnd(EndState().get()); |
| 1797 | 1797 |
| 1798 EXPECT_VECTOR_EQ( | 1798 EXPECT_VECTOR_EQ( |
| 1799 gfx::Vector2dF(200, 200), | 1799 gfx::Vector2dF(200, 200), |
| 1800 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1800 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1801 } | 1801 } |
| 1802 | 1802 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 | 1864 |
| 1865 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1865 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
| 1866 ui::LatencyInfo latency_info; | 1866 ui::LatencyInfo latency_info; |
| 1867 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, | 1867 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
| 1868 1234); | 1868 1234); |
| 1869 scoped_ptr<SwapPromise> swap_promise( | 1869 scoped_ptr<SwapPromise> swap_promise( |
| 1870 new LatencyInfoSwapPromise(latency_info)); | 1870 new LatencyInfoSwapPromise(latency_info)); |
| 1871 | 1871 |
| 1872 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1872 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1873 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1873 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1874 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1874 host_impl_ |
| 1875 InputHandler::GESTURE) | 1875 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1876 InputHandler::TOUCHSCREEN) |
| 1876 .thread); | 1877 .thread); |
| 1877 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1878 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 1878 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( | 1879 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
| 1879 std::move(swap_promise)); | 1880 std::move(swap_promise)); |
| 1880 host_impl_->ScrollEnd(EndState().get()); | 1881 host_impl_->ScrollEnd(EndState().get()); |
| 1881 | 1882 |
| 1882 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1883 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 1883 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 1884 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
| 1884 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); | 1885 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); |
| 1885 } | 1886 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 child_clip->SetScrollParent(parent); | 1921 child_clip->SetScrollParent(parent); |
| 1921 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | 1922 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); |
| 1922 scroll_children->insert(child_clip); | 1923 scroll_children->insert(child_clip); |
| 1923 parent->SetScrollChildren(scroll_children.release()); | 1924 parent->SetScrollChildren(scroll_children.release()); |
| 1924 | 1925 |
| 1925 SetNeedsRebuildPropertyTrees(); | 1926 SetNeedsRebuildPropertyTrees(); |
| 1926 DrawFrame(); | 1927 DrawFrame(); |
| 1927 | 1928 |
| 1928 { | 1929 { |
| 1929 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), | 1930 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), |
| 1930 InputHandler::GESTURE); | 1931 InputHandler::TOUCHSCREEN); |
| 1931 host_impl_->ScrollBy( | 1932 host_impl_->ScrollBy( |
| 1932 UpdateState(gfx::Point(21, 21), gfx::Vector2d(5, 5)).get()); | 1933 UpdateState(gfx::Point(21, 21), gfx::Vector2d(5, 5)).get()); |
| 1933 host_impl_->ScrollBy( | 1934 host_impl_->ScrollBy( |
| 1934 UpdateState(gfx::Point(21, 21), gfx::Vector2d(100, 100)).get()); | 1935 UpdateState(gfx::Point(21, 21), gfx::Vector2d(100, 100)).get()); |
| 1935 host_impl_->ScrollEnd(EndState().get()); | 1936 host_impl_->ScrollEnd(EndState().get()); |
| 1936 | 1937 |
| 1937 // The child should be fully scrolled by the first ScrollBy. | 1938 // The child should be fully scrolled by the first ScrollBy. |
| 1938 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 5), child->CurrentScrollOffset()); | 1939 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 5), child->CurrentScrollOffset()); |
| 1939 | 1940 |
| 1940 // The scroll_parent shouldn't receive the second ScrollBy. | 1941 // The scroll_parent shouldn't receive the second ScrollBy. |
| 1941 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), parent->CurrentScrollOffset()); | 1942 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), parent->CurrentScrollOffset()); |
| 1942 | 1943 |
| 1943 // The viewport shouldn't have been scrolled at all. | 1944 // The viewport shouldn't have been scrolled at all. |
| 1944 EXPECT_VECTOR_EQ( | 1945 EXPECT_VECTOR_EQ( |
| 1945 gfx::Vector2dF(0, 0), | 1946 gfx::Vector2dF(0, 0), |
| 1946 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1947 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1947 EXPECT_VECTOR_EQ( | 1948 EXPECT_VECTOR_EQ( |
| 1948 gfx::Vector2dF(0, 0), | 1949 gfx::Vector2dF(0, 0), |
| 1949 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); | 1950 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); |
| 1950 } | 1951 } |
| 1951 | 1952 |
| 1952 { | 1953 { |
| 1953 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), | 1954 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), |
| 1954 InputHandler::GESTURE); | 1955 InputHandler::TOUCHSCREEN); |
| 1955 host_impl_->ScrollBy( | 1956 host_impl_->ScrollBy( |
| 1956 UpdateState(gfx::Point(21, 21), gfx::Vector2d(3, 4)).get()); | 1957 UpdateState(gfx::Point(21, 21), gfx::Vector2d(3, 4)).get()); |
| 1957 host_impl_->ScrollBy( | 1958 host_impl_->ScrollBy( |
| 1958 UpdateState(gfx::Point(21, 21), gfx::Vector2d(2, 1)).get()); | 1959 UpdateState(gfx::Point(21, 21), gfx::Vector2d(2, 1)).get()); |
| 1959 host_impl_->ScrollBy( | 1960 host_impl_->ScrollBy( |
| 1960 UpdateState(gfx::Point(21, 21), gfx::Vector2d(2, 1)).get()); | 1961 UpdateState(gfx::Point(21, 21), gfx::Vector2d(2, 1)).get()); |
| 1961 host_impl_->ScrollBy( | 1962 host_impl_->ScrollBy( |
| 1962 UpdateState(gfx::Point(21, 21), gfx::Vector2d(2, 1)).get()); | 1963 UpdateState(gfx::Point(21, 21), gfx::Vector2d(2, 1)).get()); |
| 1963 host_impl_->ScrollEnd(EndState().get()); | 1964 host_impl_->ScrollEnd(EndState().get()); |
| 1964 | 1965 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1988 float max_page_scale = 4.f; | 1989 float max_page_scale = 4.f; |
| 1989 | 1990 |
| 1990 // Basic pinch zoom in gesture | 1991 // Basic pinch zoom in gesture |
| 1991 { | 1992 { |
| 1992 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1993 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1993 max_page_scale); | 1994 max_page_scale); |
| 1994 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1995 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1995 | 1996 |
| 1996 float page_scale_delta = 2.f; | 1997 float page_scale_delta = 2.f; |
| 1997 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), | 1998 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), |
| 1998 InputHandler::GESTURE); | 1999 InputHandler::TOUCHSCREEN); |
| 1999 host_impl_->PinchGestureBegin(); | 2000 host_impl_->PinchGestureBegin(); |
| 2000 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 2001 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 2001 host_impl_->PinchGestureEnd(); | 2002 host_impl_->PinchGestureEnd(); |
| 2002 host_impl_->ScrollEnd(EndState().get()); | 2003 host_impl_->ScrollEnd(EndState().get()); |
| 2003 EXPECT_FALSE(did_request_next_frame_); | 2004 EXPECT_FALSE(did_request_next_frame_); |
| 2004 EXPECT_TRUE(did_request_redraw_); | 2005 EXPECT_TRUE(did_request_redraw_); |
| 2005 EXPECT_TRUE(did_request_commit_); | 2006 EXPECT_TRUE(did_request_commit_); |
| 2006 | 2007 |
| 2007 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2008 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 2008 host_impl_->ProcessScrollDeltas(); | 2009 host_impl_->ProcessScrollDeltas(); |
| 2009 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 2010 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 2010 } | 2011 } |
| 2011 | 2012 |
| 2012 // Zoom-in clamping | 2013 // Zoom-in clamping |
| 2013 { | 2014 { |
| 2014 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2015 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2015 max_page_scale); | 2016 max_page_scale); |
| 2016 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 2017 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 2017 float page_scale_delta = 10.f; | 2018 float page_scale_delta = 10.f; |
| 2018 | 2019 |
| 2019 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), | 2020 host_impl_->ScrollBegin(BeginState(gfx::Point(50, 50)).get(), |
| 2020 InputHandler::GESTURE); | 2021 InputHandler::TOUCHSCREEN); |
| 2021 host_impl_->PinchGestureBegin(); | 2022 host_impl_->PinchGestureBegin(); |
| 2022 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 2023 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 2023 host_impl_->PinchGestureEnd(); | 2024 host_impl_->PinchGestureEnd(); |
| 2024 host_impl_->ScrollEnd(EndState().get()); | 2025 host_impl_->ScrollEnd(EndState().get()); |
| 2025 | 2026 |
| 2026 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2027 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 2027 host_impl_->ProcessScrollDeltas(); | 2028 host_impl_->ProcessScrollDeltas(); |
| 2028 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); | 2029 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); |
| 2029 } | 2030 } |
| 2030 | 2031 |
| 2031 // Zoom-out clamping | 2032 // Zoom-out clamping |
| 2032 { | 2033 { |
| 2033 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2034 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2034 max_page_scale); | 2035 max_page_scale); |
| 2035 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 2036 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 2036 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); | 2037 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); |
| 2037 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); | 2038 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 2038 | 2039 |
| 2039 float page_scale_delta = 0.1f; | 2040 float page_scale_delta = 0.1f; |
| 2040 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2041 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2041 InputHandler::GESTURE); | 2042 InputHandler::TOUCHSCREEN); |
| 2042 host_impl_->PinchGestureBegin(); | 2043 host_impl_->PinchGestureBegin(); |
| 2043 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 2044 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 2044 host_impl_->PinchGestureEnd(); | 2045 host_impl_->PinchGestureEnd(); |
| 2045 host_impl_->ScrollEnd(EndState().get()); | 2046 host_impl_->ScrollEnd(EndState().get()); |
| 2046 | 2047 |
| 2047 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2048 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 2048 host_impl_->ProcessScrollDeltas(); | 2049 host_impl_->ProcessScrollDeltas(); |
| 2049 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 2050 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
| 2050 | 2051 |
| 2051 EXPECT_TRUE(scroll_info->scrolls.empty()); | 2052 EXPECT_TRUE(scroll_info->scrolls.empty()); |
| 2052 } | 2053 } |
| 2053 | 2054 |
| 2054 // Two-finger panning should not happen based on pinch events only | 2055 // Two-finger panning should not happen based on pinch events only |
| 2055 { | 2056 { |
| 2056 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2057 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2057 max_page_scale); | 2058 max_page_scale); |
| 2058 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 2059 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 2059 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); | 2060 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); |
| 2060 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); | 2061 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
| 2061 | 2062 |
| 2062 float page_scale_delta = 1.f; | 2063 float page_scale_delta = 1.f; |
| 2063 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), | 2064 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), |
| 2064 InputHandler::GESTURE); | 2065 InputHandler::TOUCHSCREEN); |
| 2065 host_impl_->PinchGestureBegin(); | 2066 host_impl_->PinchGestureBegin(); |
| 2066 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 2067 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
| 2067 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 2068 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
| 2068 host_impl_->PinchGestureEnd(); | 2069 host_impl_->PinchGestureEnd(); |
| 2069 host_impl_->ScrollEnd(EndState().get()); | 2070 host_impl_->ScrollEnd(EndState().get()); |
| 2070 | 2071 |
| 2071 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2072 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 2072 host_impl_->ProcessScrollDeltas(); | 2073 host_impl_->ProcessScrollDeltas(); |
| 2073 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 2074 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 2074 EXPECT_TRUE(scroll_info->scrolls.empty()); | 2075 EXPECT_TRUE(scroll_info->scrolls.empty()); |
| 2075 } | 2076 } |
| 2076 | 2077 |
| 2077 // Two-finger panning should work with interleaved scroll events | 2078 // Two-finger panning should work with interleaved scroll events |
| 2078 { | 2079 { |
| 2079 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2080 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2080 max_page_scale); | 2081 max_page_scale); |
| 2081 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 2082 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 2082 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); | 2083 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); |
| 2083 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); | 2084 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
| 2084 | 2085 |
| 2085 float page_scale_delta = 1.f; | 2086 float page_scale_delta = 1.f; |
| 2086 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), | 2087 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), |
| 2087 InputHandler::GESTURE); | 2088 InputHandler::TOUCHSCREEN); |
| 2088 host_impl_->PinchGestureBegin(); | 2089 host_impl_->PinchGestureBegin(); |
| 2089 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 2090 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
| 2090 host_impl_->ScrollBy( | 2091 host_impl_->ScrollBy( |
| 2091 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); | 2092 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); |
| 2092 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 2093 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
| 2093 host_impl_->PinchGestureEnd(); | 2094 host_impl_->PinchGestureEnd(); |
| 2094 host_impl_->ScrollEnd(EndState().get()); | 2095 host_impl_->ScrollEnd(EndState().get()); |
| 2095 | 2096 |
| 2096 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2097 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 2097 host_impl_->ProcessScrollDeltas(); | 2098 host_impl_->ProcessScrollDeltas(); |
| 2098 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 2099 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 2099 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2100 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
| 2100 gfx::Vector2d(-10, -10))); | 2101 gfx::Vector2d(-10, -10))); |
| 2101 } | 2102 } |
| 2102 | 2103 |
| 2103 // Two-finger panning should work when starting fully zoomed out. | 2104 // Two-finger panning should work when starting fully zoomed out. |
| 2104 { | 2105 { |
| 2105 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); | 2106 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); |
| 2106 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 2107 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 2107 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); | 2108 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread(); |
| 2108 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); | 2109 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); |
| 2109 | 2110 |
| 2110 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 2111 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 2111 InputHandler::GESTURE); | 2112 InputHandler::TOUCHSCREEN); |
| 2112 host_impl_->PinchGestureBegin(); | 2113 host_impl_->PinchGestureBegin(); |
| 2113 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 2114 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
| 2114 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); | 2115 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); |
| 2115 | 2116 |
| 2116 // Needed so layer transform includes page scale. | 2117 // Needed so layer transform includes page scale. |
| 2117 DrawFrame(); | 2118 DrawFrame(); |
| 2118 | 2119 |
| 2119 host_impl_->ScrollBy( | 2120 host_impl_->ScrollBy( |
| 2120 UpdateState(gfx::Point(0, 0), gfx::Vector2d(10, 10)).get()); | 2121 UpdateState(gfx::Point(0, 0), gfx::Vector2d(10, 10)).get()); |
| 2121 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 2122 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3092 host_impl_->active_tree() | 3093 host_impl_->active_tree() |
| 3093 ->InnerViewportScrollLayer() | 3094 ->InnerViewportScrollLayer() |
| 3094 ->set_user_scrollable_vertical(false); | 3095 ->set_user_scrollable_vertical(false); |
| 3095 metadata = host_impl_->MakeCompositorFrameMetadata(); | 3096 metadata = host_impl_->MakeCompositorFrameMetadata(); |
| 3096 EXPECT_TRUE(metadata.root_overflow_x_hidden); | 3097 EXPECT_TRUE(metadata.root_overflow_x_hidden); |
| 3097 EXPECT_TRUE(metadata.root_overflow_y_hidden); | 3098 EXPECT_TRUE(metadata.root_overflow_y_hidden); |
| 3098 } | 3099 } |
| 3099 | 3100 |
| 3100 // Page scale should update metadata correctly (shrinking only the viewport). | 3101 // Page scale should update metadata correctly (shrinking only the viewport). |
| 3101 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3102 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 3102 InputHandler::GESTURE); | 3103 InputHandler::TOUCHSCREEN); |
| 3103 host_impl_->PinchGestureBegin(); | 3104 host_impl_->PinchGestureBegin(); |
| 3104 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); | 3105 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); |
| 3105 host_impl_->PinchGestureEnd(); | 3106 host_impl_->PinchGestureEnd(); |
| 3106 host_impl_->ScrollEnd(EndState().get()); | 3107 host_impl_->ScrollEnd(EndState().get()); |
| 3107 { | 3108 { |
| 3108 CompositorFrameMetadata metadata = | 3109 CompositorFrameMetadata metadata = |
| 3109 host_impl_->MakeCompositorFrameMetadata(); | 3110 host_impl_->MakeCompositorFrameMetadata(); |
| 3110 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 3111 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| 3111 EXPECT_EQ(2.f, metadata.page_scale_factor); | 3112 EXPECT_EQ(2.f, metadata.page_scale_factor); |
| 3112 EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size); | 3113 EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3814 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 3815 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
| 3815 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 3816 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
| 3816 | 3817 |
| 3817 // The top controls should start off showing so the viewport should be shrunk. | 3818 // The top controls should start off showing so the viewport should be shrunk. |
| 3818 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); | 3819 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); |
| 3819 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); | 3820 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); |
| 3820 | 3821 |
| 3821 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); | 3822 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); |
| 3822 | 3823 |
| 3823 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3824 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 3824 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3825 host_impl_ |
| 3825 InputHandler::GESTURE) | 3826 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 3827 InputHandler::TOUCHSCREEN) |
| 3826 .thread); | 3828 .thread); |
| 3827 | 3829 |
| 3828 host_impl_->top_controls_manager()->ScrollBegin(); | 3830 host_impl_->top_controls_manager()->ScrollBegin(); |
| 3829 | 3831 |
| 3830 // Hide the top controls by a bit, the scrollable size should increase but the | 3832 // Hide the top controls by a bit, the scrollable size should increase but the |
| 3831 // actual content bounds shouldn't. | 3833 // actual content bounds shouldn't. |
| 3832 { | 3834 { |
| 3833 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); | 3835 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); |
| 3834 ASSERT_EQ(gfx::Size(50, 75), inner_container->bounds()); | 3836 ASSERT_EQ(gfx::Size(50, 75), inner_container->bounds()); |
| 3835 ASSERT_EQ(gfx::Size(50, 75), outer_container->bounds()); | 3837 ASSERT_EQ(gfx::Size(50, 75), outer_container->bounds()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3858 host_impl_->top_controls_manager()->ScrollEnd(); | 3860 host_impl_->top_controls_manager()->ScrollEnd(); |
| 3859 host_impl_->ScrollEnd(EndState().get()); | 3861 host_impl_->ScrollEnd(EndState().get()); |
| 3860 } | 3862 } |
| 3861 | 3863 |
| 3862 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { | 3864 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { |
| 3863 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3865 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3864 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); | 3866 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); |
| 3865 DrawFrame(); | 3867 DrawFrame(); |
| 3866 | 3868 |
| 3867 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3869 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 3868 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3870 host_impl_ |
| 3869 InputHandler::GESTURE) | 3871 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 3872 InputHandler::TOUCHSCREEN) |
| 3870 .thread); | 3873 .thread); |
| 3871 | 3874 |
| 3872 // Make the test scroll delta a fractional amount, to verify that the | 3875 // Make the test scroll delta a fractional amount, to verify that the |
| 3873 // fixed container size delta is (1) non-zero, and (2) fractional, and | 3876 // fixed container size delta is (1) non-zero, and (2) fractional, and |
| 3874 // (3) matches the movement of the top controls. | 3877 // (3) matches the movement of the top controls. |
| 3875 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); | 3878 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); |
| 3876 host_impl_->top_controls_manager()->ScrollBegin(); | 3879 host_impl_->top_controls_manager()->ScrollBegin(); |
| 3877 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 3880 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 3878 host_impl_->top_controls_manager()->ScrollEnd(); | 3881 host_impl_->top_controls_manager()->ScrollEnd(); |
| 3879 | 3882 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3903 host_impl_->active_tree()->OuterViewportScrollLayer(); | 3906 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 3904 outer_scroll->SetDrawsContent(true); | 3907 outer_scroll->SetDrawsContent(true); |
| 3905 LayerImpl* outer_container = | 3908 LayerImpl* outer_container = |
| 3906 host_impl_->active_tree()->OuterViewportContainerLayer(); | 3909 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 3907 | 3910 |
| 3908 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. | 3911 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
| 3909 outer_scroll->SetDrawsContent(true); | 3912 outer_scroll->SetDrawsContent(true); |
| 3910 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 3913 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 3911 | 3914 |
| 3912 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3915 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 3913 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3916 host_impl_ |
| 3914 InputHandler::GESTURE) | 3917 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 3918 InputHandler::TOUCHSCREEN) |
| 3915 .thread); | 3919 .thread); |
| 3916 host_impl_->ScrollBy( | 3920 host_impl_->ScrollBy( |
| 3917 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 50.f)).get()); | 3921 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 50.f)).get()); |
| 3918 | 3922 |
| 3919 // The entire scroll delta should have been used to hide the top controls. | 3923 // The entire scroll delta should have been used to hide the top controls. |
| 3920 // The viewport layers should be resized back to their full sizes. | 3924 // The viewport layers should be resized back to their full sizes. |
| 3921 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 3925 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 3922 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 3926 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 3923 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 3927 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
| 3924 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 3928 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
| 3925 | 3929 |
| 3926 // The inner viewport should be scrollable by 50px * page_scale. | 3930 // The inner viewport should be scrollable by 50px * page_scale. |
| 3927 host_impl_->ScrollBy( | 3931 host_impl_->ScrollBy( |
| 3928 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 100.f)).get()); | 3932 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 100.f)).get()); |
| 3929 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); | 3933 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
| 3930 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 3934 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 3931 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 3935 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
| 3932 | 3936 |
| 3933 host_impl_->ScrollEnd(EndState().get()); | 3937 host_impl_->ScrollEnd(EndState().get()); |
| 3934 | 3938 |
| 3935 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3939 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 3936 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3940 host_impl_ |
| 3937 InputHandler::GESTURE) | 3941 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 3942 InputHandler::TOUCHSCREEN) |
| 3938 .thread); | 3943 .thread); |
| 3939 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 3944 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 3940 | 3945 |
| 3941 host_impl_->ScrollBy( | 3946 host_impl_->ScrollBy( |
| 3942 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); | 3947 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); |
| 3943 | 3948 |
| 3944 // The entire scroll delta should have been used to show the top controls. | 3949 // The entire scroll delta should have been used to show the top controls. |
| 3945 // The outer viewport should be resized to accomodate and scrolled to the | 3950 // The outer viewport should be resized to accomodate and scrolled to the |
| 3946 // bottom of the document to keep the viewport in place. | 3951 // bottom of the document to keep the viewport in place. |
| 3947 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 3952 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 | 3985 |
| 3981 float page_scale = 1.5f; | 3986 float page_scale = 1.5f; |
| 3982 LayerImpl* outer_viewport_scroll_layer = | 3987 LayerImpl* outer_viewport_scroll_layer = |
| 3983 host_impl_->active_tree()->OuterViewportScrollLayer(); | 3988 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 3984 | 3989 |
| 3985 // Zoom in, since the fixed container is the outer viewport, the delta should | 3990 // Zoom in, since the fixed container is the outer viewport, the delta should |
| 3986 // not be scaled. | 3991 // not be scaled. |
| 3987 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 3992 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
| 3988 | 3993 |
| 3989 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3994 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 3990 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3995 host_impl_ |
| 3991 InputHandler::GESTURE) | 3996 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 3997 InputHandler::TOUCHSCREEN) |
| 3992 .thread); | 3998 .thread); |
| 3993 | 3999 |
| 3994 // Scroll down, the top controls hiding should expand the viewport size so | 4000 // Scroll down, the top controls hiding should expand the viewport size so |
| 3995 // the delta should be equal to the scroll distance. | 4001 // the delta should be equal to the scroll distance. |
| 3996 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); | 4002 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); |
| 3997 host_impl_->top_controls_manager()->ScrollBegin(); | 4003 host_impl_->top_controls_manager()->ScrollBegin(); |
| 3998 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4004 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 3999 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), | 4005 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), |
| 4000 host_impl_->top_controls_manager()->ContentTopOffset()); | 4006 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4001 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), | 4007 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4030 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4036 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4031 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); | 4037 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 4032 DrawFrame(); | 4038 DrawFrame(); |
| 4033 | 4039 |
| 4034 // Show top controls | 4040 // Show top controls |
| 4035 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4041 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4036 | 4042 |
| 4037 // Scroll 25px to hide top controls | 4043 // Scroll 25px to hide top controls |
| 4038 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4044 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4039 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4045 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4040 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4046 host_impl_ |
| 4041 InputHandler::GESTURE) | 4047 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4048 InputHandler::TOUCHSCREEN) |
| 4042 .thread); | 4049 .thread); |
| 4043 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4050 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4044 EXPECT_FALSE(did_request_commit_); | 4051 EXPECT_FALSE(did_request_commit_); |
| 4045 } | 4052 } |
| 4046 | 4053 |
| 4047 // Test that if a scrollable sublayer doesn't consume the scroll, | 4054 // Test that if a scrollable sublayer doesn't consume the scroll, |
| 4048 // top controls should hide when scrolling down. | 4055 // top controls should hide when scrolling down. |
| 4049 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollableSublayer) { | 4056 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollableSublayer) { |
| 4050 gfx::Size sub_content_size(100, 400); | 4057 gfx::Size sub_content_size(100, 400); |
| 4051 gfx::Size sub_content_layer_size(100, 300); | 4058 gfx::Size sub_content_layer_size(100, 300); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4075 // scroll child to limit | 4082 // scroll child to limit |
| 4076 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); | 4083 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); |
| 4077 child_clip->AddChild(std::move(child)); | 4084 child_clip->AddChild(std::move(child)); |
| 4078 outer_viewport_scroll_layer->AddChild(std::move(child_clip)); | 4085 outer_viewport_scroll_layer->AddChild(std::move(child_clip)); |
| 4079 | 4086 |
| 4080 // Scroll 25px to hide top controls | 4087 // Scroll 25px to hide top controls |
| 4081 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4088 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4082 host_impl_->active_tree()->property_trees()->needs_rebuild = true; | 4089 host_impl_->active_tree()->property_trees()->needs_rebuild = true; |
| 4083 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4090 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4084 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4091 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4085 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4092 host_impl_ |
| 4086 InputHandler::GESTURE) | 4093 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4094 InputHandler::TOUCHSCREEN) |
| 4087 .thread); | 4095 .thread); |
| 4088 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4096 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4089 host_impl_->ScrollEnd(EndState().get()); | 4097 host_impl_->ScrollEnd(EndState().get()); |
| 4090 | 4098 |
| 4091 // Top controls should be hidden | 4099 // Top controls should be hidden |
| 4092 EXPECT_EQ(scroll_delta.y(), | 4100 EXPECT_EQ(scroll_delta.y(), |
| 4093 top_controls_height_ - | 4101 top_controls_height_ - |
| 4094 host_impl_->top_controls_manager()->ContentTopOffset()); | 4102 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4095 } | 4103 } |
| 4096 | 4104 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4236 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 4244 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
| 4237 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 4245 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
| 4238 | 4246 |
| 4239 gfx::ScrollOffset viewport_offset = | 4247 gfx::ScrollOffset viewport_offset = |
| 4240 host_impl_->active_tree()->TotalScrollOffset(); | 4248 host_impl_->active_tree()->TotalScrollOffset(); |
| 4241 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 4249 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
| 4242 | 4250 |
| 4243 // Hide the top controls by 25px. | 4251 // Hide the top controls by 25px. |
| 4244 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4252 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4245 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4253 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4246 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4254 host_impl_ |
| 4247 InputHandler::GESTURE) | 4255 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4256 InputHandler::TOUCHSCREEN) |
| 4248 .thread); | 4257 .thread); |
| 4249 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4258 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4250 | 4259 |
| 4251 // scrolling down at the max extents no longer hides the top controls | 4260 // scrolling down at the max extents no longer hides the top controls |
| 4252 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4261 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4253 | 4262 |
| 4254 // forcefully hide the top controls by 25px | 4263 // forcefully hide the top controls by 25px |
| 4255 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); | 4264 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); |
| 4256 host_impl_->ScrollEnd(EndState().get()); | 4265 host_impl_->ScrollEnd(EndState().get()); |
| 4257 | 4266 |
| 4258 EXPECT_FLOAT_EQ(scroll_delta.y(), | 4267 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 4259 top_controls_height_ - | 4268 top_controls_height_ - |
| 4260 host_impl_->top_controls_manager()->ContentTopOffset()); | 4269 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4261 | 4270 |
| 4262 inner_scroll->ClampScrollToMaxScrollOffset(); | 4271 inner_scroll->ClampScrollToMaxScrollOffset(); |
| 4263 outer_scroll->ClampScrollToMaxScrollOffset(); | 4272 outer_scroll->ClampScrollToMaxScrollOffset(); |
| 4264 | 4273 |
| 4265 // We should still be fully scrolled. | 4274 // We should still be fully scrolled. |
| 4266 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 4275 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 4267 host_impl_->active_tree()->TotalScrollOffset()); | 4276 host_impl_->active_tree()->TotalScrollOffset()); |
| 4268 | 4277 |
| 4269 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 4278 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
| 4270 | 4279 |
| 4271 // Bring the top controls down by 25px. | 4280 // Bring the top controls down by 25px. |
| 4272 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 4281 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
| 4273 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4282 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4274 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4283 host_impl_ |
| 4275 InputHandler::GESTURE) | 4284 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4285 InputHandler::TOUCHSCREEN) |
| 4276 .thread); | 4286 .thread); |
| 4277 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4287 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4278 host_impl_->ScrollEnd(EndState().get()); | 4288 host_impl_->ScrollEnd(EndState().get()); |
| 4279 | 4289 |
| 4280 // The viewport offset shouldn't have changed. | 4290 // The viewport offset shouldn't have changed. |
| 4281 EXPECT_EQ(viewport_offset, | 4291 EXPECT_EQ(viewport_offset, |
| 4282 host_impl_->active_tree()->TotalScrollOffset()); | 4292 host_impl_->active_tree()->TotalScrollOffset()); |
| 4283 | 4293 |
| 4284 // Scroll the viewports to max scroll offset. | 4294 // Scroll the viewports to max scroll offset. |
| 4285 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 4295 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
| 4286 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 4296 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
| 4287 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 4297 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 4288 host_impl_->active_tree()->TotalScrollOffset()); | 4298 host_impl_->active_tree()->TotalScrollOffset()); |
| 4289 } | 4299 } |
| 4290 | 4300 |
| 4291 // Test that the top controls coming in and out maintains the same aspect ratio | 4301 // Test that the top controls coming in and out maintains the same aspect ratio |
| 4292 // between the inner and outer viewports. | 4302 // between the inner and outer viewports. |
| 4293 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { | 4303 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { |
| 4294 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4304 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4295 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 4305 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 4296 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f); | 4306 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f); |
| 4297 DrawFrame(); | 4307 DrawFrame(); |
| 4298 | 4308 |
| 4299 EXPECT_FLOAT_EQ(top_controls_height_, | 4309 EXPECT_FLOAT_EQ(top_controls_height_, |
| 4300 host_impl_->top_controls_manager()->ContentTopOffset()); | 4310 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4301 | 4311 |
| 4302 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4312 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4303 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4313 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4304 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4314 host_impl_ |
| 4305 InputHandler::GESTURE) | 4315 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4316 InputHandler::TOUCHSCREEN) |
| 4306 .thread); | 4317 .thread); |
| 4307 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4318 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4308 host_impl_->ScrollEnd(EndState().get()); | 4319 host_impl_->ScrollEnd(EndState().get()); |
| 4309 | 4320 |
| 4310 EXPECT_FLOAT_EQ(scroll_delta.y(), | 4321 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 4311 top_controls_height_ - | 4322 top_controls_height_ - |
| 4312 host_impl_->top_controls_manager()->ContentTopOffset()); | 4323 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4313 | 4324 |
| 4314 // Top controls were hidden by 25px so the inner viewport should have expanded | 4325 // Top controls were hidden by 25px so the inner viewport should have expanded |
| 4315 // by that much. | 4326 // by that much. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4336 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 4347 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 4337 DrawFrame(); | 4348 DrawFrame(); |
| 4338 | 4349 |
| 4339 EXPECT_EQ(top_controls_height_, | 4350 EXPECT_EQ(top_controls_height_, |
| 4340 host_impl_->top_controls_manager()->ContentTopOffset()); | 4351 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4341 | 4352 |
| 4342 // Send a gesture scroll that will scroll the outer viewport, make sure the | 4353 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 4343 // top controls get scrolled. | 4354 // top controls get scrolled. |
| 4344 gfx::Vector2dF scroll_delta(0.f, 15.f); | 4355 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 4345 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4356 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4346 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4357 host_impl_ |
| 4347 InputHandler::GESTURE) | 4358 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4359 InputHandler::TOUCHSCREEN) |
| 4348 .thread); | 4360 .thread); |
| 4349 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4361 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4350 | 4362 |
| 4351 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), | 4363 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), |
| 4352 host_impl_->CurrentlyScrollingLayer()); | 4364 host_impl_->CurrentlyScrollingLayer()); |
| 4353 host_impl_->ScrollEnd(EndState().get()); | 4365 host_impl_->ScrollEnd(EndState().get()); |
| 4354 | 4366 |
| 4355 EXPECT_FLOAT_EQ(scroll_delta.y(), | 4367 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 4356 top_controls_height_ - | 4368 top_controls_height_ - |
| 4357 host_impl_->top_controls_manager()->ContentTopOffset()); | 4369 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4358 | 4370 |
| 4359 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 4371 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 4360 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4372 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4361 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4373 host_impl_ |
| 4362 InputHandler::GESTURE) | 4374 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4375 InputHandler::TOUCHSCREEN) |
| 4363 .thread); | 4376 .thread); |
| 4364 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4377 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4365 | 4378 |
| 4366 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 4379 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4367 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), | 4380 EXPECT_EQ(host_impl_->InnerViewportScrollLayer(), |
| 4368 host_impl_->CurrentlyScrollingLayer()); | 4381 host_impl_->CurrentlyScrollingLayer()); |
| 4369 | 4382 |
| 4370 host_impl_->ScrollEnd(EndState().get()); | 4383 host_impl_->ScrollEnd(EndState().get()); |
| 4371 | 4384 |
| 4372 // Position the viewports such that the inner viewport will be scrolled. | 4385 // Position the viewports such that the inner viewport will be scrolled. |
| 4373 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 4386 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 4374 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 4387 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 4375 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 4388 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
| 4376 | 4389 |
| 4377 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 4390 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
| 4378 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4391 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4379 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4392 host_impl_ |
| 4380 InputHandler::GESTURE) | 4393 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4394 InputHandler::TOUCHSCREEN) |
| 4381 .thread); | 4395 .thread); |
| 4382 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4396 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4383 | 4397 |
| 4384 EXPECT_EQ(top_controls_height_, | 4398 EXPECT_EQ(top_controls_height_, |
| 4385 host_impl_->top_controls_manager()->ContentTopOffset()); | 4399 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4386 EXPECT_FLOAT_EQ( | 4400 EXPECT_FLOAT_EQ( |
| 4387 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), | 4401 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
| 4388 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); | 4402 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); |
| 4389 | 4403 |
| 4390 host_impl_->ScrollEnd(EndState().get()); | 4404 host_impl_->ScrollEnd(EndState().get()); |
| 4391 } | 4405 } |
| 4392 | 4406 |
| 4393 TEST_F(LayerTreeHostImplTopControlsTest, | 4407 TEST_F(LayerTreeHostImplTopControlsTest, |
| 4394 ScrollNonScrollableRootWithTopControls) { | 4408 ScrollNonScrollableRootWithTopControls) { |
| 4395 settings_ = DefaultSettings(); | 4409 settings_ = DefaultSettings(); |
| 4396 CreateHostImpl(settings_, CreateOutputSurface()); | 4410 CreateHostImpl(settings_, CreateOutputSurface()); |
| 4397 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4411 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4398 layer_size_, layer_size_, layer_size_); | 4412 layer_size_, layer_size_, layer_size_); |
| 4399 DrawFrame(); | 4413 DrawFrame(); |
| 4400 | 4414 |
| 4401 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4415 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4402 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4416 host_impl_ |
| 4403 InputHandler::GESTURE) | 4417 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4418 InputHandler::TOUCHSCREEN) |
| 4404 .thread); | 4419 .thread); |
| 4405 | 4420 |
| 4406 host_impl_->top_controls_manager()->ScrollBegin(); | 4421 host_impl_->top_controls_manager()->ScrollBegin(); |
| 4407 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 4422 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
| 4408 host_impl_->top_controls_manager()->ScrollEnd(); | 4423 host_impl_->top_controls_manager()->ScrollEnd(); |
| 4409 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4424 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4410 // Now that top controls have moved, expect the clip to resize. | 4425 // Now that top controls have moved, expect the clip to resize. |
| 4411 LayerImpl* inner_clip_ptr = | 4426 LayerImpl* inner_clip_ptr = |
| 4412 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4427 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
| 4413 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4428 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4414 | 4429 |
| 4415 host_impl_->ScrollEnd(EndState().get()); | 4430 host_impl_->ScrollEnd(EndState().get()); |
| 4416 | 4431 |
| 4417 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4432 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4418 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4433 host_impl_ |
| 4419 InputHandler::GESTURE) | 4434 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4435 InputHandler::TOUCHSCREEN) |
| 4420 .thread); | 4436 .thread); |
| 4421 | 4437 |
| 4422 float scroll_increment_y = -25.f; | 4438 float scroll_increment_y = -25.f; |
| 4423 host_impl_->top_controls_manager()->ScrollBegin(); | 4439 host_impl_->top_controls_manager()->ScrollBegin(); |
| 4424 host_impl_->top_controls_manager()->ScrollBy( | 4440 host_impl_->top_controls_manager()->ScrollBy( |
| 4425 gfx::Vector2dF(0.f, scroll_increment_y)); | 4441 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 4426 EXPECT_FLOAT_EQ(-scroll_increment_y, | 4442 EXPECT_FLOAT_EQ(-scroll_increment_y, |
| 4427 host_impl_->top_controls_manager()->ContentTopOffset()); | 4443 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4428 // Now that top controls have moved, expect the clip to resize. | 4444 // Now that top controls have moved, expect the clip to resize. |
| 4429 EXPECT_EQ(gfx::Size(viewport_size_.width(), | 4445 EXPECT_EQ(gfx::Size(viewport_size_.width(), |
| 4430 viewport_size_.height() + scroll_increment_y), | 4446 viewport_size_.height() + scroll_increment_y), |
| 4431 inner_clip_ptr->bounds()); | 4447 inner_clip_ptr->bounds()); |
| 4432 | 4448 |
| 4433 host_impl_->top_controls_manager()->ScrollBy( | 4449 host_impl_->top_controls_manager()->ScrollBy( |
| 4434 gfx::Vector2dF(0.f, scroll_increment_y)); | 4450 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 4435 host_impl_->top_controls_manager()->ScrollEnd(); | 4451 host_impl_->top_controls_manager()->ScrollEnd(); |
| 4436 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, | 4452 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, |
| 4437 host_impl_->top_controls_manager()->ContentTopOffset()); | 4453 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4438 // Now that top controls have moved, expect the clip to resize. | 4454 // Now that top controls have moved, expect the clip to resize. |
| 4439 EXPECT_EQ(clip_size_, inner_clip_ptr->bounds()); | 4455 EXPECT_EQ(clip_size_, inner_clip_ptr->bounds()); |
| 4440 | 4456 |
| 4441 host_impl_->ScrollEnd(EndState().get()); | 4457 host_impl_->ScrollEnd(EndState().get()); |
| 4442 | 4458 |
| 4443 // Verify the layer is once-again non-scrollable. | 4459 // Verify the layer is once-again non-scrollable. |
| 4444 EXPECT_EQ( | 4460 EXPECT_EQ( |
| 4445 gfx::ScrollOffset(), | 4461 gfx::ScrollOffset(), |
| 4446 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); | 4462 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); |
| 4447 | 4463 |
| 4448 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4464 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4449 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4465 host_impl_ |
| 4450 InputHandler::GESTURE) | 4466 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4467 InputHandler::TOUCHSCREEN) |
| 4451 .thread); | 4468 .thread); |
| 4452 } | 4469 } |
| 4453 | 4470 |
| 4454 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { | 4471 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { |
| 4455 // Test the configuration where a non-composited root layer is embedded in a | 4472 // Test the configuration where a non-composited root layer is embedded in a |
| 4456 // scrollable outer layer. | 4473 // scrollable outer layer. |
| 4457 gfx::Size surface_size(10, 10); | 4474 gfx::Size surface_size(10, 10); |
| 4458 gfx::Size contents_size(20, 20); | 4475 gfx::Size contents_size(20, 20); |
| 4459 | 4476 |
| 4460 scoped_ptr<LayerImpl> content_layer = | 4477 scoped_ptr<LayerImpl> content_layer = |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4667 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 4684 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
| 4668 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4685 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4669 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4686 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 4670 InputHandler::WHEEL) | 4687 InputHandler::WHEEL) |
| 4671 .thread); | 4688 .thread); |
| 4672 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4689 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4673 host_impl_->ScrollEnd(EndState().get()); | 4690 host_impl_->ScrollEnd(EndState().get()); |
| 4674 | 4691 |
| 4675 // Set new page scale on impl thread by pinching. | 4692 // Set new page scale on impl thread by pinching. |
| 4676 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4693 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4677 InputHandler::GESTURE); | 4694 InputHandler::TOUCHSCREEN); |
| 4678 host_impl_->PinchGestureBegin(); | 4695 host_impl_->PinchGestureBegin(); |
| 4679 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 4696 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
| 4680 host_impl_->PinchGestureEnd(); | 4697 host_impl_->PinchGestureEnd(); |
| 4681 host_impl_->ScrollEnd(EndState().get()); | 4698 host_impl_->ScrollEnd(EndState().get()); |
| 4682 DrawOneFrame(); | 4699 DrawOneFrame(); |
| 4683 | 4700 |
| 4684 // The scroll delta is not scaled because the main thread did not scale. | 4701 // The scroll delta is not scaled because the main thread did not scale. |
| 4685 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 4702 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 4686 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 4703 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
| 4687 expected_scroll_delta)); | 4704 expected_scroll_delta)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4717 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 4734 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
| 4718 scrollable_child_clip->AddChild(std::move(scrollable_child)); | 4735 scrollable_child_clip->AddChild(std::move(scrollable_child)); |
| 4719 child->AddChild(std::move(scrollable_child_clip)); | 4736 child->AddChild(std::move(scrollable_child_clip)); |
| 4720 LayerImpl* grand_child = child->children()[0].get(); | 4737 LayerImpl* grand_child = child->children()[0].get(); |
| 4721 grand_child->SetDrawsContent(true); | 4738 grand_child->SetDrawsContent(true); |
| 4722 | 4739 |
| 4723 // Set new page scale on impl thread by pinching. | 4740 // Set new page scale on impl thread by pinching. |
| 4724 SetNeedsRebuildPropertyTrees(); | 4741 SetNeedsRebuildPropertyTrees(); |
| 4725 RebuildPropertyTrees(); | 4742 RebuildPropertyTrees(); |
| 4726 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 4743 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4727 InputHandler::GESTURE); | 4744 InputHandler::TOUCHSCREEN); |
| 4728 host_impl_->PinchGestureBegin(); | 4745 host_impl_->PinchGestureBegin(); |
| 4729 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 4746 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
| 4730 host_impl_->PinchGestureEnd(); | 4747 host_impl_->PinchGestureEnd(); |
| 4731 host_impl_->ScrollEnd(EndState().get()); | 4748 host_impl_->ScrollEnd(EndState().get()); |
| 4732 DrawOneFrame(); | 4749 DrawOneFrame(); |
| 4733 | 4750 |
| 4734 // Make sure all the layers are drawn with the page scale delta applied, i.e., | 4751 // Make sure all the layers are drawn with the page scale delta applied, i.e., |
| 4735 // the page scale delta on the root layer is applied hierarchically. | 4752 // the page scale delta on the root layer is applied hierarchically. |
| 4736 LayerTreeHostImpl::FrameData frame; | 4753 LayerTreeHostImpl::FrameData frame; |
| 4737 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 4754 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5073 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); | 5090 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); |
| 5074 | 5091 |
| 5075 gfx::Size surface_size(50, 50); | 5092 gfx::Size surface_size(50, 50); |
| 5076 host_impl_->SetViewportSize(surface_size); | 5093 host_impl_->SetViewportSize(surface_size); |
| 5077 SetNeedsRebuildPropertyTrees(); | 5094 SetNeedsRebuildPropertyTrees(); |
| 5078 DrawFrame(); | 5095 DrawFrame(); |
| 5079 | 5096 |
| 5080 // Scroll to the right in screen coordinates with a gesture. | 5097 // Scroll to the right in screen coordinates with a gesture. |
| 5081 gfx::Vector2d gesture_scroll_delta(10, 0); | 5098 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 5082 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5099 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5083 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5100 host_impl_ |
| 5084 InputHandler::GESTURE) | 5101 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5102 InputHandler::TOUCHSCREEN) |
| 5085 .thread); | 5103 .thread); |
| 5086 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5104 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
| 5087 host_impl_->ScrollEnd(EndState().get()); | 5105 host_impl_->ScrollEnd(EndState().get()); |
| 5088 | 5106 |
| 5089 // The layer should have scrolled down in its local coordinates. | 5107 // The layer should have scrolled down in its local coordinates. |
| 5090 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 5108 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5091 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5109 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
| 5092 gfx::Vector2d(0, gesture_scroll_delta.x()))); | 5110 gfx::Vector2d(0, gesture_scroll_delta.x()))); |
| 5093 | 5111 |
| 5094 // Reset and scroll down with the wheel. | 5112 // Reset and scroll down with the wheel. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5137 scroll_layer->AddChild(std::move(clip_layer)); | 5155 scroll_layer->AddChild(std::move(clip_layer)); |
| 5138 | 5156 |
| 5139 gfx::Size surface_size(50, 50); | 5157 gfx::Size surface_size(50, 50); |
| 5140 host_impl_->SetViewportSize(surface_size); | 5158 host_impl_->SetViewportSize(surface_size); |
| 5141 SetNeedsRebuildPropertyTrees(); | 5159 SetNeedsRebuildPropertyTrees(); |
| 5142 DrawFrame(); | 5160 DrawFrame(); |
| 5143 { | 5161 { |
| 5144 // Scroll down in screen coordinates with a gesture. | 5162 // Scroll down in screen coordinates with a gesture. |
| 5145 gfx::Vector2d gesture_scroll_delta(0, 10); | 5163 gfx::Vector2d gesture_scroll_delta(0, 10); |
| 5146 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5164 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5147 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5165 host_impl_ |
| 5148 InputHandler::GESTURE) | 5166 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
| 5167 InputHandler::TOUCHSCREEN) |
| 5149 .thread); | 5168 .thread); |
| 5150 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5169 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
| 5151 host_impl_->ScrollEnd(EndState().get()); | 5170 host_impl_->ScrollEnd(EndState().get()); |
| 5152 | 5171 |
| 5153 // The child layer should have scrolled down in its local coordinates an | 5172 // The child layer should have scrolled down in its local coordinates an |
| 5154 // amount proportional to the angle between it and the input scroll delta. | 5173 // amount proportional to the angle between it and the input scroll delta. |
| 5155 gfx::Vector2d expected_scroll_delta( | 5174 gfx::Vector2d expected_scroll_delta( |
| 5156 0, gesture_scroll_delta.y() * | 5175 0, gesture_scroll_delta.y() * |
| 5157 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | 5176 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
| 5158 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5177 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 5159 host_impl_->ProcessScrollDeltas(); | 5178 host_impl_->ProcessScrollDeltas(); |
| 5160 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 5179 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
| 5161 expected_scroll_delta)); | 5180 expected_scroll_delta)); |
| 5162 | 5181 |
| 5163 // The root scroll layer should not have scrolled, because the input delta | 5182 // The root scroll layer should not have scrolled, because the input delta |
| 5164 // was close to the layer's axis of movement. | 5183 // was close to the layer's axis of movement. |
| 5165 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 5184 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
| 5166 } | 5185 } |
| 5167 { | 5186 { |
| 5168 // Now reset and scroll the same amount horizontally. | 5187 // Now reset and scroll the same amount horizontally. |
| 5169 child_ptr->SetScrollDelta(gfx::Vector2dF()); | 5188 child_ptr->SetScrollDelta(gfx::Vector2dF()); |
| 5170 gfx::Vector2d gesture_scroll_delta(10, 0); | 5189 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 5171 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5190 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5172 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5191 host_impl_ |
| 5173 InputHandler::GESTURE) | 5192 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
| 5193 InputHandler::TOUCHSCREEN) |
| 5174 .thread); | 5194 .thread); |
| 5175 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5195 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
| 5176 host_impl_->ScrollEnd(EndState().get()); | 5196 host_impl_->ScrollEnd(EndState().get()); |
| 5177 | 5197 |
| 5178 // The child layer shouldn't have scrolled. | 5198 // The child layer shouldn't have scrolled. |
| 5179 gfx::Vector2d expected_scroll_delta( | 5199 gfx::Vector2d expected_scroll_delta( |
| 5180 0, -gesture_scroll_delta.x() * | 5200 0, -gesture_scroll_delta.x() * |
| 5181 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 5201 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
| 5182 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5202 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 5183 host_impl_->ProcessScrollDeltas(); | 5203 host_impl_->ProcessScrollDeltas(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5243 gfx::Point viewport_point(1, 1); | 5263 gfx::Point viewport_point(1, 1); |
| 5244 | 5264 |
| 5245 SetNeedsRebuildPropertyTrees(); | 5265 SetNeedsRebuildPropertyTrees(); |
| 5246 // Scroll in screen coordinates with a gesture. Each scroll starts | 5266 // Scroll in screen coordinates with a gesture. Each scroll starts |
| 5247 // where the previous scroll ended, but the scroll position is reset | 5267 // where the previous scroll ended, but the scroll position is reset |
| 5248 // for each scroll. | 5268 // for each scroll. |
| 5249 for (int i = 0; i < 4; ++i) { | 5269 for (int i = 0; i < 4; ++i) { |
| 5250 child_ptr->SetScrollDelta(gfx::Vector2dF()); | 5270 child_ptr->SetScrollDelta(gfx::Vector2dF()); |
| 5251 DrawFrame(); | 5271 DrawFrame(); |
| 5252 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5272 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5253 host_impl_->ScrollBegin(BeginState(viewport_point).get(), | 5273 host_impl_ |
| 5254 InputHandler::GESTURE) | 5274 ->ScrollBegin(BeginState(viewport_point).get(), |
| 5275 InputHandler::TOUCHSCREEN) |
| 5255 .thread); | 5276 .thread); |
| 5256 host_impl_->ScrollBy( | 5277 host_impl_->ScrollBy( |
| 5257 UpdateState(viewport_point, gesture_scroll_deltas[i]).get()); | 5278 UpdateState(viewport_point, gesture_scroll_deltas[i]).get()); |
| 5258 viewport_point += gesture_scroll_deltas[i]; | 5279 viewport_point += gesture_scroll_deltas[i]; |
| 5259 host_impl_->ScrollEnd(EndState().get()); | 5280 host_impl_->ScrollEnd(EndState().get()); |
| 5260 | 5281 |
| 5261 scroll_info = host_impl_->ProcessScrollDeltas(); | 5282 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5262 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 5283 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
| 5263 expected_scroll_deltas[i])); | 5284 expected_scroll_deltas[i])); |
| 5264 | 5285 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5279 scroll_layer->parent()->SetTransform(scale_transform); | 5300 scroll_layer->parent()->SetTransform(scale_transform); |
| 5280 | 5301 |
| 5281 gfx::Size surface_size(50, 50); | 5302 gfx::Size surface_size(50, 50); |
| 5282 host_impl_->SetViewportSize(surface_size); | 5303 host_impl_->SetViewportSize(surface_size); |
| 5283 SetNeedsRebuildPropertyTrees(); | 5304 SetNeedsRebuildPropertyTrees(); |
| 5284 DrawFrame(); | 5305 DrawFrame(); |
| 5285 | 5306 |
| 5286 // Scroll down in screen coordinates with a gesture. | 5307 // Scroll down in screen coordinates with a gesture. |
| 5287 gfx::Vector2d scroll_delta(0, 10); | 5308 gfx::Vector2d scroll_delta(0, 10); |
| 5288 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5309 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5289 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5310 host_impl_ |
| 5290 InputHandler::GESTURE) | 5311 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5312 InputHandler::TOUCHSCREEN) |
| 5291 .thread); | 5313 .thread); |
| 5292 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5314 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5293 host_impl_->ScrollEnd(EndState().get()); | 5315 host_impl_->ScrollEnd(EndState().get()); |
| 5294 | 5316 |
| 5295 // The layer should have scrolled down in its local coordinates, but half the | 5317 // The layer should have scrolled down in its local coordinates, but half the |
| 5296 // amount. | 5318 // amount. |
| 5297 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 5319 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5298 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5320 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
| 5299 gfx::Vector2d(0, scroll_delta.y() / scale))); | 5321 gfx::Vector2d(0, scroll_delta.y() / scale))); |
| 5300 | 5322 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5442 gfx::Vector2d(0, 0), false, 1.f, base::TimeDelta()); | 5464 gfx::Vector2d(0, 0), false, 1.f, base::TimeDelta()); |
| 5443 host_impl_->Animate(); | 5465 host_impl_->Animate(); |
| 5444 EXPECT_EQ(1.f, scroll_watcher.page_scale_factor()); | 5466 EXPECT_EQ(1.f, scroll_watcher.page_scale_factor()); |
| 5445 EXPECT_EQ(.5f, scroll_watcher.min_page_scale_factor()); | 5467 EXPECT_EQ(.5f, scroll_watcher.min_page_scale_factor()); |
| 5446 EXPECT_EQ(4.f, scroll_watcher.max_page_scale_factor()); | 5468 EXPECT_EQ(4.f, scroll_watcher.max_page_scale_factor()); |
| 5447 | 5469 |
| 5448 // The pinch gesture doesn't put the delegate into a state where the scroll | 5470 // The pinch gesture doesn't put the delegate into a state where the scroll |
| 5449 // offset is outside of the scroll range. (this is verified by DCHECKs in the | 5471 // offset is outside of the scroll range. (this is verified by DCHECKs in the |
| 5450 // delegate). | 5472 // delegate). |
| 5451 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5473 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5452 InputHandler::GESTURE); | 5474 InputHandler::TOUCHSCREEN); |
| 5453 host_impl_->PinchGestureBegin(); | 5475 host_impl_->PinchGestureBegin(); |
| 5454 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); | 5476 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); |
| 5455 host_impl_->PinchGestureUpdate(.5f, gfx::Point()); | 5477 host_impl_->PinchGestureUpdate(.5f, gfx::Point()); |
| 5456 host_impl_->PinchGestureEnd(); | 5478 host_impl_->PinchGestureEnd(); |
| 5457 host_impl_->ScrollEnd(EndState().get()); | 5479 host_impl_->ScrollEnd(EndState().get()); |
| 5458 | 5480 |
| 5459 // Scrolling should be relative to the offset as given by the delegate. | 5481 // Scrolling should be relative to the offset as given by the delegate. |
| 5460 gfx::Vector2dF scroll_delta(0.f, 10.f); | 5482 gfx::Vector2dF scroll_delta(0.f, 10.f); |
| 5461 gfx::ScrollOffset current_offset(7.f, 8.f); | 5483 gfx::ScrollOffset current_offset(7.f, 8.f); |
| 5462 | 5484 |
| 5463 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5485 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5464 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5486 host_impl_ |
| 5465 InputHandler::GESTURE) | 5487 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5488 InputHandler::TOUCHSCREEN) |
| 5466 .thread); | 5489 .thread); |
| 5467 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); | 5490 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); |
| 5468 | 5491 |
| 5469 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5492 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5470 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), | 5493 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), |
| 5471 scroll_watcher.last_set_scroll_offset()); | 5494 scroll_watcher.last_set_scroll_offset()); |
| 5472 | 5495 |
| 5473 current_offset = gfx::ScrollOffset(42.f, 41.f); | 5496 current_offset = gfx::ScrollOffset(42.f, 41.f); |
| 5474 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); | 5497 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); |
| 5475 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5498 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| (...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7575 | 7598 |
| 7576 host_impl_->SetViewportSize(surface_size); | 7599 host_impl_->SetViewportSize(surface_size); |
| 7577 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 7600 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
| 7578 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, | 7601 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, |
| 7579 Layer::INVALID_ID); | 7602 Layer::INVALID_ID); |
| 7580 host_impl_->active_tree()->DidBecomeActive(); | 7603 host_impl_->active_tree()->DidBecomeActive(); |
| 7581 SetNeedsRebuildPropertyTrees(); | 7604 SetNeedsRebuildPropertyTrees(); |
| 7582 DrawFrame(); | 7605 DrawFrame(); |
| 7583 { | 7606 { |
| 7584 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7607 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 7585 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 7608 host_impl_ |
| 7586 InputHandler::GESTURE) | 7609 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 7610 InputHandler::TOUCHSCREEN) |
| 7587 .thread); | 7611 .thread); |
| 7588 | 7612 |
| 7589 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7613 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 7590 host_impl_->FlingScrollBegin().thread); | 7614 host_impl_->FlingScrollBegin().thread); |
| 7591 | 7615 |
| 7592 gfx::Vector2d scroll_delta(0, 100); | 7616 gfx::Vector2d scroll_delta(0, 100); |
| 7593 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 7617 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 7594 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 7618 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 7595 | 7619 |
| 7596 host_impl_->ScrollEnd(EndState().get()); | 7620 host_impl_->ScrollEnd(EndState().get()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7631 DrawFrame(); | 7655 DrawFrame(); |
| 7632 { | 7656 { |
| 7633 scoped_ptr<ScrollAndScaleSet> scroll_info; | 7657 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 7634 LayerImpl* child = | 7658 LayerImpl* child = |
| 7635 host_impl_->active_tree()->root_layer()->children()[0]->children() | 7659 host_impl_->active_tree()->root_layer()->children()[0]->children() |
| 7636 [0].get(); | 7660 [0].get(); |
| 7637 LayerImpl* grand_child = child->children()[0].get(); | 7661 LayerImpl* grand_child = child->children()[0].get(); |
| 7638 | 7662 |
| 7639 gfx::Vector2d scroll_delta(0, -2); | 7663 gfx::Vector2d scroll_delta(0, -2); |
| 7640 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7664 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 7641 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 7665 host_impl_ |
| 7642 InputHandler::GESTURE) | 7666 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 7667 InputHandler::TOUCHSCREEN) |
| 7643 .thread); | 7668 .thread); |
| 7644 EXPECT_TRUE( | 7669 EXPECT_TRUE( |
| 7645 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 7670 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 7646 .did_scroll); | 7671 .did_scroll); |
| 7647 | 7672 |
| 7648 // The grand child should have scrolled up to its limit. | 7673 // The grand child should have scrolled up to its limit. |
| 7649 scroll_info = host_impl_->ProcessScrollDeltas(); | 7674 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 7650 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7675 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 7651 EXPECT_TRUE( | 7676 EXPECT_TRUE( |
| 7652 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 7677 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8117 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8142 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
| 8118 new SimpleSwapPromiseMonitor(NULL, | 8143 new SimpleSwapPromiseMonitor(NULL, |
| 8119 host_impl_.get(), | 8144 host_impl_.get(), |
| 8120 &set_needs_commit_count, | 8145 &set_needs_commit_count, |
| 8121 &set_needs_redraw_count, | 8146 &set_needs_redraw_count, |
| 8122 &forward_to_main_count)); | 8147 &forward_to_main_count)); |
| 8123 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8148 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8124 | 8149 |
| 8125 // Scrolling normally should not trigger any forwarding. | 8150 // Scrolling normally should not trigger any forwarding. |
| 8126 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8151 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8127 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8152 host_impl_ |
| 8128 InputHandler::GESTURE) | 8153 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8154 InputHandler::TOUCHSCREEN) |
| 8129 .thread); | 8155 .thread); |
| 8130 EXPECT_TRUE( | 8156 EXPECT_TRUE( |
| 8131 host_impl_->ScrollBy( | 8157 host_impl_->ScrollBy( |
| 8132 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8158 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
| 8133 .did_scroll); | 8159 .did_scroll); |
| 8134 host_impl_->ScrollEnd(EndState().get()); | 8160 host_impl_->ScrollEnd(EndState().get()); |
| 8135 | 8161 |
| 8136 EXPECT_EQ(0, set_needs_commit_count); | 8162 EXPECT_EQ(0, set_needs_commit_count); |
| 8137 EXPECT_EQ(1, set_needs_redraw_count); | 8163 EXPECT_EQ(1, set_needs_redraw_count); |
| 8138 EXPECT_EQ(0, forward_to_main_count); | 8164 EXPECT_EQ(0, forward_to_main_count); |
| 8139 | 8165 |
| 8140 // Scrolling with a scroll handler should defer the swap to the main | 8166 // Scrolling with a scroll handler should defer the swap to the main |
| 8141 // thread. | 8167 // thread. |
| 8142 host_impl_->active_tree()->set_have_scroll_event_handlers(true); | 8168 host_impl_->active_tree()->set_have_scroll_event_handlers(true); |
| 8143 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8169 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8144 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8170 host_impl_ |
| 8145 InputHandler::GESTURE) | 8171 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8172 InputHandler::TOUCHSCREEN) |
| 8146 .thread); | 8173 .thread); |
| 8147 EXPECT_TRUE( | 8174 EXPECT_TRUE( |
| 8148 host_impl_->ScrollBy( | 8175 host_impl_->ScrollBy( |
| 8149 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8176 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
| 8150 .did_scroll); | 8177 .did_scroll); |
| 8151 host_impl_->ScrollEnd(EndState().get()); | 8178 host_impl_->ScrollEnd(EndState().get()); |
| 8152 | 8179 |
| 8153 EXPECT_EQ(0, set_needs_commit_count); | 8180 EXPECT_EQ(0, set_needs_commit_count); |
| 8154 EXPECT_EQ(2, set_needs_redraw_count); | 8181 EXPECT_EQ(2, set_needs_redraw_count); |
| 8155 EXPECT_EQ(1, forward_to_main_count); | 8182 EXPECT_EQ(1, forward_to_main_count); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8218 | 8245 |
| 8219 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 8246 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
| 8220 InputHandlerScrollResult result; | 8247 InputHandlerScrollResult result; |
| 8221 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8248 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8222 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8249 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8223 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8250 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 8224 BOTH, SHOWN, false); | 8251 BOTH, SHOWN, false); |
| 8225 DrawFrame(); | 8252 DrawFrame(); |
| 8226 | 8253 |
| 8227 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8254 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8228 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8255 host_impl_ |
| 8229 InputHandler::GESTURE) | 8256 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8257 InputHandler::TOUCHSCREEN) |
| 8230 .thread); | 8258 .thread); |
| 8231 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8259 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8232 EXPECT_EQ(gfx::Vector2dF().ToString(), | 8260 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 8233 scroll_layer->CurrentScrollOffset().ToString()); | 8261 scroll_layer->CurrentScrollOffset().ToString()); |
| 8234 | 8262 |
| 8235 // Scroll just the top controls and verify that the scroll succeeds. | 8263 // Scroll just the top controls and verify that the scroll succeeds. |
| 8236 const float residue = 10; | 8264 const float residue = 10; |
| 8237 float offset = top_controls_height_ - residue; | 8265 float offset = top_controls_height_ - residue; |
| 8238 result = host_impl_->ScrollBy( | 8266 result = host_impl_->ScrollBy( |
| 8239 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); | 8267 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8327 } | 8355 } |
| 8328 | 8356 |
| 8329 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 8357 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
| 8330 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8358 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8331 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 8359 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
| 8332 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8360 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 8333 BOTH, SHOWN, false); | 8361 BOTH, SHOWN, false); |
| 8334 DrawFrame(); | 8362 DrawFrame(); |
| 8335 | 8363 |
| 8336 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8364 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8337 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8365 host_impl_ |
| 8338 InputHandler::GESTURE) | 8366 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8367 InputHandler::TOUCHSCREEN) |
| 8339 .thread); | 8368 .thread); |
| 8340 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8369 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8341 EXPECT_EQ(gfx::Vector2dF().ToString(), | 8370 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 8342 scroll_layer->CurrentScrollOffset().ToString()); | 8371 scroll_layer->CurrentScrollOffset().ToString()); |
| 8343 | 8372 |
| 8344 // Scroll the top controls partially. | 8373 // Scroll the top controls partially. |
| 8345 const float residue = 35; | 8374 const float residue = 35; |
| 8346 float offset = top_controls_height_ - residue; | 8375 float offset = top_controls_height_ - residue; |
| 8347 EXPECT_TRUE( | 8376 EXPECT_TRUE( |
| 8348 host_impl_->ScrollBy( | 8377 host_impl_->ScrollBy( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8405 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8434 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8406 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8435 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8407 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8436 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 8408 BOTH, SHOWN, false); | 8437 BOTH, SHOWN, false); |
| 8409 float initial_scroll_offset = 50; | 8438 float initial_scroll_offset = 50; |
| 8410 scroll_layer->PushScrollOffsetFromMainThread( | 8439 scroll_layer->PushScrollOffsetFromMainThread( |
| 8411 gfx::ScrollOffset(0, initial_scroll_offset)); | 8440 gfx::ScrollOffset(0, initial_scroll_offset)); |
| 8412 DrawFrame(); | 8441 DrawFrame(); |
| 8413 | 8442 |
| 8414 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8443 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8415 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8444 host_impl_ |
| 8416 InputHandler::GESTURE) | 8445 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8446 InputHandler::TOUCHSCREEN) |
| 8417 .thread); | 8447 .thread); |
| 8418 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8448 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8419 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 8449 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 8420 scroll_layer->CurrentScrollOffset().ToString()); | 8450 scroll_layer->CurrentScrollOffset().ToString()); |
| 8421 | 8451 |
| 8422 // Scroll the top controls partially. | 8452 // Scroll the top controls partially. |
| 8423 const float residue = 15; | 8453 const float residue = 15; |
| 8424 float offset = top_controls_height_ - residue; | 8454 float offset = top_controls_height_ - residue; |
| 8425 EXPECT_TRUE( | 8455 EXPECT_TRUE( |
| 8426 host_impl_->ScrollBy( | 8456 host_impl_->ScrollBy( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8476 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8506 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8477 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8507 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8478 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 8508 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
| 8479 false); | 8509 false); |
| 8480 float initial_scroll_offset = 50; | 8510 float initial_scroll_offset = 50; |
| 8481 scroll_layer->PushScrollOffsetFromMainThread( | 8511 scroll_layer->PushScrollOffsetFromMainThread( |
| 8482 gfx::ScrollOffset(0, initial_scroll_offset)); | 8512 gfx::ScrollOffset(0, initial_scroll_offset)); |
| 8483 DrawFrame(); | 8513 DrawFrame(); |
| 8484 | 8514 |
| 8485 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8515 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8486 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8516 host_impl_ |
| 8487 InputHandler::GESTURE) | 8517 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8518 InputHandler::TOUCHSCREEN) |
| 8488 .thread); | 8519 .thread); |
| 8489 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8520 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8490 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 8521 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 8491 scroll_layer->CurrentScrollOffset().ToString()); | 8522 scroll_layer->CurrentScrollOffset().ToString()); |
| 8492 | 8523 |
| 8493 // Scroll the top controls partially. | 8524 // Scroll the top controls partially. |
| 8494 const float residue = 15; | 8525 const float residue = 15; |
| 8495 float offset = top_controls_height_ - residue; | 8526 float offset = top_controls_height_ - residue; |
| 8496 EXPECT_TRUE( | 8527 EXPECT_TRUE( |
| 8497 host_impl_->ScrollBy( | 8528 host_impl_->ScrollBy( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8545 // Verifies that the overscroll delta should not have accumulated in | 8576 // Verifies that the overscroll delta should not have accumulated in |
| 8546 // the top controls if we do a hide and show without releasing finger. | 8577 // the top controls if we do a hide and show without releasing finger. |
| 8547 | 8578 |
| 8548 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8579 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8549 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8580 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8550 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 8581 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
| 8551 false); | 8582 false); |
| 8552 DrawFrame(); | 8583 DrawFrame(); |
| 8553 | 8584 |
| 8554 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8585 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8555 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8586 host_impl_ |
| 8556 InputHandler::GESTURE) | 8587 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8588 InputHandler::TOUCHSCREEN) |
| 8557 .thread); | 8589 .thread); |
| 8558 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8590 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8559 | 8591 |
| 8560 float offset = 50; | 8592 float offset = 50; |
| 8561 EXPECT_TRUE( | 8593 EXPECT_TRUE( |
| 8562 host_impl_->ScrollBy( | 8594 host_impl_->ScrollBy( |
| 8563 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 8595 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 8564 .did_scroll); | 8596 .did_scroll); |
| 8565 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8597 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8566 EXPECT_EQ(gfx::Vector2dF().ToString(), | 8598 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8723 DrawFrame(); | 8755 DrawFrame(); |
| 8724 { | 8756 { |
| 8725 gfx::Vector2dF inner_expected; | 8757 gfx::Vector2dF inner_expected; |
| 8726 gfx::Vector2dF outer_expected; | 8758 gfx::Vector2dF outer_expected; |
| 8727 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8759 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 8728 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8760 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 8729 | 8761 |
| 8730 // Scrolling the viewport always sets the outer scroll layer as the | 8762 // Scrolling the viewport always sets the outer scroll layer as the |
| 8731 // currently scrolling layer. | 8763 // currently scrolling layer. |
| 8732 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8764 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8733 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8765 host_impl_ |
| 8734 InputHandler::GESTURE) | 8766 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8767 InputHandler::TOUCHSCREEN) |
| 8735 .thread); | 8768 .thread); |
| 8736 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 8769 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 8737 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8770 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8738 host_impl_->FlingScrollBegin().thread); | 8771 host_impl_->FlingScrollBegin().thread); |
| 8739 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 8772 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 8740 | 8773 |
| 8741 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 8774 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
| 8742 inner_viewport.height() / 2.f); | 8775 inner_viewport.height() / 2.f); |
| 8743 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8776 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 8744 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 8777 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 8745 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 8778 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 8746 | 8779 |
| 8747 host_impl_->ScrollEnd(EndState().get()); | 8780 host_impl_->ScrollEnd(EndState().get()); |
| 8748 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 8781 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); |
| 8749 | 8782 |
| 8750 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8783 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 8751 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8784 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 8752 | 8785 |
| 8753 // Fling past the inner viewport boundry, make sure outer viewport scrolls. | 8786 // Fling past the inner viewport boundry, make sure outer viewport scrolls. |
| 8754 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8787 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8755 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8788 host_impl_ |
| 8756 InputHandler::GESTURE) | 8789 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8790 InputHandler::TOUCHSCREEN) |
| 8757 .thread); | 8791 .thread); |
| 8758 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 8792 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 8759 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8793 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8760 host_impl_->FlingScrollBegin().thread); | 8794 host_impl_->FlingScrollBegin().thread); |
| 8761 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 8795 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 8762 | 8796 |
| 8763 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8797 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 8764 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 8798 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 8765 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); | 8799 EXPECT_EQ(inner_scroll, host_impl_->CurrentlyScrollingLayer()); |
| 8766 | 8800 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 8789 SetNeedsRebuildPropertyTrees(); | 8823 SetNeedsRebuildPropertyTrees(); |
| 8790 DrawFrame(); | 8824 DrawFrame(); |
| 8791 { | 8825 { |
| 8792 gfx::Vector2dF inner_expected; | 8826 gfx::Vector2dF inner_expected; |
| 8793 gfx::Vector2dF outer_expected; | 8827 gfx::Vector2dF outer_expected; |
| 8794 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8828 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 8795 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8829 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 8796 | 8830 |
| 8797 // Make sure the scroll goes to the inner viewport first. | 8831 // Make sure the scroll goes to the inner viewport first. |
| 8798 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8832 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8799 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8833 host_impl_ |
| 8800 InputHandler::GESTURE) | 8834 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8835 InputHandler::TOUCHSCREEN) |
| 8801 .thread); | 8836 .thread); |
| 8802 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8837 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8803 host_impl_->FlingScrollBegin().thread); | 8838 host_impl_->FlingScrollBegin().thread); |
| 8804 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 8839 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8805 InputHandler::GESTURE)); | 8840 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8806 | 8841 |
| 8807 // Scroll near the edge of the outer viewport. | 8842 // Scroll near the edge of the outer viewport. |
| 8808 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 8843 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
| 8809 inner_viewport.height() / 2.f); | 8844 inner_viewport.height() / 2.f); |
| 8810 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8845 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 8811 inner_expected += scroll_delta; | 8846 inner_expected += scroll_delta; |
| 8812 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 8847 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8813 InputHandler::GESTURE)); | 8848 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8814 | 8849 |
| 8815 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8850 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 8816 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8851 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 8817 | 8852 |
| 8818 // Now diagonal scroll across the outer viewport boundary in a single event. | 8853 // Now diagonal scroll across the outer viewport boundary in a single event. |
| 8819 // The entirety of the scroll should be consumed, as bubbling between inner | 8854 // The entirety of the scroll should be consumed, as bubbling between inner |
| 8820 // and outer viewport layers is perfect. | 8855 // and outer viewport layers is perfect. |
| 8821 host_impl_->ScrollBy( | 8856 host_impl_->ScrollBy( |
| 8822 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); | 8857 UpdateState(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)).get()); |
| 8823 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 8858 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8824 InputHandler::GESTURE)); | 8859 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8825 outer_expected += scroll_delta; | 8860 outer_expected += scroll_delta; |
| 8826 inner_expected += scroll_delta; | 8861 inner_expected += scroll_delta; |
| 8827 host_impl_->ScrollEnd(EndState().get()); | 8862 host_impl_->ScrollEnd(EndState().get()); |
| 8828 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 8863 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8829 gfx::Point(), InputHandler::GESTURE)); | 8864 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8830 | 8865 |
| 8831 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 8866 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 8832 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 8867 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 8833 } | 8868 } |
| 8834 } | 8869 } |
| 8835 | 8870 |
| 8836 TEST_F(LayerTreeHostImplVirtualViewportTest, | 8871 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 8837 TouchFlingDoesntSwitchScrollingLayer) { | 8872 TouchFlingDoesntSwitchScrollingLayer) { |
| 8838 gfx::Size content_size = gfx::Size(100, 160); | 8873 gfx::Size content_size = gfx::Size(100, 160); |
| 8839 gfx::Size outer_viewport = gfx::Size(50, 80); | 8874 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 8840 gfx::Size inner_viewport = gfx::Size(25, 40); | 8875 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 8841 | 8876 |
| 8842 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 8877 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 8843 | 8878 |
| 8844 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 8879 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 8845 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 8880 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 8846 | 8881 |
| 8847 scoped_ptr<LayerImpl> child = | 8882 scoped_ptr<LayerImpl> child = |
| 8848 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 8883 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 8849 LayerImpl* child_scroll = child.get(); | 8884 LayerImpl* child_scroll = child.get(); |
| 8850 outer_scroll->children()[0]->AddChild(std::move(child)); | 8885 outer_scroll->children()[0]->AddChild(std::move(child)); |
| 8851 | 8886 |
| 8852 SetNeedsRebuildPropertyTrees(); | 8887 SetNeedsRebuildPropertyTrees(); |
| 8853 DrawFrame(); | 8888 DrawFrame(); |
| 8854 { | 8889 { |
| 8855 scoped_ptr<ScrollAndScaleSet> scroll_info; | 8890 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 8856 | 8891 |
| 8857 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 8892 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
| 8858 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8893 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8859 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8894 host_impl_ |
| 8860 InputHandler::GESTURE) | 8895 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8896 InputHandler::TOUCHSCREEN) |
| 8861 .thread); | 8897 .thread); |
| 8862 EXPECT_TRUE( | 8898 EXPECT_TRUE( |
| 8863 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8899 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8864 .did_scroll); | 8900 .did_scroll); |
| 8865 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 8901 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8866 InputHandler::GESTURE)); | 8902 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8867 | 8903 |
| 8868 // The child should have scrolled up to its limit. | 8904 // The child should have scrolled up to its limit. |
| 8869 scroll_info = host_impl_->ProcessScrollDeltas(); | 8905 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 8870 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 8906 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 8871 EXPECT_TRUE( | 8907 EXPECT_TRUE( |
| 8872 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 8908 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 8873 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 8909 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 8874 | 8910 |
| 8875 // The fling have no effect on the currently scrolling layer. | 8911 // The fling have no effect on the currently scrolling layer. |
| 8876 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8912 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8877 host_impl_->FlingScrollBegin().thread); | 8913 host_impl_->FlingScrollBegin().thread); |
| 8878 EXPECT_FALSE( | 8914 EXPECT_FALSE( |
| 8879 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8915 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8880 .did_scroll); | 8916 .did_scroll); |
| 8881 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 8917 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 8882 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 8918 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8883 InputHandler::GESTURE)); | 8919 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8884 | 8920 |
| 8885 // The inner viewport shouldn't have scrolled. | 8921 // The inner viewport shouldn't have scrolled. |
| 8886 scroll_info = host_impl_->ProcessScrollDeltas(); | 8922 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 8887 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 8923 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 8888 EXPECT_TRUE( | 8924 EXPECT_TRUE( |
| 8889 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 8925 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 8890 ExpectNone(*scroll_info, inner_scroll->id()); | 8926 ExpectNone(*scroll_info, inner_scroll->id()); |
| 8891 | 8927 |
| 8892 // As the locked layer is at its limit, no further scrolling can occur. | 8928 // As the locked layer is at its limit, no further scrolling can occur. |
| 8893 EXPECT_FALSE( | 8929 EXPECT_FALSE( |
| 8894 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8930 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8895 .did_scroll); | 8931 .did_scroll); |
| 8896 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 8932 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 8897 host_impl_->ScrollEnd(EndState().get()); | 8933 host_impl_->ScrollEnd(EndState().get()); |
| 8898 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 8934 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 8899 gfx::Point(), InputHandler::GESTURE)); | 8935 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 8900 } | 8936 } |
| 8901 } | 8937 } |
| 8902 | 8938 |
| 8903 TEST_F(LayerTreeHostImplVirtualViewportTest, | 8939 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 8904 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 8940 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
| 8905 gfx::Size content_size = gfx::Size(100, 160); | 8941 gfx::Size content_size = gfx::Size(100, 160); |
| 8906 gfx::Size outer_viewport = gfx::Size(50, 80); | 8942 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 8907 gfx::Size inner_viewport = gfx::Size(25, 40); | 8943 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 8908 | 8944 |
| 8909 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 8945 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 8910 | 8946 |
| 8911 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 8947 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 8912 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 8948 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 8913 | 8949 |
| 8914 scoped_ptr<LayerImpl> child = | 8950 scoped_ptr<LayerImpl> child = |
| 8915 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 8951 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 8916 LayerImpl* child_scroll = child.get(); | 8952 LayerImpl* child_scroll = child.get(); |
| 8917 outer_scroll->children()[0]->AddChild(std::move(child)); | 8953 outer_scroll->children()[0]->AddChild(std::move(child)); |
| 8918 | 8954 |
| 8919 SetNeedsRebuildPropertyTrees(); | 8955 SetNeedsRebuildPropertyTrees(); |
| 8920 DrawFrame(); | 8956 DrawFrame(); |
| 8921 | 8957 |
| 8922 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8958 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8923 host_impl_->RootScrollBegin(BeginState(gfx::Point()).get(), | 8959 host_impl_ |
| 8924 InputHandler::GESTURE) | 8960 ->RootScrollBegin(BeginState(gfx::Point()).get(), |
| 8961 InputHandler::TOUCHSCREEN) |
| 8925 .thread); | 8962 .thread); |
| 8926 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 8963 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 8927 host_impl_->ScrollEnd(EndState().get()); | 8964 host_impl_->ScrollEnd(EndState().get()); |
| 8928 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8965 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8929 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8966 host_impl_ |
| 8930 InputHandler::GESTURE) | 8967 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8968 InputHandler::TOUCHSCREEN) |
| 8931 .thread); | 8969 .thread); |
| 8932 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 8970 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 8933 host_impl_->ScrollEnd(EndState().get()); | 8971 host_impl_->ScrollEnd(EndState().get()); |
| 8934 } | 8972 } |
| 8935 | 8973 |
| 8936 TEST_F(LayerTreeHostImplVirtualViewportTest, | 8974 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 8937 NoOverscrollWhenInnerViewportCantScroll) { | 8975 NoOverscrollWhenInnerViewportCantScroll) { |
| 8938 InputHandlerScrollResult scroll_result; | 8976 InputHandlerScrollResult scroll_result; |
| 8939 gfx::Size content_size = gfx::Size(100, 160); | 8977 gfx::Size content_size = gfx::Size(100, 160); |
| 8940 gfx::Size outer_viewport = gfx::Size(50, 80); | 8978 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 8941 gfx::Size inner_viewport = gfx::Size(25, 40); | 8979 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 8942 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 8980 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 8943 SetNeedsRebuildPropertyTrees(); | 8981 SetNeedsRebuildPropertyTrees(); |
| 8944 DrawFrame(); | 8982 DrawFrame(); |
| 8945 | 8983 |
| 8946 // Make inner viewport unscrollable. | 8984 // Make inner viewport unscrollable. |
| 8947 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 8985 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 8948 inner_scroll->set_user_scrollable_horizontal(false); | 8986 inner_scroll->set_user_scrollable_horizontal(false); |
| 8949 inner_scroll->set_user_scrollable_vertical(false); | 8987 inner_scroll->set_user_scrollable_vertical(false); |
| 8950 | 8988 |
| 8951 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). | 8989 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). |
| 8952 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); | 8990 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); |
| 8953 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8991 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8954 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8992 host_impl_ |
| 8955 InputHandler::GESTURE) | 8993 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8994 InputHandler::TOUCHSCREEN) |
| 8956 .thread); | 8995 .thread); |
| 8957 scroll_result = host_impl_->ScrollBy( | 8996 scroll_result = host_impl_->ScrollBy( |
| 8958 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); | 8997 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); |
| 8959 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); | 8998 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); |
| 8960 | 8999 |
| 8961 // When inner viewport is unscrollable, a fling gives zero overscroll. | 9000 // When inner viewport is unscrollable, a fling gives zero overscroll. |
| 8962 EXPECT_FALSE(scroll_result.did_overscroll_root); | 9001 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 8963 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 9002 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 8964 } | 9003 } |
| 8965 | 9004 |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9749 | 9788 |
| 9750 // The scroll deltas should have the page scale factor applied. | 9789 // The scroll deltas should have the page scale factor applied. |
| 9751 { | 9790 { |
| 9752 host_impl_->active_tree()->PushPageScaleFromMainThread( | 9791 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 9753 page_scale_factor, min_page_scale, max_page_scale); | 9792 page_scale_factor, min_page_scale, max_page_scale); |
| 9754 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 9793 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 9755 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 9794 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 9756 | 9795 |
| 9757 float page_scale_delta = 2.f; | 9796 float page_scale_delta = 2.f; |
| 9758 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 9797 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9759 InputHandler::GESTURE); | 9798 InputHandler::TOUCHSCREEN); |
| 9760 host_impl_->PinchGestureBegin(); | 9799 host_impl_->PinchGestureBegin(); |
| 9761 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 9800 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 9762 host_impl_->PinchGestureEnd(); | 9801 host_impl_->PinchGestureEnd(); |
| 9763 host_impl_->ScrollEnd(EndState().get()); | 9802 host_impl_->ScrollEnd(EndState().get()); |
| 9764 | 9803 |
| 9765 gfx::Vector2dF scroll_delta(0, 5); | 9804 gfx::Vector2dF scroll_delta(0, 5); |
| 9766 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9805 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9767 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 9806 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9768 InputHandler::WHEEL) | 9807 InputHandler::WHEEL) |
| 9769 .thread); | 9808 .thread); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10165 gfx::Size(100, 100)); | 10204 gfx::Size(100, 100)); |
| 10166 | 10205 |
| 10167 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 10206 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 10168 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 10207 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 10169 const int scroll = 5; | 10208 const int scroll = 5; |
| 10170 int accumulated_scroll = 0; | 10209 int accumulated_scroll = 0; |
| 10171 for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1; | 10210 for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1; |
| 10172 ++i) { | 10211 ++i) { |
| 10173 host_impl_->ActivateSyncTree(); | 10212 host_impl_->ActivateSyncTree(); |
| 10174 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 10213 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 10175 InputHandler::GESTURE); | 10214 InputHandler::TOUCHSCREEN); |
| 10176 host_impl_->ScrollBy( | 10215 host_impl_->ScrollBy( |
| 10177 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); | 10216 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); |
| 10178 accumulated_scroll += scroll; | 10217 accumulated_scroll += scroll; |
| 10179 host_impl_->ScrollEnd(EndState().get()); | 10218 host_impl_->ScrollEnd(EndState().get()); |
| 10180 host_impl_->active_tree()->UpdateDrawProperties(false); | 10219 host_impl_->active_tree()->UpdateDrawProperties(false); |
| 10181 | 10220 |
| 10182 host_impl_->CreatePendingTree(); | 10221 host_impl_->CreatePendingTree(); |
| 10183 host_impl_->pending_tree()->set_source_frame_number(i + 1); | 10222 host_impl_->pending_tree()->set_source_frame_number(i + 1); |
| 10184 LayerImpl* content_layer = host_impl_->pending_tree() | 10223 LayerImpl* content_layer = host_impl_->pending_tree() |
| 10185 ->OuterViewportScrollLayer() | 10224 ->OuterViewportScrollLayer() |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10218 // There should not be any jitter measured till we hit the fixed point hits | 10257 // There should not be any jitter measured till we hit the fixed point hits |
| 10219 // threshold. | 10258 // threshold. |
| 10220 float expected_jitter = | 10259 float expected_jitter = |
| 10221 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10260 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
| 10222 EXPECT_EQ(jitter, expected_jitter); | 10261 EXPECT_EQ(jitter, expected_jitter); |
| 10223 } | 10262 } |
| 10224 } | 10263 } |
| 10225 | 10264 |
| 10226 } // namespace | 10265 } // namespace |
| 10227 } // namespace cc | 10266 } // namespace cc |
| OLD | NEW |