Author: e...@google.com
Date: Fri Feb  6 11:20:51 2009
New Revision: 4656

Modified:
    releases/1.6/user/src/com/google/gwt/user/client/ui/Image.java

Log:
Fixes issue 3340 by preventing IE race condition from occurring when the on  
load handler is set.
Review by:jlabanca

Modified: releases/1.6/user/src/com/google/gwt/user/client/ui/Image.java
==============================================================================
--- releases/1.6/user/src/com/google/gwt/user/client/ui/Image.java       
(original)
+++ releases/1.6/user/src/com/google/gwt/user/client/ui/Image.java      Fri Feb 
  
6 11:20:51 2009
@@ -64,10 +64,7 @@
   * will be lost.
   * </p>
   *
- * <h3>CSS Style Rules</h3>
- * <ul class="css">
- * <li>.gwt-Image { }</li>
- * </ul>
+ * <h3>CSS Style Rules</h3> <ul class="css"> <li>.gwt-Image { }</li> </ul>
   *
   * Tranformations between clipped and unclipped state will result in a  
loss of
   * any style names that were set/added; the only style names that are  
preserved
@@ -225,16 +222,20 @@
    private static class UnclippedState extends State {

      UnclippedState(Element element) {
-      // Todo(ecc) This is wrong, we should not be sinking these here on  
such a
-      // common widget.After the branch is stable, this should be fixed.
+      // This case is relatively unusual, in that we swapped a clipped  
image
+      // out, so does not need to be efficient.
        Event.sinkEvents(element, Event.ONCLICK | Event.MOUSEEVENTS
            | Event.ONLOAD | Event.ONERROR | Event.ONMOUSEWHEEL);
      }

      UnclippedState(Image image) {
        image.replaceElement(Document.get().createImageElement());
-      // Todo(ecc) This is wrong, we should not be sinking these here on  
such a
-      // common widget.After the branch is stable, this should be fixed.
+      // We are working around an IE race condition that can make the image
+      // incorrectly cache itself if the load event is assigned at the  
same time
+      // as the image is added to the dom.
+      Event.sinkEvents(image.getElement(), Event.ONLOAD);
+
+      // Todo(ecc) this could be more efficient overall.
        image.sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.ONLOAD
            | Event.ONERROR | Event.ONMOUSEWHEEL);
      }

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to