From: Matti Tahvonen Date: Mon, 7 Sep 2009 15:11:57 +0000 (+0000) Subject: fixes #3295 X-Git-Tag: 6.7.0.beta1~2507 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5ebc11a599389cca423783191ce5af8a3547fe44;p=vaadin-framework.git fixes #3295 svn changeset:8688/svn branch:6.1 --- diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index fd1b6774ea..770214f45e 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -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(" "); + RootPanel.getBodyElement().removeChild(shaker); + + } + } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java index d107f519ed..fb6831e31a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java @@ -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 diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 95e85aaa1f..e9a7588d93 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -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() {