| 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/base/thread_impl.h" | 8 #include "cc/base/thread_impl.h" |
| 9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 class LayerTreeHostScrollTestLayerStructureChange | 755 class LayerTreeHostScrollTestLayerStructureChange |
| 756 : public LayerTreeHostScrollTest { | 756 : public LayerTreeHostScrollTest { |
| 757 public: | 757 public: |
| 758 LayerTreeHostScrollTestLayerStructureChange() | 758 LayerTreeHostScrollTestLayerStructureChange() |
| 759 : scroll_destroy_whole_tree_(false) {} | 759 : scroll_destroy_whole_tree_(false) {} |
| 760 | 760 |
| 761 virtual void SetupTree() OVERRIDE { | 761 virtual void SetupTree() OVERRIDE { |
| 762 scoped_refptr<Layer> root_layer = Layer::Create(); | 762 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 763 root_layer->SetBounds(gfx::Size(10, 10)); | 763 root_layer->SetBounds(gfx::Size(10, 10)); |
| 764 | 764 |
| 765 Layer* root_scroll_layer = CreateScrollLayer(root_layer, | 765 Layer* root_scroll_layer = |
| 766 &root_scroll_layer_client_); | 766 CreateScrollLayer(root_layer.get(), &root_scroll_layer_client_); |
| 767 CreateScrollLayer(root_layer, &sibling_scroll_layer_client_); | 767 CreateScrollLayer(root_layer.get(), &sibling_scroll_layer_client_); |
| 768 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); | 768 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); |
| 769 | 769 |
| 770 layer_tree_host()->SetRootLayer(root_layer); | 770 layer_tree_host()->SetRootLayer(root_layer); |
| 771 LayerTreeHostScrollTest::SetupTree(); | 771 LayerTreeHostScrollTest::SetupTree(); |
| 772 } | 772 } |
| 773 | 773 |
| 774 virtual void BeginTest() OVERRIDE { | 774 virtual void BeginTest() OVERRIDE { |
| 775 PostSetNeedsCommitToMainThread(); | 775 PostSetNeedsCommitToMainThread(); |
| 776 } | 776 } |
| 777 | 777 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 scoped_refptr<Layer> scroll_layer = | 815 scoped_refptr<Layer> scroll_layer = |
| 816 ContentLayer::Create(&fake_content_layer_client_); | 816 ContentLayer::Create(&fake_content_layer_client_); |
| 817 scroll_layer->SetBounds(gfx::Size(110, 110)); | 817 scroll_layer->SetBounds(gfx::Size(110, 110)); |
| 818 scroll_layer->SetPosition(gfx::Point(0, 0)); | 818 scroll_layer->SetPosition(gfx::Point(0, 0)); |
| 819 scroll_layer->SetAnchorPoint(gfx::PointF()); | 819 scroll_layer->SetAnchorPoint(gfx::PointF()); |
| 820 scroll_layer->SetIsDrawable(true); | 820 scroll_layer->SetIsDrawable(true); |
| 821 scroll_layer->SetScrollable(true); | 821 scroll_layer->SetScrollable(true); |
| 822 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(100, 100)); | 822 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
| 823 scroll_layer->set_layer_scroll_client(client); | 823 scroll_layer->set_layer_scroll_client(client); |
| 824 client->owner_ = this; | 824 client->owner_ = this; |
| 825 client->layer_ = scroll_layer; | 825 client->layer_ = scroll_layer.get(); |
| 826 parent->AddChild(scroll_layer); | 826 parent->AddChild(scroll_layer); |
| 827 return scroll_layer.get(); | 827 return scroll_layer.get(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 FakeWebLayerScrollClient root_scroll_layer_client_; | 830 FakeWebLayerScrollClient root_scroll_layer_client_; |
| 831 FakeWebLayerScrollClient sibling_scroll_layer_client_; | 831 FakeWebLayerScrollClient sibling_scroll_layer_client_; |
| 832 FakeWebLayerScrollClient child_scroll_layer_client_; | 832 FakeWebLayerScrollClient child_scroll_layer_client_; |
| 833 | 833 |
| 834 FakeContentLayerClient fake_content_layer_client_; | 834 FakeContentLayerClient fake_content_layer_client_; |
| 835 | 835 |
| 836 bool scroll_destroy_whole_tree_; | 836 bool scroll_destroy_whole_tree_; |
| 837 }; | 837 }; |
| 838 | 838 |
| 839 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyLayer) { | 839 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyLayer) { |
| 840 RunTest(true, false, false); | 840 RunTest(true, false, false); |
| 841 } | 841 } |
| 842 | 842 |
| 843 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 843 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
| 844 scroll_destroy_whole_tree_ = true; | 844 scroll_destroy_whole_tree_ = true; |
| 845 RunTest(true, false, false); | 845 RunTest(true, false, false); |
| 846 } | 846 } |
| 847 | 847 |
| 848 } // namespace | 848 } // namespace |
| 849 } // namespace cc | 849 } // namespace cc |
| OLD | NEW |