From a98cc714e557d9925388817cc127f5d4567a9739 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Tue, 20 Sep 2011 10:26:46 +0000 Subject: [PATCH] #3125 Portlet size is not updated when window is resized svn changeset:21180/svn branch:6.6 --- .../vaadin/terminal/gwt/client/ui/VView.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 9f1acb52fe..a4e8b5ca30 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -14,6 +14,8 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Display; import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; @@ -581,11 +583,38 @@ public class VView extends SimplePanel implements Container, ResizeHandler, @Override public int getWidth() { - int w = getElement().getOffsetWidth() - getExcessWidth(); + int w = getRealWidth(); if (w < 10 && BrowserInfo.get().isIE7()) { // Overcome an IE7 bug #3295 Util.shakeBodyElement(); - w = getElement().getOffsetWidth() - getExcessWidth(); + w = getRealWidth(); + } + return w; + } + + private int getRealWidth() { + if (connection.getConfiguration().isStandalone()) { + return getElement().getOffsetWidth() - getExcessWidth(); + } + + // If not running standalone, we might be inside elements that does + // not shrink with the browser window with the our own components + // having calculated widths (#3125) + Element layoutElement = ((Widget) layout).getElement(); + Style layoutStyle = layoutElement.getStyle(); + + // Set display:none to the entire application to get a width not + // influenced by the contents + String originalDisplay = layoutStyle.getDisplay(); + layoutStyle.setDisplay(Display.NONE); + + int w = getElement().getOffsetWidth() - getExcessWidth(); + + // Then restore the old display style before returning + if (originalDisplay.length() == 0) { + layoutStyle.clearDisplay(); + } else { + layoutStyle.setDisplay(Display.valueOf(originalDisplay)); } return w; } -- 2.39.5