OLD | NEW |
---|---|
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 Loading... | |
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::ComputeMainThreadStickyOffset( | |
93 const PaintLayer& ancestor_overflow_layer) const { | |
flackr
2017/06/02 15:33:58
Instead of passing in the ancestor_overflow_layer
yigu
2017/06/02 17:59:56
Done.
| |
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 ancestor_overflow_layer.GetScrollableArea() | |
98 ->GetStickyConstraintsMap() | |
99 .at(nearest_sticky_box_shifting_sticky_box_->Layer()) | |
100 .GetTotalStickyBoxStickyOffset(); | |
101 } | |
102 return total_sticky_box_sticky_offset_ - | |
103 nearest_sticky_box_shifting_sticky_box_constraints_offset; | |
104 } | |
105 | |
91 } // namespace blink | 106 } // namespace blink |
OLD | NEW |