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 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 | 1805 |
1806 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) | 1806 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) |
1807 dirtyAncestorChainVisibleDescendantStatus(); | 1807 dirtyAncestorChainVisibleDescendantStatus(); |
1808 | 1808 |
1809 if (oldChild->isSelfPaintingLayer() || oldChild->hasSelfPaintingLayerDescend
ant()) | 1809 if (oldChild->isSelfPaintingLayer() || oldChild->hasSelfPaintingLayerDescend
ant()) |
1810 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | 1810 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); |
1811 | 1811 |
1812 return oldChild; | 1812 return oldChild; |
1813 } | 1813 } |
1814 | 1814 |
| 1815 bool RenderLayer::hasAncestor(const RenderLayer* ancestor) const |
| 1816 { |
| 1817 if (!ancestor) |
| 1818 return false; |
| 1819 |
| 1820 for (const RenderLayer* layer = this; layer; layer = layer->parent()) { |
| 1821 if (layer == ancestor) |
| 1822 return true; |
| 1823 } |
| 1824 |
| 1825 return false; |
| 1826 } |
| 1827 |
1815 void RenderLayer::removeOnlyThisLayer() | 1828 void RenderLayer::removeOnlyThisLayer() |
1816 { | 1829 { |
1817 if (!m_parent) | 1830 if (!m_parent) |
1818 return; | 1831 return; |
1819 | 1832 |
1820 // Mark that we are about to lose our layer. This makes render tree | 1833 // Mark that we are about to lose our layer. This makes render tree |
1821 // walks ignore this layer while we're removing it. | 1834 // walks ignore this layer while we're removing it. |
1822 m_renderer->setHasLayer(false); | 1835 m_renderer->setHasLayer(false); |
1823 | 1836 |
1824 compositor()->layerWillBeRemoved(m_parent, this); | 1837 compositor()->layerWillBeRemoved(m_parent, this); |
(...skipping 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4888 void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C
lipRects& clipRects) const | 4901 void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C
lipRects& clipRects) const |
4889 { | 4902 { |
4890 if (!parent()) { | 4903 if (!parent()) { |
4891 // The root layer's clip rect is always infinite. | 4904 // The root layer's clip rect is always infinite. |
4892 clipRects.reset(PaintInfo::infiniteRect()); | 4905 clipRects.reset(PaintInfo::infiniteRect()); |
4893 return; | 4906 return; |
4894 } | 4907 } |
4895 | 4908 |
4896 ClipRectsType clipRectsType = clipRectsContext.clipRectsType; | 4909 ClipRectsType clipRectsType = clipRectsContext.clipRectsType; |
4897 bool useCached = clipRectsType != TemporaryClipRects; | 4910 bool useCached = clipRectsType != TemporaryClipRects; |
| 4911 bool isRoot = this == clipRectsContext.rootLayer; |
4898 | 4912 |
4899 // For transformed layers, the root layer was shifted to be us, so there is
no need to | 4913 // For transformed layers, the root layer was shifted to be us, so there is
no need to |
4900 // examine the parent. We want to cache clip rects with us as the root. | 4914 // examine the parent. We want to cache clip rects with us as the root. |
4901 RenderLayer* parentLayer = clipRectsContext.rootLayer != this ? parent() : 0
; | 4915 RenderLayer* parentLayer = isRoot ? 0 : parent(); |
4902 | 4916 |
4903 // Ensure that our parent's clip has been calculated so that we can examine
the values. | 4917 // Ensure that our parent's clip has been calculated so that we can examine
the values. |
4904 if (parentLayer) { | 4918 if (parentLayer) { |
4905 if (useCached && parentLayer->clipRects(clipRectsContext)) | 4919 if (useCached && parentLayer->clipRects(clipRectsContext)) |
4906 clipRects = *parentLayer->clipRects(clipRectsContext); | 4920 clipRects = *parentLayer->clipRects(clipRectsContext); |
4907 else { | 4921 else { |
4908 ClipRectsContext parentContext(clipRectsContext); | 4922 ClipRectsContext parentContext(clipRectsContext); |
4909 parentContext.overlayScrollbarSizeRelevancy = IgnoreOverlayScrollbar
Size; // FIXME: why? | 4923 parentContext.overlayScrollbarSizeRelevancy = IgnoreOverlayScrollbar
Size; // FIXME: why? |
| 4924 if (this == clipRectsContext.scrollParent) |
| 4925 parentContext.scrollParent = 0; |
4910 parentLayer->calculateClipRects(parentContext, clipRects); | 4926 parentLayer->calculateClipRects(parentContext, clipRects); |
4911 } | 4927 } |
4912 } else | 4928 } else |
4913 clipRects.reset(PaintInfo::infiniteRect()); | 4929 clipRects.reset(PaintInfo::infiniteRect()); |
4914 | 4930 |
4915 // A fixed object is essentially the root of its containing block hierarchy,
so when | 4931 // A fixed object is essentially the root of its containing block hierarchy,
so when |
4916 // we encounter such an object, we reset our clip rects to the fixedClipRect
. | 4932 // we encounter such an object, we reset our clip rects to the fixedClipRect
. |
4917 if (renderer()->style()->position() == FixedPosition) { | 4933 if (renderer()->style()->position() == FixedPosition) { |
4918 clipRects.setPosClipRect(clipRects.fixedClipRect()); | 4934 clipRects.setPosClipRect(clipRects.fixedClipRect()); |
4919 clipRects.setOverflowClipRect(clipRects.fixedClipRect()); | 4935 clipRects.setOverflowClipRect(clipRects.fixedClipRect()); |
4920 clipRects.setFixed(true); | 4936 clipRects.setFixed(true); |
4921 } else if (renderer()->style()->hasInFlowPosition()) | 4937 } else if (renderer()->style()->hasInFlowPosition()) |
4922 clipRects.setPosClipRect(clipRects.overflowClipRect()); | 4938 clipRects.setPosClipRect(clipRects.overflowClipRect()); |
4923 else if (renderer()->style()->position() == AbsolutePosition) | 4939 else if (renderer()->style()->position() == AbsolutePosition) |
4924 clipRects.setOverflowClipRect(clipRects.posClipRect()); | 4940 clipRects.setOverflowClipRect(clipRects.posClipRect()); |
4925 | 4941 |
4926 // Update the clip rects that will be passed to child layers. | 4942 // Update the clip rects that will be passed to child layers. There are two
reasons |
4927 if ((renderer()->hasOverflowClip() && (clipRectsContext.respectOverflowClip
== RespectOverflowClip || this != clipRectsContext.rootLayer)) || renderer()->ha
sClip()) { | 4943 // we may ignor the cilp here. If we've been told to ignore the overflow cli
p (via |
| 4944 // ClipRectsContext::respectOverflowClip), we do so, but only if this is the
clip |
| 4945 // root (this setting only applies to the root layer). Also, if a scroll par
ent is |
| 4946 // set, we ignore all clips until we've reached it (the point of the scrollP
arent |
| 4947 // member of ClipRectsContext is to determine the clip the scrollParent esta
blishes |
| 4948 // with respect to the clipRoot, regardless of any subsequent clipping that
may happen |
| 4949 // between us and our scroll parent). |
| 4950 bool shouldIgnoreClip = clipRectsContext.scrollParent && this != clipRectsCo
ntext.scrollParent; |
| 4951 bool shouldIgnoreOverflowClip = clipRectsContext.respectOverflowClip == Igno
reOverflowClip && isRoot; |
| 4952 |
| 4953 bool shouldApplyClip = renderer()->hasClip() && !shouldIgnoreClip; |
| 4954 bool shouldApplyOverflowClip = renderer()->hasOverflowClip() && !shouldIgnor
eOverflowClip && !shouldIgnoreClip; |
| 4955 |
| 4956 if (shouldApplyOverflowClip || shouldApplyClip) { |
4928 // This layer establishes a clip of some kind. | 4957 // This layer establishes a clip of some kind. |
4929 | 4958 |
4930 // This offset cannot use convertToLayerCoords, because sometimes our ro
otLayer may be across | 4959 // This offset cannot use convertToLayerCoords, because sometimes our ro
otLayer may be across |
4931 // some transformed layer boundary, for example, in the RenderLayerCompo
sitor overlapMap, where | 4960 // some transformed layer boundary, for example, in the RenderLayerCompo
sitor overlapMap, where |
4932 // clipRects are needed in view space. | 4961 // clipRects are needed in view space. |
4933 LayoutPoint offset; | 4962 LayoutPoint offset; |
4934 offset = roundedLayoutPoint(renderer()->localToContainerPoint(FloatPoint
(), clipRectsContext.rootLayer->renderer())); | 4963 offset = roundedLayoutPoint(renderer()->localToContainerPoint(FloatPoint
(), clipRectsContext.rootLayer->renderer())); |
4935 RenderView* view = renderer()->view(); | 4964 RenderView* view = renderer()->view(); |
4936 ASSERT(view); | 4965 ASSERT(view); |
4937 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer()
== view) { | 4966 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer()
== view) { |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5431 bool RenderLayer::hasCompositedMask() const | 5460 bool RenderLayer::hasCompositedMask() const |
5432 { | 5461 { |
5433 return m_backing && m_backing->hasMaskLayer(); | 5462 return m_backing && m_backing->hasMaskLayer(); |
5434 } | 5463 } |
5435 | 5464 |
5436 GraphicsLayer* RenderLayer::layerForScrolling() const | 5465 GraphicsLayer* RenderLayer::layerForScrolling() const |
5437 { | 5466 { |
5438 return m_backing ? m_backing->scrollingContentsLayer() : 0; | 5467 return m_backing ? m_backing->scrollingContentsLayer() : 0; |
5439 } | 5468 } |
5440 | 5469 |
| 5470 GraphicsLayer* RenderLayer::layerForScrollChild() const |
| 5471 { |
| 5472 // If we have an ancestor clipping layer because of our scroll parent, we do
not want to |
| 5473 // scroll that clip layer -- we need it to stay put and we will slide within
it. If, on |
| 5474 // the other hand, we have an ancestor clipping layer due to some other clip
ping layer, we |
| 5475 // want to scroll the root of the layer's associate graphics layer subtree.
I.e., we want it |
| 5476 // and its clip to move in concert. |
| 5477 |
| 5478 if (!backing()) |
| 5479 return 0; |
| 5480 |
| 5481 if (backing()->hasAncestorScrollClippingLayer()) { |
| 5482 return backing()->hasAncestorClippingLayer() |
| 5483 ? backing()->ancestorClippingLayer() |
| 5484 : backing()->graphicsLayer(); |
| 5485 } |
| 5486 |
| 5487 if (renderer()->containingBlock()->enclosingLayer() == ancestorScrollingLaye
r()) |
| 5488 return backing()->graphicsLayer(); |
| 5489 |
| 5490 return backing()->childForSuperlayers(); |
| 5491 } |
| 5492 |
5441 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const | 5493 GraphicsLayer* RenderLayer::layerForHorizontalScrollbar() const |
5442 { | 5494 { |
5443 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; | 5495 return m_backing ? m_backing->layerForHorizontalScrollbar() : 0; |
5444 } | 5496 } |
5445 | 5497 |
5446 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const | 5498 GraphicsLayer* RenderLayer::layerForVerticalScrollbar() const |
5447 { | 5499 { |
5448 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; | 5500 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; |
5449 } | 5501 } |
5450 | 5502 |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6427 } | 6479 } |
6428 } | 6480 } |
6429 | 6481 |
6430 void showLayerTree(const WebCore::RenderObject* renderer) | 6482 void showLayerTree(const WebCore::RenderObject* renderer) |
6431 { | 6483 { |
6432 if (!renderer) | 6484 if (!renderer) |
6433 return; | 6485 return; |
6434 showLayerTree(renderer->enclosingLayer()); | 6486 showLayerTree(renderer->enclosingLayer()); |
6435 } | 6487 } |
6436 #endif | 6488 #endif |
OLD | NEW |