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

Side by Side Diff: cc/layers/layer.cc

Issue 2733633002: Handle nested position:sticky elements correctly (compositor) (Closed)
Patch Set: Fix unittest 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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 11 matching lines...) Expand all
22 #include "cc/layers/layer_impl.h" 22 #include "cc/layers/layer_impl.h"
23 #include "cc/layers/scrollbar_layer_interface.h" 23 #include "cc/layers/scrollbar_layer_interface.h"
24 #include "cc/output/copy_output_request.h" 24 #include "cc/output/copy_output_request.h"
25 #include "cc/output/copy_output_result.h" 25 #include "cc/output/copy_output_result.h"
26 #include "cc/trees/draw_property_utils.h" 26 #include "cc/trees/draw_property_utils.h"
27 #include "cc/trees/effect_node.h" 27 #include "cc/trees/effect_node.h"
28 #include "cc/trees/layer_tree_host.h" 28 #include "cc/trees/layer_tree_host.h"
29 #include "cc/trees/layer_tree_impl.h" 29 #include "cc/trees/layer_tree_impl.h"
30 #include "cc/trees/mutable_properties.h" 30 #include "cc/trees/mutable_properties.h"
31 #include "cc/trees/mutator_host.h" 31 #include "cc/trees/mutator_host.h"
32 #include "cc/trees/scroll_node.h"
32 #include "cc/trees/transform_node.h" 33 #include "cc/trees/transform_node.h"
33 #include "third_party/skia/include/core/SkImageFilter.h" 34 #include "third_party/skia/include/core/SkImageFilter.h"
34 #include "ui/gfx/geometry/rect_conversions.h" 35 #include "ui/gfx/geometry/rect_conversions.h"
35 #include "ui/gfx/geometry/vector2d_conversions.h" 36 #include "ui/gfx/geometry/vector2d_conversions.h"
36 37
37 namespace cc { 38 namespace cc {
38 39
39 base::StaticAtomicSequenceNumber g_next_layer_id; 40 base::StaticAtomicSequenceNumber g_next_layer_id;
40 41
41 Layer::Inputs::Inputs(int layer_id) 42 Layer::Inputs::Inputs(int layer_id)
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 id())) { 584 id())) {
584 DCHECK_EQ(transform_tree_index(), 585 DCHECK_EQ(transform_tree_index(),
585 property_trees->layer_id_to_transform_node_index[id()]); 586 property_trees->layer_id_to_transform_node_index[id()]);
586 TransformNode* transform_node = 587 TransformNode* transform_node =
587 property_trees->transform_tree.Node(transform_tree_index()); 588 property_trees->transform_tree.Node(transform_tree_index());
588 transform_node->update_post_local_transform(position, transform_origin()); 589 transform_node->update_post_local_transform(position, transform_origin());
589 if (transform_node->sticky_position_constraint_id >= 0) { 590 if (transform_node->sticky_position_constraint_id >= 0) {
590 StickyPositionNodeData* sticky_data = 591 StickyPositionNodeData* sticky_data =
591 property_trees->transform_tree.StickyPositionData( 592 property_trees->transform_tree.StickyPositionData(
592 transform_tree_index()); 593 transform_tree_index());
594 // The sticky box offset calculated in CompositedLayerMapping must be
595 // adjusted for the enclosing layers sticky offset.
596 // TODO(smcgruer): We may want to do this blink side instead like the
597 // scroll.
flackr 2017/03/09 20:22:08 Unless we add a data channel for updating this (si
smcgruer 2017/03/14 22:04:05 Acknowledged.
598 gfx::Point sticky_box_offset(
599 sticky_data->constraints.parent_relative_sticky_box_offset);
600 ScrollNode* scroll_ancestor =
601 property_trees->scroll_tree.Node(scroll_tree_index());
602 if (parent()->id() != scroll_ancestor->owning_layer_id) {
603 sticky_box_offset += gfx::ToFlooredVector2d(
604 draw_property_utils::CalculateTotalStickyOffsetToScroller(
605 parent(), scroll_ancestor->owning_layer_id));
606 }
593 sticky_data->main_thread_offset = 607 sticky_data->main_thread_offset =
594 position.OffsetFromOrigin() - 608 position.OffsetFromOrigin() - sticky_box_offset.OffsetFromOrigin();
595 sticky_data->constraints.parent_relative_sticky_box_offset 609 // Set the ancestor nodes for later use in the property tree.
596 .OffsetFromOrigin(); 610 if (Layer* layer =
611 sticky_data->constraints.nearest_layer_shifting_sticky_box) {
612 sticky_data->nearest_node_shifting_sticky_box =
613 layer->transform_tree_index();
flackr 2017/03/09 20:22:08 I don't understand this, do the constraints or the
smcgruer 2017/03/14 22:04:05 It was mostly just copy/paste. Removed.
614 }
615 if (Layer* layer = sticky_data->constraints
616 .nearest_layer_shifting_containing_block) {
617 sticky_data->nearest_node_shifting_containing_block =
618 layer->transform_tree_index();
619 }
597 } 620 }
598 transform_node->needs_local_transform_update = true; 621 transform_node->needs_local_transform_update = true;
599 transform_node->transform_changed = true; 622 transform_node->transform_changed = true;
600 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); 623 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
601 SetNeedsCommitNoRebuild(); 624 SetNeedsCommitNoRebuild();
602 return; 625 return;
603 } 626 }
604 627
605 SetNeedsCommit(); 628 SetNeedsCommit();
606 } 629 }
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 ->num_copy_requests_in_subtree; 1553 ->num_copy_requests_in_subtree;
1531 } 1554 }
1532 1555
1533 gfx::Transform Layer::screen_space_transform() const { 1556 gfx::Transform Layer::screen_space_transform() const {
1534 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1557 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1535 return draw_property_utils::ScreenSpaceTransform( 1558 return draw_property_utils::ScreenSpaceTransform(
1536 this, layer_tree_host_->property_trees()->transform_tree); 1559 this, layer_tree_host_->property_trees()->transform_tree);
1537 } 1560 }
1538 1561
1539 } // namespace cc 1562 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698