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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 BackgroundImageGeometry geometry; 1511 BackgroundImageGeometry geometry;
1512 layerRenderer->calculateBackgroundImageGeometry(curLayer, rendererRe ct, geometry); 1512 layerRenderer->calculateBackgroundImageGeometry(curLayer, rendererRe ct, geometry);
1513 layerRenderer->repaintRectangle(geometry.destRect()); 1513 layerRenderer->repaintRectangle(geometry.destRect());
1514 if (geometry.destRect() == rendererRect) 1514 if (geometry.destRect() == rendererRect)
1515 return true; 1515 return true;
1516 } 1516 }
1517 } 1517 }
1518 return false; 1518 return false;
1519 } 1519 }
1520 1520
1521 bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu latedOffset) 1521 bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu latedOffset, ContentsClipBehavior contentsClipBehavior)
1522 { 1522 {
1523 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == Paint PhaseSelfOutline || paintInfo.phase == PaintPhaseMask) 1523 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == Paint PhaseSelfOutline || paintInfo.phase == PaintPhaseMask)
1524 return false; 1524 return false;
1525 1525
1526 bool isControlClip = hasControlClip(); 1526 bool isControlClip = hasControlClip();
1527 bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer(); 1527 bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer();
1528 1528
1529 if (!isControlClip && !isOverflowClip) 1529 if (!isControlClip && !isOverflowClip)
1530 return false; 1530 return false;
1531 1531
1532 LayoutRect clipRect = isControlClip ? controlClipRect(accumulatedOffset) : o verflowClipRect(accumulatedOffset, paintInfo.renderRegion);
1533 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|.
1534 bool hasBorderRadius = style()->hasBorderRadius();
1535 if (hasBorderRadius)
1536 clipRRect = style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffs et, size()));
1537
1538 if (contentsClipBehavior == ContentsClipAutomatic) {
1539 LayoutRect contentsVisualOverflow = contentsVisualOverflowRect();
1540 if (contentsVisualOverflow.isEmpty())
1541 return false;
1542
1543 LayoutRect conservativeClipRect = clipRect;
1544 if (hasBorderRadius)
1545 conservativeClipRect.intersect(clipRRect.enclosedRect());
1546 conservativeClipRect.moveBy(-accumulatedOffset);
1547 if (hasLayer())
1548 conservativeClipRect.move(scrolledContentOffset());
1549 if (conservativeClipRect.contains(contentsVisualOverflow))
1550 return false;
1551 }
1552
1532 if (paintInfo.phase == PaintPhaseOutline) 1553 if (paintInfo.phase == PaintPhaseOutline)
1533 paintInfo.phase = PaintPhaseChildOutlines; 1554 paintInfo.phase = PaintPhaseChildOutlines;
1534 else if (paintInfo.phase == PaintPhaseChildBlockBackground) { 1555 else if (paintInfo.phase == PaintPhaseChildBlockBackground) {
1535 paintInfo.phase = PaintPhaseBlockBackground; 1556 paintInfo.phase = PaintPhaseBlockBackground;
1536 paintObject(paintInfo, accumulatedOffset); 1557 paintObject(paintInfo, accumulatedOffset);
1537 paintInfo.phase = PaintPhaseChildBlockBackgrounds; 1558 paintInfo.phase = PaintPhaseChildBlockBackgrounds;
1538 } 1559 }
1539 IntRect clipRect = pixelSnappedIntRect(isControlClip ? controlClipRect(accum ulatedOffset) : overflowClipRect(accumulatedOffset, paintInfo.renderRegion));
1540 paintInfo.context->save(); 1560 paintInfo.context->save();
1541 if (style()->hasBorderRadius()) 1561 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.
1542 paintInfo.context->clipRoundedRect(style()->getRoundedInnerBorderFor(Lay outRect(accumulatedOffset, size()))); 1562 paintInfo.context->clipRoundedRect(clipRRect);
1543 paintInfo.context->clip(clipRect); 1563 paintInfo.context->clip(pixelSnappedIntRect(clipRect));
1544 return true; 1564 return true;
1545 } 1565 }
1546 1566
1547 void RenderBox::popContentsClip(PaintInfo& paintInfo, PaintPhase originalPhase, const LayoutPoint& accumulatedOffset) 1567 void RenderBox::popContentsClip(PaintInfo& paintInfo, PaintPhase originalPhase, const LayoutPoint& accumulatedOffset)
1548 { 1568 {
1549 ASSERT(hasControlClip() || (hasOverflowClip() && !layer()->isSelfPaintingLay er())); 1569 ASSERT(hasControlClip() || (hasOverflowClip() && !layer()->isSelfPaintingLay er()));
1550 1570
1551 paintInfo.context->restore(); 1571 paintInfo.context->restore();
1552 if (originalPhase == PaintPhaseOutline) { 1572 if (originalPhase == PaintPhaseOutline) {
1553 paintInfo.phase = PaintPhaseSelfOutline; 1573 paintInfo.phase = PaintPhaseSelfOutline;
(...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 4224
4205 // In flipped blocks writing modes, the physical sides are inverted. For example in vertical-rl, the right 4225 // In flipped blocks writing modes, the physical sides are inverted. For example in vertical-rl, the right
4206 // border is at the lower x coordinate value. 4226 // border is at the lower x coordinate value.
4207 overflowMinX = min(overflowMinX, borderBox.x() - ((!isFlipped || isHoriz ontal) ? borderOutsets.left() : borderOutsets.right())); 4227 overflowMinX = min(overflowMinX, borderBox.x() - ((!isFlipped || isHoriz ontal) ? borderOutsets.left() : borderOutsets.right()));
4208 overflowMaxX = max(overflowMaxX, borderBox.maxX() + ((!isFlipped || isHo rizontal) ? borderOutsets.right() : borderOutsets.left())); 4228 overflowMaxX = max(overflowMaxX, borderBox.maxX() + ((!isFlipped || isHo rizontal) ? borderOutsets.right() : borderOutsets.left()));
4209 overflowMinY = min(overflowMinY, borderBox.y() - ((!isFlipped || !isHori zontal) ? borderOutsets.top() : borderOutsets.bottom())); 4229 overflowMinY = min(overflowMinY, borderBox.y() - ((!isFlipped || !isHori zontal) ? borderOutsets.top() : borderOutsets.bottom()));
4210 overflowMaxY = max(overflowMaxY, borderBox.maxY() + ((!isFlipped || !isH orizontal) ? borderOutsets.bottom() : borderOutsets.top())); 4230 overflowMaxY = max(overflowMaxY, borderBox.maxY() + ((!isFlipped || !isH orizontal) ? borderOutsets.bottom() : borderOutsets.top()));
4211 } 4231 }
4212 4232
4213 // Add in the final overflow with shadows and outsets combined. 4233 // Add in the final overflow with shadows and outsets combined.
4214 addVisualOverflow(LayoutRect(overflowMinX, overflowMinY, overflowMaxX - over flowMinX, overflowMaxY - overflowMinY)); 4234 LayoutRect visualEffectOverflow(overflowMinX, overflowMinY, overflowMaxX - o verflowMinX, overflowMaxY - overflowMinY);
4235 addVisualOverflow(visualEffectOverflow, VisualOverflowNotClipped);
4215 } 4236 }
4216 4237
4217 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta) 4238 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
4218 { 4239 {
4219 // Never allow flow threads to propagate overflow up to a parent. 4240 // Never allow flow threads to propagate overflow up to a parent.
4220 if (child->isRenderFlowThread()) 4241 if (child->isRenderFlowThread())
4221 return; 4242 return;
4222 4243
4223 // Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then 4244 // Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then
4224 // its overflow is internal to it, and we don't care about it. layoutOverfl owRectForPropagation takes care of this 4245 // its overflow is internal to it, and we don't care about it. layoutOverfl owRectForPropagation takes care of this
4225 // and just propagates the border box rect instead. 4246 // and just propagates the border box rect instead.
4226 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation (style()); 4247 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation (style());
4227 childLayoutOverflowRect.move(delta); 4248 childLayoutOverflowRect.move(delta);
4228 addLayoutOverflow(childLayoutOverflowRect); 4249 addLayoutOverflow(childLayoutOverflowRect);
4229 4250
4230 // Add in visual overflow from the child. Even if the child clips its overf low, it may still 4251 // Add in visual overflow from the child. Even if the child clips its overf low, it may still
4231 // have visual overflow of its own set from box shadows or reflections. It is unnecessary to propagate this 4252 // have visual overflow of its own set from box shadows or reflections. It is unnecessary to propagate this
4232 // overflow if we are clipping our own overflow. 4253 // overflow if we are clipping our own overflow.
4233 if (child->hasSelfPaintingLayer() || hasOverflowClip()) 4254 if (child->hasSelfPaintingLayer())
4234 return; 4255 return;
4235 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation (style()); 4256 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation (style());
4236 childVisualOverflowRect.move(delta); 4257 childVisualOverflowRect.move(delta);
4237 addVisualOverflow(childVisualOverflowRect); 4258 addVisualOverflow(childVisualOverflowRect, VisualOverflowClippedByContentsCl ip);
4238 } 4259 }
4239 4260
4240 void RenderBox::addLayoutOverflow(const LayoutRect& rect) 4261 void RenderBox::addLayoutOverflow(const LayoutRect& rect)
4241 { 4262 {
4242 LayoutRect clientBox = noOverflowRect(); 4263 LayoutRect clientBox = noOverflowRect();
4243 if (clientBox.contains(rect) || rect.isEmpty()) 4264 if (clientBox.contains(rect) || rect.isEmpty())
4244 return; 4265 return;
4245 4266
4246 // For overflow clip objects, we don't want to propagate overflow into unrea chable areas. 4267 // For overflow clip objects, we don't want to propagate overflow into unrea chable areas.
4247 LayoutRect overflowRect(rect); 4268 LayoutRect overflowRect(rect);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4280 if (clientBox.contains(overflowRect) || overflowRect.isEmpty()) 4301 if (clientBox.contains(overflowRect) || overflowRect.isEmpty())
4281 return; 4302 return;
4282 } 4303 }
4283 4304
4284 if (!m_overflow) 4305 if (!m_overflow)
4285 m_overflow = adoptPtr(new RenderOverflow(clientBox, borderBoxRect())); 4306 m_overflow = adoptPtr(new RenderOverflow(clientBox, borderBoxRect()));
4286 4307
4287 m_overflow->addLayoutOverflow(overflowRect); 4308 m_overflow->addLayoutOverflow(overflowRect);
4288 } 4309 }
4289 4310
4290 void RenderBox::addVisualOverflow(const LayoutRect& rect) 4311 void RenderBox::addVisualOverflow(const LayoutRect& rect, VisualOverflowClipBeha vior clipBehavior)
4291 { 4312 {
4313 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.
4314 return;
4315
4316 if (clipBehavior == VisualOverflowClippedByContentsClip && hasOverflowClip() ) {
4317 if (!m_overflow)
4318 m_overflow = adoptPtr(new RenderOverflow(clientBoxRect(), borderBoxR ect()));
4319 m_overflow->addContentsVisualOverflow(rect);
4320 return;
4321 }
4322
4292 LayoutRect borderBox = borderBoxRect(); 4323 LayoutRect borderBox = borderBoxRect();
4293 if (borderBox.contains(rect) || rect.isEmpty()) 4324 if (borderBox.contains(rect))
4294 return; 4325 return;
4295 4326
4296 if (!m_overflow) 4327 if (!m_overflow)
4297 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox)); 4328 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox));
4298 4329
4299 m_overflow->addVisualOverflow(rect); 4330 m_overflow->addVisualOverflow(rect);
4300 } 4331 }
4301 4332
4302 void RenderBox::clearLayoutOverflow() 4333 void RenderBox::clearLayoutOverflow()
4303 { 4334 {
4304 if (!m_overflow) 4335 if (!m_overflow)
4305 return; 4336 return;
4306 4337
4307 if (!hasVisualOverflow()) { 4338 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
4308 m_overflow.clear(); 4339 m_overflow.clear();
4309 return; 4340 return;
4310 } 4341 }
4311 4342
4312 m_overflow->setLayoutOverflow(noOverflowRect()); 4343 m_overflow->setLayoutOverflow(noOverflowRect());
4313 } 4344 }
4314 4345
4315 inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box) 4346 inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
4316 { 4347 {
4317 return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containi ngBlock(), box->isOutOfFlowPositioned()); 4348 return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containi ngBlock(), box->isOutOfFlowPositioned());
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
4687 } 4718 }
4688 4719
4689 if (didSplitParentAnonymousBoxes) 4720 if (didSplitParentAnonymousBoxes)
4690 markBoxForRelayoutAfterSplit(this); 4721 markBoxForRelayoutAfterSplit(this);
4691 4722
4692 ASSERT(beforeChild->parent() == this); 4723 ASSERT(beforeChild->parent() == this);
4693 return beforeChild; 4724 return beforeChild;
4694 } 4725 }
4695 4726
4696 } // namespace WebCore 4727 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698