Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1163)

Unified Diff: Source/core/rendering/RenderLayerClipper.cpp

Issue 211683003: Return an infinite rect when calling RenderLayerClipper::parentClipRects on the root context layer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed nit. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderLayerClipper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderLayerClipper.cpp
diff --git a/Source/core/rendering/RenderLayerClipper.cpp b/Source/core/rendering/RenderLayerClipper.cpp
index 9181b0a09220dcc3f29e9ffdf72ce61f1cbbc967..6c87430f5ee2a7ee31ba895af0195b4cd97db8e3 100644
--- a/Source/core/rendering/RenderLayerClipper.cpp
+++ b/Source/core/rendering/RenderLayerClipper.cpp
@@ -71,7 +71,7 @@ void RenderLayerClipper::updateClipRects(const ClipRectsContext& clipRectsContex
// 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 != m_renderer->layer() ? m_renderer->layer()->parent() : 0;
+ RenderLayer* parentLayer = !isClippingRootForContext(clipRectsContext) ? m_renderer->layer()->parent() : 0;
if (parentLayer)
parentLayer->clipper().updateClipRects(clipRectsContext);
@@ -169,7 +169,9 @@ LayoutRect RenderLayerClipper::localClipRect() const
void RenderLayerClipper::calculateRects(const ClipRectsContext& clipRectsContext, const LayoutRect& paintDirtyRect, LayoutRect& layerBounds,
ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRect, const LayoutPoint* offsetFromRoot) const
{
- if (clipRectsContext.rootLayer != m_renderer->layer() && m_renderer->layer()->parent()) {
+ bool isClippingRoot = isClippingRootForContext(clipRectsContext);
+
+ if (!isClippingRoot && m_renderer->layer()->parent()) {
backgroundRect = backgroundClipRect(clipRectsContext);
backgroundRect.move(roundedIntSize(clipRectsContext.subPixelAccumulation));
backgroundRect.intersect(paintDirtyRect);
@@ -190,7 +192,7 @@ void RenderLayerClipper::calculateRects(const ClipRectsContext& clipRectsContext
// Update the clip rects that will be passed to child layers.
if (m_renderer->hasOverflowClip()) {
// This layer establishes a clip of some kind.
- if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContext.respectOverflowClip == RespectOverflowClip) {
+ if (!isClippingRoot || clipRectsContext.respectOverflowClip == RespectOverflowClip) {
foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(offset, clipRectsContext.overlayScrollbarSizeRelevancy));
if (m_renderer->style()->hasBorderRadius())
foregroundRect.setHasRadius(true);
@@ -207,12 +209,12 @@ void RenderLayerClipper::calculateRects(const ClipRectsContext& clipRectsContext
LayoutRect layerBoundsWithVisualOverflow = toRenderBox(m_renderer)->visualOverflowRect();
toRenderBox(m_renderer)->flipForWritingMode(layerBoundsWithVisualOverflow); // Layers are in physical coordinates, so the overflow has to be flipped.
layerBoundsWithVisualOverflow.moveBy(offset);
- if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContext.respectOverflowClip == RespectOverflowClip)
+ if (!isClippingRoot || clipRectsContext.respectOverflowClip == RespectOverflowClip)
backgroundRect.intersect(layerBoundsWithVisualOverflow);
} else {
LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRect();
bounds.moveBy(offset);
- if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContext.respectOverflowClip == RespectOverflowClip)
+ if (!isClippingRoot || clipRectsContext.respectOverflowClip == RespectOverflowClip)
backgroundRect.intersect(bounds);
}
}
@@ -238,9 +240,11 @@ void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon
ClipRectsType clipRectsType = clipRectsContext.clipRectsType;
bool useCached = clipRectsType != TemporaryClipRects;
+ bool isClippingRoot = isClippingRootForContext(clipRectsContext);
+
// 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 != m_renderer->layer() ? m_renderer->layer()->parent() : 0;
+ RenderLayer* parentLayer = !isClippingRoot ? m_renderer->layer()->parent() : 0;
// Ensure that our parent's clip has been calculated so that we can examine the values.
if (parentLayer) {
@@ -268,7 +272,7 @@ void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon
}
// Update the clip rects that will be passed to child layers.
- if ((m_renderer->hasOverflowClip() && (clipRectsContext.respectOverflowClip == RespectOverflowClip || m_renderer->layer() != clipRectsContext.rootLayer)) || m_renderer->hasClip()) {
+ if ((m_renderer->hasOverflowClip() && (clipRectsContext.respectOverflowClip == RespectOverflowClip || !isClippingRoot)) || m_renderer->hasClip()) {
// This layer establishes a clip of some kind.
// This offset cannot use convertToLayerCoords, because sometimes our rootLayer may be across
@@ -345,8 +349,19 @@ ClipRect RenderLayerClipper::backgroundClipRect(const ClipRectsContext& clipRect
return backgroundClipRect;
}
+bool RenderLayerClipper::isClippingRootForContext(const ClipRectsContext& clipRectsContext) const
+{
+ return clipRectsContext.rootLayer == m_renderer->layer();
+}
+
void RenderLayerClipper::parentClipRects(const ClipRectsContext& clipRectsContext, ClipRects& clipRects) const
{
+ // The root is not clipped.
+ if (isClippingRootForContext(clipRectsContext)) {
+ clipRects.reset(PaintInfo::infiniteRect());
+ return;
+ }
+
ASSERT(m_renderer->layer()->parent());
RenderLayerClipper& parentClipper = m_renderer->layer()->parent()->clipper();
« no previous file with comments | « Source/core/rendering/RenderLayerClipper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698