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

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

Issue 2911463002: Unify the calculation of main thread offset of sticky element (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/trees/property_tree.cc ('k') | cc/trees/transform_node.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/property_tree_builder.h" 5 #include "cc/trees/property_tree_builder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 static LayerStickyPositionConstraint StickyPositionConstraint(Layer* layer) { 70 static LayerStickyPositionConstraint StickyPositionConstraint(Layer* layer) {
71 return layer->sticky_position_constraint(); 71 return layer->sticky_position_constraint();
72 } 72 }
73 73
74 static LayerStickyPositionConstraint StickyPositionConstraint( 74 static LayerStickyPositionConstraint StickyPositionConstraint(
75 LayerImpl* layer) { 75 LayerImpl* layer) {
76 return layer->test_properties()->sticky_position_constraint; 76 return layer->test_properties()->sticky_position_constraint;
77 } 77 }
78 78
79 static gfx::Size OffsetForStickyPositionFromMainThread(Layer* layer) {
80 return layer->offset_for_sticky_position_from_main_thread();
81 }
82
83 static gfx::Size OffsetForStickyPositionFromMainThread(LayerImpl* layer) {
84 return layer->test_properties()->offset_for_sticky_position_from_main_thread;
85 }
86
79 static LayerImplList& Children(LayerImpl* layer) { 87 static LayerImplList& Children(LayerImpl* layer) {
80 return layer->test_properties()->children; 88 return layer->test_properties()->children;
81 } 89 }
82 90
83 static const LayerList& Children(Layer* layer) { 91 static const LayerList& Children(Layer* layer) {
84 return layer->children(); 92 return layer->children();
85 } 93 }
86 94
87 static LayerImpl* ChildAt(LayerImpl* layer, int index) { 95 static LayerImpl* ChildAt(LayerImpl* layer, int index) {
88 return layer->test_properties()->children[index]; 96 return layer->test_properties()->children[index];
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // viewport bounds change, but do not unconditionally move by that delta 541 // viewport bounds change, but do not unconditionally move by that delta
534 // like fixed position nodes. 542 // like fixed position nodes.
535 if (scroll_ancestor->scrolls_inner_viewport) { 543 if (scroll_ancestor->scrolls_inner_viewport) {
536 data_for_children->property_trees->transform_tree 544 data_for_children->property_trees->transform_tree
537 .AddNodeAffectedByInnerViewportBoundsDelta(node->id); 545 .AddNodeAffectedByInnerViewportBoundsDelta(node->id);
538 } else if (scroll_ancestor->scrolls_outer_viewport) { 546 } else if (scroll_ancestor->scrolls_outer_viewport) {
539 data_for_children->property_trees->transform_tree 547 data_for_children->property_trees->transform_tree
540 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); 548 .AddNodeAffectedByOuterViewportBoundsDelta(node->id);
541 } 549 }
542 } 550 }
543 // TODO(smcgruer): Pass main thread sticky-shifting offsets of
544 // non-promoted ancestors, or promote all ancestor sticky elements.
545 // See http://crbug.com/702229
546 sticky_data->main_thread_offset =
547 layer->position().OffsetFromOrigin() -
548 sticky_data->constraints.parent_relative_sticky_box_offset
549 .OffsetFromOrigin();
550
551 // Copy the ancestor nodes for later use. These layers are guaranteed to 551 // Copy the ancestor nodes for later use. These layers are guaranteed to
552 // have transform nodes at this point because they are our ancestors (so 552 // have transform nodes at this point because they are our ancestors (so
553 // have already been processed) and are sticky (so have transform nodes). 553 // have already been processed) and are sticky (so have transform nodes).
554 int shifting_sticky_box_layer_id = 554 int shifting_sticky_box_layer_id =
555 sticky_data->constraints.nearest_layer_shifting_sticky_box; 555 sticky_data->constraints.nearest_layer_shifting_sticky_box;
556 if (shifting_sticky_box_layer_id != Layer::INVALID_ID) { 556 if (shifting_sticky_box_layer_id != Layer::INVALID_ID) {
557 sticky_data->nearest_node_shifting_sticky_box = 557 sticky_data->nearest_node_shifting_sticky_box =
558 data_for_children->property_trees->transform_tree 558 data_for_children->property_trees->transform_tree
559 .FindNodeIndexFromOwningLayerId(shifting_sticky_box_layer_id); 559 .FindNodeIndexFromOwningLayerId(shifting_sticky_box_layer_id);
560 DCHECK(sticky_data->nearest_node_shifting_sticky_box != 560 DCHECK(sticky_data->nearest_node_shifting_sticky_box !=
561 TransformTree::kInvalidNodeId); 561 TransformTree::kInvalidNodeId);
562 } 562 }
563 int shifting_containing_block_layer_id = 563 int shifting_containing_block_layer_id =
564 sticky_data->constraints.nearest_layer_shifting_containing_block; 564 sticky_data->constraints.nearest_layer_shifting_containing_block;
565 if (shifting_containing_block_layer_id != Layer::INVALID_ID) { 565 if (shifting_containing_block_layer_id != Layer::INVALID_ID) {
566 sticky_data->nearest_node_shifting_containing_block = 566 sticky_data->nearest_node_shifting_containing_block =
567 data_for_children->property_trees->transform_tree 567 data_for_children->property_trees->transform_tree
568 .FindNodeIndexFromOwningLayerId( 568 .FindNodeIndexFromOwningLayerId(
569 shifting_containing_block_layer_id); 569 shifting_containing_block_layer_id);
570 DCHECK(sticky_data->nearest_node_shifting_containing_block != 570 DCHECK(sticky_data->nearest_node_shifting_containing_block !=
571 TransformTree::kInvalidNodeId); 571 TransformTree::kInvalidNodeId);
572 } 572 }
573 node->offset_for_sticky_position_from_main_thread =
574 gfx::Vector2dF(OffsetForStickyPositionFromMainThread(layer).width(),
575 OffsetForStickyPositionFromMainThread(layer).height());
573 } 576 }
574 577
575 node->needs_local_transform_update = true; 578 node->needs_local_transform_update = true;
576 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); 579 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id);
577 580
578 layer->set_offset_to_transform_parent(gfx::Vector2dF()); 581 layer->set_offset_to_transform_parent(gfx::Vector2dF());
579 582
580 // Flattening (if needed) will be handled by |node|. 583 // Flattening (if needed) will be handled by |node|.
581 layer->set_should_flatten_transform_from_property_tree(false); 584 layer->set_should_flatten_transform_from_property_tree(false);
582 585
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1405 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1403 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1406 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1404 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1407 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1405 device_transform, property_trees, color); 1408 device_transform, property_trees, color);
1406 property_trees->effect_tree.CreateOrReuseRenderSurfaces( 1409 property_trees->effect_tree.CreateOrReuseRenderSurfaces(
1407 &render_surfaces, root_layer->layer_tree_impl()); 1410 &render_surfaces, root_layer->layer_tree_impl());
1408 property_trees->ResetCachedData(); 1411 property_trees->ResetCachedData();
1409 } 1412 }
1410 1413
1411 } // namespace cc 1414 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.cc ('k') | cc/trees/transform_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698