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

Side by Side Diff: Source/core/rendering/RenderBox.cpp

Issue 337473008: Refactor RenderBox::addVisualEffectOverflow() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 4049 matching lines...) Expand 10 before | Expand all | Expand 10 after
4060 { 4060 {
4061 ASSERT(!needsLayout()); 4061 ASSERT(!needsLayout());
4062 // If fragmentation height has changed, we need to lay out. No need to enter the renderer if it 4062 // If fragmentation height has changed, we need to lay out. No need to enter the renderer if it
4063 // is childless, though. 4063 // is childless, though.
4064 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) 4064 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild())
4065 layoutScope.setChildNeedsLayout(this); 4065 layoutScope.setChildNeedsLayout(this);
4066 } 4066 }
4067 4067
4068 void RenderBox::addVisualEffectOverflow() 4068 void RenderBox::addVisualEffectOverflow()
4069 { 4069 {
4070 if (!style()->boxShadow() && !style()->hasBorderImageOutsets() && !style()-> hasOutline()) 4070 if (!hasVisualEffectOverflow())
4071 return; 4071 return;
4072 4072
4073 LayoutRect borderBox = borderBoxRect(); 4073 // Add in the final overflow with shadows, outsets and outline combined.
4074 LayoutUnit overflowMinX = borderBox.x(); 4074 LayoutRect visualEffectOverflow = borderBoxRect();
Julien - ping for review 2014/07/01 23:00:16 We have a helper function for "no overflow" that s
Xianzhu 2014/07/02 00:02:03 noOverflowRect seems incorrect to me: - the curren
Xianzhu 2014/07/02 00:05:23 Correction: noOverflowRect is context-box in borde
4075 LayoutUnit overflowMaxX = borderBox.maxX(); 4075 visualEffectOverflow.expand(computeVisualEffectOverflowExtent());
4076 LayoutUnit overflowMinY = borderBox.y(); 4076 addVisualOverflow(visualEffectOverflow);
4077 LayoutUnit overflowMaxY = borderBox.maxY(); 4077 }
4078 4078
4079 // Compute box-shadow overflow first. 4079 LayoutBoxExtent RenderBox::computeVisualEffectOverflowExtent() const
4080 if (style()->boxShadow()) { 4080 {
4081 LayoutUnit shadowLeft; 4081 if (!hasVisualEffectOverflow())
Julien - ping for review 2014/07/01 23:00:15 Nobody calls this without a visual effect overflow
Xianzhu 2014/07/02 00:02:03 Done.
4082 LayoutUnit shadowRight; 4082 return LayoutBoxExtent();
4083 LayoutUnit shadowTop;
4084 LayoutUnit shadowBottom;
4085 style()->getBoxShadowExtent(shadowTop, shadowRight, shadowBottom, shadow Left);
4086 4083
4087 // Note that box-shadow extent's left and top are negative when extends to left and top, respectively. 4084 LayoutUnit top;
4088 overflowMinX = borderBox.x() + shadowLeft; 4085 LayoutUnit right;
4089 overflowMaxX = borderBox.maxX() + shadowRight; 4086 LayoutUnit bottom;
4090 overflowMinY = borderBox.y() + shadowTop; 4087 LayoutUnit left;
4091 overflowMaxY = borderBox.maxY() + shadowBottom;
4092 }
4093 4088
4094 // Now compute border-image-outset overflow. 4089 style()->getBoxShadowExtent(top, right, bottom, left);
Julien - ping for review 2014/07/01 23:00:16 While it's a no-op to call getBoxShadowExtent with
Xianzhu 2014/07/02 00:02:03 Done.
4090 // Box shadow extent's top and left are negative when extend to left and top direction, respectively.
4091 // Negate to make them positive.
4092 top = -top;
4093 left = -left;
Julien - ping for review 2014/07/01 23:00:15 I wonder if we couldn't make the code more consist
Xianzhu 2014/07/02 00:02:03 I tried that several days ago but haven't finished
4094
4095 if (style()->hasBorderImageOutsets()) { 4095 if (style()->hasBorderImageOutsets()) {
4096 LayoutBoxExtent borderOutsets = style()->borderImageOutsets(); 4096 LayoutBoxExtent borderOutsets = style()->borderImageOutsets();
4097 4097 top = std::max(top, borderOutsets.top());
4098 overflowMinX = std::min(overflowMinX, borderBox.x() - borderOutsets.left ()); 4098 right = std::max(right, borderOutsets.right());
4099 overflowMaxX = std::max(overflowMaxX, borderBox.maxX() + borderOutsets.r ight()); 4099 bottom = std::max(bottom, borderOutsets.bottom());
4100 overflowMinY = std::min(overflowMinY, borderBox.y() - borderOutsets.top( )); 4100 left = std::max(left, borderOutsets.left());
4101 overflowMaxY = std::max(overflowMaxY, borderBox.maxY() + borderOutsets.b ottom());
4102 } 4101 }
4103 4102
4104 if (style()->hasOutline()) { 4103 if (style()->hasOutline()) {
4105 LayoutUnit outlineSize = style()->outlineSize(); 4104 LayoutUnit outlineSize = style()->outlineSize();
4106 4105 top = std::max(top, outlineSize);
4107 overflowMinX = std::min(overflowMinX, borderBox.x() - outlineSize); 4106 right = std::max(right, outlineSize);
4108 overflowMaxX = std::max(overflowMaxX, borderBox.maxX() + outlineSize); 4107 bottom = std::max(bottom, outlineSize);
4109 overflowMinY = std::min(overflowMinY, borderBox.y() - outlineSize); 4108 left = std::max(left, outlineSize);
4110 overflowMaxY = std::max(overflowMaxY, borderBox.maxY() + outlineSize);
4111 } 4109 }
4112 4110
4113 // Add in the final overflow with shadows, outsets and outline combined. 4111 return LayoutBoxExtent(top, right, bottom, left);
4114 LayoutRect visualEffectOverflow(overflowMinX, overflowMinY, overflowMaxX - o verflowMinX, overflowMaxY - overflowMinY);
4115 addVisualOverflow(visualEffectOverflow);
4116 } 4112 }
4117 4113
4118 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta) 4114 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
4119 { 4115 {
4120 // Never allow flow threads to propagate overflow up to a parent. 4116 // Never allow flow threads to propagate overflow up to a parent.
4121 if (child->isRenderFlowThread()) 4117 if (child->isRenderFlowThread())
4122 return; 4118 return;
4123 4119
4124 // Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then 4120 // Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then
4125 // its overflow is internal to it, and we don't care about it. layoutOverfl owRectForPropagation takes care of this 4121 // its overflow is internal to it, and we don't care about it. layoutOverfl owRectForPropagation takes care of this
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4605 return 0; 4601 return 0;
4606 4602
4607 if (!layoutState && !flowThreadContainingBlock()) 4603 if (!layoutState && !flowThreadContainingBlock())
4608 return 0; 4604 return 0;
4609 4605
4610 RenderBlock* containerBlock = containingBlock(); 4606 RenderBlock* containerBlock = containingBlock();
4611 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); 4607 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop();
4612 } 4608 }
4613 4609
4614 } // namespace WebCore 4610 } // namespace WebCore
OLDNEW
« Source/core/rendering/RenderBox.h ('K') | « Source/core/rendering/RenderBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698