Revision: 6401 Author: rj...@google.com Date: Fri Oct 16 14:48:33 2009 Log: Update user code to use $entry.
Patch by: bobv Review by: jgw http://gwt-code-reviews.appspot.com/77813 http://code.google.com/p/google-web-toolkit/source/detail?r=6401 Modified: /trunk/user/src/com/google/gwt/http/client/Request.java /trunk/user/src/com/google/gwt/jsonp/client/JsonpRequest.java /trunk/user/src/com/google/gwt/layout/client/LayoutImplIE6.java /trunk/user/src/com/google/gwt/user/client/AsyncProxy.java /trunk/user/src/com/google/gwt/user/client/DOM.java /trunk/user/src/com/google/gwt/user/client/HTTPRequest.java /trunk/user/src/com/google/gwt/user/client/Timer.java /trunk/user/src/com/google/gwt/user/client/Window.java /trunk/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java /trunk/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java /trunk/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java /trunk/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java /trunk/user/src/com/google/gwt/user/client/impl/HistoryImpl.java /trunk/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java /trunk/user/src/com/google/gwt/user/client/impl/HistoryImplTimer.java /trunk/user/src/com/google/gwt/user/client/impl/WindowImpl.java /trunk/user/src/com/google/gwt/user/client/impl/WindowImplIE.java /trunk/user/src/com/google/gwt/user/client/ui/FormPanel.java /trunk/user/src/com/google/gwt/user/client/ui/HorizontalSplitPanel.java /trunk/user/src/com/google/gwt/user/client/ui/VerticalSplitPanel.java /trunk/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java /trunk/user/src/com/google/gwt/user/client/ui/impl/FormPanelImplIE6.java /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java /trunk/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java ======================================= --- /trunk/user/src/com/google/gwt/http/client/Request.java Mon Mar 16 16:27:28 2009 +++ /trunk/user/src/com/google/gwt/http/client/Request.java Fri Oct 16 14:48:33 2009 @@ -15,8 +15,6 @@ */ package com.google.gwt.http.client; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.xhr.client.XMLHttpRequest; @@ -148,7 +146,7 @@ * and set this field to null. */ private XMLHttpRequest xmlHttpRequest; - + /** * Only used for building a * {...@link com.google.gwt.user.client.rpc.impl.FailedRequest}. @@ -265,33 +263,6 @@ * reaches 4 (LOADED). */ void fireOnResponseReceived(RequestCallback callback) { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - fireOnResponseReceivedAndCatch(handler, callback); - } else { - fireOnResponseReceivedImpl(callback); - } - } - - /* - * Stops the current HTTPRequest timer if there is one. - */ - private void cancelTimer() { - if (timer != null) { - timer.cancel(); - } - } - - private void fireOnResponseReceivedAndCatch(UncaughtExceptionHandler handler, - RequestCallback callback) { - try { - fireOnResponseReceivedImpl(callback); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } - - private void fireOnResponseReceivedImpl(RequestCallback callback) { if (xmlHttpRequest == null) { // the request has timed out at this point return; @@ -316,6 +287,15 @@ callback.onResponseReceived(this, response); } } + + /* + * Stops the current HTTPRequest timer if there is one. + */ + private void cancelTimer() { + if (timer != null) { + timer.cancel(); + } + } /* * Method called when this request times out. @@ -340,22 +320,20 @@ * <ol> * <li>On Mozilla, after a network error, attempting to read the status code * results in an exception being thrown. See <a - * href="https://bugzilla.mozilla.org/show_bug.cgi?id=238559">https://bugzilla.mozilla.org/show_bug.cgi?id=238559</a>. - * </li> - * <li>On Safari, if the HTTP response does not include any response text. - * See <a - * href="http://bugs.webkit.org/show_bug.cgi?id=3810">http://bugs.webkit.org/show_bug.cgi?id=3810</a>. - * </li> + * href="https://bugzilla.mozilla.org/show_bug.cgi?id=238559" + * >https://bugzilla.mozilla.org/show_bug.cgi?id=238559</a>.</li> + * <li>On Safari, if the HTTP response does not include any response text. See + * <a + * href="http://bugs.webkit.org/show_bug.cgi?id=3810">http://bugs.webkit.org + * /show_bug.cgi?id=3810</a>.</li> * </ol> * - * @param xhr the JavaScript <code>XmlHttpRequest</code> object - * to test + * @param xhr the JavaScript <code>XmlHttpRequest</code> object to test * @return a String message containing an error message if the * <code>XmlHttpRequest.status</code> code is unreadable or null if * the status code could be successfully read. */ - private native String getBrowserSpecificFailure( - XMLHttpRequest xhr) /*-{ + private native String getBrowserSpecificFailure(XMLHttpRequest xhr) /*-{ try { if (xhr.status === undefined) { return "XmlHttpRequest.status == undefined, please see Safari bug " + ======================================= --- /trunk/user/src/com/google/gwt/jsonp/client/JsonpRequest.java Fri Oct 2 15:07:42 2009 +++ /trunk/user/src/com/google/gwt/jsonp/client/JsonpRequest.java Fri Oct 16 14:48:33 2009 @@ -191,7 +191,7 @@ var self = this; var callback = new Object(); callbacks[th...@com.google.gwt.jsonp.client.jsonprequest::callbackId] = callback; - callback.onSuccess = function(data) { + callback.onSuccess = $entry(function(data) { // Box primitive types if (typeof data == 'boolean') { data = @java.lang.Boolean::new(Z)(data); @@ -203,11 +203,11 @@ } } se...@com.google.gwt.jsonp.client.jsonprequest::onSuccess(Ljava/lang/Object;)(data); - }; + }); if (th...@com.google.gwt.jsonp.client.jsonprequest::failureCallbackParam) { - callback.onFailure = function(message) { + callback.onFailure = $entry(function(message) { se...@com.google.gwt.jsonp.client.jsonprequest::onFailure(Ljava/lang/String;)(message); - }; + }); } }-*/; ======================================= --- /trunk/user/src/com/google/gwt/layout/client/LayoutImplIE6.java Mon Oct 12 13:35:17 2009 +++ /trunk/user/src/com/google/gwt/layout/client/LayoutImplIE6.java Fri Oct 16 14:48:33 2009 @@ -242,6 +242,10 @@ resize(); }-*/; + /** + * This does not call $entry() because no user code is reachable from + * resizeHandler. + */ private native void initResizeHandler(Element parent) /*-{ // Potential leak: This is cleaned up in detach(). var self = this; @@ -250,6 +254,10 @@ }; }-*/; + /** + * This does not call $entry() because no user code is reachable from + * resizeHandler. + */ private native void initUnitChangeHandler(Element parent, Element ruler) /*-{ // Potential leak: This is cleaned up in detach(). var self = this; ======================================= --- /trunk/user/src/com/google/gwt/user/client/AsyncProxy.java Tue Aug 25 15:54:19 2009 +++ /trunk/user/src/com/google/gwt/user/client/AsyncProxy.java Fri Oct 16 14:48:33 2009 @@ -178,7 +178,9 @@ * Invokes the global uncaught exception handler. */ public void onFailure(Throwable t) { - GWT.getUncaughtExceptionHandler().onUncaughtException(t); + if (GWT.getUncaughtExceptionHandler() != null) { + GWT.getUncaughtExceptionHandler().onUncaughtException(t); + } } /** ======================================= --- /trunk/user/src/com/google/gwt/user/client/DOM.java Thu Jul 16 08:05:27 2009 +++ /trunk/user/src/com/google/gwt/user/client/DOM.java Fri Oct 16 14:48:33 2009 @@ -16,7 +16,6 @@ package com.google.gwt.user.client; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.ImageElement; import com.google.gwt.dom.client.OptionElement; @@ -1261,12 +1260,7 @@ Event prevCurrentEvent = currentEvent; currentEvent = evt; - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - dispatchEventAndCatch(evt, elem, listener, handler); - } else { - dispatchEventImpl(evt, elem, listener); - } + dispatchEventImpl(evt, elem, listener); currentEvent = prevCurrentEvent; } @@ -1298,15 +1292,6 @@ return ret; } - - private static void dispatchEventAndCatch(Event evt, Element elem, - EventListener listener, UncaughtExceptionHandler handler) { - try { - dispatchEventImpl(evt, elem, listener); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } private static void dispatchEventImpl(Event evt, Element elem, EventListener listener) { ======================================= --- /trunk/user/src/com/google/gwt/user/client/HTTPRequest.java Wed Feb 18 05:39:02 2009 +++ /trunk/user/src/com/google/gwt/user/client/HTTPRequest.java Fri Oct 16 14:48:33 2009 @@ -84,14 +84,14 @@ try { xmlHttp.open("GET", url, true); xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8"); - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = $entry(function() { if (xmlHttp.readyState == 4) { $wnd.setTimeout(function() { xmlHttp.onreadystatechange = @com.google.gwt.user.client.impl.HTTPRequestImpl::nullFunc; }, 0); handl...@com.google.gwt.user.client.responsetexthandler::onCompletion(Ljava/lang/String;)(xmlHttp.responseText || ""); } - }; + }); xmlHttp.send(''); return true; } catch (e) { @@ -106,14 +106,14 @@ try { xmlHttp.open("POST", url, true); xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8"); - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = $entry(function() { if (xmlHttp.readyState == 4) { $wnd.setTimeout(function() { xmlHttp.onreadystatechange = @com.google.gwt.user.client.impl.HTTPRequestImpl::nullFunc; }, 0); handl...@com.google.gwt.user.client.responsetexthandler::onCompletion(Ljava/lang/String;)(xmlHttp.responseText || ""); } - }; + }); xmlHttp.send(postData); return true; } ======================================= --- /trunk/user/src/com/google/gwt/user/client/Timer.java Fri Feb 6 13:06:24 2009 +++ /trunk/user/src/com/google/gwt/user/client/Timer.java Fri Oct 16 14:48:33 2009 @@ -15,8 +15,6 @@ */ package com.google.gwt.user.client; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; @@ -53,13 +51,13 @@ private static native int createInterval(Timer timer, int period) /*-{ return $wnd.setInterval( - function() { tim...@com.google.gwt.user.client.timer::fire()(); }, + $entry(function() { tim...@com.google.gwt.user.client.timer::fire()(); }), period); }-*/; private static native int createTimeout(Timer timer, int delay) /*-{ return $wnd.setTimeout( - function() { tim...@com.google.gwt.user.client.timer::fire()(); }, + $entry(function() { tim...@com.google.gwt.user.client.timer::fire()(); }), delay); }-*/; @@ -133,23 +131,6 @@ * Called by native code when this timer fires. */ final void fire() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - fireAndCatch(handler); - } else { - fireImpl(); - } - } - - private void fireAndCatch(UncaughtExceptionHandler handler) { - try { - fireImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } - - private void fireImpl() { // If this is a one-shot timer, remove it from the timer list. This will // allow it to be garbage collected. if (!isRepeating) { ======================================= --- /trunk/user/src/com/google/gwt/user/client/Window.java Mon Oct 12 14:48:21 2009 +++ /trunk/user/src/com/google/gwt/user/client/Window.java Fri Oct 16 14:48:33 2009 @@ -16,7 +16,6 @@ package com.google.gwt.user.client; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.dom.client.Document; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; @@ -705,38 +704,37 @@ }-*/; static void onClosed() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - fireClosedAndCatch(handler); - } else { - fireClosedImpl(); + if (closeHandlersInitialized) { + CloseEvent.fire(getHandlers(), null); } } static String onClosing() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - return fireClosingAndCatch(handler); - } else { - return fireClosingImpl(); - } + if (closeHandlersInitialized) { + Window.ClosingEvent event = new Window.ClosingEvent(); + fireEvent(event); + return event.getMessage(); + } + return null; } static void onResize() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - fireResizedAndCatch(handler); - } else { - fireResizedImpl(); + if (resizeHandlersInitialized) { + // On webkit and IE we sometimes get duplicate window resize events. + // Here, we manually filter them. + int width = getClientWidth(); + int height = getClientHeight(); + if (lastResizeWidth != width || lastResizeHeight != height) { + lastResizeWidth = width; + lastResizeHeight = height; + ResizeEvent.fire(getHandlers(), width, height); + } } } static void onScroll() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - fireScrollAndCatch(handler); - } else { - fireScrollImpl(); + if (scrollHandlersInitialized) { + fireEvent(new Window.ScrollEvent(getScrollLeft(), getScrollTop())); } } @@ -752,38 +750,6 @@ GwtEvent.Type<H> type, final H handler) { return getHandlers().addHandler(type, handler); } - - private static void fireClosedAndCatch(UncaughtExceptionHandler handler) { - try { - fireClosedImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } - - private static void fireClosedImpl() { - if (closeHandlersInitialized) { - CloseEvent.fire(getHandlers(), null); - } - } - - private static String fireClosingAndCatch(UncaughtExceptionHandler handler) { - try { - return fireClosingImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - return null; - } - } - - private static String fireClosingImpl() { - if (closeHandlersInitialized) { - Window.ClosingEvent event = new Window.ClosingEvent(); - fireEvent(event); - return event.getMessage(); - } - return null; - } /** * Fires an event. @@ -795,42 +761,6 @@ handlers.fireEvent(event); } } - - private static void fireResizedAndCatch(UncaughtExceptionHandler handler) { - try { - fireResizedImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } - - private static void fireResizedImpl() { - if (resizeHandlersInitialized) { - // On webkit and IE we sometimes get duplicate window resize events. - // Here, we manually filter them. - int width = getClientWidth(); - int height = getClientHeight(); - if (lastResizeWidth != width || lastResizeHeight != height) { - lastResizeWidth = width; - lastResizeHeight = height; - ResizeEvent.fire(getHandlers(), width, height); - } - } - } - - private static void fireScrollAndCatch(UncaughtExceptionHandler handler) { - try { - fireScrollImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } - - private static void fireScrollImpl() { - if (scrollHandlersInitialized) { - fireEvent(new Window.ScrollEvent(getScrollLeft(), getScrollTop())); - } - } private static WindowHandlers getHandlers() { if (handlers == null) { ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java Fri Feb 6 13:06:24 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java Fri Oct 16 14:48:33 2009 @@ -43,7 +43,7 @@ private native void initSyntheticMouseUpEvents() /*-{ $wnd.addEventListener( 'mouseout', - function(evt) { + $entry(function(evt) { var cap = $wnd.__captureElem; if (cap && !evt.relatedTarget) { // Mozilla has the interesting habit of sending a mouseout event @@ -59,7 +59,7 @@ cap.dispatchEvent(muEvent); } } - }, + }), true ); ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java Tue Jul 21 07:10:53 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java Fri Oct 16 14:48:33 2009 @@ -143,7 +143,7 @@ @Override protected native void initEventSystem() /*-{ - @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent = function(evt) { + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent = $entry(function(evt) { if ((@com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedEvent)(evt)) { var cap = @com.google.gwt.user.client.impl.DOMImplStandard::captureElem; if (cap && cap.__listener) { @@ -153,9 +153,9 @@ } } } - }; - - @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedEvent = function(evt) { + }); + + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedEvent = $entry(function(evt) { if (!...@com.google.gwt.user.client.dom::previewEvent(Lcom/google/gwt/user/client/Event;)(evt)) { evt.stopPropagation(); evt.preventDefault(); @@ -163,9 +163,9 @@ } return true; - }; - - @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent = function(evt) { + }); + + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent = $entry(function(evt) { var listener, curElem = this; while (curElem && !(listener = curElem.__listener)) { curElem = curElem.parentNode; @@ -180,7 +180,7 @@ @com.google.gwt.user.client.DOM::dispatchEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/EventListener;)(evt, curElem, listener); } } - }; + }); $wnd.addEventListener('click', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent, true); $wnd.addEventListener('dblclick', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent, true); ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java Fri Sep 18 11:17:07 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java Fri Oct 16 14:48:33 2009 @@ -99,11 +99,11 @@ if ($wnd.__gwt_globalEventArray == null) { $wnd.__gwt_globalEventArray = new Array(); } - $wnd.__gwt_globalEventArray[$wnd.__gwt_globalEventArray.length] = function() { + $wnd.__gwt_globalEventArray[$wnd.__gwt_globalEventArray.length] = $entry(function() { return @com.google.gwt.user.client.DOM::previewEvent(Lcom/google/gwt/user/client/Event;)($wnd.event); - } - - @com.google.gwt.user.client.impl.DOMImplTrident::dispatchEvent = function() { + }); + + @com.google.gwt.user.client.impl.DOMImplTrident::dispatchEvent = $entry(function() { // IE doesn't define event.currentTarget, so we squirrel it away here. It // also seems that IE won't allow you to add expandos to the event object, // so we have to store it in a global. This is ok because only one event @@ -134,9 +134,9 @@ } @com.google.gwt.dom.client.DOMImplTrident::currentEventTarget = oldEventTarget; - }; - - @com.google.gwt.user.client.impl.DOMImplTrident::dispatchDblClickEvent = function() { + }); + + @com.google.gwt.user.client.impl.DOMImplTrident::dispatchDblClickEvent = $entry(function() { var newEvent = $doc.createEventObject(); // Synthesize a click event if one hasn't already been synthesized. if ($wnd.event.returnValue == null) { @@ -149,13 +149,13 @@ $wnd.event.returnValue = true; @com.google.gwt.user.client.impl.DOMImplTrident::previewEventImpl()(); } - }; + }); // We need to create these delegate functions to fix up the 'this' context. // Normally, 'this' is the firing element, but this is only true for // 'onclick = ...' event handlers, not for handlers setup via attachEvent(). - var bodyDispatcher = function() { @com.google.gwt.user.client.impl.DOMImplTrident::dispatchEvent.call($doc.body); }; - var bodyDblClickDispatcher = function() { @com.google.gwt.user.client.impl.DOMImplTrident::dispatchDblClickEvent.call($doc.body); }; + var bodyDispatcher = $entry(function() { @com.google.gwt.user.client.impl.DOMImplTrident::dispatchEvent.call($doc.body); }); + var bodyDblClickDispatcher = $entry(function() { @com.google.gwt.user.client.impl.DOMImplTrident::dispatchDblClickEvent.call($doc.body); }); $doc.body.attachEvent('onclick', bodyDispatcher); $doc.body.attachEvent('onmousedown', bodyDispatcher); ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java Mon May 18 11:47:32 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java Fri Oct 16 14:48:33 2009 @@ -68,14 +68,14 @@ try { xmlHttp.open("GET", url, true); xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8"); - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = $entry(function() { if (xmlHttp.readyState == 4) { - $wnd.setTimeout(function() { + $wnd.setTimeout($entry(function() { xmlHttp.onreadystatechange = @com.google.gwt.user.client.impl.HTTPRequestImpl::nullFunc; - }, 0); + }), 0); handl...@com.google.gwt.user.client.responsetexthandler::onCompletion(Ljava/lang/String;)(xmlHttp.responseText || ""); } - }; + }); xmlHttp.send(''); return true; } catch (e) { @@ -90,14 +90,14 @@ try { xmlHttp.open("POST", url, true); xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8"); - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = $entry(function() { if (xmlHttp.readyState == 4) { - $wnd.setTimeout(function() { + $wnd.setTimeout($entry(function() { xmlHttp.onreadystatechange = @com.google.gwt.user.client.impl.HTTPRequestImpl::nullFunc; - }, 0); + }), 0); handl...@com.google.gwt.user.client.responsetexthandler::onCompletion(Ljava/lang/String;)(xmlHttp.responseText || ""); } - }; + }); xmlHttp.send(postData); return true; } ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/HistoryImpl.java Thu Jul 9 09:10:32 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/HistoryImpl.java Fri Oct 16 14:48:33 2009 @@ -15,8 +15,6 @@ */ package com.google.gwt.user.client.impl; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; @@ -27,16 +25,15 @@ /** * Native implementation associated with - * {...@link com.google.gwt.user.client.History}. - * User classes should not use this class directly. + * {...@link com.google.gwt.user.client.History}. User classes should not use this + * class directly. * * <p> * This base version uses the HTML5 standard window.onhashchange event to * determine when the URL hash identifier changes. * </p> */ -public class HistoryImpl implements HasValueChangeHandlers<String>, - HasHandlers { +public class HistoryImpl implements HasValueChangeHandlers<String>, HasHandlers { public static native String getToken() /*-{ return $wnd.__gwt_historyToken || ""; @@ -45,11 +42,11 @@ /** * Sets whether the IE6 history implementation will update the URL hash when * creating a new item. This should be used only for applications with large - * DOM structures that are suffering from performance problems when creating - * a new history item on IE6 and 7. - * + * DOM structures that are suffering from performance problems when creating a + * new history item on IE6 and 7. + * * @deprecated This is no longer necessary, as the underlying performance - * problem has been solved. It is now a no-op. + * problem has been solved. It is now a no-op. */ @Deprecated public static void setUpdateHashOnIE6(boolean updateHash) { @@ -99,14 +96,14 @@ @com.google.gwt.user.client.impl.HistoryImpl::setToken(Ljava/lang/String;)(token); var historyImpl = this; - $wnd.onhashchange = function() { + $wnd.onhashchange = $entry(function() { var token = '', hash = $wnd.location.hash; if (hash.length > 0) { token = historyim...@com.google.gwt.user.client.impl.historyimpl::decodeFragment(Ljava/lang/String;)(hash.substring(1)); } historyim...@com.google.gwt.user.client.impl.historyimpl::newItemOnEvent(Ljava/lang/String;)(token); - }; + }); return true; }-*/; @@ -127,7 +124,7 @@ if (!historyToken.equals(getToken())) { setToken(historyToken); nativeUpdateOnEvent(historyToken); - fireHistoryChanged(historyToken); + fireHistoryChangedImpl(historyToken); } } @@ -152,22 +149,4 @@ protected void nativeUpdateOnEvent(String historyToken) { // Do nothing, the hash is already updated. } - - private void fireHistoryChanged(String newToken) { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - fireHistoryChangedAndCatch(newToken, handler); - } else { - fireHistoryChangedImpl(newToken); - } - } - - private void fireHistoryChangedAndCatch(String newToken, - UncaughtExceptionHandler handler) { - try { - fireHistoryChangedImpl(newToken); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } -} +} ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java Thu Jul 9 09:10:32 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java Fri Oct 16 14:48:33 2009 @@ -148,7 +148,7 @@ // nasty bug that totally mangles its history stack and causes the location // bar in the UI to stop working under these circumstances. var historyImplRef = this; - var urlChecker = function() { + var urlChecker = $entry(function() { $wnd.setTimeout(urlChecker, 250); // Reset the hash if the user cancels a window reload triggered by the @@ -173,16 +173,16 @@ historyimplr...@com.google.gwt.user.client.impl.historyimplie6::reloadWindow()(); } } - }; + }); urlChecker(); }-*/; private native void injectGlobalHandler() /*-{ var historyImplRef = this; - $wnd.__gwt_onHistoryLoad = function(token) { + $wnd.__gwt_onHistoryLoad = $entry(function(token) { historyimplr...@com.google.gwt.user.client.impl.historyimpl::newItemOnEvent(Ljava/lang/String;)(token); - }; + }); }-*/; private native void navigateFrame(String token) /*-{ ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/HistoryImplTimer.java Tue Apr 28 09:11:39 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/HistoryImplTimer.java Fri Oct 16 14:48:33 2009 @@ -35,7 +35,7 @@ // Create the timer that checks the browser's url hash every 1/4 s. var historyImpl = this; - $wnd.__checkHistory = function() { + $wnd.__checkHistory = $entry(function() { $wnd.setTimeout($wnd.__checkHistory, 250); var token = '', hash = $wnd.location.hash; @@ -44,7 +44,7 @@ } historyim...@com.google.gwt.user.client.impl.historyimpl::newItemOnEvent(Ljava/lang/String;)(token); - }; + }); // Kick off the timer. $wnd.__checkHistory(); ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/WindowImpl.java Wed Mar 11 16:11:41 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/WindowImpl.java Fri Oct 16 14:48:33 2009 @@ -33,10 +33,14 @@ var oldOnBeforeUnload = $wnd.onbeforeunload; var oldOnUnload = $wnd.onunload; + // Old mozilla doesn't like $entry's explicit return statement and + // will always pop up a confirmation dialog. This is worked around by + // just wrapping the call to onClosing(), which still has the semantics + // that we want. $wnd.onbeforeunload = function(evt) { var ret, oldRet; try { - ret = @com.google.gwt.user.client.Window::onClosing()(); + ret = $entry(@com.google.gwt.user.client.Window::onClosing())(); } finally { oldRet = oldOnBeforeUnload && oldOnBeforeUnload(evt); } @@ -51,7 +55,7 @@ // returns undefined. }; - $wnd.onunload = function(evt) { + $wnd.onunload = $entry(function(evt) { try { @com.google.gwt.user.client.Window::onClosed()(); } finally { @@ -61,28 +65,28 @@ $wnd.onbeforeunload = null; $wnd.onunload = null; } - }; + }); }-*/; public native void initWindowResizeHandler() /*-{ var oldOnResize = $wnd.onresize; - $wnd.onresize = function(evt) { + $wnd.onresize = $entry(function(evt) { try { @com.google.gwt.user.client.Window::onResize()(); } finally { oldOnResize && oldOnResize(evt); } - }; + }); }-*/; public native void initWindowScrollHandler() /*-{ var oldOnScroll = $wnd.onscroll; - $wnd.onscroll = function(evt) { + $wnd.onscroll = $entry(function(evt) { try { @com.google.gwt.user.client.Window::onScroll()(); } finally { oldOnScroll && oldOnScroll(evt); } - }; + }); }-*/; } ======================================= --- /trunk/user/src/com/google/gwt/user/client/impl/WindowImplIE.java Tue Jul 28 09:21:27 2009 +++ /trunk/user/src/com/google/gwt/user/client/impl/WindowImplIE.java Fri Oct 16 14:48:33 2009 @@ -133,28 +133,20 @@ private native void initWindowCloseHandlerImpl() /*-{ $wnd.__gwt_initWindowCloseHandler( - function() { - return @com.google.gwt.user.client.Window::onClosing()(); - }, - function() { - @com.google.gwt.user.client.Window::onClosed()(); - } + $entry(@com.google.gwt.user.client.Window::onClosing()), + $entry(@com.google.gwt.user.client.Window::onClosed()) ); }-*/; private native void initWindowResizeHandlerImpl() /*-{ $wnd.__gwt_initWindowResizeHandler( - function() { - @com.google.gwt.user.client.Window::onResize()(); - } + $entry(@com.google.gwt.user.client.Window::onResize()) ); }-*/; private native void initWindowScrollHandlerImpl() /*-{ $wnd.__gwt_initWindowScrollHandler( - function() { - @com.google.gwt.user.client.Window::onScroll()(); - } + $entry(@com.google.gwt.user.client.Window::onScroll()) ); }-*/; ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/FormPanel.java Wed Sep 2 07:58:52 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/FormPanel.java Fri Oct 16 14:48:33 2009 @@ -16,7 +16,6 @@ package com.google.gwt.user.client.ui; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.FormElement; @@ -310,8 +309,8 @@ * 'text/html', meaning that the text returned will be treated as HTML. If any * other content-type is specified by the server, then the result HTML sent in * the onFormSubmit event will be unpredictable across browsers, and the - * {...@link SubmitCompleteHandler#onSubmitComplete(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) onSubmitComplete} event - * may not fire at all. + * {...@link SubmitCompleteHandler#onSubmitComplete(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) + * onSubmitComplete} event may not fire at all. * </p> * * @tip The initial implementation of FormPanel specified that the server @@ -404,7 +403,7 @@ /** * @deprecated Use {...@link #addSubmitCompleteHandler} and - * {...@link #addSubmitHandler} instead + * {...@link #addSubmitHandler} instead */ @Deprecated public void addFormHandler(FormHandler handler) { @@ -479,26 +478,16 @@ * @return true if the form is submitted, false if canceled */ public boolean onFormSubmit() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - return onFormSubmitAndCatch(handler); - } else { - return onFormSubmitImpl(); - } + return onFormSubmitImpl(); } public void onFrameLoad() { - UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); - if (handler != null) { - onFrameLoadAndCatch(handler); - } else { - onFrameLoadImpl(); - } + onFrameLoadImpl(); } /** - * @deprecated Use the {...@link HandlerRegistration#removeHandler} - * method on the object returned by and add*Handler method instead + * @deprecated Use the {...@link HandlerRegistration#removeHandler} method on the + * object returned by and add*Handler method instead */ @Deprecated public void removeFormHandler(FormHandler handler) { @@ -623,15 +612,6 @@ private FormElement getFormElement() { return getElement().cast(); } - - private boolean onFormSubmitAndCatch(UncaughtExceptionHandler handler) { - try { - return onFormSubmitImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - return false; - } - } /** * @return true if the form is submitted, false if canceled @@ -639,14 +619,6 @@ private boolean onFormSubmitImpl() { return fireSubmitEvent(); } - - private void onFrameLoadAndCatch(UncaughtExceptionHandler handler) { - try { - onFrameLoadImpl(); - } catch (Throwable e) { - handler.onUncaughtException(e); - } - } private void onFrameLoadImpl() { // Fire onComplete events in a deferred command. This is necessary ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/HorizontalSplitPanel.java Mon May 18 11:47:32 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/HorizontalSplitPanel.java Fri Oct 16 14:48:33 2009 @@ -290,9 +290,9 @@ private native void addResizeListener(Element container) /*-{ var self = this; - container.onresize = function() { + container.onresize = $entry(function() { se...@com.google.gwt.user.client.ui.horizontalsplitpanel$implie6::onResize()(); - }; + }); }-*/; private void onResize() { ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/VerticalSplitPanel.java Mon May 18 11:47:32 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/VerticalSplitPanel.java Fri Oct 16 14:48:33 2009 @@ -220,9 +220,9 @@ private native void addResizeListener(Element container) /*-{ var self = this; - container.onresize = function() { + container.onresize = $entry(function() { se...@com.google.gwt.user.client.ui.verticalsplitpanel$implie6::onResize()(); - }; + }); }-*/; private void onResize() { ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java Thu Sep 18 12:31:46 2008 +++ /trunk/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java Fri Oct 16 14:48:33 2009 @@ -63,23 +63,23 @@ public native void hookEvents(Element iframe, Element form, FormPanelImplHost listener) /*-{ if (iframe) { - iframe.onload = function() { + iframe.onload = $entry(function() { // If there is no __formAction yet, this is a spurious onload // generated when the iframe is first added to the DOM. if (!iframe.__formAction) return; listen...@com.google.gwt.user.client.ui.impl.formpanelimplhost::onFrameLoad()(); - }; + }); } - form.onsubmit = function() { + form.onsubmit = $entry(function() { // Hang on to the form's action url, needed in the // onload/onreadystatechange handler. if (iframe) iframe.__formAction = form.action; return listen...@com.google.gwt.user.client.ui.impl.formpanelimplhost::onFormSubmit()(); - }; + }); }-*/; /** ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/impl/FormPanelImplIE6.java Tue Jul 8 12:08:40 2008 +++ /trunk/user/src/com/google/gwt/user/client/ui/impl/FormPanelImplIE6.java Fri Oct 16 14:48:33 2009 @@ -25,7 +25,7 @@ @Override public native void hookEvents(Element iframe, Element form, FormPanelImplHost listener) /*-{ if (iframe) { - iframe.onreadystatechange = function() { + iframe.onreadystatechange = $entry(function() { // If there is no __formAction yet, this is a spurious onreadystatechange // generated when the iframe is first added to the DOM. if (!iframe.__formAction) @@ -36,16 +36,16 @@ // url, then it must be an error, so we ignore it. listen...@com.google.gwt.user.client.ui.impl.formpanelimplhost::onFrameLoad()(); } - }; + }); } - form.onsubmit = function() { + form.onsubmit = $entry(function() { // Hang on to the form's action url, needed in the // onload/onreadystatechange handler. if (iframe) iframe.__formAction = form.action; return listen...@com.google.gwt.user.client.ui.impl.formpanelimplhost::onFormSubmit()(); - }; + }); }-*/; @Override ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java Thu Jul 16 17:54:03 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplIE6.java Fri Oct 16 14:48:33 2009 @@ -35,7 +35,7 @@ var _this = this; _th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::initializing = true; - setTimeout(function() { + setTimeout($entry(function() { if (_th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::initializing == false) { return; } @@ -57,7 +57,7 @@ // Send notification that the iframe has reached design mode. _th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::onElementInitialized()(); - }, 1); + }, 1)); }-*/; @Override @@ -91,14 +91,14 @@ var elem = th...@com.google.gwt.user.client.ui.impl.richtextareaimpl::elem; var body = elem.contentWindow.document.body; - var handler = function() { + var handler = $entry(function() { if (elem.__listener) { // Weird: this code has the context of the script frame, but we need the // event from the edit iframe's window. var evt = elem.contentWindow.event; elem.__listen...@com.google.gwt.user.client.ui.widget::onBrowserEvent(Lcom/google/gwt/user/client/Event;)(evt); } - }; + }); body.onkeydown = body.onkeyup = ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java Thu Jul 16 17:54:03 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java Fri Oct 16 14:48:33 2009 @@ -28,7 +28,7 @@ var iframe = _th...@com.google.gwt.user.client.ui.impl.richtextareaimpl::elem; _th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::initializing = true; - iframe.onload = function() { + iframe.onload = $entry(function() { // Some Mozillae have the nasty habit of calling onload again when you set // designMode, so let's avoid doing it more than once. iframe.onload = null; @@ -58,7 +58,7 @@ iframe.contentWindow.onmouseover = null; iframe.contentWindow.document.designMode = 'On'; }; - }; + }); }-*/; @Override ======================================= --- /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java Wed Sep 23 13:12:51 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplStandard.java Fri Oct 16 14:48:33 2009 @@ -90,13 +90,13 @@ // just fine. var _this = this; _th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::initializing = true; - setTimeout(function() { + setTimeout($entry(function() { // Turn on design mode. _th...@com.google.gwt.user.client.ui.impl.richtextareaimpl::elem.contentWindow.document.designMode = 'On'; // Send notification that the iframe has reached design mode. _th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::onElementInitialized()(); - }, 1); + }), 1); }-*/; public void insertHorizontalRule() { @@ -286,11 +286,11 @@ var elem = th...@com.google.gwt.user.client.ui.impl.richtextareaimpl::elem; var wnd = elem.contentWindow; - elem.__gwt_handler = function(evt) { + elem.__gwt_handler = $entry(function(evt) { if (elem.__listener) { elem.__listen...@com.google.gwt.user.client.ui.widget::onBrowserEvent(Lcom/google/gwt/user/client/Event;)(evt); } - }; + }); elem.__gwt_focusHandler = function(evt) { if (elem.__gwt_isFocused) { ======================================= --- /trunk/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java Wed Mar 11 11:18:13 2009 +++ /trunk/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java Fri Oct 16 14:48:33 2009 @@ -251,9 +251,9 @@ // The 'this' context is always supposed to point to the xhr object in the // onreadystatechange handler, but we reference it via closure to be extra sure. var _this = this; - this.onreadystatechange = function() { + this.onreadystatechange = $entry(function() { handl...@com.google.gwt.xhr.client.readystatechangehandler::onReadyStateChange(Lcom/google/gwt/xhr/client/XMLHttpRequest;)(_this); - }; + }); }-*/; /** --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---