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

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: Add back changes in RenderBoxModelObject.cpp eaten by rebase. Created 6 years, 11 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
« no previous file with comments | « Source/core/rendering/RenderLayer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint(); 651 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint();
652 if (!repaintContainer) 652 if (!repaintContainer)
653 repaintContainer = m_renderView; 653 repaintContainer = m_renderView;
654 654
655 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine r); 655 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine r);
656 } 656 }
657 657
658 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge(). 658 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge().
659 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect) 659 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect)
660 { 660 {
661 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/); 661 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (ExcludeSelf);
662 if (compositedAncestor) { 662 if (compositedAncestor) {
663 // FIXME: make sure repaintRect is computed correctly for squashed scena rio 663 // FIXME: make sure repaintRect is computed correctly for squashed scena rio
664 LayoutPoint offset; 664 LayoutPoint offset;
665 layer->convertToLayerCoords(compositedAncestor, offset); 665 layer->convertToLayerCoords(compositedAncestor, offset);
666 666
667 LayoutRect repaintRect = rect; 667 LayoutRect repaintRect = rect;
668 repaintRect.moveBy(offset); 668 repaintRect.moveBy(offset);
669 669
670 if (compositedAncestor->compositingState() == PaintsIntoOwnBacking) { 670 if (compositedAncestor->compositingState() == PaintsIntoOwnBacking) {
671 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaint Rect); 671 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaint Rect);
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 bool RenderLayerCompositor::requiresCompositingForOverflowScrollingParent(const RenderLayer* layer) const 1898 bool RenderLayerCompositor::requiresCompositingForOverflowScrollingParent(const RenderLayer* layer) const
1899 { 1899 {
1900 return !!layer->scrollParent(); 1900 return !!layer->scrollParent();
1901 } 1901 }
1902 1902
1903 bool RenderLayerCompositor::requiresCompositingForOutOfFlowClipping(const Render Layer* layer) const 1903 bool RenderLayerCompositor::requiresCompositingForOutOfFlowClipping(const Render Layer* layer) const
1904 { 1904 {
1905 return layer->compositorDrivenAcceleratedScrollingEnabled() && layer->isUncl ippedDescendant(); 1905 return layer->compositorDrivenAcceleratedScrollingEnabled() && layer->isUncl ippedDescendant();
1906 } 1906 }
1907 1907
1908 static bool isViewportConstrainedFixedOrStickyLayer(const RenderLayer* layer)
1909 {
1910 if (layer->renderer()->isStickyPositioned())
1911 return !layer->enclosingOverflowClipLayer(ExcludeSelf);
1912
1913 if (layer->renderer()->style()->position() != FixedPosition)
1914 return false;
1915
1916 for (const RenderLayerStackingNode* stackingContainer = layer->stackingNode( ); stackingContainer;
1917 stackingContainer = stackingContainer->ancestorStackingContainerNode()) {
1918 if (stackingContainer->layer()->compositingState() != NotComposited
1919 && stackingContainer->layer()->renderer()->style()->position() == Fi xedPosition)
1920 return false;
1921 }
1922
1923 return true;
1924 }
1925
1908 bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere r, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason * viewportConstrainedNotCompositedReason) const 1926 bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere r, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason * viewportConstrainedNotCompositedReason) const
1909 { 1927 {
1910 // position:fixed elements that create their own stacking context (e.g. have an explicit z-index, 1928 // position:fixed elements that create their own stacking context (e.g. have an explicit z-index,
1911 // opacity, transform) can get their own composited layer. A stacking contex t is required otherwise 1929 // opacity, transform) can get their own composited layer. A stacking contex t is required otherwise
1912 // z-index and clipping will be broken. 1930 // z-index and clipping will be broken.
1913 if (!renderer->isPositioned()) 1931 if (!renderer->isPositioned())
1914 return false; 1932 return false;
1915 1933
1916 EPosition position = renderer->style()->position(); 1934 EPosition position = renderer->style()->position();
1917 bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPositio n; 1935 bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPositio n;
1918 if (isFixed && !layer->stackingNode()->isStackingContainer()) 1936 if (isFixed && !layer->stackingNode()->isStackingContainer())
1919 return false; 1937 return false;
1920 1938
1921 bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition ; 1939 bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition ;
1922 if (!isFixed && !isSticky) 1940 if (!isFixed && !isSticky)
1923 return false; 1941 return false;
1924 1942
1925 // FIXME: acceleratedCompositingForFixedPositionEnabled should probably be r enamed acceleratedCompositingForViewportConstrainedPositionEnabled(). 1943 // FIXME: acceleratedCompositingForFixedPositionEnabled should probably be r enamed acceleratedCompositingForViewportConstrainedPositionEnabled().
1926 if (Settings* settings = m_renderView->document().settings()) { 1944 if (Settings* settings = m_renderView->document().settings()) {
1927 if (!settings->acceleratedCompositingForFixedPositionEnabled()) 1945 if (!settings->acceleratedCompositingForFixedPositionEnabled())
1928 return false; 1946 return false;
1929 } 1947 }
1930 1948
1931 if (isSticky) 1949 if (isSticky)
1932 return true; 1950 return isViewportConstrainedFixedOrStickyLayer(layer);
1933 1951
1934 RenderObject* container = renderer->container(); 1952 RenderObject* container = renderer->container();
1935 // If the renderer is not hooked up yet then we have to wait until it is. 1953 // If the renderer is not hooked up yet then we have to wait until it is.
1936 if (!container) { 1954 if (!container) {
1937 m_needsToRecomputeCompositingRequirements = true; 1955 m_needsToRecomputeCompositingRequirements = true;
1938 return false; 1956 return false;
1939 } 1957 }
1940 1958
1941 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. 1959 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements.
1942 // They will stay fixed wrt the container rather than the enclosing frame. 1960 // They will stay fixed wrt the container rather than the enclosing frame.
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 2461
2444 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren ); 2462 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren );
2445 while (RenderLayerStackingNode* curNode = iterator.next()) { 2463 while (RenderLayerStackingNode* curNode = iterator.next()) {
2446 if (layerHas3DContent(curNode->layer())) 2464 if (layerHas3DContent(curNode->layer()))
2447 return true; 2465 return true;
2448 } 2466 }
2449 2467
2450 return false; 2468 return false;
2451 } 2469 }
2452 2470
2453 static bool isRootmostFixedOrStickyLayer(RenderLayer* layer)
2454 {
2455 if (layer->renderer()->isStickyPositioned())
2456 return true;
2457
2458 if (layer->renderer()->style()->position() != FixedPosition)
2459 return false;
2460
2461 for (RenderLayerStackingNode* stackingContainerNode = layer->stackingNode()- >ancestorStackingContainerNode(); stackingContainerNode; stackingContainerNode = stackingContainerNode->ancestorStackingContainerNode()) {
2462 if (stackingContainerNode->layer()->hasCompositedLayerMapping() && stack ingContainerNode->layer()->renderer()->style()->position() == FixedPosition)
2463 return false;
2464 }
2465
2466 return true;
2467 }
2468
2469 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer) 2471 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer)
2470 { 2472 {
2471 if (isRootmostFixedOrStickyLayer(layer)) 2473 if (isViewportConstrainedFixedOrStickyLayer(layer))
2472 addViewportConstrainedLayer(layer); 2474 addViewportConstrainedLayer(layer);
2473 else 2475 else
2474 removeViewportConstrainedLayer(layer); 2476 removeViewportConstrainedLayer(layer);
2475 } 2477 }
2476 2478
2477 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer) 2479 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer)
2478 { 2480 {
2479 m_viewportConstrainedLayers.add(layer); 2481 m_viewportConstrainedLayers.add(layer);
2480 } 2482 }
2481 2483
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 // If top and bottom are auto, use top. 2523 // If top and bottom are auto, use top.
2522 if (style->top().isAuto() && style->bottom().isAuto()) 2524 if (style->top().isAuto() && style->bottom().isAuto())
2523 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); 2525 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
2524 2526
2525 return constraints; 2527 return constraints;
2526 } 2528 }
2527 2529
2528 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const 2530 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const
2529 { 2531 {
2530 ASSERT(layer->hasCompositedLayerMapping()); 2532 ASSERT(layer->hasCompositedLayerMapping());
2533 // We should never get here for stickies constrained by an enclosing clippin g layer.
2534 ASSERT(!layer->enclosingOverflowClipLayer(ExcludeSelf));
2531 2535
2532 FrameView* frameView = m_renderView->frameView(); 2536 FrameView* frameView = m_renderView->frameView();
2533 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ; 2537 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ;
2534 2538
2535 StickyPositionViewportConstraints constraints; 2539 StickyPositionViewportConstraints constraints;
2536 2540
2537 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer()); 2541 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer());
2538 2542
2539 renderer->computeStickyPositionConstraints(constraints, viewportRect); 2543 renderer->computeStickyPositionConstraints(constraints, viewportRect);
2540 2544
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 } else if (graphicsLayer == m_scrollLayer.get()) { 2592 } else if (graphicsLayer == m_scrollLayer.get()) {
2589 name = "Frame Scrolling Layer"; 2593 name = "Frame Scrolling Layer";
2590 } else { 2594 } else {
2591 ASSERT_NOT_REACHED(); 2595 ASSERT_NOT_REACHED();
2592 } 2596 }
2593 2597
2594 return name; 2598 return name;
2595 } 2599 }
2596 2600
2597 } // namespace WebCore 2601 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698