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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp

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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/page/scrolling/StickyPositionScrollingConstraints.h" 5 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
6 #include "core/paint/PaintLayer.h"
6 7
7 namespace blink { 8 namespace blink {
8 9
9 FloatSize StickyPositionScrollingConstraints::ComputeStickyOffset( 10 FloatSize StickyPositionScrollingConstraints::ComputeStickyOffset(
10 const FloatRect& viewport_rect, 11 const FloatRect& viewport_rect,
11 const StickyPositionScrollingConstraints* ancestor_sticky_box_constraints, 12 const StickyPositionScrollingConstraints* ancestor_sticky_box_constraints,
12 const StickyPositionScrollingConstraints* 13 const StickyPositionScrollingConstraints*
13 ancestor_containing_block_constraints) { 14 ancestor_containing_block_constraints) {
14 // Adjust the constraint rect locations based on our ancestor sticky elements 15 // Adjust the constraint rect locations based on our ancestor sticky elements
15 // These adjustments are necessary to avoid double offsetting in the case of 16 // These adjustments are necessary to avoid double offsetting in the case of
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 FloatSize sticky_offset = box_rect.Location() - sticky_box_rect.Location(); 82 FloatSize sticky_offset = box_rect.Location() - sticky_box_rect.Location();
82 83
83 total_sticky_box_sticky_offset_ = ancestor_sticky_box_offset + sticky_offset; 84 total_sticky_box_sticky_offset_ = ancestor_sticky_box_offset + sticky_offset;
84 total_containing_block_sticky_offset_ = ancestor_sticky_box_offset + 85 total_containing_block_sticky_offset_ = ancestor_sticky_box_offset +
85 ancestor_containing_block_offset + 86 ancestor_containing_block_offset +
86 sticky_offset; 87 sticky_offset;
87 88
88 return sticky_offset; 89 return sticky_offset;
89 } 90 }
90 91
92 FloatSize StickyPositionScrollingConstraints::GetOffsetForStickyPosition(
93 const StickyConstraintsMap& constraints_map) const {
94 FloatSize nearest_sticky_box_shifting_sticky_box_constraints_offset;
95 if (nearest_sticky_box_shifting_sticky_box_) {
96 nearest_sticky_box_shifting_sticky_box_constraints_offset =
97 constraints_map.at(nearest_sticky_box_shifting_sticky_box_->Layer())
98 .GetTotalStickyBoxStickyOffset();
99 }
100 return total_sticky_box_sticky_offset_ -
101 nearest_sticky_box_shifting_sticky_box_constraints_offset;
102 }
103
91 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698