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

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: Pass in constraints_map instead of ancestor_overflow_layer && nit 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;
17
18 typedef WTF::HashMap<PaintLayer*, StickyPositionScrollingConstraints>
19 StickyConstraintsMap;
14 20
15 class StickyPositionScrollingConstraints final { 21 class StickyPositionScrollingConstraints final {
16 public: 22 public:
17 enum AnchorEdgeFlags { 23 enum AnchorEdgeFlags {
18 kAnchorEdgeLeft = 1 << 0, 24 kAnchorEdgeLeft = 1 << 0,
19 kAnchorEdgeRight = 1 << 1, 25 kAnchorEdgeRight = 1 << 1,
20 kAnchorEdgeTop = 1 << 2, 26 kAnchorEdgeTop = 1 << 2,
21 kAnchorEdgeBottom = 1 << 3 27 kAnchorEdgeBottom = 1 << 3
22 }; 28 };
23 typedef unsigned AnchorEdges; 29 typedef unsigned AnchorEdges;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return nearest_sticky_box_shifting_containing_block_; 112 return nearest_sticky_box_shifting_containing_block_;
107 } 113 }
108 114
109 const FloatSize& GetTotalStickyBoxStickyOffset() const { 115 const FloatSize& GetTotalStickyBoxStickyOffset() const {
110 return total_sticky_box_sticky_offset_; 116 return total_sticky_box_sticky_offset_;
111 } 117 }
112 const FloatSize& GetTotalContainingBlockStickyOffset() const { 118 const FloatSize& GetTotalContainingBlockStickyOffset() const {
113 return total_containing_block_sticky_offset_; 119 return total_containing_block_sticky_offset_;
114 } 120 }
115 121
122 FloatSize GetLocalStickyOffset(const StickyConstraintsMap&) const;
chrishtr 2017/06/05 17:17:34 Document clearly what this returns. Not your faul
yigu 2017/06/05 18:16:34 Added a TODO for adding the class-level comment wi
123
116 const LayoutBoxModelObject* NearestStickyAncestor() const { 124 const LayoutBoxModelObject* NearestStickyAncestor() const {
117 // If we have one or more sticky ancestor elements between ourselves and our 125 // If we have one or more sticky ancestor elements between ourselves and our
118 // containing block, |m_nearestStickyBoxShiftingStickyBox| points to the 126 // containing block, |m_nearestStickyBoxShiftingStickyBox| points to the
119 // closest. Otherwise, |m_nearestStickyBoxShiftingContainingBlock| points 127 // closest. Otherwise, |m_nearestStickyBoxShiftingContainingBlock| points
120 // to the the first sticky ancestor between our containing block (inclusive) 128 // to the the first sticky ancestor between our containing block (inclusive)
121 // and our scroll ancestor (exclusive). Therefore our nearest sticky 129 // and our scroll ancestor (exclusive). Therefore our nearest sticky
122 // ancestor is the former if it exists, or the latter otherwise. 130 // ancestor is the former if it exists, or the latter otherwise.
123 // 131 //
124 // If both are null, then we have no sticky ancestors before our scroll 132 // If both are null, then we have no sticky ancestors before our scroll
125 // ancestor, so the correct action is to return null. 133 // 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 185 // constraining block constriant rect for different sticky descendants is
178 // quite complex. See the StickyPositionComplexTableNesting test in 186 // quite complex. See the StickyPositionComplexTableNesting test in
179 // LayoutBoxModelObjectTest.cpp. 187 // LayoutBoxModelObjectTest.cpp.
180 FloatSize total_sticky_box_sticky_offset_; 188 FloatSize total_sticky_box_sticky_offset_;
181 FloatSize total_containing_block_sticky_offset_; 189 FloatSize total_containing_block_sticky_offset_;
182 }; 190 };
183 191
184 } // namespace blink 192 } // namespace blink
185 193
186 #endif // StickyPositionScrollingConstraints_h 194 #endif // StickyPositionScrollingConstraints_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698