Bug 854263: Add special-case for flex items that are instances of nsFrame, whose trivial reflow impl doesn't request enough space for its border/padding. r=dbaron

This commit is contained in:
Daniel Holbert 2013-03-28 01:50:21 -07:00
parent f9b3c00f60
commit 264013b5df
3 changed files with 51 additions and 9 deletions

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<style>
.flexContainer {
display: flex;
width: 300px;
height: 300px;
background: yellow;
}
.flexItem {
border: 1px dashed purple;
}
</style>
<script>
function finish() {
document.documentElement.removeAttribute('class');
}
</script>
</head>
<body onload="setTimeout(finish, 0)">
<div class="flexContainer">
<embed src="about:blank" class="flexItem"></embed>
</div>
</body>
</html>

View File

@ -455,3 +455,4 @@ load 847208.html
asserts(4) load 847209.html # bug 847368
load 849603.html
test-pref(layout.css.flexbox.enabled,true) load 851396-1.html
test-pref(layout.css.flexbox.enabled,true) load 854263-1.html

View File

@ -309,6 +309,8 @@ public:
// Getters for border/padding
// ==========================
const nsMargin& GetBorderPadding() const { return mBorderPadding; }
// Returns the border+padding component for a given mozilla::css::Side
nscoord GetBorderPaddingComponentForSide(Side aSide) const
{ return MarginComponentForSide(mBorderPadding, aSide); }
@ -1990,15 +1992,27 @@ nsFlexContainerFrame::SizeItemInCrossAxis(
// Save the sizing info that we learned from this reflow
// -----------------------------------------------------
// Tentatively accept the child's desired size, minus border/padding, as its
// cross-size:
MOZ_ASSERT(childDesiredSize.height >=
aItem.GetBorderPaddingSizeInAxis(aAxisTracker.GetCrossAxis()),
"Child should ask for at least enough space for border/padding");
nscoord crossSize =
aAxisTracker.GetCrossComponent(childDesiredSize) -
aItem.GetBorderPaddingSizeInAxis(aAxisTracker.GetCrossAxis());
aItem.SetCrossSize(crossSize);
// Tentatively store the child's desired content-box cross-size.
// Note that childDesiredSize is the border-box size, so we have to
// subtract border & padding to get the content-box size.
// (Note that at this point in the code, we know our cross axis is vertical,
// so we don't bother with making aAxisTracker pick the cross-axis component
// for us.)
nscoord crossAxisBorderPadding = aItem.GetBorderPadding().TopBottom();
if (childDesiredSize.height < crossAxisBorderPadding) {
// Child's requested size isn't large enough for its border/padding!
// This is OK for the trivial nsFrame::Reflow() impl, but other frame
// classes should know better. So, if we get here, the child had better be
// an instance of nsFrame (i.e. it should return null from GetType()).
// XXXdholbert Once we've fixed bug 765861, we should upgrade this to an
// assertion that trivially passes if bug 765861's flag has been flipped.
NS_WARN_IF_FALSE(!aItem.Frame()->GetType(),
"Child should at least request space for border/padding");
aItem.SetCrossSize(0);
} else {
// (normal case)
aItem.SetCrossSize(childDesiredSize.height - crossAxisBorderPadding);
}
// If we need to do baseline-alignment, store the child's ascent.
if (aItem.GetAlignSelf() == NS_STYLE_ALIGN_ITEMS_BASELINE) {