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

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

Issue 2432043007: Include scroll snap in scroll position used for sticky offset calculation. (Closed)
Patch Set: Include scroll snap in scroll position used for sticky offset. Created 4 years, 1 month 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 | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (node->sticky_position_constraint_id == -1) 417 if (node->sticky_position_constraint_id == -1)
418 return gfx::Vector2dF(); 418 return gfx::Vector2dF();
419 const StickyPositionNodeData* sticky_data = 419 const StickyPositionNodeData* sticky_data =
420 tree->StickyPositionData(node->id); 420 tree->StickyPositionData(node->id);
421 const LayerStickyPositionConstraint& constraint = sticky_data->constraints; 421 const LayerStickyPositionConstraint& constraint = sticky_data->constraints;
422 ScrollNode* scroll_node = 422 ScrollNode* scroll_node =
423 tree->property_trees()->scroll_tree.Node(sticky_data->scroll_ancestor); 423 tree->property_trees()->scroll_tree.Node(sticky_data->scroll_ancestor);
424 gfx::ScrollOffset scroll_offset = 424 gfx::ScrollOffset scroll_offset =
425 tree->property_trees()->scroll_tree.current_scroll_offset( 425 tree->property_trees()->scroll_tree.current_scroll_offset(
426 scroll_node->owner_id); 426 scroll_node->owner_id);
427 gfx::PointF scroll_position(scroll_offset.x(), scroll_offset.y());
428 // The scroll position does not include snapping which shifts the scroll
429 // offset to align to a pixel boundary, we need to manually include it here.
430 scroll_position -= tree->property_trees()
431 ->transform_tree.Node(scroll_node->transform_id)
432 ->scroll_snap;
427 433
428 gfx::RectF clip( 434 gfx::RectF clip(
429 gfx::PointF(scroll_offset.x(), scroll_offset.y()), 435 scroll_position,
430 gfx::SizeF(tree->property_trees()->scroll_tree.scroll_clip_layer_bounds( 436 gfx::SizeF(tree->property_trees()->scroll_tree.scroll_clip_layer_bounds(
431 scroll_node->id))); 437 scroll_node->id)));
432 gfx::Vector2dF sticky_offset( 438 gfx::Vector2dF sticky_offset(
433 constraint.scroll_container_relative_sticky_box_rect.OffsetFromOrigin()); 439 constraint.scroll_container_relative_sticky_box_rect.OffsetFromOrigin());
434 gfx::Vector2dF layer_offset(sticky_data->main_thread_offset); 440 gfx::Vector2dF layer_offset(sticky_data->main_thread_offset);
435 441
436 // In each of the following cases, we measure the limit which is the point 442 // In each of the following cases, we measure the limit which is the point
437 // that the element should stick to, clamping on one side to 0 (because sticky 443 // that the element should stick to, clamping on one side to 0 (because sticky
438 // only pushes elements in one direction). Then we clamp to how far we can 444 // only pushes elements in one direction). Then we clamp to how far we can
439 // push the element in that direction without being pushed outside of its 445 // push the element in that direction without being pushed outside of its
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 2338
2333 const EffectNode* effect_node = effect_tree.Node(effect_id); 2339 const EffectNode* effect_node = effect_tree.Node(effect_id);
2334 2340
2335 bool success = GetFromTarget(transform_id, effect_id, transform); 2341 bool success = GetFromTarget(transform_id, effect_id, transform);
2336 transform->Scale(effect_node->surface_contents_scale.x(), 2342 transform->Scale(effect_node->surface_contents_scale.x(),
2337 effect_node->surface_contents_scale.y()); 2343 effect_node->surface_contents_scale.y());
2338 return success; 2344 return success;
2339 } 2345 }
2340 2346
2341 } // namespace cc 2347 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698