| OLD | NEW |
| 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 Loading... |
| 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} eventTarget |
| 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, eventTarget, type, useCapture, pas
sive, handler, originalHandler, location, removeFunction, listenerType) |
| 727 { | 728 { |
| 728 WebInspector.SDKObject.call(this, target); | 729 WebInspector.SDKObject.call(this, target); |
| 730 this._eventTarget = eventTarget; |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 * @this {Function} | 827 * @this {Function} |
| 826 * @suppressReceiverCheck | 828 * @suppressReceiverCheck |
| 827 */ | 829 */ |
| 828 function callCustomRemove(type, listener, useCapture, passive) | 830 function callCustomRemove(type, listener, useCapture, passive) |
| 829 { | 831 { |
| 830 this.call(null, type, listener, useCapture, passive); | 832 this.call(null, type, listener, useCapture, passive); |
| 831 } | 833 } |
| 832 }, | 834 }, |
| 833 | 835 |
| 834 /** | 836 /** |
| 837 * @return {!Promise<undefined>} |
| 838 */ |
| 839 togglePassive: function() |
| 840 { |
| 841 return new Promise(promiseConstructor.bind(this)); |
| 842 |
| 843 /** |
| 844 * @param {function()} success |
| 845 * @this {WebInspector.EventListener} |
| 846 */ |
| 847 function promiseConstructor(success) |
| 848 { |
| 849 this._eventTarget.callFunctionPromise(callTogglePassive, [ |
| 850 WebInspector.RemoteObject.toCallArgument(this._type), |
| 851 WebInspector.RemoteObject.toCallArgument(this._originalHandler), |
| 852 WebInspector.RemoteObject.toCallArgument(this._useCapture), |
| 853 WebInspector.RemoteObject.toCallArgument(this._passive), |
| 854 ]).then(success); |
| 855 |
| 856 /** |
| 857 * @param {string} type |
| 858 * @param {function()} listener |
| 859 * @param {boolean} useCapture |
| 860 * @param {boolean} passive |
| 861 * @this {Object} |
| 862 * @suppressReceiverCheck |
| 863 */ |
| 864 function callTogglePassive(type, listener, useCapture, passive) |
| 865 { |
| 866 this.removeEventListener(type, listener, {capture: useCapture}); |
| 867 this.addEventListener(type, listener, {capture: useCapture, pass
ive: !passive}); |
| 868 } |
| 869 } |
| 870 }, |
| 871 |
| 872 /** |
| 835 * @return {string} | 873 * @return {string} |
| 836 */ | 874 */ |
| 837 listenerType: function() | 875 listenerType: function() |
| 838 { | 876 { |
| 839 return this._listenerType; | 877 return this._listenerType; |
| 840 }, | 878 }, |
| 841 | 879 |
| 842 /** | 880 /** |
| 843 * @param {string} listenerType | 881 * @param {string} listenerType |
| 844 */ | 882 */ |
| 845 setListenerType: function(listenerType) | 883 setListenerType: function(listenerType) |
| 846 { | 884 { |
| 847 this._listenerType = listenerType; | 885 this._listenerType = listenerType; |
| 848 }, | 886 }, |
| 849 | 887 |
| 888 /** |
| 889 * @return {boolean} |
| 890 */ |
| 891 isScrollBlockingType: function() |
| 892 { |
| 893 return this._type === "touchstart" || this._type === "touchmove" || this
._type === "mousewheel" || this._type === "wheel"; |
| 894 }, |
| 895 |
| 896 /** |
| 897 * @return {boolean} |
| 898 */ |
| 899 isNormalListenerType: function() |
| 900 { |
| 901 return this._listenerType === "normal"; |
| 902 }, |
| 903 |
| 850 __proto__: WebInspector.SDKObject.prototype | 904 __proto__: WebInspector.SDKObject.prototype |
| 851 } | 905 } |
| OLD | NEW |