]> source.dussan.org Git - vaadin-framework.git/commitdiff
Rewrote [15706]
authorJohn Alhroos <john.ahlroos@itmill.com>
Tue, 26 Oct 2010 11:23:52 +0000 (11:23 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Tue, 26 Oct 2010 11:23:52 +0000 (11:23 +0000)
svn changeset:15713/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java

index d06d6b11a3ccebafcc3465ce1de3af3f29c9cbed..beee1c486338d724632aa20a86f88d44bae13007 100644 (file)
@@ -404,23 +404,36 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
             x += columnWidths[i] + spacingPixelsHorizontal;
         }
 
-        if ("".equals(width)) {
+        if (isUndefinedWidth()) {
             canvas.setWidth((x - spacingPixelsHorizontal) + "px");
         } else {
             // main element defines width
             canvas.setWidth("");
         }
+
+        if (!isUndefinedHeight() && getOffsetHeight() < marginTopAndBottom) {
+            // Prevent a negative height value
+            canvas.setHeight("0px");
+            return;
+        }
+
         int canvasHeight;
-        if ("".equals(height)) {
+        if (isUndefinedHeight()) {
             canvasHeight = y - spacingPixelsVertical;
-        } else if (getOffsetHeight() > marginTopAndBottom) {
-            canvasHeight = getOffsetHeight() - marginTopAndBottom;
         } else {
-            canvasHeight = 0;
+            canvasHeight = getOffsetHeight() - marginTopAndBottom;
         }
         canvas.setHeight(canvasHeight + "px");
     }
 
+    public boolean isUndefinedHeight() {
+        return "".equals(height) || "-1px".equals(height);
+    }
+
+    public boolean isUndefinedWidth() {
+        return "".equals(width) || "-1px".equals(width);
+    }
+
     private void renderRemainingComponents(LinkedList<Cell> pendingCells) {
         for (Cell cell : pendingCells) {
             cell.render();