Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2432043007: Include scroll snap in scroll position used for sticky offset calculation. (Closed)
Patch Set: Include scroll snap in scroll position used for sticky offset. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/trees/property_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6843 matching lines...) Expand 10 before | Expand all | Expand 10 after
6854 6854
6855 // Scroll past the end of the sticky container (note: this element does not 6855 // Scroll past the end of the sticky container (note: this element does not
6856 // have its own layer as it does not need to be composited). 6856 // have its own layer as it does not need to be composited).
6857 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 50.f)); 6857 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 50.f));
6858 ExecuteCalculateDrawProperties(root_impl); 6858 ExecuteCalculateDrawProperties(root_impl);
6859 EXPECT_VECTOR2DF_EQ( 6859 EXPECT_VECTOR2DF_EQ(
6860 gfx::Vector2dF(-5.f, -10.f), 6860 gfx::Vector2dF(-5.f, -10.f),
6861 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); 6861 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
6862 } 6862 }
6863 6863
6864 TEST_F(LayerTreeHostCommonTest, StickyPositionSubpixelScroll) {
6865 scoped_refptr<Layer> root = Layer::Create();
6866 scoped_refptr<Layer> container = Layer::Create();
6867 scoped_refptr<Layer> scroller = Layer::Create();
6868 scoped_refptr<Layer> sticky_pos = Layer::Create();
6869 root->AddChild(container);
6870 container->AddChild(scroller);
6871 scroller->AddChild(sticky_pos);
6872 host()->SetRootLayer(root);
6873 scroller->SetScrollClipLayerId(container->id());
6874
6875 LayerStickyPositionConstraint sticky_position;
6876 sticky_position.is_sticky = true;
6877 sticky_position.is_anchored_bottom = true;
6878 sticky_position.bottom_offset = 10.0f;
6879 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 200);
6880 sticky_position.scroll_container_relative_sticky_box_rect =
6881 gfx::Rect(0, 200, 10, 10);
6882 sticky_position.scroll_container_relative_containing_block_rect =
6883 gfx::Rect(0, 0, 100, 500);
6884 sticky_pos->SetStickyPositionConstraint(sticky_position);
6885
6886 root->SetBounds(gfx::Size(100, 100));
6887 container->SetBounds(gfx::Size(100, 100));
6888 scroller->SetBounds(gfx::Size(100, 1000));
6889 sticky_pos->SetBounds(gfx::Size(10, 10));
6890 sticky_pos->SetPosition(gfx::PointF(0, 200));
6891
6892 ExecuteCalculateDrawProperties(root.get());
6893 host()->host_impl()->CreatePendingTree();
6894 host()->CommitAndCreatePendingTree();
6895 host()->host_impl()->ActivateSyncTree();
6896 LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree();
6897
6898 LayerImpl* root_impl = layer_tree_impl->LayerById(root->id());
6899 LayerImpl* scroller_impl = layer_tree_impl->LayerById(scroller->id());
6900 LayerImpl* sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id());
6901
6902 ExecuteCalculateDrawProperties(root_impl);
6903 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 0.8f));
6904 ExecuteCalculateDrawProperties(root_impl);
6905 EXPECT_VECTOR2DF_EQ(
6906 gfx::Vector2dF(0.f, 80.f),
6907 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
6908 }
6909
6864 TEST_F(LayerTreeHostCommonTest, StickyPositionBottom) { 6910 TEST_F(LayerTreeHostCommonTest, StickyPositionBottom) {
6865 scoped_refptr<Layer> root = Layer::Create(); 6911 scoped_refptr<Layer> root = Layer::Create();
6866 scoped_refptr<Layer> container = Layer::Create(); 6912 scoped_refptr<Layer> container = Layer::Create();
6867 scoped_refptr<Layer> scroller = Layer::Create(); 6913 scoped_refptr<Layer> scroller = Layer::Create();
6868 scoped_refptr<Layer> sticky_pos = Layer::Create(); 6914 scoped_refptr<Layer> sticky_pos = Layer::Create();
6869 root->AddChild(container); 6915 root->AddChild(container);
6870 container->AddChild(scroller); 6916 container->AddChild(scroller);
6871 scroller->AddChild(sticky_pos); 6917 scroller->AddChild(sticky_pos);
6872 host()->SetRootLayer(root); 6918 host()->SetRootLayer(root);
6873 scroller->SetScrollClipLayerId(container->id()); 6919 scroller->SetScrollClipLayerId(container->id());
(...skipping 3419 matching lines...) Expand 10 before | Expand all | Expand 10 after
10293 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10339 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10294 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10340 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10295 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10341 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10296 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10342 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10297 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10343 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10298 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10344 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10299 } 10345 }
10300 10346
10301 } // namespace 10347 } // namespace
10302 } // namespace cc 10348 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698