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

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

Issue 2911463002: Unify the calculation of main thread offset of sticky element (Closed)
Patch Set: Address comments Created 3 years, 7 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // The scroll position does not include snapping which shifts the scroll 365 // The scroll position does not include snapping which shifts the scroll
366 // offset to align to a pixel boundary, we need to manually include it here. 366 // offset to align to a pixel boundary, we need to manually include it here.
367 // In this case, snapping is caused by a scroll. 367 // In this case, snapping is caused by a scroll.
368 scroll_position -= transform_node->snap_amount; 368 scroll_position -= transform_node->snap_amount;
369 } 369 }
370 370
371 gfx::RectF clip( 371 gfx::RectF clip(
372 scroll_position, 372 scroll_position,
373 gfx::SizeF(property_trees.scroll_tree.scroll_clip_layer_bounds( 373 gfx::SizeF(property_trees.scroll_tree.scroll_clip_layer_bounds(
374 scroll_node->id))); 374 scroll_node->id)));
375 gfx::Vector2dF layer_offset(sticky_data->main_thread_offset);
376 375
377 gfx::Vector2dF ancestor_sticky_box_offset; 376 gfx::Vector2dF ancestor_sticky_box_offset;
378 if (sticky_data->nearest_node_shifting_sticky_box != 377 if (sticky_data->nearest_node_shifting_sticky_box !=
379 TransformTree::kInvalidNodeId) { 378 TransformTree::kInvalidNodeId) {
380 ancestor_sticky_box_offset = 379 ancestor_sticky_box_offset =
381 tree->StickyPositionData(sticky_data->nearest_node_shifting_sticky_box) 380 tree->StickyPositionData(sticky_data->nearest_node_shifting_sticky_box)
382 ->total_sticky_box_sticky_offset; 381 ->total_sticky_box_sticky_offset;
383 } 382 }
384 383
385 gfx::Vector2dF ancestor_containing_block_offset; 384 gfx::Vector2dF ancestor_containing_block_offset;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 sticky_offset.set_y(sticky_offset.y() + top_delta); 449 sticky_offset.set_y(sticky_offset.y() + top_delta);
451 } 450 }
452 451
453 sticky_data->total_sticky_box_sticky_offset = 452 sticky_data->total_sticky_box_sticky_offset =
454 ancestor_sticky_box_offset + sticky_offset - 453 ancestor_sticky_box_offset + sticky_offset -
455 sticky_box_rect.OffsetFromOrigin(); 454 sticky_box_rect.OffsetFromOrigin();
456 sticky_data->total_containing_block_sticky_offset = 455 sticky_data->total_containing_block_sticky_offset =
457 ancestor_sticky_box_offset + ancestor_containing_block_offset + 456 ancestor_sticky_box_offset + ancestor_containing_block_offset +
458 sticky_offset - sticky_box_rect.OffsetFromOrigin(); 457 sticky_offset - sticky_box_rect.OffsetFromOrigin();
459 458
460 return sticky_offset - layer_offset - node->source_to_parent - 459 gfx::Vector2dF sticky_main_thread_offset(
flackr 2017/05/31 14:08:22 Rather than converting to a Vector2dF every time,
yigu 2017/06/01 15:15:19 Done.
460 node->sticky_main_thread_offset.width(),
461 node->sticky_main_thread_offset.height());
462
463 return sticky_offset - sticky_main_thread_offset -
461 sticky_box_rect.OffsetFromOrigin(); 464 sticky_box_rect.OffsetFromOrigin();
462 } 465 }
463 466
464 void TransformTree::UpdateLocalTransform(TransformNode* node) { 467 void TransformTree::UpdateLocalTransform(TransformNode* node) {
465 gfx::Transform transform = node->post_local; 468 gfx::Transform transform = node->post_local;
466 if (NeedsSourceToParentUpdate(node)) { 469 if (NeedsSourceToParentUpdate(node)) {
467 gfx::Transform to_parent; 470 gfx::Transform to_parent;
468 ComputeTranslation(node->source_node_id, node->parent_id, &to_parent); 471 ComputeTranslation(node->source_node_id, node->parent_id, &to_parent);
469 gfx::Vector2dF unsnapping; 472 gfx::Vector2dF unsnapping;
470 TransformNode* current; 473 TransformNode* current;
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 const EffectNode* effect_node = effect_tree.Node(effect_id); 2105 const EffectNode* effect_node = effect_tree.Node(effect_id);
2103 2106
2104 if (effect_node->surface_contents_scale.x() != 0.0 && 2107 if (effect_node->surface_contents_scale.x() != 0.0 &&
2105 effect_node->surface_contents_scale.y() != 0.0) 2108 effect_node->surface_contents_scale.y() != 0.0)
2106 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), 2109 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(),
2107 1.0 / effect_node->surface_contents_scale.y()); 2110 1.0 / effect_node->surface_contents_scale.y());
2108 return screen_space_transform; 2111 return screen_space_transform;
2109 } 2112 }
2110 2113
2111 } // namespace cc 2114 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698