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

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 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 51f1102b5c21d7bc5e353e76789d3600633851a2..5fd76aff7c5835106ee31005698a4da8e75eb0f7 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2739,10 +2739,37 @@ LayoutUnit RenderBox::computeReplacedLogicalHeight() const
return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
}
+bool RenderBox::logicalHeightComputesAsNone(SizeType sizeType) const
+{
+ ASSERT(sizeType == MinSize || sizeType == MaxSize);
+ Length logicalHeight = sizeType == MinSize ? style()->logicalMinHeight() : style()->logicalMaxHeight();
+ Length initialLogicalHeight = sizeType == MinSize ? RenderStyle::initialMinSize() : RenderStyle::initialMaxSize();
+
+ if (logicalHeight == initialLogicalHeight)
+ return true;
+
+ if (!logicalHeight.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* containingBlock = this->containingBlock();
+ while (containingBlock->isAnonymous())
+ containingBlock = containingBlock->containingBlock();
+
+ return containingBlock->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;
+ if (!logicalHeightComputesAsNone(MinSize))
+ minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight());
+ LayoutUnit maxLogicalHeight = logicalHeight;
+ if (!logicalHeightComputesAsNone(MaxSize))
+ maxLogicalHeight = 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