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

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: Addressed the easier reviewer comments. 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 layoutObject.isVideo(); 166 layoutObject.isVideo();
167 } 167 }
168 168
169 // Get the scrolling coordinator in a way that works inside 169 // Get the scrolling coordinator in a way that works inside
170 // CompositedLayerMapping's destructor. 170 // CompositedLayerMapping's destructor.
171 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { 171 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
172 Page* page = layer.layoutObject().frame()->page(); 172 Page* page = layer.layoutObject().frame()->page();
173 return (!page) ? nullptr : page->scrollingCoordinator(); 173 return (!page) ? nullptr : page->scrollingCoordinator();
174 } 174 }
175 175
176 static WebLayer* nearestCompositedStickyLayer(
177 const StickyConstraintsMap& constraintsMap,
178 LayoutBoxModelObject* obj) {
179 while (obj && !obj->layer()->compositedLayerMapping()) {
180 DCHECK(constraintsMap.contains(obj->layer()));
181 const StickyPositionScrollingConstraints constraints =
182 constraintsMap.at(obj->layer());
183 obj = constraints.nearestStickyBoxShiftingStickyBox()
184 ? constraints.nearestStickyBoxShiftingStickyBox()
185 : constraints.nearestStickyBoxShiftingContainingBlock();
186 }
187
188 if (!obj)
189 return nullptr;
190
191 return obj->layer()
192 ->compositedLayerMapping()
193 ->mainGraphicsLayer()
194 ->platformLayer();
195 }
196
176 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) 197 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
177 : m_owningLayer(layer), 198 : m_owningLayer(layer),
178 m_contentOffsetInCompositingLayerDirty(false), 199 m_contentOffsetInCompositingLayerDirty(false),
179 m_pendingUpdateScope(GraphicsLayerUpdateNone), 200 m_pendingUpdateScope(GraphicsLayerUpdateNone),
180 m_isMainFrameLayoutViewLayer(false), 201 m_isMainFrameLayoutViewLayer(false),
181 m_backgroundLayerPaintsFixedRootBackground(false), 202 m_backgroundLayerPaintsFixedRootBackground(false),
182 m_scrollingContentsAreEmpty(false), 203 m_scrollingContentsAreEmpty(false),
183 m_backgroundPaintsOntoScrollingContentsLayer(false), 204 m_backgroundPaintsOntoScrollingContentsLayer(false),
184 m_backgroundPaintsOntoGraphicsLayer(false), 205 m_backgroundPaintsOntoGraphicsLayer(false),
185 m_drawsBackgroundOntoContentLayer(false) { 206 m_drawsBackgroundOntoContentLayer(false) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (sticky) { 322 if (sticky) {
302 if (!ancestorOverflowLayer->isRootLayer()) { 323 if (!ancestorOverflowLayer->isRootLayer()) {
303 sticky = ancestorOverflowLayer->needsCompositedScrolling(); 324 sticky = ancestorOverflowLayer->needsCompositedScrolling();
304 } else { 325 } else {
305 sticky = layoutObject().view()->frameView()->isScrollable(); 326 sticky = layoutObject().view()->frameView()->isScrollable();
306 } 327 }
307 } 328 }
308 329
309 WebLayerStickyPositionConstraint webConstraint; 330 WebLayerStickyPositionConstraint webConstraint;
310 if (sticky) { 331 if (sticky) {
332 const StickyConstraintsMap& constraintsMap =
333 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap();
311 const StickyPositionScrollingConstraints& constraints = 334 const StickyPositionScrollingConstraints& constraints =
312 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().at( 335 constraintsMap.at(&m_owningLayer);
313 &m_owningLayer);
314 336
315 // Find the layout offset of the unshifted sticky box within its 337 // Find the layout offset of the unshifted sticky box within its
316 // compositingContainer. If the enclosing layer is not the scroller, then 338 // compositingContainer. If the enclosing layer is not the scroller, then
317 // the offset must be adjusted to include the scroll offset to keep it 339 // the offset must be adjusted to include the scroll offset to keep it
318 // relative to compositingContainer. 340 // relative to compositingContainer.
319 LayoutPoint enclosingLayerOffset; 341 LayoutPoint enclosingLayerOffset;
320 compositingContainer->convertToLayerCoords(ancestorOverflowLayer, 342 compositingContainer->convertToLayerCoords(ancestorOverflowLayer,
321 enclosingLayerOffset); 343 enclosingLayerOffset);
322 if (compositingContainer != ancestorOverflowLayer) { 344 if (compositingContainer != ancestorOverflowLayer) {
323 enclosingLayerOffset += LayoutSize( 345 enclosingLayerOffset += LayoutSize(
(...skipping 22 matching lines...) Expand all
346 webConstraint.leftOffset = constraints.leftOffset(); 368 webConstraint.leftOffset = constraints.leftOffset();
347 webConstraint.rightOffset = constraints.rightOffset(); 369 webConstraint.rightOffset = constraints.rightOffset();
348 webConstraint.topOffset = constraints.topOffset(); 370 webConstraint.topOffset = constraints.topOffset();
349 webConstraint.bottomOffset = constraints.bottomOffset(); 371 webConstraint.bottomOffset = constraints.bottomOffset();
350 webConstraint.parentRelativeStickyBoxOffset = 372 webConstraint.parentRelativeStickyBoxOffset =
351 roundedIntPoint(stickyBoxOffset); 373 roundedIntPoint(stickyBoxOffset);
352 webConstraint.scrollContainerRelativeStickyBoxRect = 374 webConstraint.scrollContainerRelativeStickyBoxRect =
353 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); 375 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect());
354 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( 376 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect(
355 constraints.scrollContainerRelativeContainingBlockRect()); 377 constraints.scrollContainerRelativeContainingBlockRect());
356 // TODO(smcgruer): Copy fields for nested sticky in cc (crbug.com/672710) 378 webConstraint.nearestLayerShiftingStickyBox = nearestCompositedStickyLayer(
379 constraintsMap, constraints.nearestStickyBoxShiftingStickyBox());
380 webConstraint.nearestLayerShiftingContainingBlock =
381 nearestCompositedStickyLayer(
382 constraintsMap,
383 constraints.nearestStickyBoxShiftingContainingBlock());
384 webConstraint.localStickyOffset = constraints.getLocalStickyOffset();
357 } 385 }
358 386
359 m_graphicsLayer->setStickyPositionConstraint(webConstraint); 387 m_graphicsLayer->setStickyPositionConstraint(webConstraint);
360 } 388 }
361 389
362 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { 390 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) {
363 setBlendMode(style.blendMode()); 391 setBlendMode(style.blendMode());
364 } 392 }
365 393
366 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { 394 void CompositedLayerMapping::updateIsRootForIsolatedGroup() {
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3540 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3513 name = "Decoration Layer"; 3541 name = "Decoration Layer";
3514 } else { 3542 } else {
3515 ASSERT_NOT_REACHED(); 3543 ASSERT_NOT_REACHED();
3516 } 3544 }
3517 3545
3518 return name; 3546 return name;
3519 } 3547 }
3520 3548
3521 } // namespace blink 3549 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698