From 4d3cdd25dc56304bab160786166dd37f5f8103de Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 19 Sep 2008 14:14:21 +0000 Subject: [PATCH] Better fix for #1923 - Panel issues in IE6 svn changeset:5468/svn branch:trunk --- .../toolkit/terminal/gwt/client/Util.java | 38 +++++++++++-- .../terminal/gwt/client/ui/IPanel.java | 54 +++++++++++-------- 2 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Util.java b/src/com/itmill/toolkit/terminal/gwt/client/Util.java index 24ceb5d21b..164d3e0d32 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Util.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Util.java @@ -53,10 +53,6 @@ public class Util { Set parents = new HashSet(); 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"); + + } + + } + } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java index 315d2d0d1a..bc29be96fb 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -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 != "") { -- 2.39.5