Fixes Issue 1942
FF3 Beta 1 throws WRONG_DOCUMENT_ERROR in getBoxObjectFor if the
element is not attached to the DOM. This affects our implementation
of Tree when an element is selected programmatically on a tree that
is unattached. This change wraps the call to getBoxObjectFor in a
try/catch and returns 0 if a WRONG_DOCUMENT_ERROR occurs, which
emulates what getBoxObjectFor is supposed to do. This bug is set
to P1 in bugzilla, https://bugzilla.mozilla.org/show_bug.cgi?id=409111,
so this change can be saftely removed in the future.

Found by: mmastrac
Review by: jgw



git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1871 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
index 72b18c6..1c2b824 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
@@ -48,8 +48,20 @@
     // here due to a change in getBoxObjectFor which causes inconsistencies
     // on whether the calculations are inside or outside of the element's
     // border.
-    return $doc.getBoxObjectFor(elem).screenX
-        - $doc.getBoxObjectFor($doc.documentElement).screenX;
+    try {
+      return $doc.getBoxObjectFor(elem).screenX
+          - $doc.getBoxObjectFor($doc.documentElement).screenX;
+    } catch (e) {
+      // This works around a bug in the FF3 betas. The bug
+      // should be fixed before they release, so this can
+      // be removed at a later date.
+      // https://bugzilla.mozilla.org/show_bug.cgi?id=409111
+      // DOMException.WRONG_DOCUMENT_ERR == 4
+      if (e.code == 4) {
+        return 0;
+      }
+      throw e;
+    }
   }-*/;
 
   @Override
@@ -59,8 +71,20 @@
     // here due to a change in getBoxObjectFor which causes inconsistencies
     // on whether the calculations are inside or outside of the element's
     // border.
-    return $doc.getBoxObjectFor(elem).screenY
-        - $doc.getBoxObjectFor($doc.documentElement).screenY;
+    try {
+      return $doc.getBoxObjectFor(elem).screenY
+          - $doc.getBoxObjectFor($doc.documentElement).screenY;
+    } catch (e) {
+      // This works around a bug in the FF3 betas. The bug
+      // should be fixed before they release, so this can
+      // be removed at a later date.
+      // https://bugzilla.mozilla.org/show_bug.cgi?id=409111
+      // DOMException.WRONG_DOCUMENT_ERR == 4
+      if (e.code == 4) {
+        return 0;
+      }
+      throw e;
+    }
   }-*/;
 
   @Override