}
final int left = paddingLeftMeasure.sizeOf(layoutPanel);
final int top = paddingTopMeasure.sizeOf(layoutPanel);
final Dimension box = DOM.getClientSize(layoutPanel.getElement());
int width = box.width - (left + paddingRightMeasure.sizeOf(layoutPanel));
int height = box.height - (top + paddingBottomMeasure.sizeOf(layoutPanel));
final Widget parent = child.getParent();
if (parent instanceof InternalDecoratorPanel) {
final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
final int borderSizes[] = decPanel.getBorderSizes();
width -= (borderSizes[1] + borderSizes[3]);
height -= (borderSizes[0] + borderSizes[2]);
}
HorizontalAlignmentConstant hAlignment = layoutData.getHorizontalAlignment();
if (hAlignment == null) {
hAlignment = getHorizontalAlignment();
}
Dimension prefSize = null;
if (hAlignment == null) {
layoutData.targetLeft = left;
layoutData.targetWidth = width;
} else {
// (ggeorg) this call to WidgetHelper.getPreferredSize() is
// required even for ALIGN_LEFT
prefSize = new Dimension(preferredWidthMeasure.sizeOf(child),
preferredHeightMeasure.sizeOf(child));
if (HasHorizontalAlignment.ALIGN_LEFT == hAlignment) {
layoutData.targetLeft = left;
} else if (HasHorizontalAlignment.ALIGN_CENTER == hAlignment) {
layoutData.targetLeft = left + (width - prefSize.width) / 2;
} else {
layoutData.targetLeft = left + width - prefSize.width;
}
layoutData.targetWidth = prefSize.width;
}
VerticalAlignmentConstant vAlignment = layoutData.getVerticalAlignment();
if (vAlignment == null) {
vAlignment = getVerticalAlignment();
}
if (vAlignment == null) {
layoutData.targetTop = top;
layoutData.targetHeight = height;
} else {
if (prefSize == null) {
// (ggeorg) this call to WidgetHelper.getPreferredSize() is
// required even for ALIGN_TOP
prefSize = new Dimension(preferredWidthMeasure.sizeOf(child),
preferredHeightMeasure.sizeOf(child));
}
if (HasVerticalAlignment.ALIGN_TOP == vAlignment) {
layoutData.targetTop = top;