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

Unified Diff: cc/layers/layer.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl_test_properties.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 76d0bd2946af8fae1162a404ee584bfc099b4853..04776f97c4fcaf9050b12eedeeddeeb867149b99 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -597,18 +597,6 @@ void Layer::SetPosition(const gfx::PointF& position) {
property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) {
DCHECK_EQ(transform_tree_index(), transform_node->id);
transform_node->update_post_local_transform(position, transform_origin());
- if (transform_node->sticky_position_constraint_id >= 0) {
- StickyPositionNodeData* sticky_data =
- property_trees->transform_tree.StickyPositionData(
- transform_tree_index());
- // TODO(smcgruer): Pass main thread sticky-shifting offsets of
- // non-promoted ancestors, or promote all ancestor sticky elements.
- // See http://crbug.com/702229
- sticky_data->main_thread_offset =
- position.OffsetFromOrigin() -
- sticky_data->constraints.parent_relative_sticky_box_offset
- .OffsetFromOrigin();
- }
transform_node->needs_local_transform_update = true;
transform_node->transform_changed = true;
layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
@@ -1108,6 +1096,31 @@ void Layer::SetStickyPositionConstraint(
SetNeedsCommit();
}
+void Layer::SetOffsetForStickyPositionFromMainThread(const gfx::Size& offset) {
+ DCHECK(IsPropertyChangeAllowed());
+ if (inputs_.offset_for_sticky_position_from_main_thread == offset)
+ return;
+ inputs_.offset_for_sticky_position_from_main_thread = offset;
+
+ if (!layer_tree_host_)
+ return;
+
+ SetSubtreePropertyChanged();
+ PropertyTrees* property_trees = layer_tree_host_->property_trees();
+ if (TransformNode* transform_node =
+ property_trees->transform_tree.FindNodeFromElementId(
+ inputs_.element_id)) {
+ DCHECK_EQ(transform_tree_index(), transform_node->id);
+ transform_node->offset_for_sticky_position_from_main_thread =
+ gfx::Vector2dF(offset.width(), offset.height());
+ transform_node->needs_local_transform_update = true;
+ transform_node->transform_changed = true;
+ layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
+ }
+
+ SetNeedsCommit();
+}
+
static void RunCopyCallbackOnMainThread(
std::unique_ptr<CopyOutputRequest> request,
std::unique_ptr<CopyOutputResult> result) {
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl_test_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698