A recent change to DOM.isOrHasChild(parent,child) results in a NS_ERROR_INVALID_POINTER exception if the child is null.  MouseListenerCollection.fireMouseEvent can pass null as the child on an onMouseOut event if the cursor moves from the widget to the browser window (outside the client body but inside the web browser).  The same applied to CustomButtom.  While the previous implementation of isOrHasChild allowed child to be null, we consider it an invalid value.

Issue: 2078
Patch by: jlabanca
Review by: jlabanca



git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1874 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/CustomButton.java b/user/src/com/google/gwt/user/client/ui/CustomButton.java
index 44d699d..6810922 100644
--- a/user/src/com/google/gwt/user/client/ui/CustomButton.java
+++ b/user/src/com/google/gwt/user/client/ui/CustomButton.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 Google Inc.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
@@ -543,8 +543,9 @@
         }
         break;
       case Event.ONMOUSEOUT:
+        Element to = DOM.eventGetToElement(event);
         if (DOM.isOrHasChild(getElement(), DOM.eventGetTarget(event)) &&
-            !DOM.isOrHasChild(getElement(), DOM.eventGetToElement(event))) {
+            (to == null || !DOM.isOrHasChild(getElement(), to))) {
           if (isCapturing) {
             onClickCancel();
           }
diff --git a/user/src/com/google/gwt/user/client/ui/MouseListenerCollection.java b/user/src/com/google/gwt/user/client/ui/MouseListenerCollection.java
index b2e2107..e979546 100644
--- a/user/src/com/google/gwt/user/client/ui/MouseListenerCollection.java
+++ b/user/src/com/google/gwt/user/client/ui/MouseListenerCollection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 Google Inc.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
@@ -84,7 +84,7 @@
         // Only fire the mouseEnter event if it's coming from outside this
         // widget.
         Element from = DOM.eventGetFromElement(event);
-        if (!DOM.isOrHasChild(senderElem, from)) {
+        if (from == null || !DOM.isOrHasChild(senderElem, from)) {
           fireMouseEnter(sender);
         }
         break;
@@ -92,7 +92,7 @@
         // Only fire the mouseLeave event if it's actually leaving this
         // widget.
         Element to = DOM.eventGetToElement(event);
-        if (!DOM.isOrHasChild(senderElem, to)) {
+        if (to == null || !DOM.isOrHasChild(senderElem, to)) {
           fireMouseLeave(sender);
         }
         break;