From: Matti Tahvonen Date: Thu, 12 Jun 2008 09:21:51 +0000 (+0000) Subject: fixes #1764 X-Git-Tag: 6.7.0.beta1~4612 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b3cab0ab2ee9fca4d79f75b71332c31963bd1aba;p=vaadin-framework.git fixes #1764 svn changeset:4861/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java b/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java index e47708b205..c90c31047d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java @@ -89,6 +89,10 @@ public class BrowserInfo { return isIE && ieVersion == 7; } + public boolean isGecko() { + return isGecko; + } + public boolean isFF2() { return isGecko && geckoVersion == 1.8; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java index 69c05223c1..b4ce0318c0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -10,6 +10,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; +import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; import com.itmill.toolkit.terminal.gwt.client.ErrorMessage; import com.itmill.toolkit.terminal.gwt.client.Paintable; @@ -45,6 +46,10 @@ public class IPanel extends SimplePanel implements Paintable, ShortcutActionHandler shortcutHandler; + private String width; + + private Element geckoCaptionMeter; + public IPanel() { super(); DOM.appendChild(getElement(), captionNode); @@ -136,7 +141,7 @@ public class IPanel extends SimplePanel implements Paintable, } // Height adjustment - iLayout(); + iLayout(false); // Render content final UIDL layoutUidl = uidl.getChildUIDL(0); @@ -212,6 +217,10 @@ public class IPanel extends SimplePanel implements Paintable, } public void iLayout() { + iLayout(true); + } + + public void iLayout(boolean runGeckoFix) { if (height != null && height != "") { final boolean hasChildren = getWidget() != null; Element contentEl = null; @@ -267,6 +276,30 @@ public class IPanel extends SimplePanel implements Paintable, } else { DOM.setStyleAttribute(contentNode, "height", ""); } + + if (runGeckoFix && BrowserInfo.get().isGecko()) { + // workaround for #1764 + if (width == null || width.equals("")) { + if (geckoCaptionMeter == null) { + geckoCaptionMeter = DOM.createDiv(); + DOM.appendChild(captionNode, geckoCaptionMeter); + } + int captionWidth = DOM.getElementPropertyInt(captionText, + "offsetWidth"); + int availWidth = DOM.getElementPropertyInt(geckoCaptionMeter, + "offsetWidth"); + if (captionWidth == availWidth) { + /* + * Caption width defines panel width -> Gecko based browsers + * somehow fails to float things right, without the + * "noncode" below + */ + setWidth(getOffsetWidth() + "px"); + } else { + DOM.setStyleAttribute(captionNode, "width", ""); + } + } + } Util.runDescendentsLayout(this); } @@ -311,9 +344,11 @@ public class IPanel extends SimplePanel implements Paintable, * Panel handles dimensions by itself. */ public void setWidth(String width) { - // Let browser handle 100% width (DIV element takes all size by default). + this.width = width; + // Let browser handle 100% width (DIV element takes all size by + // default). // This way we can specify borders for Panel's outer element. - if(!width.equals("100%")) { + if (!width.equals("100%")) { super.setWidth(width); } }