]> source.dussan.org Git - vaadin-framework.git/commitdiff
#3125 Portlet size is not updated when window is resized
authorLeif Åstrand <leif@vaadin.com>
Tue, 20 Sep 2011 10:26:46 +0000 (10:26 +0000)
committerLeif Åstrand <leif@vaadin.com>
Tue, 20 Sep 2011 10:26:46 +0000 (10:26 +0000)
svn changeset:21180/svn branch:6.6

src/com/vaadin/terminal/gwt/client/ui/VView.java

index 9f1acb52fe564befa63d33888ce0ffa31a680500..a4e8b5ca30814d428306a98d305cd7795592dd31 100644 (file)
@@ -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;
         }