summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-03-12 17:10:53 +0200
committerLeif Åstrand <leif@vaadin.com>2012-03-12 17:10:53 +0200
commitcc088b3f23e2538377e01ac89a864a11c1e5faca (patch)
tree4c24af367b0077132c19c017996921182dd37bef
parentc5bf506903b1e0eb1661d9be9b0cff5e54a7b949 (diff)
downloadvaadin-framework-cc088b3f23e2538377e01ac89a864a11c1e5faca.tar.gz
vaadin-framework-cc088b3f23e2538377e01ac89a864a11c1e5faca.zip
Use absolute positioning to avoid some scrollbars (#8313)
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
index 000e743a78..5bae9cd99a 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
@@ -6,6 +6,7 @@ package com.vaadin.terminal.gwt.client.ui;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.DomEvent.Type;
import com.google.gwt.event.shared.EventHandler;
@@ -238,9 +239,10 @@ public class WindowConnector extends AbstractComponentContainerConnector
public void layout() {
LayoutManager lm = getLayoutManager();
VWindow window = getWidget();
+ ComponentConnector layout = window.layout;
Element contentElement = window.contentPanel.getElement();
- boolean needsMinWidth = !isUndefinedWidth()
- || window.layout.isRelativeWidth();
+
+ boolean needsMinWidth = !isUndefinedWidth() || layout.isRelativeWidth();
int minWidth = window.getMinWidth();
if (needsMinWidth && lm.getInnerWidth(contentElement) < minWidth) {
// Use minimum width if less than a certain size
@@ -248,7 +250,7 @@ public class WindowConnector extends AbstractComponentContainerConnector
}
boolean needsMinHeight = !isUndefinedHeight()
- || window.layout.isRelativeHeight();
+ || layout.isRelativeHeight();
int minHeight = window.getMinHeight();
if (needsMinHeight && lm.getInnerHeight(contentElement) < minHeight) {
// Use minimum height if less than a certain size
@@ -265,6 +267,33 @@ public class WindowConnector extends AbstractComponentContainerConnector
contentStyle.setPaddingBottom(footerHeight, Unit.PX);
contentStyle.setMarginBottom(-footerHeight, Unit.PX);
+ /*
+ * Must set absolute position if the child has relative height and
+ * there's a chance of horizontal scrolling as some browsers will
+ * otherwise not take the scrollbar into account when calculating the
+ * height.
+ */
+ Element layoutElement = layout.getWidget().getElement();
+ Style childStyle = layoutElement.getStyle();
+ if (layout.isRelativeHeight()) {
+ childStyle.setPosition(Position.ABSOLUTE);
+
+ Style wrapperStyle = contentElement.getStyle();
+ if (window.getElement().getStyle().getWidth().length() == 0
+ && !layout.isRelativeWidth()) {
+ /*
+ * Need to lock width to make undefined width work even with
+ * absolute positioning
+ */
+ int contentWidth = lm.getOuterWidth(layoutElement);
+ wrapperStyle.setWidth(contentWidth, Unit.PX);
+ } else {
+ wrapperStyle.clearWidth();
+ }
+ } else {
+ childStyle.clearPosition();
+ }
+
Util.runWebkitOverflowAutoFix(window.contentPanel.getElement());
}