]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #2091. Issues with gecko and orizontal expand layout.
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 26 Sep 2008 09:37:16 +0000 (09:37 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 26 Sep 2008 09:37:16 +0000 (09:37 +0000)
svn changeset:5523/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java

index 6ac56770eb73c1726b362b1c418f91dc106466bd..a3f4d4aa63818eb8345f925c98c6dc5a7da06396 100644 (file)
@@ -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")