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

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

Issue 16402019: Remove clips where we can show that they are unnecessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: NeedsRebaseline for Mac Created 7 years, 5 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
Index: Source/core/rendering/RenderBox.cpp
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index dde7f3e214dab547ce99e9c02335db5710d688dd..9a6bf7bff4148e06bee0530e4e67addf6e298644 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -1518,7 +1518,7 @@ bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer
return false;
}
-bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumulatedOffset)
+bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior)
{
if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseSelfOutline || paintInfo.phase == PaintPhaseMask)
return false;
@@ -1529,6 +1529,27 @@ bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu
if (!isControlClip && !isOverflowClip)
return false;
+ LayoutRect clipRect = isControlClip ? controlClipRect(accumulatedOffset) : overflowClipRect(accumulatedOffset, paintInfo.renderRegion);
+ RoundedRect clipRRect(0, 0, 0, 0);
Julien - ping for review 2013/08/07 00:17:08 Let's not abbreviate this variable. On top of that
jbroman 2013/08/08 14:35:39 Changed to |clipRoundedRect|.
+ bool hasBorderRadius = style()->hasBorderRadius();
+ if (hasBorderRadius)
+ clipRRect = style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size()));
+
+ if (contentsClipBehavior == ContentsClipAutomatic) {
+ LayoutRect contentsVisualOverflow = contentsVisualOverflowRect();
+ if (contentsVisualOverflow.isEmpty())
+ return false;
+
+ LayoutRect conservativeClipRect = clipRect;
+ if (hasBorderRadius)
+ conservativeClipRect.intersect(clipRRect.enclosedRect());
+ conservativeClipRect.moveBy(-accumulatedOffset);
+ if (hasLayer())
+ conservativeClipRect.move(scrolledContentOffset());
+ if (conservativeClipRect.contains(contentsVisualOverflow))
+ return false;
+ }
+
if (paintInfo.phase == PaintPhaseOutline)
paintInfo.phase = PaintPhaseChildOutlines;
else if (paintInfo.phase == PaintPhaseChildBlockBackground) {
@@ -1536,11 +1557,10 @@ bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu
paintObject(paintInfo, accumulatedOffset);
paintInfo.phase = PaintPhaseChildBlockBackgrounds;
}
- IntRect clipRect = pixelSnappedIntRect(isControlClip ? controlClipRect(accumulatedOffset) : overflowClipRect(accumulatedOffset, paintInfo.renderRegion));
paintInfo.context->save();
if (style()->hasBorderRadius())
Julien - ping for review 2013/08/07 00:17:08 This could reuse hasBorderRadius.
jbroman 2013/08/08 14:35:39 And now it does. :) Done.
- paintInfo.context->clipRoundedRect(style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size())));
- paintInfo.context->clip(clipRect);
+ paintInfo.context->clipRoundedRect(clipRRect);
+ paintInfo.context->clip(pixelSnappedIntRect(clipRect));
return true;
}
@@ -4211,7 +4231,8 @@ void RenderBox::addVisualEffectOverflow()
}
// Add in the final overflow with shadows and outsets combined.
- addVisualOverflow(LayoutRect(overflowMinX, overflowMinY, overflowMaxX - overflowMinX, overflowMaxY - overflowMinY));
+ LayoutRect visualEffectOverflow(overflowMinX, overflowMinY, overflowMaxX - overflowMinX, overflowMaxY - overflowMinY);
+ addVisualOverflow(visualEffectOverflow, VisualOverflowNotClipped);
}
void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
@@ -4230,11 +4251,11 @@ void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
// Add in visual overflow from the child. Even if the child clips its overflow, it may still
// have visual overflow of its own set from box shadows or reflections. It is unnecessary to propagate this
// overflow if we are clipping our own overflow.
- if (child->hasSelfPaintingLayer() || hasOverflowClip())
+ if (child->hasSelfPaintingLayer())
return;
LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation(style());
childVisualOverflowRect.move(delta);
- addVisualOverflow(childVisualOverflowRect);
+ addVisualOverflow(childVisualOverflowRect, VisualOverflowClippedByContentsClip);
}
void RenderBox::addLayoutOverflow(const LayoutRect& rect)
@@ -4287,10 +4308,20 @@ void RenderBox::addLayoutOverflow(const LayoutRect& rect)
m_overflow->addLayoutOverflow(overflowRect);
}
-void RenderBox::addVisualOverflow(const LayoutRect& rect)
+void RenderBox::addVisualOverflow(const LayoutRect& rect, VisualOverflowClipBehavior clipBehavior)
{
+ if (rect.isEmpty())
Julien - ping for review 2013/08/07 00:17:08 Is that very frequent? (merely interesting as it s
jbroman 2013/08/08 14:35:39 I suspect not, for the reason you mention; was pre
Julien - ping for review 2013/08/08 21:36:49 Removed, it seems like a corner case.
jbroman 2013/08/09 15:34:34 Done.
+ return;
+
+ if (clipBehavior == VisualOverflowClippedByContentsClip && hasOverflowClip()) {
+ if (!m_overflow)
+ m_overflow = adoptPtr(new RenderOverflow(clientBoxRect(), borderBoxRect()));
+ m_overflow->addContentsVisualOverflow(rect);
+ return;
+ }
+
LayoutRect borderBox = borderBoxRect();
- if (borderBox.contains(rect) || rect.isEmpty())
+ if (borderBox.contains(rect))
return;
if (!m_overflow)
@@ -4304,7 +4335,7 @@ void RenderBox::clearLayoutOverflow()
if (!m_overflow)
return;
- if (!hasVisualOverflow()) {
+ if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) {
Julien - ping for review 2013/08/07 00:17:08 When do we clear contentsVisualOverflowRect()?
jbroman 2013/08/08 14:35:39 The same time we clear the rest of the overflow. F
m_overflow.clear();
return;
}

Powered by Google App Engine
This is Rietveld 408576698