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

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

Issue 2251303003: Implement position: sticky updates on compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and add unit test for impl side sticky position update. Created 4 years, 3 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 9ccc571f92f13b4630fbe0964a6a8d79db5369b6..16146d16488c38a33004f56b7cd2eaa297a6638a 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -50,6 +50,7 @@
#include "core/page/ChromeClient.h"
#include "core/page/Page.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
+#include "core/page/scrolling/StickyPositionScrollingConstraints.h"
#include "core/paint/ObjectPaintInvalidator.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayerPainter.h"
@@ -71,6 +72,7 @@
#include "platform/graphics/paint/PaintController.h"
#include "platform/graphics/paint/SkPictureBuilder.h"
#include "platform/graphics/paint/TransformDisplayItem.h"
+#include "public/platform/WebLayerStickyPositionConstraint.h"
#include "wtf/CurrentTime.h"
#include "wtf/text/StringBuilder.h"
#include <memory>
@@ -231,6 +233,7 @@ void CompositedLayerMapping::createPrimaryGraphicsLayer()
updateTransform(layoutObject()->styleRef());
updateFilters(layoutObject()->styleRef());
updateBackdropFilters(layoutObject()->styleRef());
+ updateStickyConstraints(layoutObject()->styleRef());
updateLayerBlendMode(layoutObject()->styleRef());
updateIsRootForIsolatedGroup();
}
@@ -281,6 +284,38 @@ void CompositedLayerMapping::updateBackdropFilters(const ComputedStyle& style)
m_graphicsLayer->setBackdropFilters(owningLayer().computeBackdropFilterOperations(style));
}
+void CompositedLayerMapping::updateStickyConstraints(const ComputedStyle& style)
+{
+ bool sticky = style.position() == EPosition::StickyPosition;
+ const PaintLayer* ancestorOverflowLayer = m_owningLayer.ancestorOverflowLayer();
+ // TODO(flackr): Do we still need this?
+ if (sticky) {
+ if (!ancestorOverflowLayer->isRootLayer()) {
+ sticky = ancestorOverflowLayer->needsCompositedScrolling();
+ } else {
+ sticky = layoutObject()->view()->frameView()->isScrollable();
+ }
+ }
+
+ WebLayerStickyPositionConstraint webConstraint;
+ if (sticky) {
+ const StickyPositionScrollingConstraints& constraints = ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().get(&m_owningLayer);
+ webConstraint.isSticky = true;
+ webConstraint.isAnchoredLeft = constraints.anchorEdges() & StickyPositionScrollingConstraints::AnchorEdgeLeft;
+ webConstraint.isAnchoredRight = constraints.anchorEdges() & StickyPositionScrollingConstraints::AnchorEdgeRight;
+ webConstraint.isAnchoredTop = constraints.anchorEdges() & StickyPositionScrollingConstraints::AnchorEdgeTop;
+ webConstraint.isAnchoredBottom = constraints.anchorEdges() & StickyPositionScrollingConstraints::AnchorEdgeBottom;
+ webConstraint.leftOffset = constraints.leftOffset();
+ webConstraint.rightOffset = constraints.rightOffset();
+ webConstraint.topOffset = constraints.topOffset();
+ webConstraint.bottomOffset = constraints.bottomOffset();
+ webConstraint.absoluteStickyBoxRect = enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect());
+ webConstraint.absoluteContainingBlockRect = enclosingIntRect(constraints.scrollContainerRelativeContainingBlockRect());
+ }
+
+ m_graphicsLayer->setStickyPositionConstraint(webConstraint);
+}
+
void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style)
{
setBlendMode(style.blendMode());
@@ -735,6 +770,8 @@ void CompositedLayerMapping::updateGraphicsLayerGeometry(const PaintLayer* compo
if (!layoutObject()->style()->isRunningBackdropFilterAnimationOnCompositor())
updateBackdropFilters(layoutObject()->styleRef());
+ updateStickyConstraints(layoutObject()->styleRef());
+
// We compute everything relative to the enclosing compositing layer.
IntRect ancestorCompositingBounds;
if (compositingContainer) {

Powered by Google App Engine
This is Rietveld 408576698