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

Side by Side Diff: Source/core/rendering/RenderLayerCompositor.cpp

Issue 103213002: position:sticky should stick for the enclosing overflow ancestor (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 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 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 bool RenderLayerCompositor::requiresCompositingForOverflowScrollingParent(const RenderLayer* layer) const 1789 bool RenderLayerCompositor::requiresCompositingForOverflowScrollingParent(const RenderLayer* layer) const
1790 { 1790 {
1791 return !!layer->scrollParent(); 1791 return !!layer->scrollParent();
1792 } 1792 }
1793 1793
1794 bool RenderLayerCompositor::requiresCompositingForOutOfFlowClipping(const Render Layer* layer) const 1794 bool RenderLayerCompositor::requiresCompositingForOutOfFlowClipping(const Render Layer* layer) const
1795 { 1795 {
1796 return layer->compositorDrivenAcceleratedScrollingEnabled() && layer->isUncl ippedDescendant(); 1796 return layer->compositorDrivenAcceleratedScrollingEnabled() && layer->isUncl ippedDescendant();
1797 } 1797 }
1798 1798
1799 static bool isViewportConstrainedFixedOrStickyLayer(const RenderLayer* layer)
1800 {
1801 if (layer->renderer()->isStickyPositioned())
1802 return !layer->enclosingOverflowClipLayer(false);
1803
1804 if (layer->renderer()->style()->position() != FixedPosition)
1805 return false;
1806
1807 for (const RenderLayerStackingNode* stackingContainer = layer->stackingNode( ); stackingContainer;
1808 stackingContainer = stackingContainer->ancestorStackingContainerNode()) {
1809 if (stackingContainer->layer()->compositingState() != NotComposited
Julien - ping for review 2014/01/06 17:22:07 The old code was checking stackingContainer->layer
shawnsingh 2014/01/06 20:02:48 Actually what ostap@ has done here is reasonable.
ostap 2014/01/08 01:46:40 The original code in webkit patch calls stackingCo
Julien - ping for review 2014/01/08 15:31:45 I stand corrected by Shawn. I was more comfortable
1810 && stackingContainer->layer()->renderer()->style()->position() == Fi xedPosition)
1811 return false;
1812 }
1813
1814 return true;
1815 }
1816
1799 bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere r, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason * viewportConstrainedNotCompositedReason) const 1817 bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere r, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason * viewportConstrainedNotCompositedReason) const
1800 { 1818 {
1801 // position:fixed elements that create their own stacking context (e.g. have an explicit z-index, 1819 // position:fixed elements that create their own stacking context (e.g. have an explicit z-index,
1802 // opacity, transform) can get their own composited layer. A stacking contex t is required otherwise 1820 // opacity, transform) can get their own composited layer. A stacking contex t is required otherwise
1803 // z-index and clipping will be broken. 1821 // z-index and clipping will be broken.
1804 if (!renderer->isPositioned()) 1822 if (!renderer->isPositioned())
1805 return false; 1823 return false;
1806 1824
1807 EPosition position = renderer->style()->position(); 1825 EPosition position = renderer->style()->position();
1808 bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPositio n; 1826 bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPositio n;
1809 if (isFixed && !layer->stackingNode()->isStackingContainer()) 1827 if (isFixed && !layer->stackingNode()->isStackingContainer())
1810 return false; 1828 return false;
1811 1829
1812 bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition ; 1830 bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition ;
1813 if (!isFixed && !isSticky) 1831 if (!isFixed && !isSticky)
1814 return false; 1832 return false;
1815 1833
1816 // FIXME: acceleratedCompositingForFixedPositionEnabled should probably be r enamed acceleratedCompositingForViewportConstrainedPositionEnabled(). 1834 // FIXME: acceleratedCompositingForFixedPositionEnabled should probably be r enamed acceleratedCompositingForViewportConstrainedPositionEnabled().
1817 if (Settings* settings = m_renderView->document().settings()) { 1835 if (Settings* settings = m_renderView->document().settings()) {
1818 if (!settings->acceleratedCompositingForFixedPositionEnabled()) 1836 if (!settings->acceleratedCompositingForFixedPositionEnabled())
1819 return false; 1837 return false;
1820 } 1838 }
1821 1839
1822 if (isSticky) 1840 if (isSticky)
1823 return true; 1841 return isViewportConstrainedFixedOrStickyLayer(layer);
1824 1842
1825 RenderObject* container = renderer->container(); 1843 RenderObject* container = renderer->container();
1826 // If the renderer is not hooked up yet then we have to wait until it is. 1844 // If the renderer is not hooked up yet then we have to wait until it is.
1827 if (!container) { 1845 if (!container) {
1828 m_needsToRecomputeCompositingRequirements = true; 1846 m_needsToRecomputeCompositingRequirements = true;
1829 return false; 1847 return false;
1830 } 1848 }
1831 1849
1832 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. 1850 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements.
1833 // They will stay fixed wrt the container rather than the enclosing frame. 1851 // They will stay fixed wrt the container rather than the enclosing frame.
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 2357
2340 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren ); 2358 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren );
2341 while (RenderLayerStackingNode* curNode = iterator.next()) { 2359 while (RenderLayerStackingNode* curNode = iterator.next()) {
2342 if (layerHas3DContent(curNode->layer())) 2360 if (layerHas3DContent(curNode->layer()))
2343 return true; 2361 return true;
2344 } 2362 }
2345 2363
2346 return false; 2364 return false;
2347 } 2365 }
2348 2366
2349 static bool isRootmostFixedOrStickyLayer(RenderLayer* layer)
2350 {
2351 if (layer->renderer()->isStickyPositioned())
2352 return true;
2353
2354 if (layer->renderer()->style()->position() != FixedPosition)
2355 return false;
2356
2357 for (RenderLayerStackingNode* stackingContainerNode = layer->stackingNode()- >ancestorStackingContainerNode(); stackingContainerNode; stackingContainerNode = stackingContainerNode->ancestorStackingContainerNode()) {
2358 if (stackingContainerNode->layer()->hasCompositedLayerMapping() && stack ingContainerNode->layer()->renderer()->style()->position() == FixedPosition)
2359 return false;
2360 }
2361
2362 return true;
2363 }
2364
2365 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer) 2367 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer)
2366 { 2368 {
2367 if (isRootmostFixedOrStickyLayer(layer)) 2369 if (isViewportConstrainedFixedOrStickyLayer(layer))
2368 addViewportConstrainedLayer(layer); 2370 addViewportConstrainedLayer(layer);
2369 else 2371 else
2370 removeViewportConstrainedLayer(layer); 2372 removeViewportConstrainedLayer(layer);
2371 } 2373 }
2372 2374
2373 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer) 2375 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer)
2374 { 2376 {
2375 m_viewportConstrainedLayers.add(layer); 2377 m_viewportConstrainedLayers.add(layer);
2376 } 2378 }
2377 2379
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 // If top and bottom are auto, use top. 2419 // If top and bottom are auto, use top.
2418 if (style->top().isAuto() && style->bottom().isAuto()) 2420 if (style->top().isAuto() && style->bottom().isAuto())
2419 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); 2421 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
2420 2422
2421 return constraints; 2423 return constraints;
2422 } 2424 }
2423 2425
2424 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const 2426 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const
2425 { 2427 {
2426 ASSERT(layer->hasCompositedLayerMapping()); 2428 ASSERT(layer->hasCompositedLayerMapping());
2429 // We should never get here for stickies constrained by an enclosing clippin g layer.
2430 ASSERT(!layer->enclosingOverflowClipLayer(false));
2427 2431
2428 FrameView* frameView = m_renderView->frameView(); 2432 FrameView* frameView = m_renderView->frameView();
2429 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ; 2433 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ;
2430 2434
2431 StickyPositionViewportConstraints constraints; 2435 StickyPositionViewportConstraints constraints;
2432 2436
2433 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer()); 2437 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer());
2434 2438
2435 renderer->computeStickyPositionConstraints(constraints, viewportRect); 2439 renderer->computeStickyPositionConstraints(constraints, viewportRect);
2436 2440
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 } else if (graphicsLayer == m_scrollLayer.get()) { 2488 } else if (graphicsLayer == m_scrollLayer.get()) {
2485 name = "Frame Scrolling Layer"; 2489 name = "Frame Scrolling Layer";
2486 } else { 2490 } else {
2487 ASSERT_NOT_REACHED(); 2491 ASSERT_NOT_REACHED();
2488 } 2492 }
2489 2493
2490 return name; 2494 return name;
2491 } 2495 }
2492 2496
2493 } // namespace WebCore 2497 } // namespace WebCore
OLDNEW
« Source/core/rendering/RenderLayer.h ('K') | « Source/core/rendering/RenderLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698