]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #2789, fixed IE width detection failure with some layout configurations
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 3 Apr 2009 09:13:00 +0000 (09:13 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 3 Apr 2009 09:13:00 +0000 (09:13 +0000)
svn changeset:7297/svn branch:6.0

src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java

index 1e4badc439f7b7b37418085c803d515aad20a305..0c22da4a1ef231ad9cea6fc9d7d2a1903ab3bd05 100644 (file)
@@ -8,6 +8,8 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.DeferredCommand;
@@ -474,13 +476,31 @@ public class IView extends SimplePanel implements Container,
         }
 
         private void detectExcessSize() {
+            // TODO define that iview cannot be themed and decorations should
+            // get to parent element, then get rid of this expensive and error
+            // prone function
             final String overflow = getElement().getStyle().getProperty(
                     "overflow");
             getElement().getStyle().setProperty("overflow", "hidden");
+            if (BrowserInfo.get().isIE()
+                    && getElement().getPropertyInt("clientWidth") == 0) {
+                // can't detect possibly themed border/padding width in some
+                // situations (with some layout configurations), use empty div
+                // to measure width properly
+                DivElement div = Document.get().createDivElement();
+                div.setInnerHTML("&nbsp;");
+                div.getStyle().setProperty("overflow", "hidden");
+                div.getStyle().setProperty("height", "1px");
+                getElement().appendChild(div);
+                excessWidth = getElement().getOffsetWidth()
+                        - div.getOffsetWidth();
+                getElement().removeChild(div);
+            } else {
+                excessWidth = getElement().getOffsetWidth()
+                        - getElement().getPropertyInt("clientWidth");
+            }
             excessHeight = getElement().getOffsetHeight()
                     - getElement().getPropertyInt("clientHeight");
-            excessWidth = getElement().getOffsetWidth()
-                    - getElement().getPropertyInt("clientWidth");
 
             getElement().getStyle().setProperty("overflow", overflow);
         }