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

Unified Diff: Source/core/rendering/RenderBox.cpp

Issue 360613003: Ensure we compute the min and max height of replaced elements to 'none' or 0 when appropriate. (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
Index: Source/core/rendering/RenderBox.cpp
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index c214c7eef167186ff38a19d20f2d1018079eaf16..72a93e8c55a9ab751bf097d49cb1d21127537a04 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2771,10 +2771,32 @@ LayoutUnit RenderBox::computeReplacedLogicalHeight() const
return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
}
+bool RenderBox::logicalHeightComputesAsNone(SizeType sizeType) const
+{
+ ASSERT(sizeType == MinSize || sizeType == MaxSize);
+ Length logicalHeightLength = sizeType == MinSize ? style()->logicalMinHeight() : style()->logicalMaxHeight();
+
+ if (logicalHeightLength == (sizeType == MinSize ? RenderStyle::initialMinSize() : RenderStyle::initialMaxSize()))
+ return true;
+
+ if (!logicalHeightLength.isPercent() || isOutOfFlowPositioned() || document().inQuirksMode())
leviw_travelin_and_unemployed 2014/07/07 18:02:35 Why the Quirks Mode check here? Is this tested any
+ return false;
+
+ // Anonymous block boxes are ignored when resolving percentage values that would refer to it:
+ // the closest non-anonymous ancestor box is used instead.
+ RenderBlock* cb = containingBlock();
+ while (cb->isAnonymous())
+ cb = cb->containingBlock();
+
+ return cb->hasAutoHeightOrContainingBlockWithAutoHeight();
+}
+
LayoutUnit RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight) const
{
- LayoutUnit minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight());
- LayoutUnit maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
+ // If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned,
+ // the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').
+ LayoutUnit minLogicalHeight = logicalHeightComputesAsNone(MinSize) ? LayoutUnit() : computeReplacedLogicalHeightUsing(style()->logicalMinHeight());
esprehn 2014/07/07 18:15:53 computeReplacedLogicalHeightUsing should just know
+ LayoutUnit maxLogicalHeight = logicalHeightComputesAsNone(MaxSize) ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight));
}

Powered by Google App Engine
This is Rietveld 408576698