]> source.dussan.org Git - vaadin-framework.git/commitdiff
Patch and TestBench script for issue #7916 - setting VWindow height to undefined...
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Fri, 18 Nov 2011 12:32:36 +0000 (12:32 +0000)
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Fri, 18 Nov 2011 12:32:36 +0000 (12:32 +0000)
svn changeset:22063/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ui/VWindow.java
tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.html [new file with mode: 0644]
tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java

index 8ffb0246a39ee2c041a097710c3dfe46c76df3a4..5ffe0c640f09005e31807f59795edd5841d638be 100644 (file)
@@ -1027,7 +1027,7 @@ public class VWindow extends VOverlay implements Container,
     }
 
     @Override
-    /*
+    /**
      * Width is set to the out-most element (v-window).
      * 
      * This function should never be called with percentage values (it will
@@ -1088,33 +1088,45 @@ public class VWindow extends VOverlay implements Container,
     }
 
     @Override
-    /*
+    /**
      * Height is set to the out-most element (v-window).
      * 
      * This function should never be called with percentage values (it will
      * throw an exception)
+     * 
+     * @param height A CSS string specifying the new height of the window.
+     *               An empty string or null clears the height and lets
+     *               the browser to compute it based on the window contents. 
      */
     public void setHeight(String height) {
-        this.height = height;
-        if (!isAttached()) {
+        if (!isAttached() || 
+                (height == null && this.height == null) ||
+                height.equals(this.height)) {
             return;
         }
-        if (height != null && !"".equals(height)) {
-            DOM.setStyleAttribute(getElement(), "height", height);
-            int pixels = getElement().getOffsetHeight() - getExtraHeight();
-            if (pixels < MIN_CONTENT_AREA_HEIGHT) {
-                pixels = MIN_CONTENT_AREA_HEIGHT;
-                int rootHeight = pixels + getExtraHeight();
-                DOM.setStyleAttribute(getElement(), "height", (rootHeight)
-                        + "px");
-
+        if (height == null || "".equals(height)) {
+            getElement().getStyle().clearHeight();
+            contentPanel.getElement().getStyle().clearHeight();
+            // Reset to default, the exact value does not actually
+            // matter as an undefined-height parent should not have
+            // a relative-height child anyway.
+            renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+        } else {
+            getElement().getStyle().setProperty("height", height);
+            int contentHeight =
+                    getElement().getOffsetHeight() - getExtraHeight();
+            if (contentHeight < MIN_CONTENT_AREA_HEIGHT) {
+                contentHeight = MIN_CONTENT_AREA_HEIGHT;
+                int rootHeight = contentHeight + getExtraHeight();
+                getElement().getStyle().setProperty(
+                        "height", rootHeight + "px");
             }
-            renderSpace.setHeight(pixels);
-            height = pixels + "px";
-            contentPanel.getElement().getStyle().setProperty("height", height);
-            updateShadowSizeAndPosition();
-
+            renderSpace.setHeight(contentHeight);
+            contentPanel.getElement().getStyle().setProperty(
+                    "height", contentHeight + "px");
         }
+        this.height = height;
+        updateShadowSizeAndPosition();
     }
 
     private int extraH = 0;
diff --git a/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.html b/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.html
new file mode 100644 (file)
index 0000000..2c3f651
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>SubWindowWithUndefinedHeight</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">SubWindowWithUndefinedHeight</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.window.SubWindowWithUndefinedHeight?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentswindowSubWindowWithUndefinedHeight::/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>initial-tab1</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentswindowSubWindowWithUndefinedHeight::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+       <td>17,13</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>select-tab2</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentswindowSubWindowWithUndefinedHeight::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+       <td>8,9</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>select-tab1</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
index aa1165abdd2828e514dad5627e8fffebe149499f..dbe5eda9af50ddd9b02472f513a85c90de161b90 100644 (file)
@@ -5,7 +5,6 @@ import com.vaadin.ui.Window;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Label;
 
 public class SubWindowWithUndefinedHeight extends TestBase {