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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js

Issue 1999843002: [DevTools] Move CommandLineAPI.getEventListeners to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-monitor-events-to-native
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 514 }
515 515
516 for (var i = 0; i < jsonMLObject.length; ++i) 516 for (var i = 0; i < jsonMLObject.length; ++i)
517 this._substituteObjectTagsInCustomPreview(objectGroupName, jsonM LObject[i]); 517 this._substituteObjectTagsInCustomPreview(objectGroupName, jsonM LObject[i]);
518 } finally { 518 } finally {
519 this._customPreviewRecursionDepth--; 519 this._customPreviewRecursionDepth--;
520 } 520 }
521 }, 521 },
522 522
523 /** 523 /**
524 * @param {!Object} nativeCommandLineAPI
525 * @return {!Object}
526 */
527 installCommandLineAPI: function(nativeCommandLineAPI)
528 {
529 // NOTE: This list contains only not native Command Line API methods. Fo r full list: V8Console.
530 nativeCommandLineAPI["getEventListeners"] = CommandLineAPIImpl["getEvent Listeners"];
531 return nativeCommandLineAPI;
532 },
533
534 /**
535 * @param {*} object 524 * @param {*} object
536 * @return {boolean} 525 * @return {boolean}
537 */ 526 */
538 _isDefined: function(object) 527 _isDefined: function(object)
539 { 528 {
540 return !!object || this._isHTMLAllCollection(object); 529 return !!object || this._isHTMLAllCollection(object);
541 }, 530 },
542 531
543 /** 532 /**
544 * @param {*} object 533 * @param {*} object
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 var leftHalf = maxLength >> 1; 999 var leftHalf = maxLength >> 1;
1011 var rightHalf = maxLength - leftHalf - 1; 1000 var rightHalf = maxLength - leftHalf - 1;
1012 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); 1001 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf);
1013 } 1002 }
1014 return string.substr(0, maxLength) + "\u2026"; 1003 return string.substr(0, maxLength) + "\u2026";
1015 }, 1004 },
1016 1005
1017 __proto__: null 1006 __proto__: null
1018 } 1007 }
1019 1008
1020 var CommandLineAPIImpl = { __proto__: null }
1021
1022 /**
1023 * @param {!Node} node
1024 * @return {!Object|undefined}
1025 */
1026 CommandLineAPIImpl.getEventListeners = function(node)
1027 {
1028 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(node));
1029 if (!result)
1030 return;
1031
1032 // TODO(dtapuska): Remove this one closure compiler is updated
1033 // to handle EventListenerOptions and passive event listeners
1034 // has shipped. Don't JSDoc these otherwise it will fail.
1035 // @param {boolean} capture
1036 // @param {boolean} passive
1037 // @return {boolean|undefined|{capture: (boolean|undefined), passive: boolea n}}
1038 function eventListenerOptions(capture, passive)
1039 {
1040 return {"capture": capture, "passive": passive};
1041 }
1042
1043 /**
1044 * @param {!Node} node
1045 * @param {string} type
1046 * @param {function()} listener
1047 * @param {boolean} capture
1048 * @param {boolean} passive
1049 */
1050 function removeEventListenerWrapper(node, type, listener, capture, passive)
1051 {
1052 node.removeEventListener(type, listener, eventListenerOptions(capture, p assive));
1053 }
1054
1055 /** @this {{type: string, listener: function(), useCapture: boolean, passive : boolean}} */
1056 var removeFunc = function()
1057 {
1058 removeEventListenerWrapper(node, this.type, this.listener, this.useCaptu re, this.passive);
1059 }
1060 for (var type in result) {
1061 var listeners = result[type];
1062 for (var i = 0, listener; listener = listeners[i]; ++i) {
1063 listener["type"] = type;
1064 listener["remove"] = removeFunc;
1065 }
1066 }
1067 return result;
1068 }
1069
1070 CommandLineAPIImpl.getEventListeners.toString = (() => "function getEventListene rs(node) { [Command Line API] }");
1071
1072 return injectedScript; 1009 return injectedScript;
1073 }) 1010 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698