| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1028 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1029 | 1029 |
| 1030 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 1030 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 1031 LayerImpl* root = impl->active_tree()->root_layer(); | 1031 LayerImpl* root = impl->active_tree()->root_layer(); |
| 1032 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); | 1032 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); |
| 1033 scroll_layer->SetScrollClipLayer(root->children()[0]->id()); | 1033 scroll_layer->SetScrollClipLayer(root->children()[0]->id()); |
| 1034 | 1034 |
| 1035 // Set max_scroll_offset = (100, 100). | 1035 // Set max_scroll_offset = (100, 100). |
| 1036 scroll_layer->SetBounds( | 1036 scroll_layer->SetBounds( |
| 1037 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); | 1037 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); |
| 1038 impl->active_tree()->property_trees()->needs_rebuild = true; |
| 1039 impl->active_tree()->BuildPropertyTreesForTesting(); |
| 1038 | 1040 |
| 1039 InputHandler::ScrollStatus status = scroll_layer->TryScroll( | 1041 InputHandler::ScrollStatus status = scroll_layer->TryScroll( |
| 1040 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); | 1042 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); |
| 1041 | 1043 |
| 1042 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1044 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1043 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1045 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1044 status.main_thread_scrolling_reasons); | 1046 status.main_thread_scrolling_reasons); |
| 1045 | 1047 |
| 1046 // Set max_scroll_offset = (0, 0). | 1048 // Set max_scroll_offset = (0, 0). |
| 1047 scroll_layer->SetBounds(root->bounds()); | 1049 scroll_layer->SetBounds(root->bounds()); |
| 1050 impl->active_tree()->property_trees()->needs_rebuild = true; |
| 1051 impl->active_tree()->BuildPropertyTreesForTesting(); |
| 1048 status = scroll_layer->TryScroll( | 1052 status = scroll_layer->TryScroll( |
| 1049 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); | 1053 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); |
| 1050 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 1054 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 1051 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 1055 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 1052 status.main_thread_scrolling_reasons); | 1056 status.main_thread_scrolling_reasons); |
| 1053 | 1057 |
| 1054 // Set max_scroll_offset = (-100, -100). | 1058 // Set max_scroll_offset = (-100, -100). |
| 1055 scroll_layer->SetBounds(gfx::Size()); | 1059 scroll_layer->SetBounds(gfx::Size()); |
| 1060 impl->active_tree()->property_trees()->needs_rebuild = true; |
| 1061 impl->active_tree()->BuildPropertyTreesForTesting(); |
| 1056 status = scroll_layer->TryScroll( | 1062 status = scroll_layer->TryScroll( |
| 1057 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); | 1063 gfx::PointF(0.0f, 1.0f), InputHandler::GESTURE); |
| 1058 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 1064 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 1059 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 1065 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 1060 status.main_thread_scrolling_reasons); | 1066 status.main_thread_scrolling_reasons); |
| 1061 | 1067 |
| 1062 EndTest(); | 1068 EndTest(); |
| 1063 } | 1069 } |
| 1064 | 1070 |
| 1065 void AfterTest() override {} | 1071 void AfterTest() override {} |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 RunTest(CompositorMode::THREADED, false); | 1342 RunTest(CompositorMode::THREADED, false); |
| 1337 } | 1343 } |
| 1338 | 1344 |
| 1339 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1345 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
| 1340 scroll_destroy_whole_tree_ = true; | 1346 scroll_destroy_whole_tree_ = true; |
| 1341 RunTest(CompositorMode::THREADED, false); | 1347 RunTest(CompositorMode::THREADED, false); |
| 1342 } | 1348 } |
| 1343 | 1349 |
| 1344 } // namespace | 1350 } // namespace |
| 1345 } // namespace cc | 1351 } // namespace cc |
| OLD | NEW |