Permalink
Browse files

Return value of goog.events and goog.events.listenOnce is going to

change from ?number to goog.events.ListenableKey. As a first step, we
are switching the return value to a typedef goog.events.Key (currently
just typedef to ?number). This CL switches JS files to use this typedef.

Obviously, the subsequent change will be problematic if this code
make an assumption that the return value is a number and uses the return
value in context where the number is required (e.g. goog.isNumber, using
it as index to an array). While I've tried my best to fix these usages,
I may have missed some of them. Please check that the code will still
remain correct if the return value of goog.events.listen/listenOnce is
changed to an object (goog.events.ListenableKey). Furthermore, if
you know of any other location where the return value is used in a context
that require it to be numbers, please send me a quick email.

This is parts of goog.events refactoring to remove leaking listeners
problem.

R=nweiz,nicksantos
DELTA=20 (0 added, 2 deleted, 18 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6170


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2453 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent 60f36ab commit 47ac18b3c830b45a0a463689182aab01ddc841ff chrishenry@google.com committed Jan 21, 2013
View
5 closure/goog/async/animationdelay.js
@@ -86,7 +86,7 @@ goog.inherits(goog.async.AnimationDelay, goog.Disposable);
/**
* Identifier of the active delay timeout, or event listener,
* or null when inactive.
- * @type {?number}
+ * @type {goog.events.Key|number|null}
* @private
*/
goog.async.AnimationDelay.prototype.id_ = null;
@@ -173,7 +173,7 @@ goog.async.AnimationDelay.prototype.stop = function() {
} else if (raf && cancelRaf) {
cancelRaf.call(this.win_, /** @type {number} */ (this.id_));
} else {
- this.win_.clearTimeout(this.id_);
+ this.win_.clearTimeout(/** @type {number} */ (this.id_));
}
}
this.id_ = null;
@@ -265,4 +265,3 @@ goog.async.AnimationDelay.prototype.getCancelRaf_ = function() {
win.msCancelRequestAnimationFrame ||
null;
};
-
View
2 closure/goog/dom/viewportsizemonitor.js
@@ -133,7 +133,7 @@ goog.dom.ViewportSizeMonitor.WINDOW_SIZE_POLL_RATE = 500;
/**
* Event listener key for window the window resize handler, as returned by
* {@link goog.events.listen}.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.dom.ViewportSizeMonitor.prototype.listenerKey_ = null;
View
2 closure/goog/editor/plugins/equationeditorplugin.js
@@ -52,7 +52,7 @@ goog.editor.plugins.EquationEditorPlugin = function(opt_helpUrl) {
/**
* The listener key for double click events.
- * @type {number?}
+ * @type {goog.events.Key}
* @private
*/
this.dblClickKey_;
View
2 closure/goog/editor/plugins/undoredomanager.js
@@ -114,7 +114,7 @@ goog.editor.plugins.UndoRedoManager.EventType = {
/**
* The key for the listener for the completion of the asynchronous state whose
* undo or redo action is in progress. Null if no action is in progress.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.editor.plugins.UndoRedoManager.prototype.inProgressActionKey_ = null;
View
4 closure/goog/editor/seamlessfield.js
@@ -71,15 +71,15 @@ goog.editor.SeamlessField.prototype.logger =
/**
* The key used for listening for the "dragover" event.
- * @type {number?}
+ * @type {goog.events.Key}
* @private
*/
goog.editor.SeamlessField.prototype.listenForDragOverEventKey_;
/**
* The key used for listening for the iframe "load" event.
- * @type {number?}
+ * @type {goog.events.Key}
* @private
*/
goog.editor.SeamlessField.prototype.listenForIframeLoadEventKey_;
View
6 closure/goog/events/keyhandler.js
@@ -145,23 +145,23 @@ goog.events.KeyHandler.prototype.element_ = null;
/**
* The key for the key press listener.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.events.KeyHandler.prototype.keyPressKey_ = null;
/**
* The key for the key down listener.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.events.KeyHandler.prototype.keyDownKey_ = null;
/**
* The key for the key up listener.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.events.KeyHandler.prototype.keyUpKey_ = null;
View
4 closure/goog/events/mousewheelhandler.js
@@ -76,7 +76,7 @@ goog.events.MouseWheelHandler = function(element, opt_capture) {
/**
* The key returned from the goog.events.listen.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
this.listenKey_ = goog.events.listen(this.element_, type, this, opt_capture);
@@ -240,7 +240,7 @@ goog.events.MouseWheelHandler.smartScale_ = function(mouseWheelDelta,
goog.events.MouseWheelHandler.prototype.disposeInternal = function() {
goog.events.MouseWheelHandler.superClass_.disposeInternal.call(this);
goog.events.unlistenByKey(this.listenKey_);
- delete this.listenKey_;
+ this.listenKey_ = null;
};
View
2 closure/goog/messaging/portchannel.js
@@ -72,7 +72,7 @@ goog.messaging.PortChannel = function(underlyingPort) {
/**
* The key for the event listener.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
this.listenerKey_ = goog.events.listen(
View
3 closure/goog/net/iframeloadmonitor.js
@@ -105,7 +105,7 @@ goog.net.IframeLoadMonitor.POLL_INTERVAL_MS_ = 100;
/**
* Key for iframe load listener, or null if not currently listening on the
* iframe for a load event.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.net.IframeLoadMonitor.prototype.onloadListenerKey_ = null;
@@ -197,4 +197,3 @@ goog.net.IframeLoadMonitor.prototype.handleLoad_ = function() {
this.dispatchEvent(goog.net.IframeLoadMonitor.LOAD_EVENT);
}
};
-
View
2 closure/goog/ui/ac/remotearraymatcher.js
@@ -94,7 +94,7 @@ goog.ui.ac.RemoteArrayMatcher.prototype.headers_ = null;
/**
* Key to the listener on XHR. Used to clear previous listeners.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.ui.ac.RemoteArrayMatcher.prototype.lastListenerKey_ = null;
View
2 closure/goog/ui/bubble.js
@@ -120,7 +120,7 @@ goog.ui.Bubble.prototype.timerId_ = 0;
/**
* Key returned by the listen function for the close button.
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.ui.Bubble.prototype.listener_ = null;
View
4 closure/goog/ui/hsvpalette.js
@@ -135,15 +135,15 @@ goog.ui.HsvPalette.prototype.inputHandler_;
/**
* Listener key for the mousemove event (during a drag operation).
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.ui.HsvPalette.prototype.mouseMoveListener_;
/**
* Listener key for the mouseup event (during a drag operation).
- * @type {?number}
+ * @type {goog.events.Key}
* @private
*/
goog.ui.HsvPalette.prototype.mouseUpListener_;

0 comments on commit 47ac18b

Please sign in to comment.