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

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

Issue 2733633002: Handle nested position:sticky elements correctly (compositor) (Closed)
Patch Set: Fix unittest Created 3 years, 9 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 2b11d48670b148fad2330a31a67ba95c030d952d..49642c115df62dfa6cc209f3b10720cf048b84b2 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -172,6 +172,27 @@ static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
return (!page) ? nullptr : page->scrollingCoordinator();
}
+static WebLayer* nearestCompositedStickyLayer(
+ const StickyConstraintsMap& constraintsMap,
+ LayoutBoxModelObject* obj) {
+ while (obj && obj->compositingState() == NotComposited) {
flackr 2017/03/09 20:22:09 I think technically you want to find compositingSt
smcgruer 2017/03/10 16:37:10 Done.
+ DCHECK(constraintsMap.contains(obj->layer()));
+ const StickyPositionScrollingConstraints constraints =
+ constraintsMap.at(obj->layer());
+ obj = constraints.nearestStickyBoxShiftingStickyBox()
flackr 2017/03/09 20:22:08 This seems wrong, don't we need to follow the same
smcgruer 2017/03/14 22:04:06 I believe you're correct, done. Adding a test is w
+ ? constraints.nearestStickyBoxShiftingStickyBox()
+ : constraints.nearestStickyBoxShiftingContainingBlock();
+ }
+
+ if (!obj)
+ return nullptr;
+
+ return obj->layer()
+ ->compositedLayerMapping()
+ ->mainGraphicsLayer()
+ ->platformLayer();
+}
+
CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
: m_owningLayer(layer),
m_contentOffsetInCompositingLayerDirty(false),
@@ -307,9 +328,10 @@ void CompositedLayerMapping::updateStickyConstraints(
WebLayerStickyPositionConstraint webConstraint;
if (sticky) {
+ const StickyConstraintsMap& constraintsMap =
+ ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap();
const StickyPositionScrollingConstraints& constraints =
- ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().at(
- &m_owningLayer);
+ constraintsMap.at(&m_owningLayer);
// Find the layout offset of the unshifted sticky box within its
// compositingContainer. If the enclosing layer is not the scroller, then
@@ -352,7 +374,13 @@ void CompositedLayerMapping::updateStickyConstraints(
enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect());
webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect(
constraints.scrollContainerRelativeContainingBlockRect());
- // TODO(smcgruer): Copy fields for nested sticky in cc (crbug.com/672710)
+ webConstraint.nearestLayerShiftingStickyBox = nearestCompositedStickyLayer(
+ constraintsMap, constraints.nearestStickyBoxShiftingStickyBox());
+ webConstraint.nearestLayerShiftingContainingBlock =
+ nearestCompositedStickyLayer(
+ constraintsMap,
+ constraints.nearestStickyBoxShiftingContainingBlock());
+ webConstraint.localStickyOffset = constraints.getLocalStickyOffset();
flackr 2017/03/09 20:22:09 This seems to be passed in, but unused as far as I
smcgruer 2017/03/10 16:37:10 Its used in draw_property_utils::CalculateTotalSti
flackr 2017/03/13 19:49:45 As discussed, we should try to work out the local
smcgruer 2017/03/14 22:04:06 Done.
}
m_graphicsLayer->setStickyPositionConstraint(webConstraint);

Powered by Google App Engine
This is Rietveld 408576698