summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-09-20 10:26:46 +0000
committerLeif Åstrand <leif@vaadin.com>2011-09-20 10:26:46 +0000
commita98cc714e557d9925388817cc127f5d4567a9739 (patch)
treee87c04a6a10399a217970a3b988c5dc8151596cf
parent4a72c68e12fdeb54101a5f6816ec987e7020747a (diff)
downloadvaadin-framework-a98cc714e557d9925388817cc127f5d4567a9739.tar.gz
vaadin-framework-a98cc714e557d9925388817cc127f5d4567a9739.zip
#3125 Portlet size is not updated when window is resized
svn changeset:21180/svn branch:6.6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VView.java33
1 files 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;
}