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

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: Move RemoteObject onto EventListener 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 this.runtimeModel.dispatchEventToListeners(WebInspector.RuntimeModel.Eve nts.ExecutionContextChanged, this); 707 this.runtimeModel.dispatchEventToListeners(WebInspector.RuntimeModel.Eve nts.ExecutionContextChanged, this);
708 }, 708 },
709 709
710 __proto__: WebInspector.SDKObject.prototype 710 __proto__: WebInspector.SDKObject.prototype
711 } 711 }
712 712
713 /** 713 /**
714 * @constructor 714 * @constructor
715 * @extends {WebInspector.SDKObject} 715 * @extends {WebInspector.SDKObject}
716 * @param {!WebInspector.Target} target 716 * @param {!WebInspector.Target} target
717 * @param {!WebInspector.RemoteObject} registeredTarget
caseq 2016/06/02 19:40:27 nit: eventTarget, perhaps?
dtapuska 2016/06/02 20:10:35 Done.
717 * @param {string} type 718 * @param {string} type
718 * @param {boolean} useCapture 719 * @param {boolean} useCapture
719 * @param {boolean} passive 720 * @param {boolean} passive
720 * @param {?WebInspector.RemoteObject} handler 721 * @param {?WebInspector.RemoteObject} handler
721 * @param {?WebInspector.RemoteObject} originalHandler 722 * @param {?WebInspector.RemoteObject} originalHandler
722 * @param {!WebInspector.DebuggerModel.Location} location 723 * @param {!WebInspector.DebuggerModel.Location} location
723 * @param {?WebInspector.RemoteObject} removeFunction 724 * @param {?WebInspector.RemoteObject} removeFunction
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, registeredTarget, type, useCapture , passive, handler, originalHandler, location, removeFunction, listenerType)
727 { 728 {
728 WebInspector.SDKObject.call(this, target); 729 WebInspector.SDKObject.call(this, target);
730 this._registeredTarget = registeredTarget;
729 this._type = type; 731 this._type = type;
730 this._useCapture = useCapture; 732 this._useCapture = useCapture;
731 this._passive = passive; 733 this._passive = passive;
732 this._handler = handler; 734 this._handler = handler;
733 this._originalHandler = originalHandler || handler; 735 this._originalHandler = originalHandler || handler;
734 this._location = location; 736 this._location = location;
735 var script = location.script(); 737 var script = location.script();
736 this._sourceURL = script ? script.contentURL() : ""; 738 this._sourceURL = script ? script.contentURL() : "";
737 this._removeFunction = removeFunction; 739 this._removeFunction = removeFunction;
738 this._listenerType = listenerType || "normal"; 740 this._listenerType = listenerType || "normal";
(...skipping 95 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 {!Promise<undefined>}
847 */
848 togglePassive: function()
849 {
850 return new Promise(promiseConstructor.bind(this));
851
852 /**
853 * @param {function()} success
854 * @this {WebInspector.EventListener}
855 */
856 function promiseConstructor(success)
857 {
858 this._registeredTarget.callFunctionPromise(callTogglePassive, [
859 WebInspector.RemoteObject.toCallArgument(this._type),
860 WebInspector.RemoteObject.toCallArgument(this._originalHandler),
861 WebInspector.RemoteObject.toCallArgument(this._useCapture),
862 WebInspector.RemoteObject.toCallArgument(this._passive),
863 ]).then(success);
864
865 /**
866 * @param {string} type
867 * @param {function()} listener
868 * @param {boolean} useCapture
869 * @param {boolean} passive
870 * @this {Object}
871 * @suppressReceiverCheck
872 */
873 function callTogglePassive(type, listener, useCapture, passive)
874 {
875 this.removeEventListener(type, listener, {capture: useCapture});
876 this.addEventListener(type, listener, {capture: useCapture, pass ive: !passive});
877 }
878 }
879 },
880
881 /**
844 * @return {string} 882 * @return {string}
845 */ 883 */
846 listenerType: function() 884 listenerType: function()
847 { 885 {
848 return this._listenerType; 886 return this._listenerType;
849 }, 887 },
850 888
851 /** 889 /**
852 * @param {string} listenerType 890 * @param {string} listenerType
853 */ 891 */
854 setListenerType: function(listenerType) 892 setListenerType: function(listenerType)
855 { 893 {
856 this._listenerType = listenerType; 894 this._listenerType = listenerType;
857 }, 895 },
858 896
897 /**
898 * @return {boolean}
899 */
900 isScrollBlockingType: function()
901 {
902 return this._type === "touchstart" ||
903 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.
904 this._type === "mousewheel" ||
905 this._type === "wheel";
906 },
907
908 /**
909 * @return {boolean}
910 */
911 isNormalListenerType: function()
912 {
913 return this._listenerType === "normal";
914 },
915
859 __proto__: WebInspector.SDKObject.prototype 916 __proto__: WebInspector.SDKObject.prototype
860 } 917 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698