From: Leif Åstrand Date: Mon, 12 Mar 2012 15:10:53 +0000 (+0200) Subject: Use absolute positioning to avoid some scrollbars (#8313) X-Git-Tag: 7.0.0.alpha2~365 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cc088b3f23e2538377e01ac89a864a11c1e5faca;p=vaadin-framework.git Use absolute positioning to avoid some scrollbars (#8313) --- 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()); }