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

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: Updated per Commetns Created 6 years, 5 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
« no previous file with comments | « 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 4da182008c1bcf4f08723c6dfd358ff617219c80..54822977280dabd8d624d71a151baf3473030709 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2772,10 +2772,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();
esprehn 2014/07/16 20:43:50 Why suffix with Length?
+
+ if (logicalHeightLength == (sizeType == MinSize ? RenderStyle::initialMinSize() : RenderStyle::initialMaxSize()))
esprehn 2014/07/16 20:43:49 Can we put this in a stack var instead of inside t
+ return true;
+
+ if (!logicalHeightLength.isPercent() || isOutOfFlowPositioned())
+ 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();
esprehn 2014/07/16 20:43:50 containingBlock = this->containingBlock() ? I'd be
+ 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/16 20:43:49 Instead of using a ternary I might early initializ
+ LayoutUnit maxLogicalHeight = logicalHeightComputesAsNone(MaxSize) ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight));
}
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698