}
private static long computeHeightInternal(final RenderableReplacedContent content,
final long blockContextWidth, final long computedWidth)
{
final RenderLength requestedHeight = content.getRequestedHeight();
if (RenderLength.AUTO.equals(content.getRequestedWidth()))
{
// if width is auto, and height is auto,
if (RenderLength.AUTO.equals(requestedHeight))
{
final long contentWidth = content.getContentWidth();
if (contentWidth > 0 && computedWidth != 0)
{
// Intrinsic height must be computed to preserve the aspect ratio.
return computedWidth * content.getContentHeight() / contentWidth;
}
// use the intrinsic height ..
return content.getContentHeight();
}
// if height is not auto, then use the declared height.
else
{
// A percentage is now relative to the intrinsinc size.
// And yes, I'm aware that this is not what the standard says ..
return requestedHeight.resolve(blockContextWidth);
}
}
else
{
// width is not auto.
// If the height is auto, we have to preserve the aspect ratio ..
if (RenderLength.AUTO.equals(requestedHeight))
{
final long contentWidth = content.getContentWidth();
if (contentWidth > 0)
{
// Requested height must be computed to preserve the aspect ratio.
return computedWidth * content.getContentHeight() / contentWidth;
}
else
{
return 0;
}
}
else
{
// height is something fixed ..
return requestedHeight.resolve(blockContextWidth);
}
}
}