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

Side by Side 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, 8 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 unified diff | 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 »
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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 8958 matching lines...) Expand 10 before | Expand all | Expand 10 after
8969 8969
8970 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 8970 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
8971 host->SetRootLayer(root); 8971 host->SetRootLayer(root);
8972 8972
8973 ExecuteCalculateDrawProperties(root.get()); 8973 ExecuteCalculateDrawProperties(root.get());
8974 8974
8975 gfx::Rect expected(0, 0, 100, 100); 8975 gfx::Rect expected(0, 0, 100, 100);
8976 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees()); 8976 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
8977 } 8977 }
8978 8978
8979 TEST_F(LayerTreeHostCommonTest,
8980 PropertyTreesAccountForScrollCompensationAdjustment) {
8981 gfx::Transform identity;
8982 gfx::Transform translate_z;
8983 translate_z.Translate3d(0, 0, 10);
8984
8985 scoped_refptr<Layer> root = Layer::Create();
8986 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8987 gfx::PointF(), gfx::Size(800, 800), true, false);
8988 root->SetIsContainerForFixedPositionLayers(true);
8989
8990 scoped_refptr<Layer> frame_clip = Layer::Create();
8991 SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(),
8992 gfx::PointF(500, 100), gfx::Size(100, 100), true,
8993 false);
8994 frame_clip->SetMasksToBounds(true);
8995
8996 scoped_refptr<LayerWithForcedDrawsContent> scroller =
8997 make_scoped_refptr(new LayerWithForcedDrawsContent());
8998 SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(),
8999 gfx::PointF(), gfx::Size(1000, 1000), true,
9000 false);
9001
9002 scroller->SetScrollCompensationAdjustment(gfx::Vector2dF(0.3f, 0.7f));
9003 scroller->SetScrollOffset(gfx::ScrollOffset(0.3, 0.7));
9004 scroller->SetScrollClipLayerId(frame_clip->id());
9005
9006 scoped_refptr<LayerWithForcedDrawsContent> fixed =
9007 make_scoped_refptr(new LayerWithForcedDrawsContent());
9008 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
9009 gfx::PointF(), gfx::Size(50, 50), true, false);
9010
9011 LayerPositionConstraint constraint;
9012 constraint.set_is_fixed_position(true);
9013 fixed->SetPositionConstraint(constraint);
9014
9015 scoped_refptr<LayerWithForcedDrawsContent> fixed_child =
9016 make_scoped_refptr(new LayerWithForcedDrawsContent());
9017 SetLayerPropertiesForTesting(fixed_child.get(), identity, gfx::Point3F(),
9018 gfx::PointF(), gfx::Size(10, 10), true, false);
9019
9020 fixed_child->SetPositionConstraint(constraint);
9021
9022 root->AddChild(frame_clip);
9023 frame_clip->AddChild(scroller);
9024 scroller->AddChild(fixed);
9025 fixed->AddChild(fixed_child);
9026
9027 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9028 host->SetRootLayer(root);
9029
9030 ExecuteCalculateDrawProperties(root.get());
9031
9032 gfx::Rect expected(0, 0, 50, 50);
9033 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
9034
9035 expected = gfx::Rect(0, 0, 10, 10);
9036 EXPECT_EQ(expected, fixed_child->visible_rect_from_property_trees());
9037 }
9038
8979 } // namespace 9039 } // namespace
8980 } // namespace cc 9040 } // namespace cc
OLDNEW
« 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