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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
801 child = child_layer.get(); | 801 child = child_layer.get(); |
802 child_layer->SetDrawsContent(true); | 802 child_layer->SetDrawsContent(true); |
803 child_layer->SetPosition(gfx::PointF(0, 20)); | 803 child_layer->SetPosition(gfx::PointF(0, 20)); |
804 child_layer->SetBounds(gfx::Size(50, 50)); | 804 child_layer->SetBounds(gfx::Size(50, 50)); |
805 scroll->test_properties()->AddChild(std::move(child_layer)); | 805 scroll->test_properties()->AddChild(std::move(child_layer)); |
806 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 806 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
807 } | 807 } |
808 | 808 |
809 // Touch handler regions determine whether touch events block scroll. | 809 // Touch handler regions determine whether touch events block scroll. |
810 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 810 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
811 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 811 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10)), |
812 EventListenerProperties::kBlocking); | |
bokan
2016/11/17 15:39:28
EXPECT_EQ's arguments are (expected, actual), whic
lanwei
2016/11/18 00:54:07
Acknowledged.
| |
812 | 813 |
813 // But they don't influence the actual handling of the scroll gestures. | 814 // But they don't influence the actual handling of the scroll gestures. |
814 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 815 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
815 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 816 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
816 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 817 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
817 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 818 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
818 status.main_thread_scrolling_reasons); | 819 status.main_thread_scrolling_reasons); |
819 host_impl_->ScrollEnd(EndState().get()); | 820 host_impl_->ScrollEnd(EndState().get()); |
820 | 821 |
821 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 822 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)), |
bokan
2016/11/17 15:39:28
Ditto to these ones.
lanwei
2016/11/18 00:54:07
Done.
| |
823 EventListenerProperties::kBlocking); | |
822 root->SetTouchEventHandlerRegion(gfx::Rect()); | 824 root->SetTouchEventHandlerRegion(gfx::Rect()); |
823 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 825 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)), |
826 EventListenerProperties::kNone); | |
824 child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); | 827 child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); |
825 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 828 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 30)), |
829 EventListenerProperties::kBlocking); | |
826 } | 830 } |
827 | 831 |
828 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { | 832 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { |
829 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 833 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
830 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 834 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
831 DrawFrame(); | 835 DrawFrame(); |
832 | 836 |
833 // Ignore the fling since no layer is being scrolled | 837 // Ignore the fling since no layer is being scrolled |
834 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin(); | 838 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin(); |
835 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 839 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
(...skipping 9085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9921 last_on_draw_frame_.reset(); | 9925 last_on_draw_frame_.reset(); |
9922 | 9926 |
9923 // Different draw params does swap. | 9927 // Different draw params does swap. |
9924 did_request_redraw_ = false; | 9928 did_request_redraw_ = false; |
9925 host_impl_->OnDraw(draw_transform, draw_viewport2, | 9929 host_impl_->OnDraw(draw_transform, draw_viewport2, |
9926 resourceless_software_draw); | 9930 resourceless_software_draw); |
9927 EXPECT_TRUE(did_request_redraw_); | 9931 EXPECT_TRUE(did_request_redraw_); |
9928 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); | 9932 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
9929 } | 9933 } |
9930 | 9934 |
9935 TEST_F(LayerTreeHostImplTest, TouchInsideOrOutsideFlingLayer) { | |
bokan
2016/11/17 15:39:28
Please add a short 1-2 sentence comment above desc
lanwei
2016/11/18 00:54:07
Done.
| |
9936 gfx::Size surface_size(100, 100); | |
9937 gfx::Size inner_size(50, 50); | |
9938 | |
9939 LayerImpl* root = | |
9940 CreateBasicVirtualViewportLayers(surface_size, surface_size); | |
bokan
2016/11/17 15:39:28
I think the viewports should be the inner_size (we
lanwei
2016/11/18 00:54:07
Done.
| |
9941 root->test_properties()->force_render_surface = true; | |
9942 | |
9943 std::unique_ptr<LayerImpl> child = | |
9944 CreateScrollableLayer(26, surface_size, root); | |
9945 std::unique_ptr<LayerImpl> grand_child = | |
9946 CreateScrollableLayer(27, inner_size, root); | |
bokan
2016/11/17 15:39:28
I think the clip for the grand_child should be chi
lanwei
2016/11/18 00:54:07
Sorry, I tried, but they do not work. I want to be
bokan
2016/11/18 18:41:36
Ok, thanks for trying.
| |
9947 LayerImpl* grand_child_layer = grand_child.get(); | |
9948 child->test_properties()->AddChild(std::move(grand_child)); | |
9949 | |
9950 LayerImpl* child_layer = child.get(); | |
9951 root->test_properties()->AddChild(std::move(child)); | |
9952 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
9953 host_impl_->active_tree()->DidBecomeActive(); | |
9954 | |
9955 grand_child_layer->layer_tree_impl() | |
9956 ->property_trees() | |
9957 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | |
9958 gfx::ScrollOffset(0, 5)); | |
9959 child_layer->layer_tree_impl() | |
9960 ->property_trees() | |
9961 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | |
9962 gfx::ScrollOffset(3, 0)); | |
9963 | |
9964 host_impl_->SetViewportSize(surface_size); | |
bokan
2016/11/17 15:39:28
No need for this, it's called as part of CreateBas
lanwei
2016/11/18 00:54:07
Done.
| |
9965 DrawFrame(); | |
9966 { | |
9967 child_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | |
9968 grand_child_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | |
9969 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10)), | |
9970 EventListenerProperties::kBlocking); | |
9971 // Flinging the child layer. | |
9972 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | |
9973 host_impl_ | |
9974 ->ScrollBegin(BeginState(gfx::Point(60, 60)).get(), | |
9975 InputHandler::TOUCHSCREEN) | |
9976 .thread); | |
9977 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | |
9978 host_impl_->FlingScrollBegin().thread); | |
9979 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer); | |
9980 // Touch on the child layer, which is an active fling layer, the touch | |
9981 // event handler will force to be passive. | |
9982 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(70, 80)), | |
9983 EventListenerProperties::kBlockingAndMaybePassiveDueToFling); | |
9984 // Touch on the grand child layer, which is a descendant of an active fling | |
9985 // layer, the touch event handler will force to be passive. | |
9986 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(20, 30)), | |
9987 EventListenerProperties::kBlockingAndMaybePassiveDueToFling); | |
9988 | |
9989 // Now flinging on the grand child layer. | |
9990 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | |
9991 host_impl_ | |
9992 ->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), | |
9993 InputHandler::TOUCHSCREEN) | |
9994 .thread); | |
9995 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | |
9996 host_impl_->FlingScrollBegin().thread); | |
9997 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | |
9998 // Touch on the child layer, the touch event handler will still be blocking. | |
9999 EXPECT_EQ(host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(60, 60)), | |
10000 EventListenerProperties::kBlocking); | |
10001 } | |
10002 } | |
10003 | |
9931 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 10004 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
9932 protected: | 10005 protected: |
9933 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { | 10006 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
9934 return FakeCompositorFrameSink::Create3d(); | 10007 return FakeCompositorFrameSink::Create3d(); |
9935 } | 10008 } |
9936 }; | 10009 }; |
9937 | 10010 |
9938 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 10011 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
9939 ResourcelessSoftwareSetNeedsRedraw) { | 10012 ResourcelessSoftwareSetNeedsRedraw) { |
9940 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 10013 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11620 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11693 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11621 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11694 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11622 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11695 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11623 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11696 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11624 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11697 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11625 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11698 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11626 } | 11699 } |
11627 | 11700 |
11628 } // namespace | 11701 } // namespace |
11629 } // namespace cc | 11702 } // namespace cc |
OLD | NEW |