Chromium Code Reviews| 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 | |
| 93 StickyPositionScrollingConstraints::GetPositionRelativeToScrollAncestor( | |
| 94 const StickyConstraintsMap& constraints_map) const { | |
| 95 FloatSize nearest_sticky_box_shifting_sticky_box_constraints_offset; | |
| 96 if (nearest_sticky_box_shifting_sticky_box_) { | |
| 97 nearest_sticky_box_shifting_sticky_box_constraints_offset = | |
| 98 constraints_map.at(nearest_sticky_box_shifting_sticky_box_->Layer()) | |
| 99 .GetTotalStickyBoxStickyOffset(); | |
| 100 } | |
| 101 return total_sticky_box_sticky_offset_ - | |
|
chrishtr
2017/06/05 18:58:33
Could you explain why this logic is correct? I'm n
yigu
2017/06/05 21:03:49
We do the subtraction because total_sticky_box_sti
trchen
2017/06/05 22:43:11
+1 We need more comments in the headers. It took m
yigu
2017/06/06 19:33:18
I've updated the function name.
| |
| 102 nearest_sticky_box_shifting_sticky_box_constraints_offset; | |
| 103 } | |
| 104 | |
| 91 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |