for (int i = 0; i < 4; i++) {
if (_pageSizeCacheKeys[i] == width
&& _pageSizeCacheValues[i] != null) {
if (h > _pageSizeCacheValues[i].height) {
return new Dimension(_pageSizeCacheValues[i].width, h);
}
return _pageSizeCacheValues[i];
}
}
_pageSizeCacheKeys[3] = _pageSizeCacheKeys[2];
_pageSizeCacheKeys[2] = _pageSizeCacheKeys[1];
_pageSizeCacheKeys[1] = _pageSizeCacheKeys[0];
_pageSizeCacheKeys[0] = width;
_pageSizeCacheValues[3] = _pageSizeCacheValues[2];
_pageSizeCacheValues[2] = _pageSizeCacheValues[1];
_pageSizeCacheValues[1] = _pageSizeCacheValues[0];
// Flowpage must temporarily layout to determine its preferred size
int oldWidth = getRecommendedWidth();
setRecommendedWidth(width);
((CSSFigure) container).setValid(false);
container.validate();
((CSSFigure) container).postValidate();
_pageSizeCacheValues[0] = new Dimension(_pageSize);
if (width != oldWidth) {
setRecommendedWidth(oldWidth);
// container.getUpdateManager().addInvalidFigure(container);
}
if (h > _pageSizeCacheValues[0].height) {
return new Dimension(_pageSizeCacheValues[0].width, h);
}
return _pageSizeCacheValues[0];
} finally {
_calculatingSize = false;
}