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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1021823006: Fix scroll position adjustment for fixed-position layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 9 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 | « cc/trees/draw_property_utils.cc ('k') | cc/trees/property_tree.h » ('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 0df2b47986e87b56c1481a2a344ee69a756f8e80..0449a8a5108f051c758fdd011ea73639f50a04fa 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -8976,5 +8976,65 @@ TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) {
EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
}
+TEST_F(LayerTreeHostCommonTest,
+ PropertyTreesAccountForScrollCompensationAdjustment) {
+ gfx::Transform identity;
+ gfx::Transform translate_z;
+ translate_z.Translate3d(0, 0, 10);
+
+ scoped_refptr<Layer> root = Layer::Create();
+ SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(800, 800), true, false);
+ root->SetIsContainerForFixedPositionLayers(true);
+
+ scoped_refptr<Layer> frame_clip = Layer::Create();
+ SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(),
+ gfx::PointF(500, 100), gfx::Size(100, 100), true,
+ false);
+ frame_clip->SetMasksToBounds(true);
+
+ scoped_refptr<LayerWithForcedDrawsContent> scroller =
+ make_scoped_refptr(new LayerWithForcedDrawsContent());
+ SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(1000, 1000), true,
+ false);
+
+ scroller->SetScrollCompensationAdjustment(gfx::Vector2dF(0.3f, 0.7f));
+ scroller->SetScrollOffset(gfx::ScrollOffset(0.3, 0.7));
+ scroller->SetScrollClipLayerId(frame_clip->id());
+
+ scoped_refptr<LayerWithForcedDrawsContent> fixed =
+ make_scoped_refptr(new LayerWithForcedDrawsContent());
+ SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false);
+
+ LayerPositionConstraint constraint;
+ constraint.set_is_fixed_position(true);
+ fixed->SetPositionConstraint(constraint);
+
+ scoped_refptr<LayerWithForcedDrawsContent> fixed_child =
+ make_scoped_refptr(new LayerWithForcedDrawsContent());
+ SetLayerPropertiesForTesting(fixed_child.get(), identity, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(10, 10), true, false);
+
+ fixed_child->SetPositionConstraint(constraint);
+
+ root->AddChild(frame_clip);
+ frame_clip->AddChild(scroller);
+ scroller->AddChild(fixed);
+ fixed->AddChild(fixed_child);
+
+ scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
+ host->SetRootLayer(root);
+
+ ExecuteCalculateDrawProperties(root.get());
+
+ gfx::Rect expected(0, 0, 50, 50);
+ EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
+
+ expected = gfx::Rect(0, 0, 10, 10);
+ EXPECT_EQ(expected, fixed_child->visible_rect_from_property_trees());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698