Fixes issue #1200; instead of using about:blank as an error proxy for clear.cache.gif in ClippedImageImplIE6.java, uses "http://" or "https://" (depending on the host page base URL).
Found by: rustyshelf
Patch by: rdayal, scottb
Review by: scottb
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1188 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/impl/ClippedImageImplIE6.java b/user/src/com/google/gwt/user/client/ui/impl/ClippedImageImplIE6.java
index 77089c0..b50dc38 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/ClippedImageImplIE6.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/ClippedImageImplIE6.java
@@ -17,6 +17,7 @@
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
+import com.google.gwt.core.client.GWT;
/**
* Implements the clipped image as a IMG inside a custom tag because we can't
@@ -26,7 +27,10 @@
* may change in the future.
*/
public class ClippedImageImplIE6 extends ClippedImageImpl {
-
+
+ private static String moduleBaseUrlProtocol =
+ GWT.getHostPageBaseURL().startsWith("https") ? "https://" : "http://";
+
private static native void injectGlobalHandler() /*-{
$wnd.__gwt_transparentImgHandler = function (elem) {
elem.onerror = null;
@@ -64,14 +68,26 @@
String clipperStyle = "overflow: hidden; width: " + width + "px; height: "
+ height + "px; padding: 0px";
- String imgStyle =
- "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
- + url + "',sizingMethod='crop'); margin-left: "
- + -left + "px; margin-top: " + -top + "px; border: none";
+ String imgStyle = "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
+ + url
+ + "',sizingMethod='crop'); margin-left: "
+ + -left
+ + "px; margin-top: " + -top + "px; border: none";
+ /*
+ * We initially set the image URL to an invalid value to force onerror to be
+ * fired when this string is turned into a DOM structure. At this point, we
+ * can set the image src using DOM.setImgSrc, which is used to get around
+ * issue #282. The invalid image URL is either http:// or https://,
+ * depending on the module's base URL. We have to match the invalid image
+ * URL's protocol with that of the module's base URL's protocol due to issue
+ * #1200.
+ */
String clippedImgHtml = "<gwt:clipper style=\""
+ clipperStyle
- + "\"><img src='about:blank' onerror='if(window.__gwt_transparentImgHandler)window.__gwt_transparentImgHandler(this);else this.src=\"clear.cache.gif\"' style=\""
+ + "\"><img src='"
+ + moduleBaseUrlProtocol
+ + "' onerror='if(window.__gwt_transparentImgHandler)window.__gwt_transparentImgHandler(this);else this.src=\"clear.cache.gif\"' style=\""
+ imgStyle + "\" width=" + (left + width) + " height=" + (top + height)
+ " border='0'></gwt:clipper>";