Backport of fixes to issues 1702 and 1942 (Firefox 3 support), originally commited to trunk in r1533 and r1871. Original log messages: r1533: Fixes issue #1702. insertListItem current created an option element with the wrong owner document. This causes errors in FF3 preview builds. Review by: ecc r1871: 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/releases/1.4@1887 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 ab5dc71..07a4235 100644 --- a/user/src/com/google/gwt/user/client/impl/DOMImpl.java +++ b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
@@ -274,7 +274,7 @@ */ public native void insertListItem(Element select, String item, String value, int index)/*-{ - var option = new Option(item, value); + var option = new $wnd.Option(item, value); if (index == -1 || index > select.options.length - 1) { select.add(option, null); } else {
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 d3d7419..122471f 100644 --- a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java +++ b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
@@ -57,8 +57,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; + } }-*/; public native int getAbsoluteTop(Element elem) /*-{ @@ -67,8 +79,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; + } }-*/; public native int getChildIndex(Element parent, Element toFind) /*-{