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

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

Issue 2886243004: Refactor RegisterViewportLayers to use a struct instead of 6 values (Closed)
Patch Set: CC_EXPORT ViewportLayers to make the Windows compile+link happy. Created 3 years, 7 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/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest.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 6530 matching lines...) Expand 10 before | Expand all | Expand 10 after
6541 } 6541 }
6542 6542
6543 TEST_F(LayerTreeHostCommonTest, StickyPositionBottomInnerViewportDelta) { 6543 TEST_F(LayerTreeHostCommonTest, StickyPositionBottomInnerViewportDelta) {
6544 scoped_refptr<Layer> root = Layer::Create(); 6544 scoped_refptr<Layer> root = Layer::Create();
6545 scoped_refptr<Layer> scroller = Layer::Create(); 6545 scoped_refptr<Layer> scroller = Layer::Create();
6546 scoped_refptr<Layer> sticky_pos = Layer::Create(); 6546 scoped_refptr<Layer> sticky_pos = Layer::Create();
6547 root->AddChild(scroller); 6547 root->AddChild(scroller);
6548 scroller->AddChild(sticky_pos); 6548 scroller->AddChild(sticky_pos);
6549 host()->SetRootLayer(root); 6549 host()->SetRootLayer(root);
6550 scroller->SetScrollClipLayerId(root->id()); 6550 scroller->SetScrollClipLayerId(root->id());
6551 host()->RegisterViewportLayers(nullptr, root, root, nullptr, scroller, 6551 LayerTreeHost::ViewportLayers viewport_layers;
6552 nullptr); 6552 viewport_layers.page_scale = root;
6553 viewport_layers.inner_viewport_container = root;
6554 viewport_layers.inner_viewport_scroll = scroller;
6555 host()->RegisterViewportLayers(viewport_layers);
6553 6556
6554 LayerStickyPositionConstraint sticky_position; 6557 LayerStickyPositionConstraint sticky_position;
6555 sticky_position.is_sticky = true; 6558 sticky_position.is_sticky = true;
6556 sticky_position.is_anchored_bottom = true; 6559 sticky_position.is_anchored_bottom = true;
6557 sticky_position.bottom_offset = 10.0f; 6560 sticky_position.bottom_offset = 10.0f;
6558 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); 6561 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70);
6559 sticky_position.scroll_container_relative_sticky_box_rect = 6562 sticky_position.scroll_container_relative_sticky_box_rect =
6560 gfx::Rect(0, 70, 10, 10); 6563 gfx::Rect(0, 70, 10, 10);
6561 sticky_position.scroll_container_relative_containing_block_rect = 6564 sticky_position.scroll_container_relative_containing_block_rect =
6562 gfx::Rect(0, 60, 100, 100); 6565 gfx::Rect(0, 60, 100, 100);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6615 scoped_refptr<Layer> outer_clip = Layer::Create(); 6618 scoped_refptr<Layer> outer_clip = Layer::Create();
6616 scoped_refptr<Layer> outer_viewport = Layer::Create(); 6619 scoped_refptr<Layer> outer_viewport = Layer::Create();
6617 scoped_refptr<Layer> sticky_pos = Layer::Create(); 6620 scoped_refptr<Layer> sticky_pos = Layer::Create();
6618 root->AddChild(scroller); 6621 root->AddChild(scroller);
6619 scroller->AddChild(outer_clip); 6622 scroller->AddChild(outer_clip);
6620 outer_clip->AddChild(outer_viewport); 6623 outer_clip->AddChild(outer_viewport);
6621 outer_viewport->AddChild(sticky_pos); 6624 outer_viewport->AddChild(sticky_pos);
6622 host()->SetRootLayer(root); 6625 host()->SetRootLayer(root);
6623 scroller->SetScrollClipLayerId(root->id()); 6626 scroller->SetScrollClipLayerId(root->id());
6624 outer_viewport->SetScrollClipLayerId(outer_clip->id()); 6627 outer_viewport->SetScrollClipLayerId(outer_clip->id());
6625 host()->RegisterViewportLayers(nullptr, root, root, outer_clip, scroller, 6628 LayerTreeHost::ViewportLayers viewport_layers;
6626 outer_viewport); 6629 viewport_layers.page_scale = root;
6630 viewport_layers.inner_viewport_container = root;
6631 viewport_layers.outer_viewport_container = outer_clip;
6632 viewport_layers.inner_viewport_scroll = scroller;
6633 viewport_layers.outer_viewport_scroll = outer_viewport;
6634 host()->RegisterViewportLayers(viewport_layers);
6627 6635
6628 LayerStickyPositionConstraint sticky_position; 6636 LayerStickyPositionConstraint sticky_position;
6629 sticky_position.is_sticky = true; 6637 sticky_position.is_sticky = true;
6630 sticky_position.is_anchored_bottom = true; 6638 sticky_position.is_anchored_bottom = true;
6631 sticky_position.bottom_offset = 10.0f; 6639 sticky_position.bottom_offset = 10.0f;
6632 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); 6640 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70);
6633 sticky_position.scroll_container_relative_sticky_box_rect = 6641 sticky_position.scroll_container_relative_sticky_box_rect =
6634 gfx::Rect(0, 70, 10, 10); 6642 gfx::Rect(0, 70, 10, 10);
6635 sticky_position.scroll_container_relative_containing_block_rect = 6643 sticky_position.scroll_container_relative_containing_block_rect =
6636 gfx::Rect(0, 60, 100, 100); 6644 gfx::Rect(0, 60, 100, 100);
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
8166 8174
8167 inner_viewport_scroll_layer->SetScrollClipLayerId( 8175 inner_viewport_scroll_layer->SetScrollClipLayerId(
8168 inner_viewport_container_layer->id()); 8176 inner_viewport_container_layer->id());
8169 outer_viewport_scroll_layer->SetScrollClipLayerId( 8177 outer_viewport_scroll_layer->SetScrollClipLayerId(
8170 outer_viewport_container_layer->id()); 8178 outer_viewport_container_layer->id());
8171 8179
8172 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); 8180 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
8173 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); 8181 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
8174 8182
8175 host()->SetRootLayer(root); 8183 host()->SetRootLayer(root);
8176 host()->RegisterViewportLayers(nullptr, root, inner_viewport_container_layer, 8184 LayerTreeHost::ViewportLayers viewport_layers;
8177 outer_viewport_container_layer, 8185 viewport_layers.page_scale = root;
8178 inner_viewport_scroll_layer, 8186 viewport_layers.inner_viewport_container = inner_viewport_container_layer;
8179 outer_viewport_scroll_layer); 8187 viewport_layers.outer_viewport_container = outer_viewport_container_layer;
8188 viewport_layers.inner_viewport_scroll = inner_viewport_scroll_layer;
8189 viewport_layers.outer_viewport_scroll = outer_viewport_scroll_layer;
8190 host()->RegisterViewportLayers(viewport_layers);
8180 8191
8181 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); 8192 scoped_refptr<Layer> fixed_to_inner = Layer::Create();
8182 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); 8193 scoped_refptr<Layer> fixed_to_outer = Layer::Create();
8183 8194
8184 inner_viewport_scroll_layer->AddChild(fixed_to_inner); 8195 inner_viewport_scroll_layer->AddChild(fixed_to_inner);
8185 outer_viewport_scroll_layer->AddChild(fixed_to_outer); 8196 outer_viewport_scroll_layer->AddChild(fixed_to_outer);
8186 8197
8187 LayerPositionConstraint fixed_to_right; 8198 LayerPositionConstraint fixed_to_right;
8188 fixed_to_right.set_is_fixed_position(true); 8199 fixed_to_right.set_is_fixed_position(true);
8189 fixed_to_right.set_is_fixed_to_right_edge(true); 8200 fixed_to_right.set_is_fixed_to_right_edge(true);
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
9996 MainThreadScrollingReason::kScrollbarScrolling); 10007 MainThreadScrollingReason::kScrollbarScrolling);
9997 10008
9998 child7->SetScrollClipLayerId(parent3->id()); 10009 child7->SetScrollClipLayerId(parent3->id());
9999 10010
10000 child8->SetScrollParent(child7.get()); 10011 child8->SetScrollParent(child7.get());
10001 grand_child11->SetScrollClipLayerId(parent3->id()); 10012 grand_child11->SetScrollClipLayerId(parent3->id());
10002 10013
10003 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 10014 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
10004 parent5->SetBounds(gfx::Size(10, 10)); 10015 parent5->SetBounds(gfx::Size(10, 10));
10005 10016
10006 host()->RegisterViewportLayers(nullptr, page_scale_layer, root1, nullptr, 10017 LayerTreeHost::ViewportLayers viewport_layers;
10007 parent2, nullptr); 10018 viewport_layers.page_scale = page_scale_layer;
10019 viewport_layers.inner_viewport_container = root1;
10020 viewport_layers.inner_viewport_scroll = parent2;
10021 host()->RegisterViewportLayers(viewport_layers);
10008 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root1.get()); 10022 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root1.get());
10009 10023
10010 const int kRootPropertyTreeNodeId = 0; 10024 const int kRootPropertyTreeNodeId = 0;
10011 10025
10012 // Property tree root 10026 // Property tree root
10013 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree; 10027 ScrollTree& scroll_tree = host()->property_trees()->scroll_tree;
10014 PropertyTrees property_trees; 10028 PropertyTrees property_trees;
10015 property_trees.is_main_thread = true; 10029 property_trees.is_main_thread = true;
10016 property_trees.is_active = false; 10030 property_trees.is_active = false;
10017 ScrollTree& expected_scroll_tree = property_trees.scroll_tree; 10031 ScrollTree& expected_scroll_tree = property_trees.scroll_tree;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
10154 10168
10155 // Check child layer draw properties. 10169 // Check child layer draw properties.
10156 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10170 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10157 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10171 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10158 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10172 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10159 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10173 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10160 } 10174 }
10161 10175
10162 } // namespace 10176 } // namespace
10163 } // namespace cc 10177 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698