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

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

Issue 2698843004: Correct for enclosing layers scroll position in sticky_data->main_thread_offset (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | cc/trees/layer_tree_host_common_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 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 id())) { 587 id())) {
587 DCHECK_EQ(transform_tree_index(), 588 DCHECK_EQ(transform_tree_index(),
588 property_trees->layer_id_to_transform_node_index[id()]); 589 property_trees->layer_id_to_transform_node_index[id()]);
589 TransformNode* transform_node = 590 TransformNode* transform_node =
590 property_trees->transform_tree.Node(transform_tree_index()); 591 property_trees->transform_tree.Node(transform_tree_index());
591 transform_node->update_post_local_transform(position, transform_origin()); 592 transform_node->update_post_local_transform(position, transform_origin());
592 if (transform_node->sticky_position_constraint_id >= 0) { 593 if (transform_node->sticky_position_constraint_id >= 0) {
593 StickyPositionNodeData* sticky_data = 594 StickyPositionNodeData* sticky_data =
594 property_trees->transform_tree.StickyPositionData( 595 property_trees->transform_tree.StickyPositionData(
595 transform_tree_index()); 596 transform_tree_index());
597 gfx::Point sticky_box_offset(
598 sticky_data->constraints.parent_relative_sticky_box_offset);
599
600 // The sticky box offset calculated in CompositedLayerMapping must be
601 // adjusted for the enclosing layer's scroll position.
602 ScrollNode* scroll_ancestor =
603 property_trees->scroll_tree.Node(scroll_tree_index());
604 if (scroll_ancestor->owning_layer_id == id()) {
605 // We are a scroller, so we need our parent's scroll_ancestor.
flackr 2017/02/16 22:23:59 Can't we always get the node from the parent?
smcgruer 2017/02/17 13:55:31 Yes, of course. Done.
606 scroll_ancestor =
607 property_trees->scroll_tree.Node(parent()->scroll_tree_index());
608 }
609 if (parent()->id() != scroll_ancestor->owning_layer_id) {
610 sticky_box_offset -= gfx::ScrollOffsetToFlooredVector2d(
flackr 2017/02/16 22:23:59 Do we know that this floored scroll offset matches
smcgruer 2017/02/17 13:55:31 So the |enclosingLayerOffset| that is calculated b
flackr 2017/02/21 00:41:30 This definitely belongs blink side. If there are c
smcgruer 2017/02/21 19:17:21 Done.
611 property_trees->scroll_tree.current_scroll_offset(
612 scroll_ancestor->owning_layer_id));
613 }
614
596 sticky_data->main_thread_offset = 615 sticky_data->main_thread_offset =
597 position.OffsetFromOrigin() - 616 position.OffsetFromOrigin() - sticky_box_offset.OffsetFromOrigin();
598 sticky_data->constraints.parent_relative_sticky_box_offset
599 .OffsetFromOrigin();
600 } 617 }
601 transform_node->needs_local_transform_update = true; 618 transform_node->needs_local_transform_update = true;
602 transform_node->transform_changed = true; 619 transform_node->transform_changed = true;
603 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); 620 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
604 SetNeedsCommitNoRebuild(); 621 SetNeedsCommitNoRebuild();
605 return; 622 return;
606 } 623 }
607 624
608 SetNeedsCommit(); 625 SetNeedsCommit();
609 } 626 }
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 ->num_copy_requests_in_subtree; 1596 ->num_copy_requests_in_subtree;
1580 } 1597 }
1581 1598
1582 gfx::Transform Layer::screen_space_transform() const { 1599 gfx::Transform Layer::screen_space_transform() const {
1583 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1600 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1584 return draw_property_utils::ScreenSpaceTransform( 1601 return draw_property_utils::ScreenSpaceTransform(
1585 this, layer_tree_host_->property_trees()->transform_tree); 1602 this, layer_tree_host_->property_trees()->transform_tree);
1586 } 1603 }
1587 1604
1588 } // namespace cc 1605 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698