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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2698843004: Correct for enclosing layers scroll position in sticky_data->main_thread_offset (Closed)
Patch Set: Address reviewer comments Created 3 years, 10 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/layout/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 3babc9d05b8c435629655b7fa715dd8a26a78cc4..ab707c88a1388983ae3d600d7c82c15c257be10d 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -291,7 +291,8 @@ void CompositedLayerMapping::updateBackdropFilters(const ComputedStyle& style) {
}
void CompositedLayerMapping::updateStickyConstraints(
- const ComputedStyle& style) {
+ const ComputedStyle& style,
+ const PaintLayer* compositingContainer) {
bool sticky = style.position() == EPosition::kSticky;
const PaintLayer* ancestorOverflowLayer =
m_owningLayer.ancestorOverflowLayer();
@@ -310,12 +311,18 @@ void CompositedLayerMapping::updateStickyConstraints(
ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().at(
&m_owningLayer);
- // Find the layout offset of the unshifted sticky box within its enclosing
- // layer.
+ // Find the layout offset of the unshifted sticky box within its
+ // compositingContainer. If the enclosing layer is not the scroller, then
+ // the offset must be adjusted to include the scroll offset to keep it
+ // relative to compositingContainer.
LayoutPoint enclosingLayerOffset;
- m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf)
- ->convertToLayerCoords(m_owningLayer.ancestorOverflowLayer(),
- enclosingLayerOffset);
+ compositingContainer->convertToLayerCoords(ancestorOverflowLayer,
+ enclosingLayerOffset);
+ if (compositingContainer != ancestorOverflowLayer) {
+ enclosingLayerOffset += LayoutSize(
+ ancestorOverflowLayer->getScrollableArea()->getScrollOffset());
+ }
+
FloatPoint stickyBoxOffset =
constraints.scrollContainerRelativeStickyBoxRect().location();
DCHECK(!m_contentOffsetInCompositingLayerDirty);
@@ -1014,7 +1021,7 @@ void CompositedLayerMapping::updateGraphicsLayerGeometry(
graphicsLayerParentLocation);
updateContentsOffsetInCompositingLayer(snappedOffsetFromCompositedAncestor,
graphicsLayerParentLocation);
- updateStickyConstraints(layoutObject().styleRef());
+ updateStickyConstraints(layoutObject().styleRef(), compositingContainer);
updateSquashingLayerGeometry(
graphicsLayerParentLocation, compositingContainer, m_squashedLayers,
m_squashingLayer.get(), &m_squashingLayerOffsetFromTransformedAncestor,

Powered by Google App Engine
This is Rietveld 408576698