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

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

Issue 2733633002: Handle nested position:sticky elements correctly (compositor) (Closed)
Patch Set: Addressed the easier reviewer comments. Created 3 years, 9 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
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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 } 506 }
507 507
508 static inline bool ShouldFlattenTransform(Layer* layer) { 508 static inline bool ShouldFlattenTransform(Layer* layer) {
509 return layer->should_flatten_transform(); 509 return layer->should_flatten_transform();
510 } 510 }
511 511
512 static inline bool ShouldFlattenTransform(LayerImpl* layer) { 512 static inline bool ShouldFlattenTransform(LayerImpl* layer) {
513 return layer->test_properties()->should_flatten_transform; 513 return layer->test_properties()->should_flatten_transform;
514 } 514 }
515 515
516 static inline gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
517 LayerImpl* layer,
518 int scroll_ancestor_layer_id) {
519 NOTREACHED();
520 return gfx::Vector2dF();
521 }
522
523 static inline gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
524 Layer* layer,
525 int scroll_ancestor_layer_id) {
526 return draw_property_utils::CalculateTotalStickyOffsetToScroller(
527 layer, scroll_ancestor_layer_id);
528 }
529
516 template <typename LayerType> 530 template <typename LayerType>
517 bool AddTransformNodeIfNeeded( 531 bool AddTransformNodeIfNeeded(
518 const DataForRecursion<LayerType>& data_from_ancestor, 532 const DataForRecursion<LayerType>& data_from_ancestor,
519 LayerType* layer, 533 LayerType* layer,
520 bool created_render_surface, 534 bool created_render_surface,
521 DataForRecursion<LayerType>* data_for_children) { 535 DataForRecursion<LayerType>* data_for_children) {
522 const bool is_root = !Parent(layer); 536 const bool is_root = !Parent(layer);
523 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; 537 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer;
524 const bool is_overscroll_elasticity_layer = 538 const bool is_overscroll_elasticity_layer =
525 layer == data_from_ancestor.overscroll_elasticity_layer; 539 layer == data_from_ancestor.overscroll_elasticity_layer;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 // viewport bounds change, but do not unconditionally move by that delta 766 // viewport bounds change, but do not unconditionally move by that delta
753 // like fixed position nodes. 767 // like fixed position nodes.
754 if (scroll_ancestor->scrolls_inner_viewport) { 768 if (scroll_ancestor->scrolls_inner_viewport) {
755 data_for_children->property_trees->transform_tree 769 data_for_children->property_trees->transform_tree
756 .AddNodeAffectedByInnerViewportBoundsDelta(node->id); 770 .AddNodeAffectedByInnerViewportBoundsDelta(node->id);
757 } else if (scroll_ancestor->scrolls_outer_viewport) { 771 } else if (scroll_ancestor->scrolls_outer_viewport) {
758 data_for_children->property_trees->transform_tree 772 data_for_children->property_trees->transform_tree
759 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); 773 .AddNodeAffectedByOuterViewportBoundsDelta(node->id);
760 } 774 }
761 } 775 }
762 sticky_data->main_thread_offset = 776 // The sticky box offset calculated in CompositedLayerMapping must be
763 layer->position().OffsetFromOrigin() - 777 // adjusted for the enclosing layer's sticky offset.
764 sticky_data->constraints.parent_relative_sticky_box_offset 778 gfx::Point sticky_box_offset(
765 .OffsetFromOrigin(); 779 sticky_data->constraints.parent_relative_sticky_box_offset);
780 if (Parent(layer)->id() != scroll_ancestor->owning_layer_id) {
781 sticky_box_offset +=
782 gfx::ToFlooredVector2d(CalculateTotalStickyOffsetToScroller(
783 Parent(layer), scroll_ancestor->owning_layer_id));
784 }
785 sticky_data->main_thread_offset = layer->position().OffsetFromOrigin() -
786 sticky_box_offset.OffsetFromOrigin();
787 // Copy the ancestor nodes for later use. These layers are guaranteed to
788 // have transform nodes because they are our ancestors and they are sticky.
789 if (Layer* layer =
790 sticky_data->constraints.nearest_layer_shifting_sticky_box) {
791 sticky_data->nearest_node_shifting_sticky_box =
792 layer->transform_tree_index();
793 }
794 if (Layer* layer =
795 sticky_data->constraints.nearest_layer_shifting_containing_block) {
796 sticky_data->nearest_node_shifting_containing_block =
797 layer->transform_tree_index();
798 }
766 } 799 }
767 800
768 node->needs_local_transform_update = true; 801 node->needs_local_transform_update = true;
769 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); 802 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id);
770 803
771 layer->set_offset_to_transform_parent(gfx::Vector2dF()); 804 layer->set_offset_to_transform_parent(gfx::Vector2dF());
772 805
773 // Flattening (if needed) will be handled by |node|. 806 // Flattening (if needed) will be handled by |node|.
774 layer->set_should_flatten_transform_from_property_tree(false); 807 layer->set_should_flatten_transform_from_property_tree(false);
775 808
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1580 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1548 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1581 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1549 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1582 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1550 device_transform, property_trees, color); 1583 device_transform, property_trees, color);
1551 property_trees->effect_tree.CreateOrReuseRenderSurfaces( 1584 property_trees->effect_tree.CreateOrReuseRenderSurfaces(
1552 &render_surfaces, root_layer->layer_tree_impl()); 1585 &render_surfaces, root_layer->layer_tree_impl());
1553 property_trees->ResetCachedData(); 1586 property_trees->ResetCachedData();
1554 } 1587 }
1555 1588
1556 } // namespace cc 1589 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698