Bug 789824 - Apply min-/max-height constraints on -moz-box containers correctly. r=bz

This commit is contained in:
Mats Palmgren 2012-09-12 00:20:51 +02:00
parent d08a4048c0
commit 9d0260d0a7
4 changed files with 119 additions and 16 deletions

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML>
<html><head>
<meta charset="utf-8">
<title>Testcase for bug 789824</title>
<style type="text/css">
html,body {
color:black; background-color:white; font-size:24px; padding:0; margin:0;
}
div { padding:5px; }
hbox {
display:-moz-box;
border-top:3px solid;
border-bottom:2px solid;
padding-bottom:4px;
background:lime;
box-sizing:content-box;
-moz-box-sizing:content-box;
}
.cb {
background:pink;
box-sizing:border-box;
-moz-box-sizing:border-box;
}
.pb {
background:cyan;
}
</style>
</head>
<body>
<div><hbox style="height:11px;">border-box 20px</hbox></div>
<div><hbox style="height:41px;">border-box 50px</hbox></div>
<div><hbox style="height:11px;">border-box 20px</hbox></div>
<div><hbox class="cb" style="height:29px;">content-box 20px</hbox></div>
<div><hbox class="cb" style="height:59px;">content-box 50px</hbox></div>
<div><hbox class="cb" style="height:29px;">content-box 20px</hbox></div>
<div><hbox class="pb" style="height:16px;">padding-box 20px</hbox></div>
<div><hbox class="pb" style="height:46px;">padding-box 50px</hbox></div>
<div><hbox class="pb" style="height:16px;">padding-box 20px</hbox></div>
</body>
</html>

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html><head>
<meta charset="utf-8">
<title>Testcase for bug 789824</title>
<style type="text/css">
html,body {
color:black; background-color:white; font-size:24px; padding:0; margin:0;
}
div { padding:5px; }
hbox {
display:-moz-box;
border-top:3px solid;
border-bottom:2px solid;
padding-bottom:4px;
height:auto;
box-sizing:border-box;
-moz-box-sizing:border-box;
background:lime;
}
.cb {
box-sizing:content-box;
-moz-box-sizing:content-box;
background:pink;
}
.pb {
box-sizing:padding-box;
-moz-box-sizing:padding-box;
background:cyan;
}
</style>
</head>
<body>
<div><hbox style="height:20px;">border-box 20px</hbox></div>
<div><hbox style="min-height:50px;">border-box 50px</hbox></div>
<div><hbox style="max-height:20px;">border-box 20px</hbox></div>
<div><hbox class="cb" style="height:20px;">content-box 20px</hbox></div>
<div><hbox class="cb" style="min-height:50px;">content-box 50px</hbox></div>
<div><hbox class="cb" style="max-height:20px;">content-box 20px</hbox></div>
<div><hbox class="pb" style="height:20px;">padding-box 20px</hbox></div>
<div><hbox class="pb" style="min-height:50px;">padding-box 50px</hbox></div>
<div><hbox class="pb" style="max-height:20px;">padding-box 20px</hbox></div>
</body>
</html>

View File

@ -18,6 +18,7 @@
== box-sizing-4.html box-sizing-4-ref.html
== box-sizing-minmax-height.html box-sizing-minmax-height-ref.html
== box-sizing-minmax-width.html box-sizing-minmax-width-ref.html
== box-sizing-mozbox-minmax-height.html box-sizing-mozbox-minmax-height-ref.html
== abspos-non-replaced-width-offset-margin.html abspos-non-replaced-width-offset-margin-ref.html
== abspos-replaced-width-offset-margin.html abspos-replaced-width-offset-margin-ref.html
HTTP(..) == CSS21-t100301.xhtml CSS21-t100301-ref.xhtml

View File

@ -675,22 +675,14 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
computedSize.height = prefSize.height;
// prefSize is border-box, so we need to figure out the right
// length to apply our min/max constraints to.
nscoord outsideBoxSizing = 0;
switch (GetStylePosition()->mBoxSizing) {
case NS_STYLE_BOX_SIZING_CONTENT:
outsideBoxSizing = aReflowState.mComputedBorderPadding.TopBottom();
// fall through
case NS_STYLE_BOX_SIZING_PADDING:
outsideBoxSizing -= aReflowState.mComputedPadding.TopBottom();
break;
}
computedSize.height -= outsideBoxSizing;
// Note: might be negative now, but that's OK because min-width is
// never negative.
computedSize.height = aReflowState.ApplyMinMaxHeight(computedSize.height);
computedSize.height += outsideBoxSizing;
// prefSize is border-box but min/max constraints are content-box.
nscoord verticalBorderPadding =
aReflowState.mComputedBorderPadding.TopBottom();
nscoord contentHeight = computedSize.height - verticalBorderPadding;
// Note: contentHeight might be negative, but that's OK because min-height
// is never negative.
computedSize.height = aReflowState.ApplyMinMaxHeight(contentHeight) +
verticalBorderPadding;
} else {
computedSize.height += m.top + m.bottom;
}