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/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 scroll_layer->SetIsDrawable(true); | 43 scroll_layer->SetIsDrawable(true); |
44 scroll_layer->SetIsContainerForFixedPositionLayers(true); | 44 scroll_layer->SetIsContainerForFixedPositionLayers(true); |
45 scroll_layer->SetScrollClipLayerId(root_layer->id()); | 45 scroll_layer->SetScrollClipLayerId(root_layer->id()); |
46 scroll_layer->SetScrollOffset(initial_scroll_); | 46 scroll_layer->SetScrollOffset(initial_scroll_); |
47 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer, NULL); | 47 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer, NULL); |
48 PostSetNeedsCommitToMainThread(); | 48 PostSetNeedsCommitToMainThread(); |
49 } | 49 } |
50 | 50 |
51 virtual void Layout() OVERRIDE { | 51 virtual void Layout() OVERRIDE { |
52 Layer* root = layer_tree_host()->root_layer(); | 52 Layer* root = layer_tree_host()->root_layer(); |
53 Layer* scroll_layer = root->children()[0]; | 53 Layer* scroll_layer = root->children()[0].get(); |
54 if (!layer_tree_host()->source_frame_number()) { | 54 if (!layer_tree_host()->source_frame_number()) { |
55 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); | 55 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); |
56 } else { | 56 } else { |
57 EXPECT_VECTOR_EQ(initial_scroll_ + scroll_amount_, | 57 EXPECT_VECTOR_EQ(initial_scroll_ + scroll_amount_, |
58 scroll_layer->scroll_offset()); | 58 scroll_layer->scroll_offset()); |
59 | 59 |
60 // Pretend like Javascript updated the scroll position itself. | 60 // Pretend like Javascript updated the scroll position itself. |
61 scroll_layer->SetScrollOffset(second_scroll_); | 61 scroll_layer->SetScrollOffset(second_scroll_); |
62 } | 62 } |
63 } | 63 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 214 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
215 root_layer->AddChild(root_scroll_layer); | 215 root_layer->AddChild(root_scroll_layer); |
216 | 216 |
217 layer_tree_host()->RegisterViewportLayers( | 217 layer_tree_host()->RegisterViewportLayers( |
218 root_layer, root_scroll_layer, NULL); | 218 root_layer, root_scroll_layer, NULL); |
219 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 219 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
220 } | 220 } |
221 | 221 |
222 virtual void WillBeginMainFrame() OVERRIDE { | 222 virtual void WillBeginMainFrame() OVERRIDE { |
223 num_will_begin_main_frames_++; | 223 num_will_begin_main_frames_++; |
224 Layer* root_scroll_layer = layer_tree_host()->root_layer()->children()[0]; | 224 Layer* root_scroll_layer = |
| 225 layer_tree_host()->root_layer()->children()[0].get(); |
225 switch (num_will_begin_main_frames_) { | 226 switch (num_will_begin_main_frames_) { |
226 case 1: | 227 case 1: |
227 // This will not be aborted because of the initial prop changes. | 228 // This will not be aborted because of the initial prop changes. |
228 EXPECT_EQ(0, num_impl_scrolls_); | 229 EXPECT_EQ(0, num_impl_scrolls_); |
229 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); | 230 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); |
230 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); | 231 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); |
231 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); | 232 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); |
232 break; | 233 break; |
233 case 2: | 234 case 2: |
234 // This commit will be aborted, and another commit will be | 235 // This commit will be aborted, and another commit will be |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 root_layer, root_scroll_layer, NULL); | 767 root_layer, root_scroll_layer, NULL); |
767 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 768 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
768 } | 769 } |
769 | 770 |
770 virtual void BeginTest() OVERRIDE { | 771 virtual void BeginTest() OVERRIDE { |
771 PostSetNeedsCommitToMainThread(); | 772 PostSetNeedsCommitToMainThread(); |
772 } | 773 } |
773 | 774 |
774 virtual void Layout() OVERRIDE { | 775 virtual void Layout() OVERRIDE { |
775 Layer* root = layer_tree_host()->root_layer(); | 776 Layer* root = layer_tree_host()->root_layer(); |
776 Layer* scroll_layer = root->children()[0]; | 777 Layer* scroll_layer = root->children()[0].get(); |
777 if (!layer_tree_host()->source_frame_number()) { | 778 if (!layer_tree_host()->source_frame_number()) { |
778 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 779 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
779 } else { | 780 } else { |
780 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), | 781 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), |
781 initial_scroll_ + impl_thread_scroll1_); | 782 initial_scroll_ + impl_thread_scroll1_); |
782 | 783 |
783 // Pretend like Javascript updated the scroll position itself with a | 784 // Pretend like Javascript updated the scroll position itself with a |
784 // change of main_thread_scroll. | 785 // change of main_thread_scroll. |
785 scroll_layer->SetScrollOffset(initial_scroll_ + main_thread_scroll_ + | 786 scroll_layer->SetScrollOffset(initial_scroll_ + main_thread_scroll_ + |
786 impl_thread_scroll1_); | 787 impl_thread_scroll1_); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 root_layer, root_scroll_layer, NULL); | 895 root_layer, root_scroll_layer, NULL); |
895 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 896 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
896 } | 897 } |
897 | 898 |
898 virtual void BeginTest() OVERRIDE { | 899 virtual void BeginTest() OVERRIDE { |
899 PostSetNeedsCommitToMainThread(); | 900 PostSetNeedsCommitToMainThread(); |
900 } | 901 } |
901 | 902 |
902 virtual void WillCommit() OVERRIDE { | 903 virtual void WillCommit() OVERRIDE { |
903 Layer* root = layer_tree_host()->root_layer(); | 904 Layer* root = layer_tree_host()->root_layer(); |
904 Layer* scroll_layer = root->children()[0]; | 905 Layer* scroll_layer = root->children()[0].get(); |
905 switch (layer_tree_host()->source_frame_number()) { | 906 switch (layer_tree_host()->source_frame_number()) { |
906 case 0: | 907 case 0: |
907 EXPECT_TRUE(scroll_layer->needs_push_properties()); | 908 EXPECT_TRUE(scroll_layer->needs_push_properties()); |
908 break; | 909 break; |
909 case 1: | 910 case 1: |
910 // Even if this layer doesn't need push properties, it should | 911 // Even if this layer doesn't need push properties, it should |
911 // still pick up scrolls that happen on the active layer during | 912 // still pick up scrolls that happen on the active layer during |
912 // commit. | 913 // commit. |
913 EXPECT_FALSE(scroll_layer->needs_push_properties()); | 914 EXPECT_FALSE(scroll_layer->needs_push_properties()); |
914 break; | 915 break; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 RunTest(true, false, true); | 1215 RunTest(true, false, true); |
1215 } | 1216 } |
1216 | 1217 |
1217 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1218 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
1218 scroll_destroy_whole_tree_ = true; | 1219 scroll_destroy_whole_tree_ = true; |
1219 RunTest(true, false, true); | 1220 RunTest(true, false, true); |
1220 } | 1221 } |
1221 | 1222 |
1222 } // namespace | 1223 } // namespace |
1223 } // namespace cc | 1224 } // namespace cc |
OLD | NEW |