]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #3295
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 7 Sep 2009 15:11:57 +0000 (15:11 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 7 Sep 2009 15:11:57 +0000 (15:11 +0000)
svn changeset:8688/svn branch:6.1

src/com/vaadin/terminal/gwt/client/Util.java
src/com/vaadin/terminal/gwt/client/ui/VOverlay.java
src/com/vaadin/terminal/gwt/client/ui/VView.java

index fd1b6774ea6b55f8d8b8c4a4fc080d75f3cede54..770214f45ea89309c752208823bea7ab2622445c 100644 (file)
@@ -10,6 +10,8 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.DeferredCommand;
@@ -713,4 +715,31 @@ public class Util {
 
      }-*/;
 
+    /**
+     * IE7 sometimes "forgets" to render content. This function runs a hack to
+     * workaround the bug if needed. This happens easily in framset. See #3295.
+     */
+    public static void runIE7ZeroSizedBodyFix() {
+        if (BrowserInfo.get().isIE7()) {
+            int offsetWidth = RootPanel.getBodyElement().getOffsetWidth();
+            if (offsetWidth == 0) {
+                shakeBodyElement();
+            }
+        }
+    }
+
+    /**
+     * Does some very small adjustments to body element. We need this just to
+     * overcome some IE bugs.
+     */
+    public static void shakeBodyElement() {
+        final DivElement shaker = Document.get().createDivElement();
+        RootPanel.getBodyElement().insertBefore(shaker,
+                RootPanel.getBodyElement().getFirstChildElement());
+        shaker.getStyle().setPropertyPx("height", 0);
+        shaker.setInnerHTML("&nbsp;");
+        RootPanel.getBodyElement().removeChild(shaker);
+
+    }
+
 }
index d107f519ed00f61b36ae0e2fba735f4cd28ad2e0..fb6831e31a176605218c975e606a5d44aa5dd1b4 100644 (file)
@@ -13,6 +13,7 @@ import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.PopupPanel;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
+import com.vaadin.terminal.gwt.client.Util;
 
 /**
  * In Vaadin UI this Overlay should always be used for all elements that
@@ -130,6 +131,13 @@ public class VOverlay extends PopupPanel {
                 updateShadowSizeAndPosition(1.0);
             }
         }
+        Util.runIE7ZeroSizedBodyFix();
+    }
+
+    @Override
+    public void hide(boolean autoClosed) {
+        super.hide(autoClosed);
+        Util.runIE7ZeroSizedBodyFix();
     }
 
     @Override
index 95e85aaa1f37b48946e969fd855b2f096f07c036..e9a7588d932681f254a9734fff22a2a3cda3e55c 100644 (file)
@@ -520,7 +520,13 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
 
         @Override
         public int getWidth() {
-            return getElement().getOffsetWidth() - getExcessWidth();
+            int w = getElement().getOffsetWidth() - getExcessWidth();
+            if (w < 10 && BrowserInfo.get().isIE7()) {
+                // Overcome an IE7 bug #3295
+                Util.shakeBodyElement();
+                w = getElement().getOffsetWidth() - getExcessWidth();
+            }
+            return w;
         }
 
         private int getExcessWidth() {