}
private static long computeWidthInternal(final RenderableReplacedContentBox contentBox,
final long blockContextWidth)
{
final RenderableReplacedContent content = contentBox.getContent();
final RenderLength requestedWidth = content.getRequestedWidth();
final RenderLength requestedHeight = content.getRequestedHeight();
if (RenderLength.AUTO.equals(requestedWidth))
{
// if width is auto, and height is auto,
if (RenderLength.AUTO.equals(requestedHeight))
{
// use the intrinsic width ..
return content.getContentWidth();
}
// if height is not auto, but the width is, then compute a width that
// preserves the aspect ratio. (
else
{
final long contentHeight = content.getContentHeight();
if (contentHeight > 0)
{
final long height = requestedHeight.resolve(blockContextWidth);
return height * blockContextWidth / contentHeight;
}