private long height;
public ReplacedContentAlignContext(final RenderableReplacedContent node)
{
super(node);
final StrictDimension contentSize = node.getContentSize();
// we better compute the height of the content or we will run into
// trouble ..
if (RenderLength.AUTO.equals(node.getRequestedWidth()))
{
// if width is auto, and height is auto,
if (RenderLength.AUTO.equals(node.getRequestedHeight()))
{
// use the intrinsic height ..
height = contentSize.getHeight();
}
// if height is not auto, but the width is, 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 ..
final RenderLength blockContextWidth =
node.getComputedLayoutProperties().getBlockContextWidth();
height = node.getRequestedHeight().resolve(blockContextWidth.resolve(0));
}
}
else
{
// width is not auto.
// If the height is auto, we have to preserve the aspect ratio ..
if (RenderLength.AUTO.equals(node.getRequestedHeight()))
{
if (contentSize.getWidth() > 0)
{
final RenderLength blockContextWidth =
node.getComputedLayoutProperties().getBlockContextWidth();
final long computedWidth =
node.getRequestedWidth().resolve(blockContextWidth.resolve(0));
// Requested height must be computed to preserve the aspect ratio.
height = computedWidth * contentSize.getHeight()/contentSize.getWidth();
}
else
{
height = 0;
}