Fixing a null reference exception in Mozilla when calling getBodyOffsetLeft/Top.

The problem occurs when running getBodyOffsetLeft/Top in an iframe that is not currently visible, such as via display:none. In this case, $wnd.getComputedStyle returns null. Fix this by null-checking the return value from getComputedStyle, and returning 0 for the body offset in this case. This should be safe to do since returning 0 is the default behavior defined in DOMImpl, and so is presumably used in other browsers.

This is related to issue 4056 and implements a fix posted by a commenter. Other issues reported in the bug likely still remain, however.

Change-Id: I074f66ba12128b83ee2a98f3af84bafdc46746e2
Review-Link: https://gwt-review.googlesource.com/#/c/1510/

Review by: skybrian@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11432 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
index 6b306fc..5dd8343 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
@@ -141,14 +141,22 @@
 
   @Override
   public native int getBodyOffsetLeft(Document doc) /*-{
-    var style = $wnd.getComputedStyle(doc.documentElement, '');
-    return parseInt(style.marginLeft) + parseInt(style.borderLeftWidth);
+    var style = $wnd.getComputedStyle(doc.documentElement, null);
+    if (style == null) {
+      // Works around https://bugzilla.mozilla.org/show_bug.cgi?id=548397
+      return 0;
+    }
+    return parseInt(style.marginLeft, 10) + parseInt(style.borderLeftWidth, 10);
   }-*/;
 
   @Override
   public native int getBodyOffsetTop(Document doc) /*-{
-    var style = $wnd.getComputedStyle(doc.documentElement, '');
-    return parseInt(style.marginTop) + parseInt(style.borderTopWidth);
+    var style = $wnd.getComputedStyle(doc.documentElement, null);
+    if (style == null) {
+      // Works around https://bugzilla.mozilla.org/show_bug.cgi?id=548397
+      return 0;
+    }
+    return parseInt(style.marginTop, 10) + parseInt(style.borderTopWidth, 10);
   }-*/;
 
   @Override