summaryrefslogtreecommitdiff
path: root/assets/viz/2/goog/events
diff options
context:
space:
mode:
Diffstat (limited to 'assets/viz/2/goog/events')
-rw-r--r--assets/viz/2/goog/events/browserevent.js9
-rw-r--r--assets/viz/2/goog/events/browserfeature.js40
-rw-r--r--assets/viz/2/goog/events/event.js2
-rw-r--r--assets/viz/2/goog/events/events.js80
-rw-r--r--assets/viz/2/goog/events/eventtype.js64
-rw-r--r--assets/viz/2/goog/events/listenable.js4
-rw-r--r--assets/viz/2/goog/events/listener.js7
-rw-r--r--assets/viz/2/goog/events/listenermap.js3
8 files changed, 160 insertions, 49 deletions
diff --git a/assets/viz/2/goog/events/browserevent.js b/assets/viz/2/goog/events/browserevent.js
index 14894e1..b2261a3 100644
--- a/assets/viz/2/goog/events/browserevent.js
+++ b/assets/viz/2/goog/events/browserevent.js
@@ -130,6 +130,12 @@ goog.events.BrowserEvent = function(opt_e, opt_currentTarget) {
this.button = 0;
/**
+ * Key of key press.
+ * @type {string}
+ */
+ this.key = '';
+
+ /**
* Keycode of key press.
* @type {number}
*/
@@ -281,6 +287,7 @@ goog.events.BrowserEvent.prototype.init = function(e, opt_currentTarget) {
this.button = e.button;
this.keyCode = e.keyCode || 0;
+ this.key = e.key || '';
this.charCode = e.charCode || (type == 'keypress' ? e.keyCode : 0);
this.ctrlKey = e.ctrlKey;
this.altKey = e.altKey;
@@ -363,7 +370,7 @@ goog.events.BrowserEvent.prototype.preventDefault = function() {
if (!be.preventDefault) {
be.returnValue = false;
if (goog.events.BrowserFeature.SET_KEY_CODE_TO_PREVENT_DEFAULT) {
- /** @preserveTry */
+
try {
// Most keys can be prevented using returnValue. Some special keys
// require setting the keyCode to -1 as well:
diff --git a/assets/viz/2/goog/events/browserfeature.js b/assets/viz/2/goog/events/browserfeature.js
index 4cfa8e3..7cc7bd6 100644
--- a/assets/viz/2/goog/events/browserfeature.js
+++ b/assets/viz/2/goog/events/browserfeature.js
@@ -21,6 +21,8 @@
goog.provide('goog.events.BrowserFeature');
goog.require('goog.userAgent');
+goog.scope(function() {
+
/**
@@ -80,5 +82,41 @@ goog.events.BrowserFeature = {
'ontouchstart' in document.documentElement) ||
// IE10 uses non-standard touch events, so it has a different check.
!!(goog.global['navigator'] &&
- goog.global['navigator']['msMaxTouchPoints']))
+ goog.global['navigator']['msMaxTouchPoints'])),
+
+ /**
+ * Whether addEventListener supports {passive: true}.
+ * https://developers.google.com/web/updates/2016/06/passive-event-listeners
+ */
+ PASSIVE_EVENTS: purify(function() {
+ // If we're in a web worker or other custom environment, we can't tell.
+ if (!goog.global.addEventListener || !Object.defineProperty) { // IE 8
+ return false;
+ }
+
+ var passive = false;
+ var options = Object.defineProperty({}, 'passive', {
+ get: function() {
+ passive = true;
+ }
+ });
+ goog.global.addEventListener('test', goog.nullFunction, options);
+ goog.global.removeEventListener('test', goog.nullFunction, options);
+
+ return passive;
+ })
};
+
+
+/**
+ * Tricks Closure Compiler into believing that a function is pure. The compiler
+ * assumes that any `valueOf` function is pure, without analyzing its contents.
+ *
+ * @param {function(): T} fn
+ * @return {T}
+ * @template T
+ */
+function purify(fn) {
+ return ({valueOf: fn}).valueOf();
+}
+}); // goog.scope
diff --git a/assets/viz/2/goog/events/event.js b/assets/viz/2/goog/events/event.js
index 89db91e..ee3b3af 100644
--- a/assets/viz/2/goog/events/event.js
+++ b/assets/viz/2/goog/events/event.js
@@ -99,8 +99,6 @@ goog.events.Event = function(type, opt_target) {
* Return value for in internal capture/bubble processing for IE.
* @type {boolean}
* @public
- * @suppress {underscore|visibility} Technically public, but referencing this
- * outside this package is strongly discouraged.
*/
this.returnValue_ = true;
};
diff --git a/assets/viz/2/goog/events/events.js b/assets/viz/2/goog/events/events.js
index 6a0acf7..2787340 100644
--- a/assets/viz/2/goog/events/events.js
+++ b/assets/viz/2/goog/events/events.js
@@ -160,30 +160,34 @@ goog.events.listenerCountEstimate_ = 0;
* @param {function(this:T, EVENTOBJ):?|{handleEvent:function(?):?}|null}
* listener Callback method, or an object with a handleEvent function.
* WARNING: passing an Object is now softly deprecated.
- * @param {boolean=} opt_capt Whether to fire in capture phase (defaults to
- * false).
+ * @param {(boolean|!AddEventListenerOptions)=} opt_options
* @param {T=} opt_handler Element in whose scope to call the listener.
* @return {goog.events.Key} Unique key for the listener.
* @template T,EVENTOBJ
*/
-goog.events.listen = function(src, type, listener, opt_capt, opt_handler) {
+goog.events.listen = function(src, type, listener, opt_options, opt_handler) {
+ if (opt_options && opt_options.once) {
+ return goog.events.listenOnce(
+ src, type, listener, opt_options, opt_handler);
+ }
if (goog.isArray(type)) {
for (var i = 0; i < type.length; i++) {
- goog.events.listen(src, type[i], listener, opt_capt, opt_handler);
+ goog.events.listen(src, type[i], listener, opt_options, opt_handler);
}
return null;
}
listener = goog.events.wrapListener(listener);
if (goog.events.Listenable.isImplementedBy(src)) {
+ var capture =
+ goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
return src.listen(
- /** @type {string|!goog.events.EventId} */ (type), listener, opt_capt,
+ /** @type {string|!goog.events.EventId} */ (type), listener, capture,
opt_handler);
} else {
return goog.events.listen_(
- /** @type {!EventTarget} */ (src),
- /** @type {string|!goog.events.EventId} */ (type), listener,
- /* callOnce */ false, opt_capt, opt_handler);
+ /** @type {!EventTarget} */ (src), type, listener,
+ /* callOnce */ false, opt_options, opt_handler);
}
};
@@ -198,23 +202,24 @@ goog.events.listen = function(src, type, listener, opt_capt, opt_handler) {
* one-off listener to become a normal listener.
*
* @param {EventTarget} src The node to listen to events on.
- * @param {string|!goog.events.EventId} type Event type.
+ * @param {string|?goog.events.EventId<EVENTOBJ>} type Event type.
* @param {!Function} listener Callback function.
* @param {boolean} callOnce Whether the listener is a one-off
* listener or otherwise.
- * @param {boolean=} opt_capt Whether to fire in capture phase (defaults to
- * false).
+ * @param {(boolean|!AddEventListenerOptions)=} opt_options
* @param {Object=} opt_handler Element in whose scope to call the listener.
* @return {goog.events.ListenableKey} Unique key for the listener.
+ * @template EVENTOBJ
* @private
*/
goog.events.listen_ = function(
- src, type, listener, callOnce, opt_capt, opt_handler) {
+ src, type, listener, callOnce, opt_options, opt_handler) {
if (!type) {
throw Error('Invalid event type');
}
- var capture = !!opt_capt;
+ var capture =
+ goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
if (capture && !goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT) {
if (goog.events.CAPTURE_SIMULATION_MODE ==
goog.events.CaptureSimulationMode.OFF_AND_FAIL) {
@@ -233,8 +238,8 @@ goog.events.listen_ = function(
new goog.events.ListenerMap(src);
}
- var listenerObj =
- listenerMap.add(type, listener, callOnce, opt_capt, opt_handler);
+ var listenerObj = /** @type {goog.events.Listener} */ (
+ listenerMap.add(type, listener, callOnce, capture, opt_handler));
// If the listenerObj already has a proxy, it has been set up
// previously. We simply return.
@@ -250,7 +255,13 @@ goog.events.listen_ = function(
// Attach the proxy through the browser's API
if (src.addEventListener) {
- src.addEventListener(type.toString(), proxy, capture);
+ // Don't pass an object as `capture` if the browser doesn't support that.
+ if (!goog.events.BrowserFeature.PASSIVE_EVENTS) {
+ opt_options = capture;
+ }
+ // Don't break tests that expect a boolean.
+ if (opt_options === undefined) opt_options = false;
+ src.addEventListener(type.toString(), proxy, opt_options);
} else if (src.attachEvent) {
// The else if above used to be an unconditional else. It would call
// exception on IE11, spoiling the day of some callers. The previous
@@ -310,29 +321,31 @@ goog.events.getProxy = function() {
* type Event type or array of event types.
* @param {function(this:T, EVENTOBJ):?|{handleEvent:function(?):?}|null}
* listener Callback method.
- * @param {boolean=} opt_capt Fire in capture phase?.
+ * @param {(boolean|!AddEventListenerOptions)=} opt_options
* @param {T=} opt_handler Element in whose scope to call the listener.
* @return {goog.events.Key} Unique key for the listener.
* @template T,EVENTOBJ
*/
-goog.events.listenOnce = function(src, type, listener, opt_capt, opt_handler) {
+goog.events.listenOnce = function(
+ src, type, listener, opt_options, opt_handler) {
if (goog.isArray(type)) {
for (var i = 0; i < type.length; i++) {
- goog.events.listenOnce(src, type[i], listener, opt_capt, opt_handler);
+ goog.events.listenOnce(src, type[i], listener, opt_options, opt_handler);
}
return null;
}
listener = goog.events.wrapListener(listener);
if (goog.events.Listenable.isImplementedBy(src)) {
+ var capture =
+ goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
return src.listenOnce(
- /** @type {string|!goog.events.EventId} */ (type), listener, opt_capt,
+ /** @type {string|!goog.events.EventId} */ (type), listener, capture,
opt_handler);
} else {
return goog.events.listen_(
- /** @type {!EventTarget} */ (src),
- /** @type {string|!goog.events.EventId} */ (type), listener,
- /* callOnce */ true, opt_capt, opt_handler);
+ /** @type {!EventTarget} */ (src), type, listener,
+ /* callOnce */ true, opt_options, opt_handler);
}
};
@@ -368,25 +381,27 @@ goog.events.listenWithWrapper = function(
* type Event type or array of event types to unlisten to.
* @param {function(?):?|{handleEvent:function(?):?}|null} listener The
* listener function to remove.
- * @param {boolean=} opt_capt In DOM-compliant browsers, this determines
+ * @param {(boolean|!EventListenerOptions)=} opt_options
* whether the listener is fired during the capture or bubble phase of the
* event.
* @param {Object=} opt_handler Element in whose scope to call the listener.
* @return {?boolean} indicating whether the listener was there to remove.
* @template EVENTOBJ
*/
-goog.events.unlisten = function(src, type, listener, opt_capt, opt_handler) {
+goog.events.unlisten = function(src, type, listener, opt_options, opt_handler) {
if (goog.isArray(type)) {
for (var i = 0; i < type.length; i++) {
- goog.events.unlisten(src, type[i], listener, opt_capt, opt_handler);
+ goog.events.unlisten(src, type[i], listener, opt_options, opt_handler);
}
return null;
}
+ var capture =
+ goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
listener = goog.events.wrapListener(listener);
if (goog.events.Listenable.isImplementedBy(src)) {
return src.unlisten(
- /** @type {string|!goog.events.EventId} */ (type), listener, opt_capt,
+ /** @type {string|!goog.events.EventId} */ (type), listener, capture,
opt_handler);
}
@@ -396,7 +411,6 @@ goog.events.unlisten = function(src, type, listener, opt_capt, opt_handler) {
return false;
}
- var capture = !!opt_capt;
var listenerMap = goog.events.getListenerMap_(
/** @type {!EventTarget} */ (src));
if (listenerMap) {
@@ -461,7 +475,7 @@ goog.events.unlistenByKey = function(key) {
src[goog.events.LISTENER_MAP_PROP_] = null;
}
} else {
- listener.markAsRemoved();
+ /** @type {!goog.events.Listener} */ (listener).markAsRemoved();
}
return true;
@@ -718,7 +732,7 @@ goog.events.fireListeners_ = function(obj, type, capture, eventObject) {
*
* @param {goog.events.Listener} listener The listener object to call.
* @param {Object} eventObject The event object to pass to the listener.
- * @return {boolean} Result of listener.
+ * @return {*} Result of listener.
*/
goog.events.fireListener = function(listener, eventObject) {
var listenerFn = listener.listener;
@@ -789,7 +803,7 @@ goog.events.protectBrowserEventEntryPoint = function(errorHandler) {
* @param {goog.events.Listener} listener The listener object.
* @param {Event=} opt_evt Optional event object that gets passed in via the
* native event handlers.
- * @return {boolean} Result of the event handler.
+ * @return {*} Result of the event handler.
* @this {EventTarget} The object or Element that fired the event.
* @private
*/
@@ -804,7 +818,7 @@ goog.events.handleBrowserEvent_ = function(listener, opt_evt) {
var ieEvent = opt_evt ||
/** @type {Event} */ (goog.getObjectByName('window.event'));
var evt = new goog.events.BrowserEvent(ieEvent, this);
- /** @type {boolean} */
+ /** @type {*} */
var retval = true;
if (goog.events.CAPTURE_SIMULATION_MODE ==
@@ -880,7 +894,7 @@ goog.events.markIeEvent_ = function(e) {
// We could test that that is the case but that would allocate 3 objects.
// If we use try/catch we will only allocate extra objects in the case of a
// failure.
- /** @preserveTry */
+
try {
e.keyCode = -1;
return;
diff --git a/assets/viz/2/goog/events/eventtype.js b/assets/viz/2/goog/events/eventtype.js
index 161e88a..7d991ea 100644
--- a/assets/viz/2/goog/events/eventtype.js
+++ b/assets/viz/2/goog/events/eventtype.js
@@ -55,8 +55,10 @@ goog.events.EventType = {
MOUSEMOVE: 'mousemove',
MOUSEENTER: 'mouseenter',
MOUSELEAVE: 'mouseleave',
- // Select start is non-standard.
- // See http://msdn.microsoft.com/en-us/library/ie/ms536969(v=vs.85).aspx.
+
+ // Selection events.
+ // https://www.w3.org/TR/selection-api/
+ SELECTIONCHANGE: 'selectionchange',
SELECTSTART: 'selectstart', // IE, Safari, Chrome
// Wheel events
@@ -112,6 +114,8 @@ goog.events.EventType = {
BEFOREUNLOAD: 'beforeunload',
CONSOLEMESSAGE: 'consolemessage',
CONTEXTMENU: 'contextmenu',
+ DEVICEMOTION: 'devicemotion',
+ DEVICEORIENTATION: 'deviceorientation',
DOMCONTENTLOADED: 'DOMContentLoaded',
ERROR: 'error',
HELP: 'help',
@@ -121,9 +125,39 @@ goog.events.EventType = {
READYSTATECHANGE: 'readystatechange',
RESIZE: 'resize',
SCROLL: 'scroll',
- TIMEUPDATE: 'timeupdate',
UNLOAD: 'unload',
+ // Media events
+ CANPLAY: 'canplay',
+ CANPLAYTHROUGH: 'canplaythrough',
+ DURATIONCHANGE: 'durationchange',
+ EMPTIED: 'emptied',
+ ENDED: 'ended',
+ LOADEDDATA: 'loadeddata',
+ LOADEDMETADATA: 'loadedmetadata',
+ PAUSE: 'pause',
+ PLAY: 'play',
+ PLAYING: 'playing',
+ RATECHANGE: 'ratechange',
+ SEEKED: 'seeked',
+ SEEKING: 'seeking',
+ STALLED: 'stalled',
+ SUSPEND: 'suspend',
+ TIMEUPDATE: 'timeupdate',
+ VOLUMECHANGE: 'volumechange',
+ WAITING: 'waiting',
+
+ // Media Source Extensions events
+ // https://www.w3.org/TR/media-source/#mediasource-events
+ SOURCEOPEN: 'sourceopen',
+ SOURCEENDED: 'sourceended',
+ SOURCECLOSED: 'sourceclosed',
+ // https://www.w3.org/TR/media-source/#sourcebuffer-events
+ ABORT: 'abort',
+ UPDATE: 'update',
+ UPDATESTART: 'updatestart',
+ UPDATEEND: 'updateend',
+
// HTML 5 History events
// See http://www.w3.org/TR/html5/browsers.html#event-definitions-0
HASHCHANGE: 'hashchange',
@@ -151,6 +185,21 @@ goog.events.EventType = {
MESSAGE: 'message',
CONNECT: 'connect',
+ // Service Worker Events - ServiceWorkerGlobalScope context
+ // See https://w3c.github.io/ServiceWorker/#execution-context-events
+ // Note: message event defined in worker events section
+ INSTALL: 'install',
+ ACTIVATE: 'activate',
+ FETCH: 'fetch',
+ FOREIGNFETCH: 'foreignfetch',
+ MESSAGEERROR: 'messageerror',
+
+ // Service Worker Events - Document context
+ // See https://w3c.github.io/ServiceWorker/#document-context-events
+ STATECHANGE: 'statechange',
+ UPDATEFOUND: 'updatefound',
+ CONTROLLERCHANGE: 'controllerchange',
+
// CSS animation events.
/** @suppress {missingRequire} */
ANIMATIONSTART: goog.events.getVendorPrefixedName_('AnimationStart'),
@@ -200,11 +249,18 @@ goog.events.EventType = {
// Native IMEs/input tools events.
TEXT: 'text',
- TEXTINPUT: 'textInput',
+ // The textInput event is supported in IE9+, but only in lower case. All other
+ // browsers use the camel-case event name.
+ TEXTINPUT: goog.userAgent.IE ? 'textinput' : 'textInput',
COMPOSITIONSTART: 'compositionstart',
COMPOSITIONUPDATE: 'compositionupdate',
COMPOSITIONEND: 'compositionend',
+ // The beforeinput event is initially only supported in Safari. See
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=342670 for Chrome
+ // implementation tracking.
+ BEFOREINPUT: 'beforeinput',
+
// Webview tag events
// See http://developer.chrome.com/dev/apps/webview_tag.html
EXIT: 'exit',
diff --git a/assets/viz/2/goog/events/listenable.js b/assets/viz/2/goog/events/listenable.js
index 648d9fc..0f29d81 100644
--- a/assets/viz/2/goog/events/listenable.js
+++ b/assets/viz/2/goog/events/listenable.js
@@ -75,8 +75,8 @@ goog.events.Listenable.IMPLEMENTED_BY_PROP =
* Marks a given class (constructor) as an implementation of
* Listenable, do that we can query that fact at runtime. The class
* must have already implemented the interface.
- * @param {!Function} cls The class constructor. The corresponding
- * class must have already implemented the interface.
+ * @param {!function(new:goog.events.Listenable,...)} cls The class constructor.
+ * The corresponding class must have already implemented the interface.
*/
goog.events.Listenable.addImplementation = function(cls) {
cls.prototype[goog.events.Listenable.IMPLEMENTED_BY_PROP] = true;
diff --git a/assets/viz/2/goog/events/listener.js b/assets/viz/2/goog/events/listener.js
index 60c7370..5ac7b85 100644
--- a/assets/viz/2/goog/events/listener.js
+++ b/assets/viz/2/goog/events/listener.js
@@ -25,7 +25,7 @@ goog.require('goog.events.ListenableKey');
/**
* Simple class that stores information about a listener
- * @param {!Function} listener Callback function.
+ * @param {function(?):?} listener Callback function.
* @param {Function} proxy Wrapper for the listener that patches the event.
* @param {EventTarget|goog.events.Listenable} src Source object for
* the event.
@@ -41,10 +41,7 @@ goog.events.Listener = function(
this.creationStack = new Error().stack;
}
- /**
- * Callback function.
- * @type {Function}
- */
+ /** @override */
this.listener = listener;
/**
diff --git a/assets/viz/2/goog/events/listenermap.js b/assets/viz/2/goog/events/listenermap.js
index 40cb848..0375cf2 100644
--- a/assets/viz/2/goog/events/listenermap.js
+++ b/assets/viz/2/goog/events/listenermap.js
@@ -20,6 +20,7 @@
* WARNING: Do not use this class from outside goog.events package.
*
* @visibility {//closure/goog/bin/sizetests:__pkg__}
+ * @visibility {//closure/goog:__pkg__}
* @visibility {//closure/goog/events:__pkg__}
* @visibility {//closure/goog/labs/events:__pkg__}
*/
@@ -170,7 +171,7 @@ goog.events.ListenerMap.prototype.removeByKey = function(listener) {
var removed = goog.array.remove(this.listeners[type], listener);
if (removed) {
- listener.markAsRemoved();
+ /** @type {!goog.events.Listener} */ (listener).markAsRemoved();
if (this.listeners[type].length == 0) {
delete this.listeners[type];
this.typeCount_--;