Fixes web mode ordering issue with type checks. Foreign event handlers were tripping an exception by type-checking EventHandler first; the foriegn object would be seen to have a typeId, and that typeId would be outside the legal range for the current module. This would trip an exception.
Review by: rjrjr
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@3933 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImpl.java b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
index b9d1a5b..30da21c 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImpl.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
@@ -33,16 +33,16 @@
*/
protected static boolean isMyListener(Object object) {
/*
- * The first test ensures the Object belongs to this module in hosted mode,
- * because this hosted mode class loader will have a different copy of the
- * EventListener class than some other module would have.
+ * The first test ensures the Object belongs to this module in web mode by
+ * ensuring this is not a JavaScriptObject. In web mode, foreign Java
+ * objects appear to be JavaScriptObject. See Cast.isJavaScriptObject().
*
- * However, in web mode we could still get a collision where another module
- * happens to use the same typeId. The second test ensures the Object is not
- * "foreign". See Cast.isJavaScriptObject().
+ * The second test then checks the exact type.
+ *
+ * TODO: make the generated code smaller!
*/
- return object instanceof com.google.gwt.user.client.EventListener
- && !(object instanceof JavaScriptObject);
+ return !(object instanceof JavaScriptObject)
+ && (object instanceof com.google.gwt.user.client.EventListener);
}
public native void eventCancelBubble(Event evt, boolean cancel) /*-{