]> source.dussan.org Git - vaadin-framework.git/commitdiff
[merge from 6.7] Fix and test case for #8619: Add sanity checks to GridLayout to...
authorAutomerge <automerge@vaadin.com>
Fri, 27 Apr 2012 11:39:27 +0000 (11:39 +0000)
committerAutomerge <automerge@vaadin.com>
Fri, 27 Apr 2012 11:39:27 +0000 (11:39 +0000)
svn changeset:23656/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java [new file with mode: 0644]

index 82b3eabf406f8f94955d0ac2773d8853c0a2490a..ba37148c363888ab839212cd66aca718ae547e15 100644 (file)
@@ -29,6 +29,7 @@ import com.vaadin.terminal.gwt.client.RenderSpace;
 import com.vaadin.terminal.gwt.client.StyleConstants;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.VConsole;
 import com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout;
 import com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer;
 
@@ -768,7 +769,11 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
                     allocated += spacingPixelsHorizontal
                             + columnWidths[cell.col + i];
                 }
-                if (allocated < width) {
+                if (cell.hasRelativeWidth() && allocated != width) {
+                    // This may happen e.g. when browser zoomout causes pixel
+                    // rounding issues, see #8619
+                    VConsole.error("A relative-width child should never cause cell width to change!");
+                } else if (allocated < width) {
                     needsLayout = true;
                     if (cell.colspan == 1) {
                         // do simple column width expansion
@@ -777,7 +782,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
                         // mark that col span expansion is needed
                         reDistributeColSpanWidths = true;
                     }
-                } else if (allocated != width) {
+                } else if (allocated > width) {
                     // size is smaller thant allocated, column might
                     // shrink
                     dirtyColumns.add(cell.col);
@@ -790,7 +795,11 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
                     allocated += spacingPixelsVertical
                             + rowHeights[cell.row + i];
                 }
-                if (allocated < height) {
+                if (cell.hasRelativeHeight() && allocated != height) {
+                    // This may happen e.g. when browser zoomout causes pixel
+                    // rounding issues, see #8619
+                    VConsole.error("A relative-height child should never cause cell height to change!");
+                } else if (allocated < height) {
                     needsLayout = true;
                     if (cell.rowspan == 1) {
                         // do simple row expansion
@@ -799,7 +808,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
                         // mark that row span expansion is needed
                         reDistributeRowSpanHeights = true;
                     }
-                } else if (allocated != height) {
+                } else if (allocated > height) {
                     // size is smaller than allocated, row might shrink
                     dirtyRows.add(cell.row);
                 }
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java
new file mode 100644 (file)
index 0000000..a192f1a
--- /dev/null
@@ -0,0 +1,61 @@
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.Window;
+
+@SuppressWarnings("serial")
+public class GridLayoutComboBoxZoomOut extends TestBase {
+
+    @Override
+    public void setup() {
+        Window mainWindow = new Window("Gridlayoutbug Application");
+        setMainWindow(mainWindow);
+
+        Label description = new Label(
+                "Open this application in Chrome, zoom out (cmd + \"-\") and "
+                        + "open the ComboBox for weird behaviour.");
+        mainWindow.addComponent(description);
+
+        Layout formLayout = new GridLayout(2, 1);
+        // formLayout.setWidth("100%");
+        formLayout.setWidth("1000px");
+
+        Select countryField = new ComboBox();
+        countryField.addItem("Finland");
+        countryField.addItem("Sweden");
+        countryField.addItem("Canada");
+        countryField.addItem("USA");
+        countryField.setCaption("Country");
+        countryField.setWidth("100%");
+        formLayout.addComponent(countryField);
+
+        Select statusField = new ComboBox();
+        statusField.addItem("Available");
+        statusField.addItem("On vacation");
+        statusField.addItem("Busy");
+        statusField.addItem("Left the building");
+        statusField.setCaption("Status");
+        statusField.setWidth("100%");
+        formLayout.addComponent(statusField);
+
+        mainWindow.addComponent(formLayout);
+    }
+
+    @Override
+    protected String getDescription() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}