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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 layoutObject.isVideo(); 165 layoutObject.isVideo();
166 } 166 }
167 167
168 // Get the scrolling coordinator in a way that works inside 168 // Get the scrolling coordinator in a way that works inside
169 // CompositedLayerMapping's destructor. 169 // CompositedLayerMapping's destructor.
170 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { 170 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
171 Page* page = layer.layoutObject().frame()->page(); 171 Page* page = layer.layoutObject().frame()->page();
172 return (!page) ? nullptr : page->scrollingCoordinator(); 172 return (!page) ? nullptr : page->scrollingCoordinator();
173 } 173 }
174 174
175 static WebLayer* nearestCompositedStickyLayer(
176 const StickyConstraintsMap& constraintsMap,
177 LayoutBoxModelObject* obj) {
178 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.
179 DCHECK(constraintsMap.contains(obj->layer()));
180 const StickyPositionScrollingConstraints constraints =
181 constraintsMap.at(obj->layer());
182 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
183 ? constraints.nearestStickyBoxShiftingStickyBox()
184 : constraints.nearestStickyBoxShiftingContainingBlock();
185 }
186
187 if (!obj)
188 return nullptr;
189
190 return obj->layer()
191 ->compositedLayerMapping()
192 ->mainGraphicsLayer()
193 ->platformLayer();
194 }
195
175 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) 196 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
176 : m_owningLayer(layer), 197 : m_owningLayer(layer),
177 m_contentOffsetInCompositingLayerDirty(false), 198 m_contentOffsetInCompositingLayerDirty(false),
178 m_pendingUpdateScope(GraphicsLayerUpdateNone), 199 m_pendingUpdateScope(GraphicsLayerUpdateNone),
179 m_isMainFrameLayoutViewLayer(false), 200 m_isMainFrameLayoutViewLayer(false),
180 m_backgroundLayerPaintsFixedRootBackground(false), 201 m_backgroundLayerPaintsFixedRootBackground(false),
181 m_scrollingContentsAreEmpty(false), 202 m_scrollingContentsAreEmpty(false),
182 m_backgroundPaintsOntoScrollingContentsLayer(false), 203 m_backgroundPaintsOntoScrollingContentsLayer(false),
183 m_backgroundPaintsOntoGraphicsLayer(false), 204 m_backgroundPaintsOntoGraphicsLayer(false),
184 m_drawsBackgroundOntoContentLayer(false) { 205 m_drawsBackgroundOntoContentLayer(false) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (sticky) { 321 if (sticky) {
301 if (!ancestorOverflowLayer->isRootLayer()) { 322 if (!ancestorOverflowLayer->isRootLayer()) {
302 sticky = ancestorOverflowLayer->needsCompositedScrolling(); 323 sticky = ancestorOverflowLayer->needsCompositedScrolling();
303 } else { 324 } else {
304 sticky = layoutObject().view()->frameView()->isScrollable(); 325 sticky = layoutObject().view()->frameView()->isScrollable();
305 } 326 }
306 } 327 }
307 328
308 WebLayerStickyPositionConstraint webConstraint; 329 WebLayerStickyPositionConstraint webConstraint;
309 if (sticky) { 330 if (sticky) {
331 const StickyConstraintsMap& constraintsMap =
332 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap();
310 const StickyPositionScrollingConstraints& constraints = 333 const StickyPositionScrollingConstraints& constraints =
311 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().at( 334 constraintsMap.at(&m_owningLayer);
312 &m_owningLayer);
313 335
314 // Find the layout offset of the unshifted sticky box within its 336 // Find the layout offset of the unshifted sticky box within its
315 // compositingContainer. If the enclosing layer is not the scroller, then 337 // compositingContainer. If the enclosing layer is not the scroller, then
316 // the offset must be adjusted to include the scroll offset to keep it 338 // the offset must be adjusted to include the scroll offset to keep it
317 // relative to compositingContainer. 339 // relative to compositingContainer.
318 LayoutPoint enclosingLayerOffset; 340 LayoutPoint enclosingLayerOffset;
319 compositingContainer->convertToLayerCoords(ancestorOverflowLayer, 341 compositingContainer->convertToLayerCoords(ancestorOverflowLayer,
320 enclosingLayerOffset); 342 enclosingLayerOffset);
321 if (compositingContainer != ancestorOverflowLayer) { 343 if (compositingContainer != ancestorOverflowLayer) {
322 enclosingLayerOffset += LayoutSize( 344 enclosingLayerOffset += LayoutSize(
(...skipping 22 matching lines...) Expand all
345 webConstraint.leftOffset = constraints.leftOffset(); 367 webConstraint.leftOffset = constraints.leftOffset();
346 webConstraint.rightOffset = constraints.rightOffset(); 368 webConstraint.rightOffset = constraints.rightOffset();
347 webConstraint.topOffset = constraints.topOffset(); 369 webConstraint.topOffset = constraints.topOffset();
348 webConstraint.bottomOffset = constraints.bottomOffset(); 370 webConstraint.bottomOffset = constraints.bottomOffset();
349 webConstraint.parentRelativeStickyBoxOffset = 371 webConstraint.parentRelativeStickyBoxOffset =
350 roundedIntPoint(stickyBoxOffset); 372 roundedIntPoint(stickyBoxOffset);
351 webConstraint.scrollContainerRelativeStickyBoxRect = 373 webConstraint.scrollContainerRelativeStickyBoxRect =
352 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); 374 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect());
353 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( 375 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect(
354 constraints.scrollContainerRelativeContainingBlockRect()); 376 constraints.scrollContainerRelativeContainingBlockRect());
355 // TODO(smcgruer): Copy fields for nested sticky in cc (crbug.com/672710) 377 webConstraint.nearestLayerShiftingStickyBox = nearestCompositedStickyLayer(
378 constraintsMap, constraints.nearestStickyBoxShiftingStickyBox());
379 webConstraint.nearestLayerShiftingContainingBlock =
380 nearestCompositedStickyLayer(
381 constraintsMap,
382 constraints.nearestStickyBoxShiftingContainingBlock());
383 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.
356 } 384 }
357 385
358 m_graphicsLayer->setStickyPositionConstraint(webConstraint); 386 m_graphicsLayer->setStickyPositionConstraint(webConstraint);
359 } 387 }
360 388
361 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { 389 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) {
362 setBlendMode(style.blendMode()); 390 setBlendMode(style.blendMode());
363 } 391 }
364 392
365 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { 393 void CompositedLayerMapping::updateIsRootForIsolatedGroup() {
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3487 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3515 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3488 name = "Decoration Layer"; 3516 name = "Decoration Layer";
3489 } else { 3517 } else {
3490 ASSERT_NOT_REACHED(); 3518 ASSERT_NOT_REACHED();
3491 } 3519 }
3492 3520
3493 return name; 3521 return name;
3494 } 3522 }
3495 3523
3496 } // namespace blink 3524 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698