| 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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 1011 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 1012 status.main_thread_scrolling_reasons); | 1012 status.main_thread_scrolling_reasons); |
| 1013 | 1013 |
| 1014 // The point hits squash2 layer and also scroll layer, because scroll layer is | 1014 // The point hits squash2 layer and also scroll layer, because scroll layer is |
| 1015 // an ancestor of squash2 layer, we should scroll on impl. | 1015 // an ancestor of squash2 layer, we should scroll on impl. |
| 1016 status = host_impl_->ScrollBegin(BeginState(gfx::Point(230, 450)).get(), | 1016 status = host_impl_->ScrollBegin(BeginState(gfx::Point(230, 450)).get(), |
| 1017 InputHandler::WHEEL); | 1017 InputHandler::WHEEL); |
| 1018 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1018 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 TEST_F(LayerTreeHostImplTest, ScrolledOverlappingDrawnScrollbarLayer) { |
| 1022 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 1023 gfx::Size content_size = gfx::Size(360, 600); |
| 1024 gfx::Size scroll_content_size = gfx::Size(345, 3800); |
| 1025 gfx::Size scrollbar_size = gfx::Size(15, 600); |
| 1026 |
| 1027 host_impl_->SetViewportSize(content_size); |
| 1028 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); |
| 1029 root->SetBounds(content_size); |
| 1030 root->SetPosition(gfx::PointF()); |
| 1031 |
| 1032 std::unique_ptr<LayerImpl> clip = LayerImpl::Create(layer_tree_impl, 2); |
| 1033 clip->SetBounds(content_size); |
| 1034 clip->SetPosition(gfx::PointF()); |
| 1035 |
| 1036 std::unique_ptr<LayerImpl> scroll = LayerImpl::Create(layer_tree_impl, 3); |
| 1037 scroll->SetBounds(scroll_content_size); |
| 1038 scroll->SetScrollClipLayer(clip->id()); |
| 1039 scroll->SetDrawsContent(true); |
| 1040 |
| 1041 std::unique_ptr<SolidColorScrollbarLayerImpl> drawn_scrollbar = |
| 1042 SolidColorScrollbarLayerImpl::Create(layer_tree_impl, 4, VERTICAL, 10, 0, |
| 1043 false, true); |
| 1044 drawn_scrollbar->SetBounds(scrollbar_size); |
| 1045 drawn_scrollbar->SetPosition(gfx::PointF(345, 0)); |
| 1046 drawn_scrollbar->SetScrollLayerId(scroll->id()); |
| 1047 drawn_scrollbar->SetDrawsContent(true); |
| 1048 drawn_scrollbar->test_properties()->opacity = 1.f; |
| 1049 |
| 1050 std::unique_ptr<LayerImpl> squash = LayerImpl::Create(layer_tree_impl, 5); |
| 1051 squash->SetBounds(gfx::Size(140, 300)); |
| 1052 squash->SetPosition(gfx::PointF(220, 0)); |
| 1053 squash->SetDrawsContent(true); |
| 1054 |
| 1055 scroll->test_properties()->AddChild(std::move(drawn_scrollbar)); |
| 1056 scroll->test_properties()->AddChild(std::move(squash)); |
| 1057 clip->test_properties()->AddChild(std::move(scroll)); |
| 1058 root->test_properties()->AddChild(std::move(clip)); |
| 1059 |
| 1060 layer_tree_impl->SetRootLayerForTesting(std::move(root)); |
| 1061 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 1062 layer_tree_impl->DidBecomeActive(); |
| 1063 |
| 1064 // The point hits squash layer and also scrollbar layer, but because the |
| 1065 // scrollbar layer is a drawn scrollbar, we cannot scroll on the impl thread. |
| 1066 auto status = host_impl_->ScrollBegin(BeginState(gfx::Point(350, 150)).get(), |
| 1067 InputHandler::WHEEL); |
| 1068 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 1069 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 1070 status.main_thread_scrolling_reasons); |
| 1071 |
| 1072 // The point hits the drawn scrollbar layer completely and should not scroll |
| 1073 // on the impl thread. |
| 1074 status = host_impl_->ScrollBegin(BeginState(gfx::Point(350, 500)).get(), |
| 1075 InputHandler::WHEEL); |
| 1076 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 1077 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 1078 status.main_thread_scrolling_reasons); |
| 1079 } |
| 1080 |
| 1021 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 1081 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
| 1022 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1082 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1023 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1083 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1024 | 1084 |
| 1025 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1085 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 1026 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1086 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 1027 | 1087 |
| 1028 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1088 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1029 DrawFrame(); | 1089 DrawFrame(); |
| 1030 | 1090 |
| (...skipping 10820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11851 else | 11911 else |
| 11852 EXPECT_FALSE(tile->HasRasterTask()); | 11912 EXPECT_FALSE(tile->HasRasterTask()); |
| 11853 } | 11913 } |
| 11854 Region expected_invalidation( | 11914 Region expected_invalidation( |
| 11855 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 11915 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
| 11856 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 11916 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 11857 } | 11917 } |
| 11858 | 11918 |
| 11859 } // namespace | 11919 } // namespace |
| 11860 } // namespace cc | 11920 } // namespace cc |
| OLD | NEW |