From 704e9489069bc4fc20de0bd7c00e34dcfe75f360 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 27 Dec 2010 14:01:33 +0000 Subject: [PATCH] #6035 - Icons are no longer transparent in MenuBar in IE6 svn changeset:16655/svn branch:6.5 --- .../terminal/gwt/client/ui/VMenuBar.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 73510fbe02..6a71c02296 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -10,6 +10,7 @@ import java.util.Stack; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.KeyCodes; @@ -136,7 +137,24 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, } this.width = width; - Util.setWidthExcludingPaddingAndBorder(this, width, 0); + if (BrowserInfo.get().isIE6() && width.endsWith("px")) { + // IE6 sometimes measures wrong using + // Util.setWidthExcludingPaddingAndBorder so this is extracted to a + // special case that uses another method. Really should fix the + // Util.setWidthExcludingPaddingAndBorder method but that will + // probably break additional cases + int requestedPixelWidth = Integer.parseInt(width.substring(0, + width.length() - 2)); + int paddingBorder = Util.measureHorizontalPaddingAndBorder( + getElement(), 0); + int w = requestedPixelWidth - paddingBorder; + if (w < 0) { + w = 0; + } + getElement().getStyle().setWidth(w, Unit.PX); + } else { + Util.setWidthExcludingPaddingAndBorder(this, width, 0); + } if (!subMenu) { // Only needed for root level menu hideChildren(); @@ -988,7 +1006,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, * onAttach is never called for CustomMenuItem due to an * invalid component hierarchy (#6203)... */ - reloadImages(); + reloadImages(expand.getElement()); } } } @@ -1389,7 +1407,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, protected void onLoad() { super.onLoad(); if (BrowserInfo.get().isIE6()) { - reloadImages(); + reloadImages(getElement()); } } @@ -1397,9 +1415,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, * Force a new onload event for all images. Used only for IE6 to deal with * PNG transparency. */ - private void reloadImages() { + private void reloadImages(Element root) { - NodeList imgElements = getElement() + NodeList imgElements = root .getElementsByTagName("img"); for (int i = 0; i < imgElements.getLength(); i++) { Element e = (Element) imgElements.getItem(i); @@ -1407,7 +1425,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, // IE6 fires onload events for the icons before the listener // is attached (or never). Updating the src force another // onload event - e.setAttribute("src", e.getAttribute("src")); + String src = e.getAttribute("src"); + e.setAttribute("src", src); } } -- 2.39.5