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

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: per jchaffraix 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
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderListItem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 BackgroundImageGeometry geometry; 1510 BackgroundImageGeometry geometry;
1511 layerRenderer->calculateBackgroundImageGeometry(curLayer, rendererRe ct, geometry); 1511 layerRenderer->calculateBackgroundImageGeometry(curLayer, rendererRe ct, geometry);
1512 layerRenderer->repaintRectangle(geometry.destRect()); 1512 layerRenderer->repaintRectangle(geometry.destRect());
1513 if (geometry.destRect() == rendererRect) 1513 if (geometry.destRect() == rendererRect)
1514 return true; 1514 return true;
1515 } 1515 }
1516 } 1516 }
1517 return false; 1517 return false;
1518 } 1518 }
1519 1519
1520 bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu latedOffset) 1520 bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu latedOffset, ContentsClipBehavior contentsClipBehavior)
1521 { 1521 {
1522 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == Paint PhaseSelfOutline || paintInfo.phase == PaintPhaseMask) 1522 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == Paint PhaseSelfOutline || paintInfo.phase == PaintPhaseMask)
1523 return false; 1523 return false;
1524 1524
1525 bool isControlClip = hasControlClip(); 1525 bool isControlClip = hasControlClip();
1526 bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer(); 1526 bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer();
1527 1527
1528 if (!isControlClip && !isOverflowClip) 1528 if (!isControlClip && !isOverflowClip)
1529 return false; 1529 return false;
1530 1530
1531 LayoutRect clipRect = isControlClip ? controlClipRect(accumulatedOffset) : o verflowClipRect(accumulatedOffset, paintInfo.renderRegion);
1532 RoundedRect clipRoundedRect(0, 0, 0, 0);
1533 bool hasBorderRadius = style()->hasBorderRadius();
1534 if (hasBorderRadius)
1535 clipRoundedRect = style()->getRoundedInnerBorderFor(LayoutRect(accumulat edOffset, size()));
1536
1537 if (contentsClipBehavior == SkipContentsClipIfPossible) {
1538 LayoutRect contentsVisualOverflow = contentsVisualOverflowRect();
1539 if (contentsVisualOverflow.isEmpty())
1540 return false;
1541
1542 LayoutRect conservativeClipRect = clipRect;
1543 if (hasBorderRadius)
1544 conservativeClipRect.intersect(clipRoundedRect.radiusCenterRect());
1545 conservativeClipRect.moveBy(-accumulatedOffset);
1546 if (hasLayer())
1547 conservativeClipRect.move(scrolledContentOffset());
1548 if (conservativeClipRect.contains(contentsVisualOverflow))
1549 return false;
1550 }
1551
1531 if (paintInfo.phase == PaintPhaseOutline) 1552 if (paintInfo.phase == PaintPhaseOutline)
1532 paintInfo.phase = PaintPhaseChildOutlines; 1553 paintInfo.phase = PaintPhaseChildOutlines;
1533 else if (paintInfo.phase == PaintPhaseChildBlockBackground) { 1554 else if (paintInfo.phase == PaintPhaseChildBlockBackground) {
1534 paintInfo.phase = PaintPhaseBlockBackground; 1555 paintInfo.phase = PaintPhaseBlockBackground;
1535 paintObject(paintInfo, accumulatedOffset); 1556 paintObject(paintInfo, accumulatedOffset);
1536 paintInfo.phase = PaintPhaseChildBlockBackgrounds; 1557 paintInfo.phase = PaintPhaseChildBlockBackgrounds;
1537 } 1558 }
1538 IntRect clipRect = pixelSnappedIntRect(isControlClip ? controlClipRect(accum ulatedOffset) : overflowClipRect(accumulatedOffset, paintInfo.renderRegion));
1539 paintInfo.context->save(); 1559 paintInfo.context->save();
1540 if (style()->hasBorderRadius()) 1560 if (hasBorderRadius)
1541 paintInfo.context->clipRoundedRect(style()->getRoundedInnerBorderFor(Lay outRect(accumulatedOffset, size()))); 1561 paintInfo.context->clipRoundedRect(clipRoundedRect);
1542 paintInfo.context->clip(clipRect); 1562 paintInfo.context->clip(pixelSnappedIntRect(clipRect));
1543 return true; 1563 return true;
1544 } 1564 }
1545 1565
1546 void RenderBox::popContentsClip(PaintInfo& paintInfo, PaintPhase originalPhase, const LayoutPoint& accumulatedOffset) 1566 void RenderBox::popContentsClip(PaintInfo& paintInfo, PaintPhase originalPhase, const LayoutPoint& accumulatedOffset)
1547 { 1567 {
1548 ASSERT(hasControlClip() || (hasOverflowClip() && !layer()->isSelfPaintingLay er())); 1568 ASSERT(hasControlClip() || (hasOverflowClip() && !layer()->isSelfPaintingLay er()));
1549 1569
1550 paintInfo.context->restore(); 1570 paintInfo.context->restore();
1551 if (originalPhase == PaintPhaseOutline) { 1571 if (originalPhase == PaintPhaseOutline) {
1552 paintInfo.phase = PaintPhaseSelfOutline; 1572 paintInfo.phase = PaintPhaseSelfOutline;
(...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after
4203 4223
4204 // In flipped blocks writing modes, the physical sides are inverted. For example in vertical-rl, the right 4224 // In flipped blocks writing modes, the physical sides are inverted. For example in vertical-rl, the right
4205 // border is at the lower x coordinate value. 4225 // border is at the lower x coordinate value.
4206 overflowMinX = min(overflowMinX, borderBox.x() - ((!isFlipped || isHoriz ontal) ? borderOutsets.left() : borderOutsets.right())); 4226 overflowMinX = min(overflowMinX, borderBox.x() - ((!isFlipped || isHoriz ontal) ? borderOutsets.left() : borderOutsets.right()));
4207 overflowMaxX = max(overflowMaxX, borderBox.maxX() + ((!isFlipped || isHo rizontal) ? borderOutsets.right() : borderOutsets.left())); 4227 overflowMaxX = max(overflowMaxX, borderBox.maxX() + ((!isFlipped || isHo rizontal) ? borderOutsets.right() : borderOutsets.left()));
4208 overflowMinY = min(overflowMinY, borderBox.y() - ((!isFlipped || !isHori zontal) ? borderOutsets.top() : borderOutsets.bottom())); 4228 overflowMinY = min(overflowMinY, borderBox.y() - ((!isFlipped || !isHori zontal) ? borderOutsets.top() : borderOutsets.bottom()));
4209 overflowMaxY = max(overflowMaxY, borderBox.maxY() + ((!isFlipped || !isH orizontal) ? borderOutsets.bottom() : borderOutsets.top())); 4229 overflowMaxY = max(overflowMaxY, borderBox.maxY() + ((!isFlipped || !isH orizontal) ? borderOutsets.bottom() : borderOutsets.top()));
4210 } 4230 }
4211 4231
4212 // Add in the final overflow with shadows and outsets combined. 4232 // Add in the final overflow with shadows and outsets combined.
4213 addVisualOverflow(LayoutRect(overflowMinX, overflowMinY, overflowMaxX - over flowMinX, overflowMaxY - overflowMinY)); 4233 LayoutRect visualEffectOverflow(overflowMinX, overflowMinY, overflowMaxX - o verflowMinX, overflowMaxY - overflowMinY);
4234 addVisualOverflow(visualEffectOverflow);
4214 } 4235 }
4215 4236
4216 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta) 4237 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
4217 { 4238 {
4218 // Never allow flow threads to propagate overflow up to a parent. 4239 // Never allow flow threads to propagate overflow up to a parent.
4219 if (child->isRenderFlowThread()) 4240 if (child->isRenderFlowThread())
4220 return; 4241 return;
4221 4242
4222 // Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then 4243 // Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then
4223 // its overflow is internal to it, and we don't care about it. layoutOverfl owRectForPropagation takes care of this 4244 // its overflow is internal to it, and we don't care about it. layoutOverfl owRectForPropagation takes care of this
4224 // and just propagates the border box rect instead. 4245 // and just propagates the border box rect instead.
4225 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation (style()); 4246 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation (style());
4226 childLayoutOverflowRect.move(delta); 4247 childLayoutOverflowRect.move(delta);
4227 addLayoutOverflow(childLayoutOverflowRect); 4248 addLayoutOverflow(childLayoutOverflowRect);
4228 4249
4229 // Add in visual overflow from the child. Even if the child clips its overf low, it may still 4250 // Add in visual overflow from the child. Even if the child clips its overf low, it may still
4230 // have visual overflow of its own set from box shadows or reflections. It is unnecessary to propagate this 4251 // have visual overflow of its own set from box shadows or reflections. It is unnecessary to propagate this
4231 // overflow if we are clipping our own overflow. 4252 // overflow if we are clipping our own overflow.
4232 if (child->hasSelfPaintingLayer() || hasOverflowClip()) 4253 if (child->hasSelfPaintingLayer())
4233 return; 4254 return;
4234 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation (style()); 4255 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation (style());
4235 childVisualOverflowRect.move(delta); 4256 childVisualOverflowRect.move(delta);
4236 addVisualOverflow(childVisualOverflowRect); 4257 addContentsVisualOverflow(childVisualOverflowRect);
4237 } 4258 }
4238 4259
4239 void RenderBox::addLayoutOverflow(const LayoutRect& rect) 4260 void RenderBox::addLayoutOverflow(const LayoutRect& rect)
4240 { 4261 {
4241 LayoutRect clientBox = noOverflowRect(); 4262 LayoutRect clientBox = noOverflowRect();
4242 if (clientBox.contains(rect) || rect.isEmpty()) 4263 if (clientBox.contains(rect) || rect.isEmpty())
4243 return; 4264 return;
4244 4265
4245 // For overflow clip objects, we don't want to propagate overflow into unrea chable areas. 4266 // For overflow clip objects, we don't want to propagate overflow into unrea chable areas.
4246 LayoutRect overflowRect(rect); 4267 LayoutRect overflowRect(rect);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 LayoutRect borderBox = borderBoxRect(); 4312 LayoutRect borderBox = borderBoxRect();
4292 if (borderBox.contains(rect) || rect.isEmpty()) 4313 if (borderBox.contains(rect) || rect.isEmpty())
4293 return; 4314 return;
4294 4315
4295 if (!m_overflow) 4316 if (!m_overflow)
4296 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox)); 4317 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox));
4297 4318
4298 m_overflow->addVisualOverflow(rect); 4319 m_overflow->addVisualOverflow(rect);
4299 } 4320 }
4300 4321
4322 void RenderBox::addContentsVisualOverflow(const LayoutRect& rect)
4323 {
4324 if (!hasOverflowClip()) {
4325 addVisualOverflow(rect);
4326 return;
4327 }
4328
4329 if (!m_overflow)
4330 m_overflow = adoptPtr(new RenderOverflow(clientBoxRect(), borderBoxRect( )));
4331 m_overflow->addContentsVisualOverflow(rect);
4332 }
4333
4301 void RenderBox::clearLayoutOverflow() 4334 void RenderBox::clearLayoutOverflow()
4302 { 4335 {
4303 if (!m_overflow) 4336 if (!m_overflow)
4304 return; 4337 return;
4305 4338
4306 if (!hasVisualOverflow()) { 4339 if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) {
4307 m_overflow.clear(); 4340 m_overflow.clear();
4308 return; 4341 return;
4309 } 4342 }
4310 4343
4311 m_overflow->setLayoutOverflow(noOverflowRect()); 4344 m_overflow->setLayoutOverflow(noOverflowRect());
4312 } 4345 }
4313 4346
4314 inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box) 4347 inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
4315 { 4348 {
4316 return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containi ngBlock(), box->isOutOfFlowPositioned()); 4349 return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containi ngBlock(), box->isOutOfFlowPositioned());
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
4686 } 4719 }
4687 4720
4688 if (didSplitParentAnonymousBoxes) 4721 if (didSplitParentAnonymousBoxes)
4689 markBoxForRelayoutAfterSplit(this); 4722 markBoxForRelayoutAfterSplit(this);
4690 4723
4691 ASSERT(beforeChild->parent() == this); 4724 ASSERT(beforeChild->parent() == this);
4692 return beforeChild; 4725 return beforeChild;
4693 } 4726 }
4694 4727
4695 } // namespace WebCore 4728 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderListItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698