Chromium Code Reviews| 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> drawnScrollbar = | |
|
ajuma
2017/02/28 00:38:58
drawn_scrollbar
pdr.
2017/02/28 01:01:36
third_party/WebKitten spotted! :D
Done
| |
| 1042 SolidColorScrollbarLayerImpl::Create(layer_tree_impl, 4, VERTICAL, 10, 0, | |
| 1043 false, true); | |
| 1044 drawnScrollbar->SetBounds(scrollbar_size); | |
| 1045 drawnScrollbar->SetPosition(gfx::PointF(345, 0)); | |
| 1046 drawnScrollbar->SetScrollLayerId(scroll->id()); | |
| 1047 drawnScrollbar->SetDrawsContent(true); | |
| 1048 drawnScrollbar->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(drawnScrollbar)); | |
| 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 not an ancestor of squash, we cannot scroll on the impl | |
|
ajuma
2017/02/28 00:38:58
Just to clarify, would things change at all if scr
pdr.
2017/02/28 01:01:36
This comment was incorrectly cribbed from ScrollWi
| |
| 1066 // thread. | |
| 1067 auto status = host_impl_->ScrollBegin(BeginState(gfx::Point(350, 150)).get(), | |
| 1068 InputHandler::WHEEL); | |
| 1069 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | |
| 1070 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | |
| 1071 status.main_thread_scrolling_reasons); | |
| 1072 } | |
| 1073 | |
| 1021 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 1074 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
| 1022 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1075 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1023 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1076 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1024 | 1077 |
| 1025 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1078 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 1026 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1079 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 1027 | 1080 |
| 1028 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1081 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1029 DrawFrame(); | 1082 DrawFrame(); |
| 1030 | 1083 |
| (...skipping 10820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11851 else | 11904 else |
| 11852 EXPECT_FALSE(tile->HasRasterTask()); | 11905 EXPECT_FALSE(tile->HasRasterTask()); |
| 11853 } | 11906 } |
| 11854 Region expected_invalidation( | 11907 Region expected_invalidation( |
| 11855 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 11908 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
| 11856 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 11909 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 11857 } | 11910 } |
| 11858 | 11911 |
| 11859 } // namespace | 11912 } // namespace |
| 11860 } // namespace cc | 11913 } // namespace cc |
| OLD | NEW |