OLD | NEW |
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 Loading... |
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 StickyMainThreadOffset(Layer* layer) { |
| 80 return layer->sticky_main_thread_offset(); |
| 81 } |
| 82 |
| 83 static gfx::Size StickyMainThreadOffset(LayerImpl* layer) { |
| 84 return layer->test_properties()->sticky_main_thread_offset; |
| 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 Loading... |
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->sticky_main_thread_offset = |
| 574 gfx::Vector2dF(StickyMainThreadOffset(layer).width(), |
| 575 StickyMainThreadOffset(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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1407 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
1405 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1408 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
1406 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1409 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
1407 device_transform, property_trees, color); | 1410 device_transform, property_trees, color); |
1408 property_trees->effect_tree.CreateOrReuseRenderSurfaces( | 1411 property_trees->effect_tree.CreateOrReuseRenderSurfaces( |
1409 &render_surfaces, root_layer->layer_tree_impl()); | 1412 &render_surfaces, root_layer->layer_tree_impl()); |
1410 property_trees->ResetCachedData(); | 1413 property_trees->ResetCachedData(); |
1411 } | 1414 } |
1412 | 1415 |
1413 } // namespace cc | 1416 } // namespace cc |
OLD | NEW |