Index: Source/core/layout/compositing/CompositedDeprecatedPaintLayerMapping.cpp |
diff --git a/Source/core/layout/compositing/CompositedDeprecatedPaintLayerMapping.cpp b/Source/core/layout/compositing/CompositedDeprecatedPaintLayerMapping.cpp |
index 6d56b078c9263b881ba7e4af5028bffadbf97538..eed12e4fa59f28be2848ee87d383f2d9a01e35d3 100644 |
--- a/Source/core/layout/compositing/CompositedDeprecatedPaintLayerMapping.cpp |
+++ b/Source/core/layout/compositing/CompositedDeprecatedPaintLayerMapping.cpp |
@@ -48,6 +48,7 @@ |
#include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
#include "core/page/ChromeClient.h" |
#include "core/page/Page.h" |
+#include "core/page/scrolling/ScrollingConstraints.h" |
#include "core/page/scrolling/ScrollingCoordinator.h" |
#include "core/paint/DeprecatedPaintLayerPainter.h" |
#include "core/paint/DeprecatedPaintLayerStackingNodeIterator.h" |
@@ -63,6 +64,7 @@ |
#include "platform/graphics/paint/ClipDisplayItem.h" |
#include "platform/graphics/paint/DisplayItemList.h" |
#include "platform/graphics/paint/TransformDisplayItem.h" |
+#include "public/platform/WebLayerPositionConstraint.h" |
#include "wtf/CurrentTime.h" |
#include "wtf/text/StringBuilder.h" |
@@ -229,6 +231,7 @@ void CompositedDeprecatedPaintLayerMapping::createPrimaryGraphicsLayer() |
updateTransform(layoutObject()->styleRef()); |
updateFilters(layoutObject()->styleRef()); |
updateBackdropFilters(layoutObject()->styleRef()); |
+ updateStickyConstraints(layoutObject()->styleRef()); |
if (RuntimeEnabledFeatures::cssCompositingEnabled()) { |
updateLayerBlendMode(layoutObject()->styleRef()); |
@@ -288,6 +291,45 @@ void CompositedDeprecatedPaintLayerMapping::updateLayerBlendMode(const ComputedS |
setBlendMode(style.blendMode()); |
} |
+void CompositedDeprecatedPaintLayerMapping::updateStickyConstraints(const ComputedStyle& style) |
+{ |
+ bool sticky = style.position() == EPosition::StickyPosition; |
+ if (sticky) { |
+ const DeprecatedPaintLayer* ancestorScrollingLayer = m_owningLayer.ancestorScrollingLayer(); |
+ if (ancestorScrollingLayer) { |
+ sticky = ancestorScrollingLayer->needsCompositedScrolling(); |
+ } else { |
+ // If there's no ancestor scrolling layer the viewport is our ancestor scroller. |
+ sticky = layoutObject()->view()->frameView()->isScrollable(); |
+ } |
+ } |
+ |
+ WebLayerStickyPositionConstraint webConstraint; |
+ if (sticky) { |
+ LayoutBoxModelObject* boxModelObject = m_owningLayer.layoutObject(); |
+ LayoutRect containingRect = boxModelObject->computeStickyConstrainingRect(); |
+ StickyPositionViewportConstraints constraints; |
+ boxModelObject->computeStickyPositionConstraints(constraints, containingRect); |
+ |
+ webConstraint.isSticky = true; |
+ |
+ webConstraint.isAnchoredLeft = constraints.anchorEdges() & ViewportConstraints::AnchorEdgeLeft; |
+ webConstraint.isAnchoredRight = constraints.anchorEdges() & ViewportConstraints::AnchorEdgeRight; |
+ webConstraint.isAnchoredTop = constraints.anchorEdges() & ViewportConstraints::AnchorEdgeTop; |
+ webConstraint.isAnchoredBottom = constraints.anchorEdges() & ViewportConstraints::AnchorEdgeBottom; |
+ |
+ webConstraint.leftOffset = constraints.leftOffset().toFloat(); |
+ webConstraint.rightOffset = constraints.rightOffset().toFloat(); |
+ webConstraint.topOffset = constraints.topOffset().toFloat(); |
+ webConstraint.bottomOffset = constraints.bottomOffset().toFloat(); |
+ |
+ webConstraint.absoluteStickyBoxRect = enclosingIntRect(constraints.absoluteStickyBoxRect()); |
+ webConstraint.absoluteContainingBlockRect = enclosingIntRect(constraints.absoluteContainingBlockRect()); |
+ } |
+ |
+ m_graphicsLayer->platformLayer()->setStickyPositionConstraint(webConstraint); |
+} |
+ |
void CompositedDeprecatedPaintLayerMapping::updateIsRootForIsolatedGroup() |
{ |
bool isolate = m_owningLayer.shouldIsolateCompositedDescendants(); |
@@ -731,6 +773,8 @@ void CompositedDeprecatedPaintLayerMapping::updateGraphicsLayerGeometry(const De |
updateScrollParent(scrollParent()); |
registerScrollingLayers(); |
+ updateStickyConstraints(layoutObject()->styleRef()); |
+ |
updateCompositingReasons(); |
} |