| 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/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 virtual void SetupTree() OVERRIDE { | 446 virtual void SetupTree() OVERRIDE { |
| 447 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 447 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
| 448 | 448 |
| 449 scoped_refptr<Layer> root_layer = Layer::Create(); | 449 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 450 root_layer->SetBounds(gfx::Size(10, 10)); | 450 root_layer->SetBounds(gfx::Size(10, 10)); |
| 451 | 451 |
| 452 root_scroll_layer_ = ContentLayer::Create(&fake_content_layer_client_); | 452 root_scroll_layer_ = ContentLayer::Create(&fake_content_layer_client_); |
| 453 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); | 453 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); |
| 454 | 454 |
| 455 root_scroll_layer_->SetPosition(gfx::Point()); | 455 root_scroll_layer_->SetPosition(gfx::Point()); |
| 456 root_scroll_layer_->SetAnchorPoint(gfx::PointF()); | |
| 457 | 456 |
| 458 root_scroll_layer_->SetIsDrawable(true); | 457 root_scroll_layer_->SetIsDrawable(true); |
| 459 root_scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 458 root_scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
| 460 root_scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 459 root_scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
| 461 root_layer->AddChild(root_scroll_layer_); | 460 root_layer->AddChild(root_scroll_layer_); |
| 462 | 461 |
| 463 child_layer_ = ContentLayer::Create(&fake_content_layer_client_); | 462 child_layer_ = ContentLayer::Create(&fake_content_layer_client_); |
| 464 child_layer_->set_did_scroll_callback( | 463 child_layer_->set_did_scroll_callback( |
| 465 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, | 464 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, |
| 466 base::Unretained(this))); | 465 base::Unretained(this))); |
| 467 child_layer_->SetBounds(gfx::Size(110, 110)); | 466 child_layer_->SetBounds(gfx::Size(110, 110)); |
| 468 | 467 |
| 469 if (scroll_child_layer_) { | 468 if (scroll_child_layer_) { |
| 470 // Scrolls on the child layer will happen at 5, 5. If they are treated | 469 // Scrolls on the child layer will happen at 5, 5. If they are treated |
| 471 // like device pixels, and device scale factor is 2, then they will | 470 // like device pixels, and device scale factor is 2, then they will |
| 472 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. | 471 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. |
| 473 child_layer_->SetPosition(gfx::Point(5, 5)); | 472 child_layer_->SetPosition(gfx::Point(5, 5)); |
| 474 } else { | 473 } else { |
| 475 // Adjust the child layer horizontally so that scrolls will never hit it. | 474 // Adjust the child layer horizontally so that scrolls will never hit it. |
| 476 child_layer_->SetPosition(gfx::Point(60, 5)); | 475 child_layer_->SetPosition(gfx::Point(60, 5)); |
| 477 } | 476 } |
| 478 child_layer_->SetAnchorPoint(gfx::PointF()); | |
| 479 | 477 |
| 480 child_layer_->SetIsDrawable(true); | 478 child_layer_->SetIsDrawable(true); |
| 481 child_layer_->SetScrollClipLayerId(root_layer->id()); | 479 child_layer_->SetScrollClipLayerId(root_layer->id()); |
| 482 child_layer_->SetBounds(root_scroll_layer_->bounds()); | 480 child_layer_->SetBounds(root_scroll_layer_->bounds()); |
| 483 root_scroll_layer_->AddChild(child_layer_); | 481 root_scroll_layer_->AddChild(child_layer_); |
| 484 | 482 |
| 485 if (scroll_child_layer_) { | 483 if (scroll_child_layer_) { |
| 486 expected_scroll_layer_ = child_layer_; | 484 expected_scroll_layer_ = child_layer_; |
| 487 expected_no_scroll_layer_ = root_scroll_layer_; | 485 expected_no_scroll_layer_ = root_scroll_layer_; |
| 488 } else { | 486 } else { |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 } | 1200 } |
| 1203 LayerTreeHostScrollTestLayerStructureChange* owner_; | 1201 LayerTreeHostScrollTestLayerStructureChange* owner_; |
| 1204 Layer* layer_; | 1202 Layer* layer_; |
| 1205 }; | 1203 }; |
| 1206 | 1204 |
| 1207 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { | 1205 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { |
| 1208 scoped_refptr<Layer> scroll_layer = | 1206 scoped_refptr<Layer> scroll_layer = |
| 1209 ContentLayer::Create(&fake_content_layer_client_); | 1207 ContentLayer::Create(&fake_content_layer_client_); |
| 1210 scroll_layer->SetBounds(gfx::Size(110, 110)); | 1208 scroll_layer->SetBounds(gfx::Size(110, 110)); |
| 1211 scroll_layer->SetPosition(gfx::Point(0, 0)); | 1209 scroll_layer->SetPosition(gfx::Point(0, 0)); |
| 1212 scroll_layer->SetAnchorPoint(gfx::PointF()); | |
| 1213 scroll_layer->SetIsDrawable(true); | 1210 scroll_layer->SetIsDrawable(true); |
| 1214 scroll_layer->SetScrollClipLayerId(parent->id()); | 1211 scroll_layer->SetScrollClipLayerId(parent->id()); |
| 1215 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, | 1212 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, |
| 1216 parent->bounds().height() + 100)); | 1213 parent->bounds().height() + 100)); |
| 1217 scroll_layer->set_did_scroll_callback(base::Bind( | 1214 scroll_layer->set_did_scroll_callback(base::Bind( |
| 1218 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); | 1215 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); |
| 1219 client->owner_ = this; | 1216 client->owner_ = this; |
| 1220 client->layer_ = scroll_layer.get(); | 1217 client->layer_ = scroll_layer.get(); |
| 1221 parent->AddChild(scroll_layer); | 1218 parent->AddChild(scroll_layer); |
| 1222 return scroll_layer.get(); | 1219 return scroll_layer.get(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1235 RunTest(true, false, false); | 1232 RunTest(true, false, false); |
| 1236 } | 1233 } |
| 1237 | 1234 |
| 1238 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1235 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
| 1239 scroll_destroy_whole_tree_ = true; | 1236 scroll_destroy_whole_tree_ = true; |
| 1240 RunTest(true, false, false); | 1237 RunTest(true, false, false); |
| 1241 } | 1238 } |
| 1242 | 1239 |
| 1243 } // namespace | 1240 } // namespace |
| 1244 } // namespace cc | 1241 } // namespace cc |
| OLD | NEW |