]> source.dussan.org Git - vaadin-framework.git/commitdiff
workaround for random table collapses in IE
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 25 Feb 2008 14:56:20 +0000 (14:56 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 25 Feb 2008 14:56:20 +0000 (14:56 +0000)
svn changeset:3920/svn branch:trunk

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

index bcfbafb44f4334d7598c06f6d54e9f7d2d895d66..2074aa156240a745c1fa5f08c089d4b90ed923cf 100644 (file)
@@ -122,6 +122,12 @@ public class IScrollTable extends Composite implements Table, ScrollListener,
     /** flag to indicate that table body has changed */
     private boolean isNewBody = true;
 
+    /**
+     * Stores old height for IE, that sometimes fails to return correct height
+     * for container element. Then this value is used as a fallback.
+     */
+    private int oldAvailPixels;
+
     public IScrollTable() {
 
         bodyContainer.addScrollListener(this);
@@ -2046,14 +2052,25 @@ public class IScrollTable extends Composite implements Table, ScrollListener,
         // workaround very common 100% height problem - extract borders
         if (height.equals("100%")) {
             final int borders = getBorderSpace();
-            final Element elem = getElement();
-            final Element parentElem = DOM.getParent(elem);
+            final Element parentElem = DOM.getParent(getElement());
 
             // put table away from flow for a moment
             DOM.setStyleAttribute(getElement(), "position", "absolute");
             // get containers natural space for table
-            final int availPixels = DOM.getElementPropertyInt(parentElem,
+            int availPixels = DOM.getElementPropertyInt(parentElem,
                     "offsetHeight");
+            if (Util.isIE()) {
+                if (availPixels == 0) {
+                    // In complex layouts IE sometimes rather randomly returns 0
+                    // although container really has height. Use old value if
+                    // one exits.
+                    if (oldAvailPixels > 0) {
+                        availPixels = oldAvailPixels;
+                    }
+                } else {
+                    oldAvailPixels = availPixels;
+                }
+            }
             // put table back to flow
             DOM.setStyleAttribute(getElement(), "position", "static");
             // set 100% height with borders