OLD | NEW |
---|---|
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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1129 | 1129 |
1130 return className; | 1130 return className; |
1131 }, | 1131 }, |
1132 | 1132 |
1133 /** | 1133 /** |
1134 * @param {boolean} enabled | 1134 * @param {boolean} enabled |
1135 */ | 1135 */ |
1136 setCustomObjectFormatterEnabled: function(enabled) | 1136 setCustomObjectFormatterEnabled: function(enabled) |
1137 { | 1137 { |
1138 this._customObjectFormatterEnabled = enabled; | 1138 this._customObjectFormatterEnabled = enabled; |
1139 }, | |
1140 | |
1141 /** | |
1142 * @param {string} objectId | |
1143 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n}>} | |
1144 */ | |
1145 librariesEventListenersByObjectId: function(objectId) | |
yurys
2015/08/11 21:10:24
Can you move id -> object resolution to C++ ?
kozy
2015/08/12 18:02:22
Done.
| |
1146 { | |
1147 var parsedObjectId = this._parseObjectId(objectId); | |
1148 var object = this._objectForId(parsedObjectId); | |
1149 if (this._subtype(object) === "node") | |
1150 return this.librariesEventListeners(object); | |
1151 return []; | |
1152 }, | |
1153 | |
1154 /** | |
1155 * @param {!Node} node | |
1156 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n}>} | |
1157 */ | |
1158 librariesEventListeners: function(node) | |
yurys
2015/08/11 21:10:24
frameworkEventListeners?
kozy
2015/08/12 18:02:22
Done.
| |
1159 { | |
1160 var hasJQuery = (typeof jQuery !== 'undefined') && jQuery.fn; | |
1161 if (!hasJQuery) | |
1162 return []; | |
1163 var listeners = []; | |
1164 var data = jQuery._data || jQuery.data; | |
1165 if (data) { | |
yurys
2015/08/11 21:10:24
&& typeof data === "function" ?
kozy
2015/08/12 18:02:22
Done.
| |
1166 var events = data(node, "events"); | |
1167 for (var type in events) { | |
1168 for (var key in events[type]) { | |
1169 var listener = events[type][key]; | |
1170 if (typeof listener === "object" || typeof listener === "fun ction") { | |
1171 var listener = { | |
1172 handler: listener.handler || listener, | |
1173 useCapture: true, | |
1174 type: type | |
1175 } | |
1176 listeners.push(listener); | |
yurys
2015/08/11 21:10:24
push(listeners, listener); to avoid calling push o
kozy
2015/08/12 18:02:22
Done.
| |
1177 } | |
1178 } | |
1179 } | |
1180 } | |
1181 var entry = jQuery(node)[0]; | |
1182 if (entry) { | |
1183 var entryEvents = entry["$events"]; | |
1184 for (var type in entryEvents) { | |
1185 var events = entryEvents[type]; | |
1186 for (var key in events) { | |
1187 if (typeof events[key] === "function") { | |
yurys
2015/08/11 21:10:24
wrong alignment
kozy
2015/08/12 18:02:22
Done.
| |
1188 var listener = { | |
1189 handler: events[key], | |
1190 useCapture: true, | |
1191 type: type | |
1192 } | |
1193 listeners.push(listener); | |
1194 } | |
1195 } | |
1196 } | |
1197 } | |
1198 return listeners; | |
1139 } | 1199 } |
1140 } | 1200 } |
1141 | 1201 |
1142 /** | 1202 /** |
1143 * @type {!InjectedScript} | 1203 * @type {!InjectedScript} |
1144 * @const | 1204 * @const |
1145 */ | 1205 */ |
1146 var injectedScript = new InjectedScript(); | 1206 var injectedScript = new InjectedScript(); |
1147 | 1207 |
1148 /** | 1208 /** |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1842 | 1902 |
1843 /** | 1903 /** |
1844 * @param {!Node} node | 1904 * @param {!Node} node |
1845 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n, remove: function()}>|undefined} | 1905 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n, remove: function()}>|undefined} |
1846 */ | 1906 */ |
1847 getEventListeners: function(node) | 1907 getEventListeners: function(node) |
1848 { | 1908 { |
1849 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod e)); | 1909 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod e)); |
1850 if (!result) | 1910 if (!result) |
1851 return result; | 1911 return result; |
1912 | |
1913 var jQueryListeners = injectedScript.librariesEventListeners(node); | |
1914 for (var i = 0; i < jQueryListeners.length; ++i) { | |
1915 result[jQueryListeners[i].type] = result[jQueryListeners[i].type] || []; | |
1916 result[jQueryListeners[i].type].push(jQueryListeners[i]); | |
1917 } | |
1852 /** @this {{type: string, listener: function(), useCapture: boolean}} */ | 1918 /** @this {{type: string, listener: function(), useCapture: boolean}} */ |
1853 var removeFunc = function() | 1919 var removeFunc = function() |
1854 { | 1920 { |
1855 node.removeEventListener(this.type, this.listener, this.useCapture); | 1921 node.removeEventListener(this.type, this.listener, this.useCapture); |
1856 } | 1922 } |
1857 for (var type in result) { | 1923 for (var type in result) { |
1858 var listeners = result[type]; | 1924 var listeners = result[type]; |
1859 for (var i = 0, listener; listener = listeners[i]; ++i) { | 1925 for (var i = 0, listener; listener = listeners[i]; ++i) { |
1860 listener["type"] = type; | 1926 listener["type"] = type; |
1861 listener["remove"] = removeFunc; | 1927 listener["remove"] = removeFunc; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 */ | 1997 */ |
1932 _logEvent: function(event) | 1998 _logEvent: function(event) |
1933 { | 1999 { |
1934 inspectedGlobalObject.console.log(event.type, event); | 2000 inspectedGlobalObject.console.log(event.type, event); |
1935 } | 2001 } |
1936 } | 2002 } |
1937 | 2003 |
1938 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 2004 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1939 return injectedScript; | 2005 return injectedScript; |
1940 }) | 2006 }) |
OLD | NEW |