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

Side by Side 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: Limit Toggle Passive to touchstart, touchmove, mousewheel, wheel Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 * @constructor 714 * @constructor
715 * @extends {WebInspector.SDKObject} 715 * @extends {WebInspector.SDKObject}
716 * @param {!WebInspector.Target} target 716 * @param {!WebInspector.Target} target
717 * @param {string} type 717 * @param {string} type
718 * @param {boolean} useCapture 718 * @param {boolean} useCapture
719 * @param {boolean} passive 719 * @param {boolean} passive
720 * @param {?WebInspector.RemoteObject} handler 720 * @param {?WebInspector.RemoteObject} handler
721 * @param {?WebInspector.RemoteObject} originalHandler 721 * @param {?WebInspector.RemoteObject} originalHandler
722 * @param {!WebInspector.DebuggerModel.Location} location 722 * @param {!WebInspector.DebuggerModel.Location} location
723 * @param {?WebInspector.RemoteObject} removeFunction 723 * @param {?WebInspector.RemoteObject} removeFunction
724 * @param {?WebInspector.RemoteObject} togglePassiveFunction
724 * @param {string=} listenerType 725 * @param {string=} listenerType
725 */ 726 */
726 WebInspector.EventListener = function(target, type, useCapture, passive, handler , originalHandler, location, removeFunction, listenerType) 727 WebInspector.EventListener = function(target, type, useCapture, passive, handler , originalHandler, location, removeFunction, togglePassiveFunction, listenerType )
727 { 728 {
728 WebInspector.SDKObject.call(this, target); 729 WebInspector.SDKObject.call(this, target);
729 this._type = type; 730 this._type = type;
730 this._useCapture = useCapture; 731 this._useCapture = useCapture;
731 this._passive = passive; 732 this._passive = passive;
732 this._handler = handler; 733 this._handler = handler;
733 this._originalHandler = originalHandler || handler; 734 this._originalHandler = originalHandler || handler;
734 this._location = location; 735 this._location = location;
735 var script = location.script(); 736 var script = location.script();
736 this._sourceURL = script ? script.contentURL() : ""; 737 this._sourceURL = script ? script.contentURL() : "";
737 this._removeFunction = removeFunction; 738 this._removeFunction = removeFunction;
739 this._togglePassiveFunction = togglePassiveFunction;
738 this._listenerType = listenerType || "normal"; 740 this._listenerType = listenerType || "normal";
739 } 741 }
740 742
741 WebInspector.EventListener.prototype = { 743 WebInspector.EventListener.prototype = {
742 /** 744 /**
743 * @return {string} 745 * @return {string}
744 */ 746 */
745 type: function() 747 type: function()
746 { 748 {
747 return this._type; 749 return this._type;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 * @param {boolean} passive 836 * @param {boolean} passive
835 */ 837 */
836 function callCustomRemove(func, type, listener, useCapture, passive) 838 function callCustomRemove(func, type, listener, useCapture, passive)
837 { 839 {
838 func.call(null, type, listener, useCapture, passive); 840 func.call(null, type, listener, useCapture, passive);
839 } 841 }
840 } 842 }
841 }, 843 },
842 844
843 /** 845 /**
846 * @return {?WebInspector.RemoteObject}
847 */
848 togglePassiveFunction: function()
caseq 2016/06/01 17:48:11 I don't think this is something we should expose -
dtapuska 2016/06/01 17:54:37 About merging them... I wanted to separate the cho
849 {
850 return this._togglePassiveFunction;
851 },
852
853 /**
854 * @return {!Promise<undefined>}
855 */
856 togglePassive: function()
857 {
858 if (!this._togglePassiveFunction)
859 return Promise.resolve();
860 return new Promise(promiseConstructor.bind(this));
861
862 /**
863 * @param {function()} success
864 * @this {WebInspector.EventListener}
865 */
866 function promiseConstructor(success)
867 {
868 this._togglePassiveFunction.callFunction(callCustomRemove, [
869 WebInspector.RemoteObject.toCallArgument(this._togglePassiveFunc tion),
870 WebInspector.RemoteObject.toCallArgument(this._type),
871 WebInspector.RemoteObject.toCallArgument(this._originalHandler),
872 WebInspector.RemoteObject.toCallArgument(this._useCapture),
873 WebInspector.RemoteObject.toCallArgument(this._passive),
874 ], success);
875
876 /**
877 * @param {function(string, function(), boolean, boolean)} func
878 * @param {string} type
879 * @param {function()} listener
880 * @param {boolean} useCapture
881 * @param {boolean} passive
882 */
883 function callCustomRemove(func, type, listener, useCapture, passive)
caseq 2016/06/01 17:48:11 copy-paste hurts :-) Perhaps, extract something li
dtapuska 2016/06/02 16:02:11 Done.
884 {
885 func.call(null, type, listener, useCapture, passive);
886 }
887 }
888 },
889
890 /**
844 * @return {string} 891 * @return {string}
845 */ 892 */
846 listenerType: function() 893 listenerType: function()
847 { 894 {
848 return this._listenerType; 895 return this._listenerType;
849 }, 896 },
850 897
851 /** 898 /**
852 * @param {string} listenerType 899 * @param {string} listenerType
853 */ 900 */
854 setListenerType: function(listenerType) 901 setListenerType: function(listenerType)
855 { 902 {
856 this._listenerType = listenerType; 903 this._listenerType = listenerType;
857 }, 904 },
858 905
906 /**
907 * @return {boolean}
908 */
909 isScrollBlockingType: function()
910 {
911 return this._type == "touchstart" ||
caseq 2016/06/01 17:48:11 s/==/===/g
dtapuska 2016/06/02 16:02:11 Done.
912 this._type == "touchmove" ||
913 this._type == "mousewheel" ||
914 this._type == "wheel";
915 },
916
859 __proto__: WebInspector.SDKObject.prototype 917 __proto__: WebInspector.SDKObject.prototype
860 } 918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698