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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/trees/property_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 050c97edf95ba3365e0e70069807d55773d72b7a..85c2b0e447d8ebf1f7cdee1e79da492a4540c44a 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -6861,6 +6861,52 @@ TEST_F(LayerTreeHostCommonTest, StickyPositionTop) {
sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
}
+TEST_F(LayerTreeHostCommonTest, StickyPositionSubpixelScroll) {
+ scoped_refptr<Layer> root = Layer::Create();
+ scoped_refptr<Layer> container = Layer::Create();
+ scoped_refptr<Layer> scroller = Layer::Create();
+ scoped_refptr<Layer> sticky_pos = Layer::Create();
+ root->AddChild(container);
+ container->AddChild(scroller);
+ scroller->AddChild(sticky_pos);
+ host()->SetRootLayer(root);
+ scroller->SetScrollClipLayerId(container->id());
+
+ LayerStickyPositionConstraint sticky_position;
+ sticky_position.is_sticky = true;
+ sticky_position.is_anchored_bottom = true;
+ sticky_position.bottom_offset = 10.0f;
+ sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 200);
+ sticky_position.scroll_container_relative_sticky_box_rect =
+ gfx::Rect(0, 200, 10, 10);
+ sticky_position.scroll_container_relative_containing_block_rect =
+ gfx::Rect(0, 0, 100, 500);
+ sticky_pos->SetStickyPositionConstraint(sticky_position);
+
+ root->SetBounds(gfx::Size(100, 100));
+ container->SetBounds(gfx::Size(100, 100));
+ scroller->SetBounds(gfx::Size(100, 1000));
+ sticky_pos->SetBounds(gfx::Size(10, 10));
+ sticky_pos->SetPosition(gfx::PointF(0, 200));
+
+ ExecuteCalculateDrawProperties(root.get());
+ host()->host_impl()->CreatePendingTree();
+ host()->CommitAndCreatePendingTree();
+ host()->host_impl()->ActivateSyncTree();
+ LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree();
+
+ LayerImpl* root_impl = layer_tree_impl->LayerById(root->id());
+ LayerImpl* scroller_impl = layer_tree_impl->LayerById(scroller->id());
+ LayerImpl* sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id());
+
+ ExecuteCalculateDrawProperties(root_impl);
+ SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 0.8f));
+ ExecuteCalculateDrawProperties(root_impl);
+ EXPECT_VECTOR2DF_EQ(
+ gfx::Vector2dF(0.f, 80.f),
+ sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
+}
+
TEST_F(LayerTreeHostCommonTest, StickyPositionBottom) {
scoped_refptr<Layer> root = Layer::Create();
scoped_refptr<Layer> container = Layer::Create();
« 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