]> source.dussan.org Git - vaadin-framework.git/commitdiff
Better fix for #1923 - Panel issues in IE6
authorArtur Signell <artur.signell@itmill.com>
Fri, 19 Sep 2008 14:14:21 +0000 (14:14 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 19 Sep 2008 14:14:21 +0000 (14:14 +0000)
svn changeset:5468/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/Util.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java

index 24ceb5d21bca917a6dd3f82583f34a52da133537..164d3e0d32152ec92233ec888efc9878f807e733 100644 (file)
@@ -53,10 +53,6 @@ public class Util {
         Set<Container> parents = new HashSet<Container>();
 
         for (Widget widget : widgets) {
-/*            ApplicationConnection.getConsole().log(
-                    "Size changed for widget: "
-                            + widget.toString().split(">")[0]);
-*/
             Widget parent = widget.getParent();
             while (parent != null && !(parent instanceof Container)) {
                 parent = parent.getParent();
@@ -215,4 +211,38 @@ public class Util {
     /*-{
         return element.cloneNode(deep);
     }-*/;
+
+    public static int measureHorizontalPadding(Element element, int paddingGuess) {
+        String originalWidth = DOM.getStyleAttribute(element, "width");
+        int originalOffsetWidth = element.getOffsetWidth();
+        int widthGuess = (originalOffsetWidth + paddingGuess);
+        DOM.setStyleAttribute(element, "width", widthGuess + "px");
+        int padding = widthGuess - element.getOffsetWidth();
+
+        DOM.setStyleAttribute(element, "width", originalWidth);
+        return padding;
+    }
+
+    public static void setWidthExcludingPadding(Element element,
+            int requestedWidth, int paddingGuess) {
+
+        int widthGuess = requestedWidth - paddingGuess;
+        if (widthGuess < 0) {
+            widthGuess = 0;
+        }
+
+        DOM.setStyleAttribute(element, "width", widthGuess + "px");
+        int captionOffsetWidth = DOM.getElementPropertyInt(element,
+                "offsetWidth");
+
+        int actualPadding = captionOffsetWidth - widthGuess;
+
+        if (actualPadding != paddingGuess) {
+            DOM.setStyleAttribute(element, "width", requestedWidth
+                    - actualPadding + "px");
+
+        }
+
+    }
+
 }
index 315d2d0d1a101184cfc0bd428d12c560e27c9c9a..bc29be96fbfb1ccbcde5538e5e359f8045f28225 100644 (file)
@@ -240,29 +240,37 @@ public class IPanel extends SimplePanel implements Paintable,
 
     public void iLayout(boolean runGeckoFix) {
 
-        // IE6 width fix
-        if (BrowserInfo.get().isIE6()) {
-            int captionOffsetWidth = DOM.getElementPropertyInt(captionNode,
-                    "offsetWidth");
-            int borderWidthGuess = 200;
-            int widthGuess = captionOffsetWidth - borderWidthGuess;
-            if (widthGuess < 0) {
-                widthGuess = 0;
-            }
-            DOM.setStyleAttribute(contentNode, "width", widthGuess + "px");
-
-            int actualBorder = DOM.getElementPropertyInt(contentNode,
-                    "offsetWidth")
-                    - widthGuess;
-            if (actualBorder != borderWidthGuess) {
-                int realWidthIncludingBorder = captionOffsetWidth
-                        - actualBorder;
-                if (realWidthIncludingBorder < 0) {
-                    realWidthIncludingBorder = 0;
-                }
-                DOM.setStyleAttribute(contentNode, "width",
-                        realWidthIncludingBorder + "px");
-            }
+        if (BrowserInfo.get().isIE6() && width != null && !width.equals("")) {
+            /*
+             * IE6 requires overflow-hidden elements to have a width specified
+             */
+            /*
+             * Fixes #1923 IPanel: Horizontal scrollbar does not appear in IE6
+             * with wide content
+             */
+
+            /*
+             * Caption must be shrunk for parent measurements to return correct
+             * result in IE6
+             */
+            DOM.setStyleAttribute(captionNode, "width", "1px");
+
+            int parentPadding = Util.measureHorizontalPadding(getElement(), 0);
+
+            int parentWidthExcludingPadding = getElement().getOffsetWidth()
+                    - parentPadding;
+
+            int captionMarginLeft = captionNode.getAbsoluteLeft()
+                    - getElement().getAbsoluteLeft();
+            Util.setWidthExcludingPadding(captionNode,
+                    parentWidthExcludingPadding - captionMarginLeft, 26);
+
+            int contentMarginLeft = contentNode.getAbsoluteLeft()
+                    - getElement().getAbsoluteLeft();
+
+            Util.setWidthExcludingPadding(contentNode,
+                    parentWidthExcludingPadding - contentMarginLeft, 2);
+
         }
 
         if (height != null && height != "") {