]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #1988 (Window moving weirdness with undefined width)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 18 Aug 2008 13:27:36 +0000 (13:27 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 18 Aug 2008 13:27:36 +0000 (13:27 +0000)
svn changeset:5207/svn branch:trunk

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

index a39eca1063b32aacd10ecc8e4ee8be186beac145..a77df275474d0c7ef52e6ccfe1447af1241db2f4 100644 (file)
@@ -207,18 +207,6 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
             setModal(!modal);
         }
 
-        // Initialize the size from UIDL
-        // FIXME relational size is for outer size, others are applied for
-        // content
-        if (uidl.hasVariable("width")) {
-            final String width = uidl.getStringVariable("width");
-            if (width.indexOf("px") < 0) {
-                DOM.setStyleAttribute(getElement(), "width", width);
-            } else {
-                setWidth(width);
-            }
-        }
-
         // Initialize the position form UIDL
         try {
             final int positionx = uidl.getIntVariable("positionx");
@@ -235,6 +223,32 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
             show();
         }
 
+        // Initialize the size from UIDL
+        /*
+         * FIXME non-pixel size is set as "outer size", pixels are applied for
+         * content area. This is due history as earlier only pixels where
+         * allowed.
+         */
+        if (uidl.hasVariable("width")) {
+            final String width = uidl.getStringVariable("width");
+            if (width.indexOf("px") < 0) {
+                /*
+                 * Only using non-pixel size for initial size measurement. Then
+                 * fix content area with pixels.
+                 */
+                DOM.setStyleAttribute(getElement(), "width", width);
+                int elementPropertyInt = DOM.getElementPropertyInt(
+                        getElement(), "offsetWidth");
+                DOM.setStyleAttribute(getElement(), "width", "");
+                elementPropertyInt -= (DOM.getElementPropertyInt(getElement(),
+                        "offsetWidth") - DOM.getElementPropertyInt(contents,
+                        "offsetWidth"));
+                setWidth(elementPropertyInt + "px");
+            } else {
+                setWidth(width);
+            }
+        }
+
         // Height set after show so we can detect space used by decorations
         if (uidl.hasVariable("height")) {
             final String height = uidl.getStringVariable("height");