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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp

Issue 2911463002: Unify the calculation of main thread offset of sticky element (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
diff --git a/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp b/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
index f099cdce40417819ed11a11f133cdf54b503a75f..226e0fce0636c519af4a37691cf6a7574cc76077 100644
--- a/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
+++ b/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "core/page/scrolling/StickyPositionScrollingConstraints.h"
+#include "core/paint/PaintLayer.h"
namespace blink {
@@ -88,4 +89,17 @@ FloatSize StickyPositionScrollingConstraints::ComputeStickyOffset(
return sticky_offset;
}
+FloatSize
+StickyPositionScrollingConstraints::GetPositionRelativeToScrollAncestor(
+ const StickyConstraintsMap& constraints_map) const {
+ FloatSize nearest_sticky_box_shifting_sticky_box_constraints_offset;
+ if (nearest_sticky_box_shifting_sticky_box_) {
+ nearest_sticky_box_shifting_sticky_box_constraints_offset =
+ constraints_map.at(nearest_sticky_box_shifting_sticky_box_->Layer())
+ .GetTotalStickyBoxStickyOffset();
+ }
+ 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.
+ nearest_sticky_box_shifting_sticky_box_constraints_offset;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698