{
final StaticBoxLayoutProperties blp = box.getStaticBoxLayoutProperties();
final BoxDefinition bdef = box.getBoxDefinition();
final BoxDefinition boxDefinition = box.getBoxDefinition();
final RenderLength minHeight = boxDefinition.getMinimumHeight();
final RenderLength preferredHeight = boxDefinition.getPreferredHeight();
final RenderLength maxHeight = boxDefinition.getMaximumHeight();
final long insetsTop = (blp.getBorderTop() + bdef.getPaddingTop());
final long insetsBottom = blp.getBorderBottom() + bdef.getPaddingBottom();
final long insets = insetsTop + insetsBottom;
final long parentHeight;
final long usableParentHeight;
if (heightResolvesToZero)
{
parentHeight = 0;
usableParentHeight = 0;
}
else
{
parentHeight = Math.max(resolveParentHeight(box), box.getCachedHeight());
usableParentHeight = resolveUseableParentHeight(box);
}
// find the maximum of the used height (for all childs) and the specified min-height.
long consumedHeight = Math.max(box.getCachedHeight(),
Math.min(minHeight.resolve(parentHeight), usableParentHeight));
// The consumed height computed above specifies the size at the border-edge.
// However, depending on the box-sizing property, we may have to resolve them against the
// content-edge instead.
if (box.isSizeSpecifiesBorderBox())
{
final long minHeightResolved = minHeight.resolve(parentHeight);
final long maxHeightResolved = maxHeight.resolve(parentHeight);
final long prefHeightResolved;
if (RenderLength.AUTO.equals(preferredHeight))
{
prefHeightResolved = consumedHeight;
}
else
{
prefHeightResolved = preferredHeight.resolve(parentHeight);
}
final long height = ProcessUtility.computeLength(minHeightResolved, maxHeightResolved, prefHeightResolved);
if (heightResolvesToZero)
return height;
return Math.min(height, usableParentHeight);
}
else
{
consumedHeight = Math.max(0, consumedHeight - insets);
final long minHeightResolved = minHeight.resolve(parentHeight);
final long maxHeightResolved = maxHeight.resolve(parentHeight);
final long prefHeightResolved;
if (RenderLength.AUTO.equals(preferredHeight))
{
prefHeightResolved = consumedHeight;
}