final int desiredWidth = getMainWidth();
debug("VFS.SP: desired[" + desiredWidth + ", " + desiredHeight
+ "]");
Element menuFirstChild = menu.getElement().getFirstChildElement();
final int naturalMenuWidth = menuFirstChild.getOffsetWidth();
if (popupOuterPadding == -1) {
popupOuterPadding = Util.measureHorizontalPaddingAndBorder(
getElement(), 2);
}
if (naturalMenuWidth < desiredWidth) {
menu.setWidth((desiredWidth - popupOuterPadding) + "px");
menuFirstChild.getStyle().setWidth(100, Unit.PCT);
}
if (BrowserInfo.get().isIE()) {
/*
* IE requires us to specify the width for the container
* element. Otherwise it will be 100% wide
*/
int rootWidth = Math.max(desiredWidth, naturalMenuWidth)
- popupOuterPadding;
getContainerElement().getStyle().setWidth(rootWidth, Unit.PX);
}
final int vfsHeight = VFilterSelect.this.getOffsetHeight();
final int spaceAvailableAbove = top - vfsHeight;
final int spaceAvailableBelow = Window.getClientHeight() - top;
if (spaceAvailableBelow < offsetHeight
&& spaceAvailableBelow < spaceAvailableAbove) {
// popup on top of input instead
top -= offsetHeight + vfsHeight;
if (top < 0) {
offsetHeight += top;
top = 0;
}
} else {
offsetHeight = Math.min(offsetHeight, spaceAvailableBelow);
}
// fetch real width (mac FF bugs here due GWT popups overflow:auto )
offsetWidth = menuFirstChild.getOffsetWidth();
if (offsetHeight < desiredHeight) {
int menuHeight = offsetHeight;
if (isPagingEnabled) {
menuHeight -= up.getOffsetHeight() + down.getOffsetHeight()