summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java48
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.html52
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java1
3 files changed, 82 insertions, 19 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index 8ffb0246a3..5ffe0c640f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -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
index 0000000000..2c3f651e41
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.html
@@ -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>
diff --git a/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java b/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
index aa1165abdd..dbe5eda9af 100644
--- a/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
+++ b/tests/testbench/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
@@ -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 {