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 // This function only takes a non-const pointer because it may update the ca ched clip | |
2100 // rects. Semantically, though, this is const, so we will cast here. | |
hartmanng
2013/09/06 01:46:38
I wonder if it might be cleaner to make the cached
Ian Vollick
2013/09/06 02:38:11
(blush) I was wrong. As I went to do this, I reali
| |
2101 const bool needsAncestorClip = compositor()->clippedByAncestor(const_cast<Re nderLayer*>(this)); | |
2102 | |
2103 RenderLayer* clipParent = 0; | |
2104 if ((compositingReasons() & CompositingReasonOutOfFlowClipping) && !needsAnc estorClip) { | |
2105 if (RenderObject* containingBlock = renderer()->containingBlock()) | |
2106 clipParent = containingBlock->enclosingLayer()->enclosingCompositing Layer(true); | |
2107 } | |
2108 | |
2109 return clipParent; | |
2110 } | |
2111 | |
2065 void RenderLayer::updateNeedsCompositedScrolling() | 2112 void RenderLayer::updateNeedsCompositedScrolling() |
2066 { | 2113 { |
2067 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); | 2114 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); |
2068 | 2115 |
2069 updateCanBeStackingContainer(); | 2116 updateCanBeStackingContainer(); |
2070 updateDescendantDependentFlags(); | 2117 updateDescendantDependentFlags(); |
2071 | 2118 |
2072 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea())); | 2119 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c ontainsScrollableArea(scrollableArea())); |
2073 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed() | 2120 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl ed() |
2074 && canBeStackingContainer() | 2121 && canBeStackingContainer() |
(...skipping 3234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5309 bool RenderLayer::hasCompositedMask() const | 5356 bool RenderLayer::hasCompositedMask() const |
5310 { | 5357 { |
5311 return m_backing && m_backing->hasMaskLayer(); | 5358 return m_backing && m_backing->hasMaskLayer(); |
5312 } | 5359 } |
5313 | 5360 |
5314 GraphicsLayer* RenderLayer::layerForScrolling() const | 5361 GraphicsLayer* RenderLayer::layerForScrolling() const |
5315 { | 5362 { |
5316 return m_backing ? m_backing->scrollingContentsLayer() : 0; | 5363 return m_backing ? m_backing->scrollingContentsLayer() : 0; |
5317 } | 5364 } |
5318 | 5365 |
5366 GraphicsLayer* RenderLayer::layerForScrollChild() const | |
5367 { | |
5368 // If we have an ancestor clipping layer because of our scroll parent, we do not want to | |
5369 // scroll that clip layer -- we need it to stay put and we will slide within it. If, on | |
5370 // the other hand, we have an ancestor clipping layer due to some other clip ping layer, we | |
5371 // want to scroll the root of the layer's associate graphics layer subtree. I.e., we want it | |
5372 // and its clip to move in concert. | |
5373 | |
5374 if (!backing()) | |
5375 return 0; | |
5376 | |
5377 if (backing()->hasAncestorScrollClippingLayer()) { | |
5378 return backing()->hasAncestorClippingLayer() | |
5379 ? backing()->ancestorClippingLayer() | |
5380 : backing()->graphicsLayer(); | |
5381 } | |
5382 | |
5383 if (renderer()->containingBlock()->enclosingLayer() == ancestorScrollingLaye r()) | |
5384 return backing()->graphicsLayer(); | |
5385 | |
5386 return backing()->childForSuperlayers(); | |
5387 } | |
5388 | |
5319 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const | 5389 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const |
5320 { | 5390 { |
5321 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; | 5391 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; |
5322 } | 5392 } |
5323 | 5393 |
5324 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const | 5394 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const |
5325 { | 5395 { |
5326 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; | 5396 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; |
5327 } | 5397 } |
5328 | 5398 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6045 return; | 6115 return; |
6046 | 6116 |
6047 FrameView* frameView = frame->view(); | 6117 FrameView* frameView = frame->view(); |
6048 if (!frameView) | 6118 if (!frameView) |
6049 return; | 6119 return; |
6050 | 6120 |
6051 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); | 6121 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); |
6052 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) | 6122 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) |
6053 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting(); | 6123 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting(); |
6054 | 6124 |
6055 if (hasOverflow && isVisibleToHitTest) { | 6125 bool requiresScrollableArea = hasOverflow && isVisibleToHitTest; |
6056 if (frameView->addScrollableArea(scrollableArea())) { | 6126 bool updatedScrollableAreaSet = false; |
6057 compositor()->setNeedsUpdateCompositingRequirementsState(); | 6127 if (requiresScrollableArea) { |
6058 | 6128 if (frameView->addScrollableArea(scrollableArea())) |
6059 // Count the total number of RenderLayers that are scrollable areas for | 6129 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 { | 6130 } else { |
6067 if (frameView->removeScrollableArea(scrollableArea())) | 6131 if (frameView->removeScrollableArea(scrollableArea())) |
6132 updatedScrollableAreaSet = true; | |
6133 } | |
6134 | |
6135 if (updatedScrollableAreaSet) { | |
6136 // Count the total number of RenderLayers that are scrollable areas for | |
6137 // any period. We only want to record this at most once per RenderLayer. | |
6138 if (requiresScrollableArea && !m_isScrollableAreaHasBeenRecorded) { | |
6139 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling ", IsScrollableAreaBucket, CompositedScrollingHistogramMax); | |
6140 m_isScrollableAreaHasBeenRecorded = true; | |
6141 } | |
6142 | |
6143 // We always want composited scrolling if compositor driven accelerated | |
6144 // scrolling is enabled. Since we will not update needs composited scrol ling | |
6145 // in this case, we must force our state to update. | |
6146 if (compositorDrivenAcceleratedScrollingEnabled()) | |
6147 didUpdateNeedsCompositedScrolling(); | |
6148 else if (requiresScrollableArea) | |
6149 compositor()->setNeedsUpdateCompositingRequirementsState(); | |
6150 else | |
6068 setNeedsCompositedScrolling(false); | 6151 setNeedsCompositedScrolling(false); |
6069 } | 6152 } |
6070 } | 6153 } |
6071 | 6154 |
6072 void RenderLayer::updateScrollCornerStyle() | 6155 void RenderLayer::updateScrollCornerStyle() |
6073 { | 6156 { |
6074 RenderObject* actualRenderer = rendererForScrollbar(renderer()); | 6157 RenderObject* actualRenderer = rendererForScrollbar(renderer()); |
6075 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0); | 6158 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0); |
6076 if (corner) { | 6159 if (corner) { |
6077 if (!m_scrollCorner) { | 6160 if (!m_scrollCorner) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6349 } | 6432 } |
6350 } | 6433 } |
6351 | 6434 |
6352 void showLayerTree(const WebCore::RenderObject* renderer) | 6435 void showLayerTree(const WebCore::RenderObject* renderer) |
6353 { | 6436 { |
6354 if (!renderer) | 6437 if (!renderer) |
6355 return; | 6438 return; |
6356 showLayerTree(renderer->enclosingLayer()); | 6439 showLayerTree(renderer->enclosingLayer()); |
6357 } | 6440 } |
6358 #endif | 6441 #endif |
OLD | NEW |