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

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

Issue 2636253002: Handle nested position:sticky elements (Closed)
Patch Set: Rebase 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 cb2b7ed3227dc3d06d6377d2d01149bba06a465f..82ceb21a92db07eee490d0904981d209edd401e7 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -170,6 +170,27 @@ static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
return (!page) ? nullptr : page->scrollingCoordinator();
}
+static WebLayer* nearestCompositedStickyLayer(
+ const StickyConstraintsMap& constraintsMap,
+ LayoutBoxModelObject* obj) {
+ while (obj && obj->compositingState() == NotComposited) {
+ DCHECK(constraintsMap.contains(obj->layer()));
+ const StickyPositionScrollingConstraints constraints =
+ constraintsMap.get(obj->layer());
+ obj = constraints.nearestStickyElementShiftingStickyBox()
+ ? constraints.nearestStickyElementShiftingStickyBox()
+ : constraints.nearestStickyElementShiftingContainingBlock();
+ }
+
+ if (!obj)
+ return nullptr;
+
+ return obj->layer()
+ ->compositedLayerMapping()
+ ->mainGraphicsLayer()
+ ->platformLayer();
+}
+
CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
: m_owningLayer(layer),
m_contentOffsetInCompositingLayerDirty(false),
@@ -303,9 +324,10 @@ void CompositedLayerMapping::updateStickyConstraints(
WebLayerStickyPositionConstraint webConstraint;
if (sticky) {
+ const StickyConstraintsMap& constraintsMap =
+ ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap();
const StickyPositionScrollingConstraints& constraints =
- ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().get(
- &m_owningLayer);
+ constraintsMap.get(&m_owningLayer);
// Find the layout offset of the unshifted sticky box within its enclosing
// layer.
@@ -313,6 +335,7 @@ void CompositedLayerMapping::updateStickyConstraints(
m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf)
->convertToLayerCoords(m_owningLayer.ancestorOverflowLayer(),
enclosingLayerOffset);
+
FloatPoint stickyBoxOffset =
constraints.scrollContainerRelativeStickyBoxRect().location();
DCHECK(!m_contentOffsetInCompositingLayerDirty);
@@ -342,6 +365,14 @@ void CompositedLayerMapping::updateStickyConstraints(
enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect());
webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect(
constraints.scrollContainerRelativeContainingBlockRect());
+ webConstraint.nearestLayerShiftingStickyBox = nearestCompositedStickyLayer(
+ constraintsMap, constraints.nearestStickyElementShiftingStickyBox());
+ webConstraint.nearestLayerShiftingContainingBlock =
+ nearestCompositedStickyLayer(
+ constraintsMap,
+ constraints.nearestStickyElementShiftingContainingBlock());
+ webConstraint.cachedComputedStickyOffset =
+ constraints.getCachedComputedStickyOffset();
}
m_graphicsLayer->setStickyPositionConstraint(webConstraint);

Powered by Google App Engine
This is Rietveld 408576698