if (sequenceElement instanceof EndSequenceElement)
{
return offset;
}
final ExtendedBaselineInfo baselineInfo;
final RenderNode node = sequenceElement.getNode();
if (sequenceElement instanceof TextSequenceElement)
{
final RenderableText text = (RenderableText) node;
baselineInfo = text.getBaselineInfo();
}
else
{
baselineInfo = null;
}
// This is the initial call.
final long preferredSize = 0;
if (baselinePositions == null)
{
this.height = Math.max (height, preferredSize);
final long delta = height - preferredSize;
if (baselineInfo == null)
{
// ok, no baseline info at all. Dont panic. We have recorded the
// height and wait for the next element. Once we hit an element
// that has a baseline, we will shift it by the delta-amount.
return delta;
}
this.dominantBaseline = baselineInfo.getDominantBaseline();
this.baselinePositions = baselineInfo.getBaselines();
if (delta > 0)
{
baselineShift += delta;
}
//this.initialBaselinePositions = (long[]) baselinePositions.clone();
return delta;
}
// now here comes the tricky part
final CSSValue verticalAlignment = null;//node.getVerticalAlignment();
if (baselineInfo == null ||
VerticalAlign.TOP.equals(verticalAlignment) ||
VerticalAlign.BOTTOM.equals(verticalAlignment) ||
VerticalAlign.MIDDLE.equals(verticalAlignment))
{
return alignSimple(verticalAlignment, preferredSize);
}
// This is one of the baseline alignments. The alignment value tells us
// which baseline will be used for the alignment.
final int localBase;
final int nodeBase;
if (VerticalAlign.CENTRAL.equals(verticalAlignment))
{
nodeBase = ExtendedBaselineInfo.CENTRAL;
localBase = ExtendedBaselineInfo.CENTRAL;
}
else if (VerticalAlign.TEXT_BOTTOM.equals(verticalAlignment))
{
nodeBase = ExtendedBaselineInfo.TEXT_AFTER_EDGE;
localBase = ExtendedBaselineInfo.TEXT_AFTER_EDGE;
}
else if (VerticalAlign.TEXT_TOP.equals(verticalAlignment))
{
nodeBase = ExtendedBaselineInfo.TEXT_BEFORE_EDGE;
localBase = ExtendedBaselineInfo.TEXT_BEFORE_EDGE;
}
else if (VerticalAlign.SUB.equals(verticalAlignment))
{
nodeBase = ExtendedBaselineInfo.MATHEMATICAL;
localBase = dominantBaseline;
}
else if (VerticalAlign.SUPER.equals(verticalAlignment))
{
nodeBase = baselineInfo.getDominantBaseline();
localBase = ExtendedBaselineInfo.MATHEMATICAL;
}
else if (VerticalAlign.BASELINE.equals(verticalAlignment))
{
nodeBase = ExtendedBaselineInfo.ALPHABETHIC;
localBase = ExtendedBaselineInfo.ALPHABETHIC;
}
else
{
nodeBase = baselineInfo.getDominantBaseline();
localBase = baselineInfo.getDominantBaseline();
}
final long[] baselines = baselineInfo.getBaselines();
final long myAscent = baselinePositions[localBase] + baselineShift;
final long nodeAscent = baselines[nodeBase];
if (nodeAscent > myAscent)
{