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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 931 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
932 status.main_thread_scrolling_reasons); | 932 status.main_thread_scrolling_reasons); |
933 | 933 |
934 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 934 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
935 InputHandler::TOUCHSCREEN); | 935 InputHandler::TOUCHSCREEN); |
936 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 936 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
937 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 937 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
938 status.main_thread_scrolling_reasons); | 938 status.main_thread_scrolling_reasons); |
939 } | 939 } |
940 | 940 |
| 941 TEST_F(LayerTreeHostImplTest, ScrollWithOverlappingNonScrollableLayer) { |
| 942 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 943 gfx::Size content_size = gfx::Size(360, 600); |
| 944 gfx::Size scroll_content_size = gfx::Size(345, 3800); |
| 945 gfx::Size scrollbar_size = gfx::Size(15, 600); |
| 946 |
| 947 host_impl_->SetViewportSize(content_size); |
| 948 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); |
| 949 root->SetBounds(content_size); |
| 950 root->SetPosition(gfx::PointF()); |
| 951 |
| 952 std::unique_ptr<LayerImpl> clip = LayerImpl::Create(layer_tree_impl, 2); |
| 953 clip->SetBounds(content_size); |
| 954 clip->SetPosition(gfx::PointF()); |
| 955 |
| 956 std::unique_ptr<LayerImpl> scroll = LayerImpl::Create(layer_tree_impl, 3); |
| 957 scroll->SetBounds(scroll_content_size); |
| 958 scroll->SetScrollClipLayer(clip->id()); |
| 959 scroll->SetDrawsContent(true); |
| 960 |
| 961 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 962 SolidColorScrollbarLayerImpl::Create(layer_tree_impl, 4, VERTICAL, 10, 0, |
| 963 false, true); |
| 964 scrollbar->SetBounds(scrollbar_size); |
| 965 scrollbar->SetPosition(gfx::PointF(345, 0)); |
| 966 scrollbar->SetScrollLayerId(scroll->id()); |
| 967 scrollbar->set_layer_or_descendant_is_drawn(true); |
| 968 scrollbar->SetDrawsContent(true); |
| 969 |
| 970 std::unique_ptr<LayerImpl> squash1 = LayerImpl::Create(layer_tree_impl, 5); |
| 971 squash1->SetBounds(gfx::Size(140, 300)); |
| 972 squash1->SetPosition(gfx::PointF(220, 0)); |
| 973 squash1->SetDrawsContent(true); |
| 974 |
| 975 std::unique_ptr<LayerImpl> squash2 = LayerImpl::Create(layer_tree_impl, 6); |
| 976 squash2->SetBounds(gfx::Size(140, 300)); |
| 977 squash2->SetPosition(gfx::PointF(220, 300)); |
| 978 squash2->SetDrawsContent(true); |
| 979 |
| 980 scroll->AddChild(std::move(squash2)); |
| 981 clip->AddChild(std::move(scroll)); |
| 982 clip->AddChild(std::move(scrollbar)); |
| 983 clip->AddChild(std::move(squash1)); |
| 984 root->AddChild(std::move(clip)); |
| 985 |
| 986 layer_tree_impl->SetRootLayer(std::move(root)); |
| 987 SetNeedsRebuildPropertyTrees(); |
| 988 RebuildPropertyTrees(); |
| 989 layer_tree_impl->DidBecomeActive(); |
| 990 |
| 991 // The point hits squash1 layer and also scroll layer, because scroll layer is |
| 992 // not an ancestor of squash1 layer, we cannot scroll on impl thread. |
| 993 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 994 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); |
| 995 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 996 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 997 status.main_thread_scrolling_reasons); |
| 998 |
| 999 // The point hits squash1 layer and also scrollbar layer. |
| 1000 status = host_impl_->ScrollBegin(BeginState(gfx::Point(350, 150)).get(), |
| 1001 InputHandler::WHEEL); |
| 1002 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 1003 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 1004 status.main_thread_scrolling_reasons); |
| 1005 |
| 1006 // The point hits squash2 layer and also scroll layer, because scroll layer is |
| 1007 // an ancestor of squash2 layer, we should scroll on impl. |
| 1008 status = host_impl_->ScrollBegin(BeginState(gfx::Point(230, 450)).get(), |
| 1009 InputHandler::WHEEL); |
| 1010 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1011 } |
| 1012 |
941 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 1013 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
942 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1014 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
943 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1015 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
944 | 1016 |
945 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1017 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
946 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1018 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
947 | 1019 |
948 SetNeedsRebuildPropertyTrees(); | 1020 SetNeedsRebuildPropertyTrees(); |
949 DrawFrame(); | 1021 DrawFrame(); |
950 | 1022 |
(...skipping 9649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10600 // There should not be any jitter measured till we hit the fixed point hits | 10672 // There should not be any jitter measured till we hit the fixed point hits |
10601 // threshold. | 10673 // threshold. |
10602 float expected_jitter = | 10674 float expected_jitter = |
10603 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10675 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
10604 EXPECT_EQ(jitter, expected_jitter); | 10676 EXPECT_EQ(jitter, expected_jitter); |
10605 } | 10677 } |
10606 } | 10678 } |
10607 | 10679 |
10608 } // namespace | 10680 } // namespace |
10609 } // namespace cc | 10681 } // namespace cc |
OLD | NEW |