}
@Override
- /*
+ /**
* Width is set to the out-most element (v-window).
*
* This function should never be called with percentage values (it will
}
@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;
--- /dev/null
+<?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>