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

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

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 #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(smcgruer): 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
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 its original position
125 // before scroll. This method is only safe to call if ComputeStickyOffset has
126 // been invoked.
127 FloatSize GetOffsetForStickyPosition(const StickyConstraintsMap&) const;
128
116 const LayoutBoxModelObject* NearestStickyAncestor() const { 129 const LayoutBoxModelObject* NearestStickyAncestor() const {
117 // If we have one or more sticky ancestor elements between ourselves and our 130 // If we have one or more sticky ancestor elements between ourselves and our
118 // containing block, |m_nearestStickyBoxShiftingStickyBox| points to the 131 // containing block, |m_nearestStickyBoxShiftingStickyBox| points to the
119 // closest. Otherwise, |m_nearestStickyBoxShiftingContainingBlock| points 132 // closest. Otherwise, |m_nearestStickyBoxShiftingContainingBlock| points
120 // to the the first sticky ancestor between our containing block (inclusive) 133 // to the the first sticky ancestor between our containing block (inclusive)
121 // and our scroll ancestor (exclusive). Therefore our nearest sticky 134 // and our scroll ancestor (exclusive). Therefore our nearest sticky
122 // ancestor is the former if it exists, or the latter otherwise. 135 // ancestor is the former if it exists, or the latter otherwise.
123 // 136 //
124 // If both are null, then we have no sticky ancestors before our scroll 137 // If both are null, then we have no sticky ancestors before our scroll
125 // ancestor, so the correct action is to return null. 138 // ancestor, so the correct action is to return null.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // constraining block constriant rect for different sticky descendants is 190 // constraining block constriant rect for different sticky descendants is
178 // quite complex. See the StickyPositionComplexTableNesting test in 191 // quite complex. See the StickyPositionComplexTableNesting test in
179 // LayoutBoxModelObjectTest.cpp. 192 // LayoutBoxModelObjectTest.cpp.
180 FloatSize total_sticky_box_sticky_offset_; 193 FloatSize total_sticky_box_sticky_offset_;
181 FloatSize total_containing_block_sticky_offset_; 194 FloatSize total_containing_block_sticky_offset_;
182 }; 195 };
183 196
184 } // namespace blink 197 } // namespace blink
185 198
186 #endif // StickyPositionScrollingConstraints_h 199 #endif // StickyPositionScrollingConstraints_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698