calcDimensions(c, getCSSWidth(c));
}
protected void calcDimensions(LayoutContext c, int cssWidth) {
if (! isDimensionsCalculated()) {
CalculatedStyle style = getStyle();
RectPropertySet padding = getPadding(c);
BorderPropertySet border = getBorder(c);
if (cssWidth != -1 && !isAnonymous() &&
(getStyle().isIdent(CSSName.MARGIN_LEFT, IdentValue.AUTO) ||
getStyle().isIdent(CSSName.MARGIN_RIGHT, IdentValue.AUTO)) &&
getStyle().isNeedAutoMarginResolution()) {
resolveAutoMargins(c, cssWidth, padding, border);
}
recalcMargin(c);
RectPropertySet margin = getMargin(c);
// CLEAN: cast to int
setLeftMBP((int) margin.left() + (int) border.left() + (int) padding.left());
setRightMBP((int) padding.right() + (int) border.right() + (int) margin.right());
if (c.isPrint() && getStyle().isDynamicAutoWidth()) {
setContentWidth(calcEffPageRelativeWidth(c));
} else {
setContentWidth((getContainingBlockWidth() - getLeftMBP() - getRightMBP()));
}
setHeight(0);
if (! isAnonymous() || (isFromCaptionedTable() && isFloated())) {
int pinnedContentWidth = -1;
if (cssWidth != -1) {
setContentWidth(cssWidth);
} else if (getStyle().isAbsolute() || getStyle().isFixed()) {
pinnedContentWidth = calcPinnedContentWidth(c);
if (pinnedContentWidth != -1) {
setContentWidth(pinnedContentWidth);
}
}
int cssHeight = getCSSHeight(c);
if (cssHeight != -1) {
setHeight(cssHeight);
}
//check if replaced
ReplacedElement re = getReplacedElement();
if (re == null) {
re = c.getReplacedElementFactory().createReplacedElement(
c, this, c.getUac(), cssWidth, cssHeight);
if (re != null){
re = fitReplacedElement(c, re);
}
}
if (re != null) {
setContentWidth(re.getIntrinsicWidth());
setHeight(re.getIntrinsicHeight());
setReplacedElement(re);
} else if (cssWidth == -1 && pinnedContentWidth == -1 &&
style.isCanBeShrunkToFit()) {
setNeedShrinkToFitCalculatation(true);
}
if (! isReplaced()) {
applyCSSMinMaxWidth(c);