Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2055 case CompositedScrollingAlwaysOn: | 2055 case CompositedScrollingAlwaysOn: |
| 2056 return true; | 2056 return true; |
| 2057 case CompositedScrollingAlwaysOff: | 2057 case CompositedScrollingAlwaysOff: |
| 2058 return false; | 2058 return false; |
| 2059 } | 2059 } |
| 2060 | 2060 |
| 2061 ASSERT_NOT_REACHED(); | 2061 ASSERT_NOT_REACHED(); |
| 2062 return m_needsCompositedScrolling; | 2062 return m_needsCompositedScrolling; |
| 2063 } | 2063 } |
| 2064 | 2064 |
| 2065 RenderLayer* RenderLayer::scrollParent() const | |
| 2066 { | |
| 2067 if (!compositorDrivenAcceleratedScrollingEnabled()) | |
| 2068 return 0; | |
| 2069 | |
| 2070 // A layer scrolls with its containing block. So to find the overflow scroll ing layer | |
| 2071 // that we scroll with respect to, we must ascend the layer tree until we re ach the | |
| 2072 // first overflow scrolling div at or above our containing block. I will ref er to this | |
| 2073 // layer as our 'scrolling ancestor'. | |
| 2074 // | |
| 2075 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling | |
| 2076 // ancestor, and we need not be composited. If, on the other hand, we reside in a z-order | |
| 2077 // list, and on our walk upwards to our scrolling ancestor we find no layer that is a stacking | |
| 2078 // context, then we know that in the stacking tree, we will not be in the su btree rooted at | |
| 2079 // our scrolling ancestor, and we will therefore not scroll with it. In this case, we must | |
| 2080 // be a composited layer since the compositor will need to take special meas ures to ensure | |
| 2081 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote. | |
| 2082 RenderLayer* scrollParent = ancestorScrollingLayer(); | |
| 2083 | |
| 2084 if (!scrollParent || scrollParent->isStackingContext()) | |
| 2085 return 0; | |
| 2086 | |
| 2087 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already | |
| 2088 // be composited due to an overflow scrolling parent, so we don't need to. | |
| 2089 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) { | |
| 2090 if (ancestor->isStackingContext()) | |
| 2091 return 0; | |
| 2092 } | |
| 2093 | |
| 2094 return scrollParent; | |
| 2095 } | |
| 2096 | |
| 2097 RenderLayer* RenderLayer::clipParent() const | |
| 2098 { | |
| 2099 const bool needsAncestorClip = compositor()->clippedByAncestor(this); | |
| 2100 | |
| 2101 RenderLayer* clipParent = 0; | |
| 2102 if ((compositingReasons() & CompositingReasonOutOfFlowClipping) && !needsAnc estorClip) { | |
| 2103 if (RenderObject* containingBlock = renderer()->containingBlock()) | |
| 2104 clipParent = containingBlock->enclosingLayer()->enclosingCompositing Layer(true); | |
| 2105 } | |
| 2106 | |
| 2107 return clipParent; | |
| 2108 } | |
| 2109 | |
| 2065 void RenderLayer::updateNeedsCompositedScrolling() | 2110 void RenderLayer::updateNeedsCompositedScrolling() |
| 2066 { | 2111 { |
| 2067 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); | 2112 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); |
| 2068 | 2113 |
| 2069 updateCanBeStackingContainer(); | 2114 updateCanBeStackingContainer(); |
| 2070 updateDescendantDependentFlags(); | 2115 updateDescendantDependentFlags(); |
| 2071 | 2116 |
| 2072 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea())); | 2117 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea())); |
| 2073 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed() | 2118 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed() |
| 2074 && canBeStackingContainer() | 2119 && canBeStackingContainer() |
| (...skipping 3234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5309 bool RenderLayer::hasCompositedMask() const | 5354 bool RenderLayer::hasCompositedMask() const |
| 5310 { | 5355 { |
| 5311 return m_backing && m_backing->hasMaskLayer(); | 5356 return m_backing && m_backing->hasMaskLayer(); |
| 5312 } | 5357 } |
| 5313 | 5358 |
| 5314 GraphicsLayer* RenderLayer::layerForScrolling() const | 5359 GraphicsLayer* RenderLayer::layerForScrolling() const |
| 5315 { | 5360 { |
| 5316 return m_backing ? m_backing->scrollingContentsLayer() : 0; | 5361 return m_backing ? m_backing->scrollingContentsLayer() : 0; |
| 5317 } | 5362 } |
| 5318 | 5363 |
| 5364 GraphicsLayer* RenderLayer::layerForScrollChild() const | |
| 5365 { | |
| 5366 // If we have an ancestor clipping layer because of our scroll parent, we do not want to | |
| 5367 // scroll that clip layer -- we need it to stay put and we will slide within it. If, on | |
| 5368 // the other hand, we have an ancestor clipping layer due to some other clip ping layer, we | |
| 5369 // want to scroll the root of the layer's associate graphics layer subtree. I.e., we want it | |
|
enne (OOO)
2013/09/10 23:45:01
associated?
Ian Vollick
2013/09/11 17:57:52
Done.
| |
| 5370 // and its clip to move in concert. | |
| 5371 | |
| 5372 if (!backing()) | |
| 5373 return 0; | |
| 5374 | |
| 5375 if (backing()->hasAncestorScrollClippingLayer()) { | |
| 5376 return backing()->hasAncestorClippingLayer() | |
| 5377 ? backing()->ancestorClippingLayer() | |
| 5378 : backing()->graphicsLayer(); | |
| 5379 } | |
| 5380 | |
| 5381 if (renderer()->containingBlock()->enclosingLayer() == ancestorScrollingLaye r()) | |
| 5382 return backing()->graphicsLayer(); | |
| 5383 | |
| 5384 return backing()->childForSuperlayers(); | |
| 5385 } | |
| 5386 | |
| 5319 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const | 5387 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const |
| 5320 { | 5388 { |
| 5321 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; | 5389 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; |
| 5322 } | 5390 } |
| 5323 | 5391 |
| 5324 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const | 5392 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const |
| 5325 { | 5393 { |
| 5326 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; | 5394 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; |
| 5327 } | 5395 } |
| 5328 | 5396 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6045 return; | 6113 return; |
| 6046 | 6114 |
| 6047 FrameView* frameView = frame->view(); | 6115 FrameView* frameView = frame->view(); |
| 6048 if (!frameView) | 6116 if (!frameView) |
| 6049 return; | 6117 return; |
| 6050 | 6118 |
| 6051 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); | 6119 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); |
| 6052 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) | 6120 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) |
| 6053 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting(); | 6121 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting(); |
| 6054 | 6122 |
| 6055 if (hasOverflow && isVisibleToHitTest) { | 6123 bool requiresScrollableArea = hasOverflow && isVisibleToHitTest; |
| 6056 if (frameView->addScrollableArea(scrollableArea())) { | 6124 bool updatedScrollableAreaSet = false; |
| 6057 compositor()->setNeedsUpdateCompositingRequirementsState(); | 6125 if (requiresScrollableArea) { |
| 6058 | 6126 if (frameView->addScrollableArea(scrollableArea())) |
| 6059 // Count the total number of RenderLayers that are scrollable areas for | 6127 updatedScrollableAreaSet = true; |
| 6060 // any period. We only want to record this at most once per RenderLa yer. | |
| 6061 if (!m_isScrollableAreaHasBeenRecorded) { | |
| 6062 HistogramSupport::histogramEnumeration("Renderer.CompositedScrol ling", IsScrollableAreaBucket, CompositedScrollingHistogramMax); | |
| 6063 m_isScrollableAreaHasBeenRecorded = true; | |
| 6064 } | |
| 6065 } | |
| 6066 } else { | 6128 } else { |
| 6067 if (frameView->removeScrollableArea(scrollableArea())) | 6129 if (frameView->removeScrollableArea(scrollableArea())) |
| 6130 updatedScrollableAreaSet = true; | |
| 6131 } | |
| 6132 | |
| 6133 if (updatedScrollableAreaSet) { | |
| 6134 // Count the total number of RenderLayers that are scrollable areas for | |
| 6135 // any period. We only want to record this at most once per RenderLayer. | |
| 6136 if (requiresScrollableArea && !m_isScrollableAreaHasBeenRecorded) { | |
| 6137 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling ", IsScrollableAreaBucket, CompositedScrollingHistogramMax); | |
| 6138 m_isScrollableAreaHasBeenRecorded = true; | |
| 6139 } | |
| 6140 | |
| 6141 // We always want composited scrolling if compositor driven accelerated | |
| 6142 // scrolling is enabled. Since we will not update needs composited scrol ling | |
| 6143 // in this case, we must force our state to update. | |
| 6144 if (compositorDrivenAcceleratedScrollingEnabled()) | |
| 6145 didUpdateNeedsCompositedScrolling(); | |
| 6146 else if (requiresScrollableArea) | |
| 6147 compositor()->setNeedsUpdateCompositingRequirementsState(); | |
| 6148 else | |
| 6068 setNeedsCompositedScrolling(false); | 6149 setNeedsCompositedScrolling(false); |
| 6069 } | 6150 } |
| 6070 } | 6151 } |
| 6071 | 6152 |
| 6072 void RenderLayer::updateScrollCornerStyle() | 6153 void RenderLayer::updateScrollCornerStyle() |
| 6073 { | 6154 { |
| 6074 RenderObject* actualRenderer = rendererForScrollbar(renderer()); | 6155 RenderObject* actualRenderer = rendererForScrollbar(renderer()); |
| 6075 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0); | 6156 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0); |
| 6076 if (corner) { | 6157 if (corner) { |
| 6077 if (!m_scrollCorner) { | 6158 if (!m_scrollCorner) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6349 } | 6430 } |
| 6350 } | 6431 } |
| 6351 | 6432 |
| 6352 void showLayerTree(const WebCore::RenderObject* renderer) | 6433 void showLayerTree(const WebCore::RenderObject* renderer) |
| 6353 { | 6434 { |
| 6354 if (!renderer) | 6435 if (!renderer) |
| 6355 return; | 6436 return; |
| 6356 showLayerTree(renderer->enclosingLayer()); | 6437 showLayerTree(renderer->enclosingLayer()); |
| 6357 } | 6438 } |
| 6358 #endif | 6439 #endif |
| OLD | NEW |