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

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

Issue 2929873002: Shifting layer position for sticky element to avoid passing unnessary variable to cc (Closed)
Patch Set: Bug fix Created 3 years, 6 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/layers/layer_impl_test_properties.h ('k') | 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 6861 matching lines...) Expand 10 before | Expand all | Expand 10 after
6872 6872
6873 LayerStickyPositionConstraint sticky_position; 6873 LayerStickyPositionConstraint sticky_position;
6874 sticky_position.is_sticky = true; 6874 sticky_position.is_sticky = true;
6875 sticky_position.is_anchored_top = true; 6875 sticky_position.is_anchored_top = true;
6876 sticky_position.top_offset = 10.0f; 6876 sticky_position.top_offset = 10.0f;
6877 sticky_position.scroll_container_relative_sticky_box_rect = 6877 sticky_position.scroll_container_relative_sticky_box_rect =
6878 gfx::Rect(10, 20, 10, 10); 6878 gfx::Rect(10, 20, 10, 10);
6879 sticky_position.scroll_container_relative_containing_block_rect = 6879 sticky_position.scroll_container_relative_containing_block_rect =
6880 gfx::Rect(0, 0, 50, 50); 6880 gfx::Rect(0, 0, 50, 50);
6881 sticky_pos->SetStickyPositionConstraint(sticky_position); 6881 sticky_pos->SetStickyPositionConstraint(sticky_position);
6882 sticky_pos->SetElementId(LayerIdToElementIdForTesting(sticky_pos->id()));
6883 6882
6884 root->SetBounds(gfx::Size(100, 100)); 6883 root->SetBounds(gfx::Size(100, 100));
6885 container->SetBounds(gfx::Size(100, 100)); 6884 container->SetBounds(gfx::Size(100, 100));
6886 scroller->SetBounds(gfx::Size(1000, 1000)); 6885 scroller->SetBounds(gfx::Size(1000, 1000));
6887 sticky_pos->SetBounds(gfx::Size(10, 10)); 6886 sticky_pos->SetBounds(gfx::Size(10, 10));
6888 sticky_pos->SetPosition(gfx::PointF(10, 20)); 6887 sticky_pos->SetPosition(gfx::PointF(10, 20));
6889 6888
6890 ExecuteCalculateDrawProperties(root.get()); 6889 ExecuteCalculateDrawProperties(root.get());
6891 host()->host_impl()->CreatePendingTree(); 6890 host()->host_impl()->CreatePendingTree();
6892 host()->CommitAndCreatePendingTree(); 6891 host()->CommitAndCreatePendingTree();
(...skipping 19 matching lines...) Expand all
6912 6911
6913 // Scroll past the sticking point, the Y coordinate should now be clamped. 6912 // Scroll past the sticking point, the Y coordinate should now be clamped.
6914 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 15.f)); 6913 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 15.f));
6915 ExecuteCalculateDrawProperties(root_impl); 6914 ExecuteCalculateDrawProperties(root_impl);
6916 EXPECT_VECTOR2DF_EQ( 6915 EXPECT_VECTOR2DF_EQ(
6917 gfx::Vector2dF(-5.f, 10.f), 6916 gfx::Vector2dF(-5.f, 10.f),
6918 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); 6917 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
6919 6918
6920 // Now the main thread commits the new position of the sticky element. 6919 // Now the main thread commits the new position of the sticky element.
6921 scroller->SetScrollOffset(gfx::ScrollOffset(15, 15)); 6920 scroller->SetScrollOffset(gfx::ScrollOffset(15, 15));
6922 sticky_pos->SetPosition(gfx::PointF(10, 25)); 6921 // Shift the layer by -offset_for_position_sticky.
6923 sticky_pos->SetOffsetForStickyPositionFromMainThread(gfx::Size(0, 5)); 6922 sticky_pos->SetPosition(gfx::PointF(10, 25) - gfx::Vector2dF(0, 5));
6924 ExecuteCalculateDrawProperties(root.get()); 6923 ExecuteCalculateDrawProperties(root.get());
6925 host()->host_impl()->CreatePendingTree(); 6924 host()->host_impl()->CreatePendingTree();
6926 host()->CommitAndCreatePendingTree(); 6925 host()->CommitAndCreatePendingTree();
6927 host()->host_impl()->ActivateSyncTree(); 6926 host()->host_impl()->ActivateSyncTree();
6928 layer_tree_impl = host()->host_impl()->active_tree(); 6927 layer_tree_impl = host()->host_impl()->active_tree();
6929 root_impl = layer_tree_impl->LayerById(root->id()); 6928 root_impl = layer_tree_impl->LayerById(root->id());
6930 scroller_impl = layer_tree_impl->LayerById(scroller->id()); 6929 scroller_impl = layer_tree_impl->LayerById(scroller->id());
6931 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); 6930 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id());
6932 6931
6933 // The element should still be where it was before. We reset the delta to 6932 // The element should still be where it was before. We reset the delta to
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6966 6965
6967 LayerStickyPositionConstraint sticky_position; 6966 LayerStickyPositionConstraint sticky_position;
6968 sticky_position.is_sticky = true; 6967 sticky_position.is_sticky = true;
6969 sticky_position.is_anchored_top = true; 6968 sticky_position.is_anchored_top = true;
6970 sticky_position.top_offset = 10.0f; 6969 sticky_position.top_offset = 10.0f;
6971 sticky_position.scroll_container_relative_sticky_box_rect = 6970 sticky_position.scroll_container_relative_sticky_box_rect =
6972 gfx::Rect(20, 30, 10, 10); 6971 gfx::Rect(20, 30, 10, 10);
6973 sticky_position.scroll_container_relative_containing_block_rect = 6972 sticky_position.scroll_container_relative_containing_block_rect =
6974 gfx::Rect(20, 20, 30, 30); 6973 gfx::Rect(20, 20, 30, 30);
6975 sticky_pos->SetStickyPositionConstraint(sticky_position); 6974 sticky_pos->SetStickyPositionConstraint(sticky_position);
6976 sticky_pos->SetElementId(LayerIdToElementIdForTesting(sticky_pos->id()));
6977 6975
6978 root->SetBounds(gfx::Size(100, 100)); 6976 root->SetBounds(gfx::Size(100, 100));
6979 container->SetBounds(gfx::Size(100, 100)); 6977 container->SetBounds(gfx::Size(100, 100));
6980 scroller->SetBounds(gfx::Size(1000, 1000)); 6978 scroller->SetBounds(gfx::Size(1000, 1000));
6981 sticky_container->SetPosition(gfx::PointF(20, 20)); 6979 sticky_container->SetPosition(gfx::PointF(20, 20));
6982 sticky_container->SetBounds(gfx::Size(30, 30)); 6980 sticky_container->SetBounds(gfx::Size(30, 30));
6983 sticky_pos->SetBounds(gfx::Size(10, 10)); 6981 sticky_pos->SetBounds(gfx::Size(10, 10));
6984 sticky_pos->SetPosition(gfx::PointF(0, 10)); 6982 sticky_pos->SetPosition(gfx::PointF(0, 10));
6985 6983
6986 ExecuteCalculateDrawProperties(root.get()); 6984 ExecuteCalculateDrawProperties(root.get());
(...skipping 21 matching lines...) Expand all
7008 7006
7009 // Scroll past the sticking point, the Y coordinate should now be clamped. 7007 // Scroll past the sticking point, the Y coordinate should now be clamped.
7010 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f)); 7008 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f));
7011 ExecuteCalculateDrawProperties(root_impl); 7009 ExecuteCalculateDrawProperties(root_impl);
7012 EXPECT_VECTOR2DF_EQ( 7010 EXPECT_VECTOR2DF_EQ(
7013 gfx::Vector2dF(20.f, 10.f), 7011 gfx::Vector2dF(20.f, 10.f),
7014 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); 7012 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
7015 7013
7016 // Now the main thread commits the new position of the sticky element. 7014 // Now the main thread commits the new position of the sticky element.
7017 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25)); 7015 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25));
7018 sticky_pos->SetPosition(gfx::PointF(0, 15)); 7016 // Shift the layer by -offset_for_position_sticky.
7019 sticky_pos->SetOffsetForStickyPositionFromMainThread(gfx::Size(0, 5)); 7017 sticky_pos->SetPosition(gfx::PointF(0, 15) - gfx::Vector2dF(0, 5));
7020 ExecuteCalculateDrawProperties(root.get()); 7018 ExecuteCalculateDrawProperties(root.get());
7021 host()->host_impl()->CreatePendingTree(); 7019 host()->host_impl()->CreatePendingTree();
7022 host()->CommitAndCreatePendingTree(); 7020 host()->CommitAndCreatePendingTree();
7023 host()->host_impl()->ActivateSyncTree(); 7021 host()->host_impl()->ActivateSyncTree();
7024 layer_tree_impl = host()->host_impl()->active_tree(); 7022 layer_tree_impl = host()->host_impl()->active_tree();
7025 root_impl = layer_tree_impl->LayerById(root->id()); 7023 root_impl = layer_tree_impl->LayerById(root->id());
7026 scroller_impl = layer_tree_impl->LayerById(scroller->id()); 7024 scroller_impl = layer_tree_impl->LayerById(scroller->id());
7027 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); 7025 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id());
7028 7026
7029 // The element should still be where it was before. We reset the delta to 7027 // The element should still be where it was before. We reset the delta to
(...skipping 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after
10239 10237
10240 // Check child layer draw properties. 10238 // Check child layer draw properties.
10241 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10239 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10242 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10240 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10243 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10241 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10244 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10242 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10245 } 10243 }
10246 10244
10247 } // namespace 10245 } // namespace
10248 } // namespace cc 10246 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl_test_properties.h ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698