| 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 #ifndef StickyPositionScrollingConstraints_h | 5 #ifndef StickyPositionScrollingConstraints_h |
| 6 #define StickyPositionScrollingConstraints_h | 6 #define StickyPositionScrollingConstraints_h |
| 7 | 7 |
| 8 #include "platform/geometry/FloatRect.h" | 8 #include "platform/geometry/FloatRect.h" |
| 9 #include "platform/geometry/FloatSize.h" | 9 #include "platform/geometry/FloatSize.h" |
| 10 #include "platform/wtf/HashMap.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 class LayoutBoxModelObject; | 14 class LayoutBoxModelObject; |
| 15 class PaintLayer; |
| 16 class StickyPositionScrollingConstraints; |
| 14 | 17 |
| 18 typedef WTF::HashMap<PaintLayer*, StickyPositionScrollingConstraints> |
| 19 StickyConstraintsMap; |
| 20 |
| 21 // TODO(yigu): Add detailed comment explaining how |
| 22 // StickyPositionScrollingConstraints works. |
| 15 class StickyPositionScrollingConstraints final { | 23 class StickyPositionScrollingConstraints final { |
| 16 public: | 24 public: |
| 17 enum AnchorEdgeFlags { | 25 enum AnchorEdgeFlags { |
| 18 kAnchorEdgeLeft = 1 << 0, | 26 kAnchorEdgeLeft = 1 << 0, |
| 19 kAnchorEdgeRight = 1 << 1, | 27 kAnchorEdgeRight = 1 << 1, |
| 20 kAnchorEdgeTop = 1 << 2, | 28 kAnchorEdgeTop = 1 << 2, |
| 21 kAnchorEdgeBottom = 1 << 3 | 29 kAnchorEdgeBottom = 1 << 3 |
| 22 }; | 30 }; |
| 23 typedef unsigned AnchorEdges; | 31 typedef unsigned AnchorEdges; |
| 24 | 32 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return nearest_sticky_box_shifting_containing_block_; | 114 return nearest_sticky_box_shifting_containing_block_; |
| 107 } | 115 } |
| 108 | 116 |
| 109 const FloatSize& GetTotalStickyBoxStickyOffset() const { | 117 const FloatSize& GetTotalStickyBoxStickyOffset() const { |
| 110 return total_sticky_box_sticky_offset_; | 118 return total_sticky_box_sticky_offset_; |
| 111 } | 119 } |
| 112 const FloatSize& GetTotalContainingBlockStickyOffset() const { | 120 const FloatSize& GetTotalContainingBlockStickyOffset() const { |
| 113 return total_containing_block_sticky_offset_; | 121 return total_containing_block_sticky_offset_; |
| 114 } | 122 } |
| 115 | 123 |
| 124 // Returns the relative position of the sticky box and ancestor scroller. |
| 125 FloatSize GetPositionRelativeToScrollAncestor( |
| 126 const StickyConstraintsMap&) const; |
| 127 |
| 116 const LayoutBoxModelObject* NearestStickyAncestor() const { | 128 const LayoutBoxModelObject* NearestStickyAncestor() const { |
| 117 // If we have one or more sticky ancestor elements between ourselves and our | 129 // If we have one or more sticky ancestor elements between ourselves and our |
| 118 // containing block, |m_nearestStickyBoxShiftingStickyBox| points to the | 130 // containing block, |m_nearestStickyBoxShiftingStickyBox| points to the |
| 119 // closest. Otherwise, |m_nearestStickyBoxShiftingContainingBlock| points | 131 // closest. Otherwise, |m_nearestStickyBoxShiftingContainingBlock| points |
| 120 // to the the first sticky ancestor between our containing block (inclusive) | 132 // to the the first sticky ancestor between our containing block (inclusive) |
| 121 // and our scroll ancestor (exclusive). Therefore our nearest sticky | 133 // and our scroll ancestor (exclusive). Therefore our nearest sticky |
| 122 // ancestor is the former if it exists, or the latter otherwise. | 134 // ancestor is the former if it exists, or the latter otherwise. |
| 123 // | 135 // |
| 124 // If both are null, then we have no sticky ancestors before our scroll | 136 // If both are null, then we have no sticky ancestors before our scroll |
| 125 // ancestor, so the correct action is to return null. | 137 // ancestor, so the correct action is to return null. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // constraining block constriant rect for different sticky descendants is | 189 // constraining block constriant rect for different sticky descendants is |
| 178 // quite complex. See the StickyPositionComplexTableNesting test in | 190 // quite complex. See the StickyPositionComplexTableNesting test in |
| 179 // LayoutBoxModelObjectTest.cpp. | 191 // LayoutBoxModelObjectTest.cpp. |
| 180 FloatSize total_sticky_box_sticky_offset_; | 192 FloatSize total_sticky_box_sticky_offset_; |
| 181 FloatSize total_containing_block_sticky_offset_; | 193 FloatSize total_containing_block_sticky_offset_; |
| 182 }; | 194 }; |
| 183 | 195 |
| 184 } // namespace blink | 196 } // namespace blink |
| 185 | 197 |
| 186 #endif // StickyPositionScrollingConstraints_h | 198 #endif // StickyPositionScrollingConstraints_h |
| OLD | NEW |