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

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

Issue 2636253002: Handle nested position:sticky elements (Closed)
Patch Set: Trying to add cc unittest, fails for unknown reason Created 3 years, 10 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 layoutObject->isVideo(); 162 layoutObject->isVideo();
163 } 163 }
164 164
165 // Get the scrolling coordinator in a way that works inside 165 // Get the scrolling coordinator in a way that works inside
166 // CompositedLayerMapping's destructor. 166 // CompositedLayerMapping's destructor.
167 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { 167 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
168 Page* page = layer.layoutObject()->frame()->page(); 168 Page* page = layer.layoutObject()->frame()->page();
169 return (!page) ? nullptr : page->scrollingCoordinator(); 169 return (!page) ? nullptr : page->scrollingCoordinator();
170 } 170 }
171 171
172 static WebLayer* nearestCompositedStickyLayer(
173 const StickyConstraintsMap& constraintsMap,
174 LayoutBoxModelObject* obj) {
175 while (obj && obj->compositingState() == NotComposited) {
176 DCHECK(constraintsMap.contains(obj->layer()));
177 const StickyPositionScrollingConstraints constraints =
178 constraintsMap.get(obj->layer());
179 obj = constraints.nearestStickyElementShiftingStickyBox()
180 ? constraints.nearestStickyElementShiftingStickyBox()
181 : constraints.nearestStickyElementShiftingContainingBlock();
182 }
183
184 if (!obj)
185 return nullptr;
186
187 return obj->layer()
188 ->compositedLayerMapping()
189 ->mainGraphicsLayer()
190 ->platformLayer();
191 }
192
172 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) 193 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
173 : m_owningLayer(layer), 194 : m_owningLayer(layer),
174 m_contentOffsetInCompositingLayerDirty(false), 195 m_contentOffsetInCompositingLayerDirty(false),
175 m_pendingUpdateScope(GraphicsLayerUpdateNone), 196 m_pendingUpdateScope(GraphicsLayerUpdateNone),
176 m_isMainFrameLayoutViewLayer(false), 197 m_isMainFrameLayoutViewLayer(false),
177 m_backgroundLayerPaintsFixedRootBackground(false), 198 m_backgroundLayerPaintsFixedRootBackground(false),
178 m_scrollingContentsAreEmpty(false), 199 m_scrollingContentsAreEmpty(false),
179 m_backgroundPaintsOntoScrollingContentsLayer(false), 200 m_backgroundPaintsOntoScrollingContentsLayer(false),
180 m_backgroundPaintsOntoGraphicsLayer(false) { 201 m_backgroundPaintsOntoGraphicsLayer(false) {
181 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) 202 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame())
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (sticky) { 316 if (sticky) {
296 if (!ancestorOverflowLayer->isRootLayer()) { 317 if (!ancestorOverflowLayer->isRootLayer()) {
297 sticky = ancestorOverflowLayer->needsCompositedScrolling(); 318 sticky = ancestorOverflowLayer->needsCompositedScrolling();
298 } else { 319 } else {
299 sticky = layoutObject()->view()->frameView()->isScrollable(); 320 sticky = layoutObject()->view()->frameView()->isScrollable();
300 } 321 }
301 } 322 }
302 323
303 WebLayerStickyPositionConstraint webConstraint; 324 WebLayerStickyPositionConstraint webConstraint;
304 if (sticky) { 325 if (sticky) {
326 const StickyConstraintsMap& constraintsMap =
327 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap();
305 const StickyPositionScrollingConstraints& constraints = 328 const StickyPositionScrollingConstraints& constraints =
306 ancestorOverflowLayer->getScrollableArea()->stickyConstraintsMap().get( 329 constraintsMap.get(&m_owningLayer);
307 &m_owningLayer);
308 330
309 // Find the layout offset of the unshifted sticky box within its enclosing 331 // Find the layout offset of the unshifted sticky box within its enclosing
310 // layer. 332 // layer.
311 LayoutPoint enclosingLayerOffset; 333 LayoutPoint enclosingLayerOffset;
312 m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf) 334 m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf)
313 ->convertToLayerCoords(m_owningLayer.ancestorOverflowLayer(), 335 ->convertToLayerCoords(m_owningLayer.ancestorOverflowLayer(),
314 enclosingLayerOffset); 336 enclosingLayerOffset);
337
315 FloatPoint stickyBoxOffset = 338 FloatPoint stickyBoxOffset =
316 constraints.scrollContainerRelativeStickyBoxRect().location(); 339 constraints.scrollContainerRelativeStickyBoxRect().location();
317 DCHECK(!m_contentOffsetInCompositingLayerDirty); 340 DCHECK(!m_contentOffsetInCompositingLayerDirty);
318 stickyBoxOffset.moveBy(FloatPoint(-enclosingLayerOffset) - 341 stickyBoxOffset.moveBy(FloatPoint(-enclosingLayerOffset) -
319 FloatSize(contentOffsetInCompositingLayer())); 342 FloatSize(contentOffsetInCompositingLayer()));
320 343
321 webConstraint.isSticky = true; 344 webConstraint.isSticky = true;
322 webConstraint.isAnchoredLeft = 345 webConstraint.isAnchoredLeft =
323 constraints.anchorEdges() & 346 constraints.anchorEdges() &
324 StickyPositionScrollingConstraints::AnchorEdgeLeft; 347 StickyPositionScrollingConstraints::AnchorEdgeLeft;
325 webConstraint.isAnchoredRight = 348 webConstraint.isAnchoredRight =
326 constraints.anchorEdges() & 349 constraints.anchorEdges() &
327 StickyPositionScrollingConstraints::AnchorEdgeRight; 350 StickyPositionScrollingConstraints::AnchorEdgeRight;
328 webConstraint.isAnchoredTop = 351 webConstraint.isAnchoredTop =
329 constraints.anchorEdges() & 352 constraints.anchorEdges() &
330 StickyPositionScrollingConstraints::AnchorEdgeTop; 353 StickyPositionScrollingConstraints::AnchorEdgeTop;
331 webConstraint.isAnchoredBottom = 354 webConstraint.isAnchoredBottom =
332 constraints.anchorEdges() & 355 constraints.anchorEdges() &
333 StickyPositionScrollingConstraints::AnchorEdgeBottom; 356 StickyPositionScrollingConstraints::AnchorEdgeBottom;
334 webConstraint.leftOffset = constraints.leftOffset(); 357 webConstraint.leftOffset = constraints.leftOffset();
335 webConstraint.rightOffset = constraints.rightOffset(); 358 webConstraint.rightOffset = constraints.rightOffset();
336 webConstraint.topOffset = constraints.topOffset(); 359 webConstraint.topOffset = constraints.topOffset();
337 webConstraint.bottomOffset = constraints.bottomOffset(); 360 webConstraint.bottomOffset = constraints.bottomOffset();
338 webConstraint.parentRelativeStickyBoxOffset = 361 webConstraint.parentRelativeStickyBoxOffset =
339 roundedIntPoint(stickyBoxOffset); 362 roundedIntPoint(stickyBoxOffset);
340 webConstraint.scrollContainerRelativeStickyBoxRect = 363 webConstraint.scrollContainerRelativeStickyBoxRect =
341 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect()); 364 enclosingIntRect(constraints.scrollContainerRelativeStickyBoxRect());
342 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect( 365 webConstraint.scrollContainerRelativeContainingBlockRect = enclosingIntRect(
343 constraints.scrollContainerRelativeContainingBlockRect()); 366 constraints.scrollContainerRelativeContainingBlockRect());
367 webConstraint.nearestLayerShiftingStickyBox = nearestCompositedStickyLayer(
368 constraintsMap, constraints.nearestStickyElementShiftingStickyBox());
369 webConstraint.nearestLayerShiftingContainingBlock =
370 nearestCompositedStickyLayer(
371 constraintsMap,
372 constraints.nearestStickyElementShiftingContainingBlock());
373 webConstraint.cachedComputedStickyOffset =
374 constraints.getCachedComputedStickyOffset();
344 } 375 }
345 376
346 m_graphicsLayer->setStickyPositionConstraint(webConstraint); 377 m_graphicsLayer->setStickyPositionConstraint(webConstraint);
347 } 378 }
348 379
349 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) { 380 void CompositedLayerMapping::updateLayerBlendMode(const ComputedStyle& style) {
350 setBlendMode(style.blendMode()); 381 setBlendMode(style.blendMode());
351 } 382 }
352 383
353 void CompositedLayerMapping::updateIsRootForIsolatedGroup() { 384 void CompositedLayerMapping::updateIsRootForIsolatedGroup() {
(...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3501 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3471 name = "Decoration Layer"; 3502 name = "Decoration Layer";
3472 } else { 3503 } else {
3473 ASSERT_NOT_REACHED(); 3504 ASSERT_NOT_REACHED();
3474 } 3505 }
3475 3506
3476 return name; 3507 return name;
3477 } 3508 }
3478 3509
3479 } // namespace blink 3510 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698