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

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: Fix layout tests 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 5b8888679ee865e76c3d34e12b5d0ea568549658..c83a4fa67a2597511dc650d7421fe9c6b2c13c81 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} eventTarget
* @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, eventTarget, type, useCapture, passive, handler, originalHandler, location, removeFunction, listenerType)
{
WebInspector.SDKObject.call(this, target);
+ this._eventTarget = eventTarget;
this._type = type;
this._useCapture = useCapture;
this._passive = passive;
@@ -832,6 +834,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._eventTarget.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()
@@ -847,5 +885,21 @@ WebInspector.EventListener.prototype = {
this._listenerType = listenerType;
},
+ /**
+ * @return {boolean}
+ */
+ isScrollBlockingType: function()
+ {
+ return this._type === "touchstart" || this._type === "touchmove" || 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