]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix Grid columns being too narrow on IE9 (#15475)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 29 Dec 2014 11:17:57 +0000 (13:17 +0200)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 29 Dec 2014 11:17:57 +0000 (13:17 +0200)
Change-Id: Ifb46093ffb43a4fa03b051719f3480ef469b460e

client/src/com/vaadin/client/widgets/Escalator.java
uitest/src/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java

index 74fb28bbd278754658469668f40a29e01ae6bdde..57c55d457d31a27867501e2e28645778e2804772 100644 (file)
@@ -50,6 +50,7 @@ import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.RequiresResize;
 import com.google.gwt.user.client.ui.UIObject;
 import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.BrowserInfo;
 import com.vaadin.client.DeferredWorker;
 import com.vaadin.client.Profiler;
 import com.vaadin.client.Util;
@@ -63,6 +64,7 @@ import com.vaadin.client.widget.escalator.PositionFunction.AbsolutePosition;
 import com.vaadin.client.widget.escalator.PositionFunction.Translate3DPosition;
 import com.vaadin.client.widget.escalator.PositionFunction.TranslatePosition;
 import com.vaadin.client.widget.escalator.PositionFunction.WebkitTranslate3DPosition;
+import com.vaadin.client.widget.escalator.Row;
 import com.vaadin.client.widget.escalator.RowContainer;
 import com.vaadin.client.widget.escalator.RowVisibilityChangeEvent;
 import com.vaadin.client.widget.escalator.RowVisibilityChangeHandler;
@@ -2009,9 +2011,19 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
                 cellClone.getStyle().clearWidth();
 
                 rowElement.insertBefore(cellClone, cellOriginal);
-                maxCellWidth = Math.max(Util
-                        .getRequiredWidthBoundingClientRectDouble(cellClone),
-                        maxCellWidth);
+                double requiredWidth = Util
+                        .getRequiredWidthBoundingClientRectDouble(cellClone);
+
+                if (BrowserInfo.get().isIE9()) {
+                    /*
+                     * IE9 does not support subpixels. Usually it is rounded
+                     * down which leads to content not shown. Increase the
+                     * counted required size by one just to be on the safe side.
+                     */
+                    requiredWidth += 1;
+                }
+
+                maxCellWidth = Math.max(requiredWidth, maxCellWidth);
                 cellClone.removeFromParent();
             }
 
index d66a95a13c14678b38752207d0ec8db7fc2592ff..cc5be455cddedf3381b0a87c3079333556d05567 100644 (file)
@@ -17,6 +17,8 @@ package com.vaadin.tests.components.grid;
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.IOException;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.openqa.selenium.By;
@@ -60,10 +62,16 @@ public abstract class AbstractGridColumnAutoWidthTest extends MultiBrowserTest {
                 bodyWidth);
         assertEquals("column should've been roughly as wide as the header",
                 headerWidth, colWidth, 5);
+
     }
 
     @Test
     public void testTooNarrowColumn() {
+        if (BrowserUtil.isIE(getDesiredCapabilities())) {
+            // IE can't deal with overflow nicely.
+            return;
+        }
+
         WebElement[] col = getColumn(3);
         int headerWidth = col[0].getSize().getWidth();
         int colWidth = col[2].getSize().getWidth() - TOTAL_MARGIN_PX;
@@ -82,6 +90,11 @@ public abstract class AbstractGridColumnAutoWidthTest extends MultiBrowserTest {
                 headerWidth);
     }
 
+    @Test
+    public void testColumnsRenderCorrectly() throws IOException {
+        compareScreen("initialRender");
+    }
+
     private WebElement[] getColumn(int i) {
         WebElement[] col = new WebElement[3];
         col[0] = getDriver().findElement(