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

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

Issue 23903012: Set up scroll and clip parents (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressing enne's review. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 case CompositedScrollingAlwaysOn: 2060 case CompositedScrollingAlwaysOn:
2061 return true; 2061 return true;
2062 case CompositedScrollingAlwaysOff: 2062 case CompositedScrollingAlwaysOff:
2063 return false; 2063 return false;
2064 } 2064 }
2065 2065
2066 ASSERT_NOT_REACHED(); 2066 ASSERT_NOT_REACHED();
2067 return m_needsCompositedScrolling; 2067 return m_needsCompositedScrolling;
2068 } 2068 }
2069 2069
2070 RenderLayer* RenderLayer::scrollParent() const
2071 {
2072 if (!compositorDrivenAcceleratedScrollingEnabled())
2073 return 0;
2074
2075 // A layer scrolls with its containing block. So to find the overflow scroll ing layer
2076 // that we scroll with respect to, we must ascend the layer tree until we re ach the
2077 // first overflow scrolling div at or above our containing block. I will ref er to this
2078 // layer as our 'scrolling ancestor'.
2079 //
2080 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling
enne (OOO) 2013/09/11 23:18:30 This comment is really great.
Ian Vollick 2013/09/12 03:17:52 Thanks :)
2081 // ancestor, and we need not be composited. If, on the other hand, we reside in a z-order
2082 // list, and on our walk upwards to our scrolling ancestor we find no layer that is a stacking
2083 // context, then we know that in the stacking tree, we will not be in the su btree rooted at
2084 // our scrolling ancestor, and we will therefore not scroll with it. In this case, we must
2085 // be a composited layer since the compositor will need to take special meas ures to ensure
2086 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote.
2087 RenderLayer* scrollParent = ancestorScrollingLayer();
2088
2089 if (!scrollParent || scrollParent->isStackingContext())
2090 return 0;
2091
2092 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already
2093 // be composited due to an overflow scrolling parent, so we don't need to.
2094 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) {
2095 if (ancestor->isStackingContext())
2096 return 0;
2097 }
2098
2099 return scrollParent;
2100 }
2101
2102 RenderLayer* RenderLayer::clipParent() const
2103 {
2104 const bool needsAncestorClip = compositor()->clippedByAncestor(this);
2105
2106 RenderLayer* clipParent = 0;
2107 if ((compositingReasons() & CompositingReasonOutOfFlowClipping) && !needsAnc estorClip) {
2108 if (RenderObject* containingBlock = renderer()->containingBlock())
2109 clipParent = containingBlock->enclosingLayer()->enclosingCompositing Layer(true);
2110 }
2111
2112 return clipParent;
2113 }
2114
2070 void RenderLayer::updateNeedsCompositedScrolling() 2115 void RenderLayer::updateNeedsCompositedScrolling()
2071 { 2116 {
2072 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); 2117 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling");
2073 2118
2074 updateCanBeStackingContainer(); 2119 updateCanBeStackingContainer();
2075 updateDescendantDependentFlags(); 2120 updateDescendantDependentFlags();
2076 2121
2077 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea())); 2122 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea()));
2078 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed() 2123 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed()
2079 && canBeStackingContainer() 2124 && canBeStackingContainer()
(...skipping 3237 matching lines...) Expand 10 before | Expand all | Expand 10 after
5317 bool RenderLayer::hasCompositedMask() const 5362 bool RenderLayer::hasCompositedMask() const
5318 { 5363 {
5319 return m_backing && m_backing->hasMaskLayer(); 5364 return m_backing && m_backing->hasMaskLayer();
5320 } 5365 }
5321 5366
5322 GraphicsLayer* RenderLayer::layerForScrolling() const 5367 GraphicsLayer* RenderLayer::layerForScrolling() const
5323 { 5368 {
5324 return m_backing ? m_backing->scrollingContentsLayer() : 0; 5369 return m_backing ? m_backing->scrollingContentsLayer() : 0;
5325 } 5370 }
5326 5371
5372 GraphicsLayer* RenderLayer::layerForScrollChild() const
5373 {
5374 // If we have an ancestor clipping layer because of our scroll parent, we do not want to
5375 // scroll that clip layer -- we need it to stay put and we will slide within it. If, on
5376 // the other hand, we have an ancestor clipping layer due to some other clip ping layer, we
5377 // want to scroll the root of the layer's associated graphics layer subtree. I.e., we want it
5378 // and its clip to move in concert.
5379
5380 if (!backing())
5381 return 0;
5382
5383 if (backing()->hasAncestorScrollClippingLayer()) {
5384 return backing()->hasAncestorClippingLayer()
5385 ? backing()->ancestorClippingLayer()
5386 : backing()->graphicsLayer();
5387 }
5388
5389 if (renderer()->containingBlock()->enclosingLayer() == ancestorScrollingLaye r())
5390 return backing()->graphicsLayer();
5391
5392 return backing()->childForSuperlayers();
5393 }
5394
5327 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const 5395 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const
5328 { 5396 {
5329 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; 5397 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0;
5330 } 5398 }
5331 5399
5332 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const 5400 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const
5333 { 5401 {
5334 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; 5402 return m_backing ? m_backing->layerForVerticalScrollbar() : 0;
5335 } 5403 }
5336 5404
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
6053 return; 6121 return;
6054 6122
6055 FrameView* frameView = frame->view(); 6123 FrameView* frameView = frame->view();
6056 if (!frameView) 6124 if (!frameView)
6057 return; 6125 return;
6058 6126
6059 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); 6127 bool isVisibleToHitTest = renderer()->visibleToHitTesting();
6060 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) 6128 if (HTMLFrameOwnerElement* owner = frame->ownerElement())
6061 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting(); 6129 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting();
6062 6130
6063 if (hasOverflow && isVisibleToHitTest) { 6131 bool requiresScrollableArea = hasOverflow && isVisibleToHitTest;
6064 if (frameView->addScrollableArea(scrollableArea())) { 6132 bool updatedScrollableAreaSet = false;
6065 compositor()->setNeedsUpdateCompositingRequirementsState(); 6133 if (requiresScrollableArea) {
6066 6134 if (frameView->addScrollableArea(scrollableArea()))
6067 // Count the total number of RenderLayers that are scrollable areas for 6135 updatedScrollableAreaSet = true;
6068 // any period. We only want to record this at most once per RenderLa yer.
6069 if (!m_isScrollableAreaHasBeenRecorded) {
6070 HistogramSupport::histogramEnumeration("Renderer.CompositedScrol ling", IsScrollableAreaBucket, CompositedScrollingHistogramMax);
6071 m_isScrollableAreaHasBeenRecorded = true;
6072 }
6073 }
6074 } else { 6136 } else {
6075 if (frameView->removeScrollableArea(scrollableArea())) 6137 if (frameView->removeScrollableArea(scrollableArea()))
6138 updatedScrollableAreaSet = true;
6139 }
6140
6141 if (updatedScrollableAreaSet) {
6142 // Count the total number of RenderLayers that are scrollable areas for
6143 // any period. We only want to record this at most once per RenderLayer.
6144 if (requiresScrollableArea && !m_isScrollableAreaHasBeenRecorded) {
6145 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling ", IsScrollableAreaBucket, CompositedScrollingHistogramMax);
6146 m_isScrollableAreaHasBeenRecorded = true;
6147 }
6148
6149 // We always want composited scrolling if compositor driven accelerated
6150 // scrolling is enabled. Since we will not update needs composited scrol ling
6151 // in this case, we must force our state to update.
6152 if (compositorDrivenAcceleratedScrollingEnabled())
6153 didUpdateNeedsCompositedScrolling();
6154 else if (requiresScrollableArea)
6155 compositor()->setNeedsUpdateCompositingRequirementsState();
6156 else
6076 setNeedsCompositedScrolling(false); 6157 setNeedsCompositedScrolling(false);
6077 } 6158 }
6078 } 6159 }
6079 6160
6080 void RenderLayer::updateScrollCornerStyle() 6161 void RenderLayer::updateScrollCornerStyle()
6081 { 6162 {
6082 RenderObject* actualRenderer = rendererForScrollbar(renderer()); 6163 RenderObject* actualRenderer = rendererForScrollbar(renderer());
6083 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0); 6164 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0);
6084 if (corner) { 6165 if (corner) {
6085 if (!m_scrollCorner) { 6166 if (!m_scrollCorner) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
6357 } 6438 }
6358 } 6439 }
6359 6440
6360 void showLayerTree(const WebCore::RenderObject* renderer) 6441 void showLayerTree(const WebCore::RenderObject* renderer)
6361 { 6442 {
6362 if (!renderer) 6443 if (!renderer)
6363 return; 6444 return;
6364 showLayerTree(renderer->enclosingLayer()); 6445 showLayerTree(renderer->enclosingLayer());
6365 } 6446 }
6366 #endif 6447 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698