]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #1764
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 12 Jun 2008 09:21:51 +0000 (09:21 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 12 Jun 2008 09:21:51 +0000 (09:21 +0000)
svn changeset:4861/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java

index e47708b20582301cb8bededff982660d2a9a14af..c90c31047ddefcc7432da876bff48fd1f0154238 100644 (file)
@@ -89,6 +89,10 @@ public class BrowserInfo {
         return isIE && ieVersion == 7;
     }
 
+    public boolean isGecko() {
+        return isGecko;
+    }
+
     public boolean isFF2() {
         return isGecko && geckoVersion == 1.8;
     }
index 69c05223c1ba3c21d86fd6b061c069169585d807..b4ce0318c0d5e39802dbf4e9bc06fc4cf6284bd5 100644 (file)
@@ -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);
         }
     }