Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js

Issue 2022503002: Add ability to toggle passive state on an individual event listener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move RemoteObject onto EventListener Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
index 30316e2572210c8b439622bb56c7c1da5537444e..065674fc53bdb105eb072cfb2745dca5bd23419f 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
@@ -714,6 +714,7 @@ WebInspector.ExecutionContext.prototype = {
* @constructor
* @extends {WebInspector.SDKObject}
* @param {!WebInspector.Target} target
+ * @param {!WebInspector.RemoteObject} registeredTarget
caseq 2016/06/02 19:40:27 nit: eventTarget, perhaps?
dtapuska 2016/06/02 20:10:35 Done.
* @param {string} type
* @param {boolean} useCapture
* @param {boolean} passive
@@ -723,9 +724,10 @@ WebInspector.ExecutionContext.prototype = {
* @param {?WebInspector.RemoteObject} removeFunction
* @param {string=} listenerType
*/
-WebInspector.EventListener = function(target, type, useCapture, passive, handler, originalHandler, location, removeFunction, listenerType)
+WebInspector.EventListener = function(target, registeredTarget, type, useCapture, passive, handler, originalHandler, location, removeFunction, listenerType)
{
WebInspector.SDKObject.call(this, target);
+ this._registeredTarget = registeredTarget;
this._type = type;
this._useCapture = useCapture;
this._passive = passive;
@@ -841,6 +843,42 @@ WebInspector.EventListener.prototype = {
},
/**
+ * @return {!Promise<undefined>}
+ */
+ togglePassive: function()
+ {
+ return new Promise(promiseConstructor.bind(this));
+
+ /**
+ * @param {function()} success
+ * @this {WebInspector.EventListener}
+ */
+ function promiseConstructor(success)
+ {
+ this._registeredTarget.callFunctionPromise(callTogglePassive, [
+ WebInspector.RemoteObject.toCallArgument(this._type),
+ WebInspector.RemoteObject.toCallArgument(this._originalHandler),
+ WebInspector.RemoteObject.toCallArgument(this._useCapture),
+ WebInspector.RemoteObject.toCallArgument(this._passive),
+ ]).then(success);
+
+ /**
+ * @param {string} type
+ * @param {function()} listener
+ * @param {boolean} useCapture
+ * @param {boolean} passive
+ * @this {Object}
+ * @suppressReceiverCheck
+ */
+ function callTogglePassive(type, listener, useCapture, passive)
+ {
+ this.removeEventListener(type, listener, {capture: useCapture});
+ this.addEventListener(type, listener, {capture: useCapture, passive: !passive});
+ }
+ }
+ },
+
+ /**
* @return {string}
*/
listenerType: function()
@@ -856,5 +894,24 @@ WebInspector.EventListener.prototype = {
this._listenerType = listenerType;
},
+ /**
+ * @return {boolean}
+ */
+ isScrollBlockingType: function()
+ {
+ return this._type === "touchstart" ||
+ this._type === "touchmove" ||
caseq 2016/06/02 19:40:27 wrong indent, just indent 4 spaces or fold to one
dtapuska 2016/06/02 20:10:35 Done.
+ this._type === "mousewheel" ||
+ this._type === "wheel";
+ },
+
+ /**
+ * @return {boolean}
+ */
+ isNormalListenerType: function()
+ {
+ return this._listenerType === "normal";
+ },
+
__proto__: WebInspector.SDKObject.prototype
}

Powered by Google App Engine
This is Rietveld 408576698