From: Artur Signell Date: Fri, 24 Oct 2008 11:42:53 +0000 (+0000) Subject: Testcase and fix for #2178 - Panel size in IE6 X-Git-Tag: 6.7.0.beta1~3939 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c24d3760d53c2b27bf5fd2aad227e103d52fe275;p=vaadin-framework.git Testcase and fix for #2178 - Panel size in IE6 svn changeset:5711/svn branch:trunk --- 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 4d6707327e..edc9a0fb12 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -69,6 +69,8 @@ public class IPanel extends SimplePanel implements Container, private int captionMarginLeft = -1; + private int contentMarginLeft = -1; + public IPanel() { super(); DOM.appendChild(getElement(), captionNode); @@ -87,6 +89,7 @@ public class IPanel extends SimplePanel implements Container, DOM.sinkEvents(getElement(), Event.ONKEYDOWN); DOM.sinkEvents(contentNode, Event.ONSCROLL); contentNode.getStyle().setProperty("position", "relative"); + DOM.setStyleAttribute(getElement(), "overflow", "hidden"); } @Override @@ -258,6 +261,8 @@ public class IPanel extends SimplePanel implements Container, if (BrowserInfo.get().isIE6() && width != null && !width.equals("")) { /* * IE6 requires overflow-hidden elements to have a width specified + * so we calculate the width of the content and caption nodes when + * no width has been specified. */ /* * Fixes #1923 IPanel: Horizontal scrollbar does not appear in IE6 @@ -278,8 +283,7 @@ public class IPanel extends SimplePanel implements Container, Util.setWidthExcludingPadding(captionNode, parentWidthExcludingPadding - getCaptionMarginLeft(), 26); - int contentMarginLeft = contentNode.getAbsoluteLeft() - - getElement().getAbsoluteLeft(); + int contentMarginLeft = getContentMarginLeft(); Util.setWidthExcludingPadding(contentNode, parentWidthExcludingPadding - contentMarginLeft, 2); @@ -288,6 +292,10 @@ public class IPanel extends SimplePanel implements Container, if ((BrowserInfo.get().isIE() || BrowserInfo.get().isFF2()) && (width == null || width.equals(""))) { + /* + * IE and FF2 needs width to be specified for the root DIV so we + * calculate that from the sizes of the caption and layout + */ int captionWidth = captionText.getOffsetWidth() + getCaptionMarginLeft() + getCaptionPaddingHorizontal(); int layoutWidth = ((Widget) layout).getOffsetWidth() @@ -400,6 +408,13 @@ public class IPanel extends SimplePanel implements Container, return captionMarginLeft; } + private int getContentMarginLeft() { + if (contentMarginLeft < 0) { + detectContainerBorders(); + } + return contentMarginLeft; + } + private int getCaptionPaddingHorizontal() { if (captionPaddingHorizontal < 0) { detectContainerBorders(); @@ -441,6 +456,7 @@ public class IPanel extends SimplePanel implements Container, 26); captionMarginLeft = Util.measureMarginLeft(captionNode); + contentMarginLeft = Util.measureMarginLeft(contentNode); } diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2178.java b/src/com/itmill/toolkit/tests/tickets/Ticket2178.java new file mode 100644 index 0000000000..29bbdad04c --- /dev/null +++ b/src/com/itmill/toolkit/tests/tickets/Ticket2178.java @@ -0,0 +1,107 @@ +package com.itmill.toolkit.tests.tickets; + +import com.itmill.toolkit.Application; +import com.itmill.toolkit.ui.ComboBox; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Window; + +public class Ticket2178 extends Application { + + public void init() { + Window w = new Window(getClass().getSimpleName()); + setMainWindow(w); + // setTheme("tests-tickets"); + createUI((OrderedLayout) w.getLayout()); + } + + private void createUI(OrderedLayout layout) { + OrderedLayout ol; + Panel p; + ComboBox cb; + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox without width"); + // p.setWidth("100px"); + cb = new ComboBox(); + // cb.setCaption("A combobox"); + // cb.setWidth("100%"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox without width with caption"); + // p.setWidth("100px"); + cb = new ComboBox(); + cb.setCaption("A combobox"); + // cb.setWidth("100px"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox 100px wide"); + // p.setWidth("100px"); + cb = new ComboBox(); + // cb.setCaption("A combobox"); + cb.setWidth("100px"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox 100px wide with caption"); + // p.setWidth("100px"); + cb = new ComboBox(); + cb.setCaption("A combobox"); + cb.setWidth("100px"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox 500px wide"); + // p.setWidth("500px"); + cb = new ComboBox(); + // cb.setCaption("A combobox"); + cb.setWidth("500px"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox 500px wide with caption"); + // p.setWidth("500px"); + cb = new ComboBox(); + cb.setCaption("A combobox"); + cb.setWidth("500px"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox 100% wide inside 200px panel"); + p.setWidth("200px"); + ol.setWidth("100%"); + cb = new ComboBox(); + // cb.setCaption("A combobox"); + cb.setWidth("100%"); + // cb.setWidth("500px"); + p.addComponent(cb); + layout.addComponent(p); + + ol = new OrderedLayout(); + p = new Panel(ol); + p.setCaption("Combobox 100% wide inside 200px panel with caption"); + p.setWidth("200px"); + ol.setWidth("100%"); + cb = new ComboBox(); + cb.setCaption("A combobox"); + cb.setWidth("100%"); + p.addComponent(cb); + layout.addComponent(p); + + } +}