Chromium Code Reviews| Index: Source/core/rendering/RenderLayer.cpp |
| diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp |
| index 0e9e4b26ce1918a62504493ff5df6f8efa58b051..1e6548e19a61e81951f570c5851c1b5e85eedae9 100644 |
| --- a/Source/core/rendering/RenderLayer.cpp |
| +++ b/Source/core/rendering/RenderLayer.cpp |
| @@ -1833,6 +1833,19 @@ RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) |
| return oldChild; |
| } |
| +bool RenderLayer::hasAncestor(const RenderLayer* ancestor) const |
| +{ |
| + if (!ancestor) |
| + return false; |
| + |
| + for (const RenderLayer* layer = this; layer; layer = layer->parent()) { |
| + if (layer == ancestor) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| void RenderLayer::removeOnlyThisLayer() |
| { |
| if (!m_parent) |
| @@ -4923,10 +4936,11 @@ void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C |
| ClipRectsType clipRectsType = clipRectsContext.clipRectsType; |
| bool useCached = clipRectsType != TemporaryClipRects; |
| + bool isRoot = this == clipRectsContext.rootLayer; |
| // For transformed layers, the root layer was shifted to be us, so there is no need to |
| // examine the parent. We want to cache clip rects with us as the root. |
| - RenderLayer* parentLayer = clipRectsContext.rootLayer != this ? parent() : 0; |
| + RenderLayer* parentLayer = isRoot ? 0 : parent(); |
| // Ensure that our parent's clip has been calculated so that we can examine the values. |
| if (parentLayer) { |
| @@ -4935,6 +4949,8 @@ void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C |
| else { |
| ClipRectsContext parentContext(clipRectsContext); |
| parentContext.overlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize; // FIXME: why? |
| + if (this == clipRectsContext.scrollParent) |
| + parentContext.scrollParent = 0; |
| parentLayer->calculateClipRects(parentContext, clipRects); |
| } |
| } else |
| @@ -4951,8 +4967,21 @@ void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C |
| else if (renderer()->style()->position() == AbsolutePosition) |
| clipRects.setOverflowClipRect(clipRects.posClipRect()); |
| - // Update the clip rects that will be passed to child layers. |
| - if ((renderer()->hasOverflowClip() && (clipRectsContext.respectOverflowClip == RespectOverflowClip || this != clipRectsContext.rootLayer)) || renderer()->hasClip()) { |
| + // Update the clip rects that will be passed to child layers. There are two reasons |
| + // we may ignor the cilp here. If we've been told to ignore the overflow clip (via |
|
enne (OOO)
2013/08/22 20:54:30
I won't ignor this cilp.
|
| + // ClipRectsContext::respectOverflowClip), we do so, but only if this is the clip |
| + // root (this setting only applies to the root layer). Also, if a scroll parent is |
| + // set, we ignore all clips until we've reached it (the point of the scrollParent |
| + // member of ClipRectsContext is to determine the clip the scrollParent establishes |
| + // with respect to the clipRoot, regardless of any subsequent clipping that may happen |
| + // between us and our scroll parent). |
| + bool shouldIgnoreClip = clipRectsContext.scrollParent && this != clipRectsContext.scrollParent; |
| + bool shouldIgnoreOverflowClip = clipRectsContext.respectOverflowClip == IgnoreOverflowClip && isRoot; |
| + |
| + bool shouldApplyClip = renderer()->hasClip() && !shouldIgnoreClip; |
| + bool shouldApplyOverflowClip = renderer()->hasOverflowClip() && !shouldIgnoreOverflowClip && !shouldIgnoreClip; |
| + |
| + if (shouldApplyOverflowClip || shouldApplyClip) { |
| // This layer establishes a clip of some kind. |
| // This offset cannot use convertToLayerCoords, because sometimes our rootLayer may be across |
| @@ -5466,6 +5495,29 @@ GraphicsLayer* RenderLayer::layerForScrolling() const |
| return m_backing ? m_backing->scrollingContentsLayer() : 0; |
| } |
| +GraphicsLayer* RenderLayer::layerForScrollChild() const |
| +{ |
| + // If we have an ancestor clipping layer because of our scroll parent, we do not want to |
| + // scroll that clip layer -- we need it to stay put and we will slide within it. If, on |
| + // the other hand, we have an ancestor clipping layer due to some other clipping layer, we |
| + // want to scroll the root of the layer's associate graphics layer subtree. I.e., we want it |
| + // and its clip to move in concert. |
| + |
| + if (!backing()) |
| + return 0; |
| + |
| + if (backing()->hasAncestorScrollClippingLayer()) { |
| + return backing()->hasAncestorClippingLayer() |
| + ? backing()->ancestorClippingLayer() |
| + : backing()->graphicsLayer(); |
| + } |
| + |
| + if (renderer()->containingBlock()->enclosingLayer() == ancestorScrollingLayer()) |
| + return backing()->graphicsLayer(); |
| + |
| + return backing()->childForSuperlayers(); |
| +} |
| + |
| GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const |
| { |
| return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; |