| 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/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/layers/painted_scrollbar_layer_impl.h" | 7 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 8 #include "cc/output/filter_operation.h" | 8 #include "cc/output/filter_operation.h" |
| 9 #include "cc/output/filter_operations.h" | 9 #include "cc/output/filter_operations.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 SkDoubleToMScalar(-100.25)); | 409 SkDoubleToMScalar(-100.25)); |
| 410 | 410 |
| 411 layer->SetTransform(transform); | 411 layer->SetTransform(transform); |
| 412 EXPECT_TRUE(layer->transform().IsInvertible()); | 412 EXPECT_TRUE(layer->transform().IsInvertible()); |
| 413 EXPECT_TRUE(layer->transform_is_invertible()); | 413 EXPECT_TRUE(layer->transform_is_invertible()); |
| 414 } | 414 } |
| 415 | 415 |
| 416 class LayerImplScrollTest : public testing::Test { | 416 class LayerImplScrollTest : public testing::Test { |
| 417 public: | 417 public: |
| 418 LayerImplScrollTest() | 418 LayerImplScrollTest() |
| 419 : host_impl_(&proxy_, &shared_bitmap_manager_), root_id_(7) { | 419 : host_impl_(settings(), &proxy_, &shared_bitmap_manager_), root_id_(7) { |
| 420 host_impl_.active_tree()->SetRootLayer( | 420 host_impl_.active_tree()->SetRootLayer( |
| 421 LayerImpl::Create(host_impl_.active_tree(), root_id_)); | 421 LayerImpl::Create(host_impl_.active_tree(), root_id_)); |
| 422 host_impl_.active_tree()->root_layer()->AddChild( | 422 host_impl_.active_tree()->root_layer()->AddChild( |
| 423 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); | 423 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); |
| 424 layer()->SetScrollClipLayer(root_id_); | 424 layer()->SetScrollClipLayer(root_id_); |
| 425 // Set the max scroll offset by noting that the root layer has bounds (1,1), | 425 // Set the max scroll offset by noting that the root layer has bounds (1,1), |
| 426 // thus whatever bounds are set for the layer will be the max scroll | 426 // thus whatever bounds are set for the layer will be the max scroll |
| 427 // offset plus 1 in each direction. | 427 // offset plus 1 in each direction. |
| 428 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); | 428 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); |
| 429 gfx::Vector2d max_scroll_offset(51, 81); | 429 gfx::Vector2d max_scroll_offset(51, 81); |
| 430 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); | 430 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); |
| 431 } | 431 } |
| 432 | 432 |
| 433 LayerImpl* layer() { | 433 LayerImpl* layer() { |
| 434 return host_impl_.active_tree()->root_layer()->children()[0]; | 434 return host_impl_.active_tree()->root_layer()->children()[0]; |
| 435 } | 435 } |
| 436 | 436 |
| 437 LayerTreeImpl* tree() { return host_impl_.active_tree(); } | 437 LayerTreeImpl* tree() { return host_impl_.active_tree(); } |
| 438 | 438 |
| 439 LayerTreeSettings settings() { |
| 440 LayerTreeSettings settings; |
| 441 settings.use_pinch_virtual_viewport = true; |
| 442 return settings; |
| 443 } |
| 444 |
| 439 private: | 445 private: |
| 440 FakeImplProxy proxy_; | 446 FakeImplProxy proxy_; |
| 441 TestSharedBitmapManager shared_bitmap_manager_; | 447 TestSharedBitmapManager shared_bitmap_manager_; |
| 442 FakeLayerTreeHostImpl host_impl_; | 448 FakeLayerTreeHostImpl host_impl_; |
| 443 int root_id_; | 449 int root_id_; |
| 444 }; | 450 }; |
| 445 | 451 |
| 446 TEST_F(LayerImplScrollTest, ScrollByWithZeroOffset) { | 452 TEST_F(LayerImplScrollTest, ScrollByWithZeroOffset) { |
| 447 // Test that LayerImpl::ScrollBy only affects ScrollDelta and total scroll | 453 // Test that LayerImpl::ScrollBy only affects ScrollDelta and total scroll |
| 448 // offset is bounded by the range [0, max scroll offset]. | 454 // offset is bounded by the range [0, max scroll offset]. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 658 |
| 653 layer()->ApplySentScrollDeltasFromAbortedCommit(); | 659 layer()->ApplySentScrollDeltasFromAbortedCommit(); |
| 654 | 660 |
| 655 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(scroll_offset, scroll_delta), | 661 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(scroll_offset, scroll_delta), |
| 656 layer()->TotalScrollOffset()); | 662 layer()->TotalScrollOffset()); |
| 657 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(scroll_offset, sent_scroll_delta), | 663 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(scroll_offset, sent_scroll_delta), |
| 658 layer()->scroll_offset()); | 664 layer()->scroll_offset()); |
| 659 EXPECT_VECTOR_EQ(gfx::Vector2d(), layer()->sent_scroll_delta()); | 665 EXPECT_VECTOR_EQ(gfx::Vector2d(), layer()->sent_scroll_delta()); |
| 660 } | 666 } |
| 661 | 667 |
| 662 // The user-scrollability breaks for zoomed-in pages. So disable this. | 668 TEST_F(LayerImplScrollTest, ScrollUserUnscrollableLayer) { |
| 663 // http://crbug.com/322223 | |
| 664 TEST_F(LayerImplScrollTest, DISABLED_ScrollUserUnscrollableLayer) { | |
| 665 gfx::ScrollOffset scroll_offset(10, 5); | 669 gfx::ScrollOffset scroll_offset(10, 5); |
| 666 gfx::Vector2dF scroll_delta(20.5f, 8.5f); | 670 gfx::Vector2dF scroll_delta(20.5f, 8.5f); |
| 667 | 671 |
| 668 layer()->set_user_scrollable_vertical(false); | 672 layer()->set_user_scrollable_vertical(false); |
| 669 layer()->SetScrollOffset(scroll_offset); | 673 layer()->SetScrollOffset(scroll_offset); |
| 670 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); | 674 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); |
| 671 | 675 |
| 672 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); | 676 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); |
| 673 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); | 677 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); |
| 674 } | 678 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 693 layer()->id(), tree()->root_layer()->id()); | 697 layer()->id(), tree()->root_layer()->id()); |
| 694 | 698 |
| 695 float expected_horizontal_maximum = | 699 float expected_horizontal_maximum = |
| 696 layer()->bounds().width() - tree()->root_layer()->bounds().width(); | 700 layer()->bounds().width() - tree()->root_layer()->bounds().width(); |
| 697 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum()); | 701 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum()); |
| 698 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos()); | 702 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos()); |
| 699 } | 703 } |
| 700 | 704 |
| 701 } // namespace | 705 } // namespace |
| 702 } // namespace cc | 706 } // namespace cc |
| OLD | NEW |