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 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
| 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 3236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5316 bool RenderLayer::hasCompositedMask() const | 5361 bool RenderLayer::hasCompositedMask() const |
5317 { | 5362 { |
5318 return m_backing && m_backing->hasMaskLayer(); | 5363 return m_backing && m_backing->hasMaskLayer(); |
5319 } | 5364 } |
5320 | 5365 |
5321 GraphicsLayer* RenderLayer::layerForScrolling() const | 5366 GraphicsLayer* RenderLayer::layerForScrolling() const |
5322 { | 5367 { |
5323 return m_backing ? m_backing->scrollingContentsLayer() : 0; | 5368 return m_backing ? m_backing->scrollingContentsLayer() : 0; |
5324 } | 5369 } |
5325 | 5370 |
| 5371 GraphicsLayer* RenderLayer::layerForScrollChild() const |
| 5372 { |
| 5373 // If we have an ancestor clipping layer because of our scroll parent, we do
not want to |
| 5374 // scroll that clip layer -- we need it to stay put and we will slide within
it. If, on |
| 5375 // the other hand, we have an ancestor clipping layer due to some other clip
ping layer, we |
| 5376 // want to scroll the root of the layer's associated graphics layer subtree.
I.e., we want it |
| 5377 // and its clip to move in concert. |
| 5378 |
| 5379 if (!backing()) |
| 5380 return 0; |
| 5381 |
| 5382 if (backing()->hasAncestorScrollClippingLayer()) { |
| 5383 return backing()->hasAncestorClippingLayer() |
| 5384 ? backing()->ancestorClippingLayer() |
| 5385 : backing()->graphicsLayer(); |
| 5386 } |
| 5387 |
| 5388 if (renderer()->containingBlock()->enclosingLayer() == ancestorScrollingLaye
r()) |
| 5389 return backing()->graphicsLayer(); |
| 5390 |
| 5391 return backing()->childForSuperlayers(); |
| 5392 } |
| 5393 |
5326 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const | 5394 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const |
5327 { | 5395 { |
5328 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; | 5396 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; |
5329 } | 5397 } |
5330 | 5398 |
5331 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const | 5399 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const |
5332 { | 5400 { |
5333 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; | 5401 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; |
5334 } | 5402 } |
5335 | 5403 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6052 return; | 6120 return; |
6053 | 6121 |
6054 FrameView* frameView = frame->view(); | 6122 FrameView* frameView = frame->view(); |
6055 if (!frameView) | 6123 if (!frameView) |
6056 return; | 6124 return; |
6057 | 6125 |
6058 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); | 6126 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); |
6059 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) | 6127 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) |
6060 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH
itTesting(); | 6128 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH
itTesting(); |
6061 | 6129 |
6062 if (hasOverflow && isVisibleToHitTest) { | 6130 bool requiresScrollableArea = hasOverflow && isVisibleToHitTest; |
6063 if (frameView->addScrollableArea(scrollableArea())) { | 6131 bool updatedScrollableAreaSet = false; |
6064 compositor()->setNeedsUpdateCompositingRequirementsState(); | 6132 if (requiresScrollableArea) { |
6065 | 6133 if (frameView->addScrollableArea(scrollableArea())) |
6066 // Count the total number of RenderLayers that are scrollable areas
for | 6134 updatedScrollableAreaSet = true; |
6067 // any period. We only want to record this at most once per RenderLa
yer. | |
6068 if (!m_isScrollableAreaHasBeenRecorded) { | |
6069 HistogramSupport::histogramEnumeration("Renderer.CompositedScrol
ling", IsScrollableAreaBucket, CompositedScrollingHistogramMax); | |
6070 m_isScrollableAreaHasBeenRecorded = true; | |
6071 } | |
6072 } | |
6073 } else { | 6135 } else { |
6074 if (frameView->removeScrollableArea(scrollableArea())) | 6136 if (frameView->removeScrollableArea(scrollableArea())) |
| 6137 updatedScrollableAreaSet = true; |
| 6138 } |
| 6139 |
| 6140 if (updatedScrollableAreaSet) { |
| 6141 // Count the total number of RenderLayers that are scrollable areas for |
| 6142 // any period. We only want to record this at most once per RenderLayer. |
| 6143 if (requiresScrollableArea && !m_isScrollableAreaHasBeenRecorded) { |
| 6144 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling
", IsScrollableAreaBucket, CompositedScrollingHistogramMax); |
| 6145 m_isScrollableAreaHasBeenRecorded = true; |
| 6146 } |
| 6147 |
| 6148 // We always want composited scrolling if compositor driven accelerated |
| 6149 // scrolling is enabled. Since we will not update needs composited scrol
ling |
| 6150 // in this case, we must force our state to update. |
| 6151 if (compositorDrivenAcceleratedScrollingEnabled()) |
| 6152 didUpdateNeedsCompositedScrolling(); |
| 6153 else if (requiresScrollableArea) |
| 6154 compositor()->setNeedsUpdateCompositingRequirementsState(); |
| 6155 else |
6075 setNeedsCompositedScrolling(false); | 6156 setNeedsCompositedScrolling(false); |
6076 } | 6157 } |
6077 } | 6158 } |
6078 | 6159 |
6079 void RenderLayer::updateScrollCornerStyle() | 6160 void RenderLayer::updateScrollCornerStyle() |
6080 { | 6161 { |
6081 RenderObject* actualRenderer = rendererForScrollbar(renderer()); | 6162 RenderObject* actualRenderer = rendererForScrollbar(renderer()); |
6082 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer-
>getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st
yle()) : PassRefPtr<RenderStyle>(0); | 6163 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer-
>getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st
yle()) : PassRefPtr<RenderStyle>(0); |
6083 if (corner) { | 6164 if (corner) { |
6084 if (!m_scrollCorner) { | 6165 if (!m_scrollCorner) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6356 } | 6437 } |
6357 } | 6438 } |
6358 | 6439 |
6359 void showLayerTree(const WebCore::RenderObject* renderer) | 6440 void showLayerTree(const WebCore::RenderObject* renderer) |
6360 { | 6441 { |
6361 if (!renderer) | 6442 if (!renderer) |
6362 return; | 6443 return; |
6363 showLayerTree(renderer->enclosingLayer()); | 6444 showLayerTree(renderer->enclosingLayer()); |
6364 } | 6445 } |
6365 #endif | 6446 #endif |
OLD | NEW |