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

Unified 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 side-by-side diff with in-line comments
Download patch
« Source/core/rendering/RenderBox.h ('K') | « Source/core/rendering/RenderBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBox.cpp
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index 269aa5dd75c1e3ea9c534c88a53874b1cd77c4b5..b28d087651868f619abf4066ab46abc1f8239c66 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -4067,52 +4067,48 @@ void RenderBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop
void RenderBox::addVisualEffectOverflow()
{
- if (!style()->boxShadow() && !style()->hasBorderImageOutsets() && !style()->hasOutline())
+ if (!hasVisualEffectOverflow())
return;
- LayoutRect borderBox = borderBoxRect();
- LayoutUnit overflowMinX = borderBox.x();
- LayoutUnit overflowMaxX = borderBox.maxX();
- LayoutUnit overflowMinY = borderBox.y();
- LayoutUnit overflowMaxY = borderBox.maxY();
-
- // Compute box-shadow overflow first.
- if (style()->boxShadow()) {
- LayoutUnit shadowLeft;
- LayoutUnit shadowRight;
- LayoutUnit shadowTop;
- LayoutUnit shadowBottom;
- style()->getBoxShadowExtent(shadowTop, shadowRight, shadowBottom, shadowLeft);
-
- // Note that box-shadow extent's left and top are negative when extends to left and top, respectively.
- overflowMinX = borderBox.x() + shadowLeft;
- overflowMaxX = borderBox.maxX() + shadowRight;
- overflowMinY = borderBox.y() + shadowTop;
- overflowMaxY = borderBox.maxY() + shadowBottom;
- }
+ // Add in the final overflow with shadows, outsets and outline combined.
+ 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
+ visualEffectOverflow.expand(computeVisualEffectOverflowExtent());
+ addVisualOverflow(visualEffectOverflow);
+}
+
+LayoutBoxExtent RenderBox::computeVisualEffectOverflowExtent() const
+{
+ 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.
+ return LayoutBoxExtent();
+
+ LayoutUnit top;
+ LayoutUnit right;
+ LayoutUnit bottom;
+ LayoutUnit left;
+
+ 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.
+ // Box shadow extent's top and left are negative when extend to left and top direction, respectively.
+ // Negate to make them positive.
+ top = -top;
+ 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
- // Now compute border-image-outset overflow.
if (style()->hasBorderImageOutsets()) {
LayoutBoxExtent borderOutsets = style()->borderImageOutsets();
-
- overflowMinX = std::min(overflowMinX, borderBox.x() - borderOutsets.left());
- overflowMaxX = std::max(overflowMaxX, borderBox.maxX() + borderOutsets.right());
- overflowMinY = std::min(overflowMinY, borderBox.y() - borderOutsets.top());
- overflowMaxY = std::max(overflowMaxY, borderBox.maxY() + borderOutsets.bottom());
+ top = std::max(top, borderOutsets.top());
+ right = std::max(right, borderOutsets.right());
+ bottom = std::max(bottom, borderOutsets.bottom());
+ left = std::max(left, borderOutsets.left());
}
if (style()->hasOutline()) {
LayoutUnit outlineSize = style()->outlineSize();
-
- overflowMinX = std::min(overflowMinX, borderBox.x() - outlineSize);
- overflowMaxX = std::max(overflowMaxX, borderBox.maxX() + outlineSize);
- overflowMinY = std::min(overflowMinY, borderBox.y() - outlineSize);
- overflowMaxY = std::max(overflowMaxY, borderBox.maxY() + outlineSize);
+ top = std::max(top, outlineSize);
+ right = std::max(right, outlineSize);
+ bottom = std::max(bottom, outlineSize);
+ left = std::max(left, outlineSize);
}
- // Add in the final overflow with shadows, outsets and outline combined.
- LayoutRect visualEffectOverflow(overflowMinX, overflowMinY, overflowMaxX - overflowMinX, overflowMaxY - overflowMinY);
- addVisualOverflow(visualEffectOverflow);
+ return LayoutBoxExtent(top, right, bottom, left);
}
void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
« 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