| 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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 7633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7644 // And if we scroll a little further it remains there. | 7644 // And if we scroll a little further it remains there. |
| 7645 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 10.f)); | 7645 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 10.f)); |
| 7646 ExecuteCalculateDrawProperties(root_impl); | 7646 ExecuteCalculateDrawProperties(root_impl); |
| 7647 EXPECT_VECTOR2DF_EQ( | 7647 EXPECT_VECTOR2DF_EQ( |
| 7648 gfx::Vector2dF(-5.f, 10.f), | 7648 gfx::Vector2dF(-5.f, 10.f), |
| 7649 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); | 7649 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); |
| 7650 } | 7650 } |
| 7651 | 7651 |
| 7652 // This tests the main thread updates with a composited sticky container. In | 7652 // This tests the main thread updates with a composited sticky container. In |
| 7653 // this case the position received from main is relative to the container but | 7653 // this case the position received from main is relative to the container but |
| 7654 // the constraint rects are relative to the ancestor scroller. | 7654 // the constraint rects are relative to the ancestor scroller. The |
| 7655 // parent_relative_sticky_box_offset from main also includes the scroll offset. |
| 7655 TEST_F(LayerTreeHostCommonTest, StickyPositionCompositedContainer) { | 7656 TEST_F(LayerTreeHostCommonTest, StickyPositionCompositedContainer) { |
| 7656 scoped_refptr<Layer> root = Layer::Create(); | 7657 scoped_refptr<Layer> root = Layer::Create(); |
| 7657 scoped_refptr<Layer> container = Layer::Create(); | 7658 scoped_refptr<Layer> container = Layer::Create(); |
| 7658 scoped_refptr<Layer> scroller = Layer::Create(); | 7659 scoped_refptr<Layer> scroller = Layer::Create(); |
| 7659 scoped_refptr<Layer> sticky_container = Layer::Create(); | 7660 scoped_refptr<Layer> sticky_container = Layer::Create(); |
| 7660 scoped_refptr<Layer> sticky_pos = Layer::Create(); | 7661 scoped_refptr<Layer> sticky_pos = Layer::Create(); |
| 7661 root->AddChild(container); | 7662 root->AddChild(container); |
| 7662 container->AddChild(scroller); | 7663 container->AddChild(scroller); |
| 7663 scroller->AddChild(sticky_container); | 7664 scroller->AddChild(sticky_container); |
| 7664 sticky_container->AddChild(sticky_pos); | 7665 sticky_container->AddChild(sticky_pos); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7712 | 7713 |
| 7713 // Scroll past the sticking point, the Y coordinate should now be clamped. | 7714 // Scroll past the sticking point, the Y coordinate should now be clamped. |
| 7714 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f)); | 7715 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f)); |
| 7715 ExecuteCalculateDrawProperties(root_impl); | 7716 ExecuteCalculateDrawProperties(root_impl); |
| 7716 EXPECT_VECTOR2DF_EQ( | 7717 EXPECT_VECTOR2DF_EQ( |
| 7717 gfx::Vector2dF(20.f, 10.f), | 7718 gfx::Vector2dF(20.f, 10.f), |
| 7718 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); | 7719 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); |
| 7719 | 7720 |
| 7720 // Now the main thread commits the new position of the sticky element. | 7721 // Now the main thread commits the new position of the sticky element. |
| 7721 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25)); | 7722 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25)); |
| 7723 sticky_position.parent_relative_sticky_box_offset += gfx::Vector2d(0, 25); |
| 7724 sticky_pos->SetStickyPositionConstraint(sticky_position); |
| 7722 sticky_pos->SetPosition(gfx::PointF(0, 15)); | 7725 sticky_pos->SetPosition(gfx::PointF(0, 15)); |
| 7723 ExecuteCalculateDrawProperties(root.get()); | 7726 ExecuteCalculateDrawProperties(root.get()); |
| 7724 host()->host_impl()->CreatePendingTree(); | 7727 host()->host_impl()->CreatePendingTree(); |
| 7725 host()->CommitAndCreatePendingTree(); | 7728 host()->CommitAndCreatePendingTree(); |
| 7726 host()->host_impl()->ActivateSyncTree(); | 7729 host()->host_impl()->ActivateSyncTree(); |
| 7727 layer_tree_impl = host()->host_impl()->active_tree(); | 7730 layer_tree_impl = host()->host_impl()->active_tree(); |
| 7728 root_impl = layer_tree_impl->LayerById(root->id()); | 7731 root_impl = layer_tree_impl->LayerById(root->id()); |
| 7729 scroller_impl = layer_tree_impl->LayerById(scroller->id()); | 7732 scroller_impl = layer_tree_impl->LayerById(scroller->id()); |
| 7730 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); | 7733 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); |
| 7731 | 7734 |
| (...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10752 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10755 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10753 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10756 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10754 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10757 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10755 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10758 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10756 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10759 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10757 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10760 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10758 } | 10761 } |
| 10759 | 10762 |
| 10760 } // namespace | 10763 } // namespace |
| 10761 } // namespace cc | 10764 } // namespace cc |
| OLD | NEW |