From: Matti Tahvonen Date: Fri, 26 Sep 2008 09:37:16 +0000 (+0000) Subject: fixes #2091. Issues with gecko and orizontal expand layout. X-Git-Tag: 6.7.0.beta1~4082 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4af1aabba837639e9356f352510f9c40d07ece66;p=vaadin-framework.git fixes #2091. Issues with gecko and orizontal expand layout. svn changeset:5523/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java index 6ac56770eb..a3f4d4aa63 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java @@ -420,6 +420,22 @@ public class IExpandLayout extends ComplexPanel implements final WidgetWrapper wr = getWidgetWrapperFor(expandedWidget); wr.setExpandedSize(spaceForExpandedWidget); + /* + * Workaround for issue #2093. Gecko base brosers have some rounding + * issues every now and then. If all elements didn't fit on same row, + * decrease expanded space until they do. + */ + if (orientationMode == ORIENTATION_HORIZONTAL + && BrowserInfo.get().isGecko()) { + int tries = 0; + while (tries < 30 + && spaceForExpandedWidget > EXPANDED_ELEMENTS_MIN_WIDTH + && isLastElementDropped()) { + spaceForExpandedWidget--; + wr.setExpandedSize(spaceForExpandedWidget); + } + } + // setting overflow auto lazy off during layout function DOM.setStyleAttribute(DOM.getParent(expandedWidget.getElement()), "overflow", "hidden"); @@ -433,6 +449,18 @@ public class IExpandLayout extends ComplexPanel implements } + /** + * Helper method to build workaround for Gecko issue. + * + * @return true if last element has dropped to another line + */ + private boolean isLastElementDropped() { + int firstTop = DOM.getAbsoluteTop(DOM.getFirstChild(childContainer)); + int lastTop = DOM.getAbsoluteTop(DOM.getChild(childContainer, + (getWidgetCount() - 1))); + return firstTop != lastTop; + } + private int getTopMargin() { if (topMargin < 0) { topMargin = DOM.getElementPropertyInt(childContainer, "offsetTop")