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

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: Created 7 years, 4 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..4604472616f5236e1c1b64767501daee769cfaa8 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 clipRoundedRect(0, 0, 0, 0);
+ bool hasBorderRadius = style()->hasBorderRadius();
+ if (hasBorderRadius)
+ clipRoundedRect = style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size()));
+
+ if (contentsClipBehavior == ContentsClipAutomatic) {
+ LayoutRect contentsVisualOverflow = contentsVisualOverflowRect();
+ if (contentsVisualOverflow.isEmpty())
+ return false;
+
+ LayoutRect conservativeClipRect = clipRect;
+ if (hasBorderRadius)
+ conservativeClipRect.intersect(clipRoundedRect.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())
- paintInfo.context->clipRoundedRect(style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size())));
- paintInfo.context->clip(clipRect);
+ if (hasBorderRadius)
+ paintInfo.context->clipRoundedRect(clipRoundedRect);
+ 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);
}
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);
+ addContentsVisualOverflow(childVisualOverflowRect);
}
void RenderBox::addLayoutOverflow(const LayoutRect& rect)
@@ -4299,12 +4320,27 @@ void RenderBox::addVisualOverflow(const LayoutRect& rect)
m_overflow->addVisualOverflow(rect);
}
+void RenderBox::addContentsVisualOverflow(const LayoutRect& rect)
+{
+ if (!hasOverflowClip()) {
+ addVisualOverflow(rect);
+ return;
+ }
+
+ if (rect.isEmpty())
+ return;
+
+ if (!m_overflow)
+ m_overflow = adoptPtr(new RenderOverflow(clientBoxRect(), borderBoxRect()));
+ m_overflow->addContentsVisualOverflow(rect);
+}
+
void RenderBox::clearLayoutOverflow()
{
if (!m_overflow)
return;
- if (!hasVisualOverflow()) {
+ if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) {
m_overflow.clear();
return;
}

Powered by Google App Engine
This is Rietveld 408576698