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 {!Node} node | |
1143 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n}>} | |
1144 */ | |
1145 frameworkEventListeners: function(node) | |
yurys
2015/08/12 21:56:03
It'd be nice if we can have this code outside of I
| |
1146 { | |
1147 var hasJQuery = (typeof inspectedGlobalObject.jQuery !== 'undefined') && inspectedGlobalObject.jQuery.fn; | |
1148 if (!hasJQuery) | |
1149 return []; | |
1150 var listeners = []; | |
1151 var data = inspectedGlobalObject.jQuery._data || inspectedGlobalObject.j Query.data; | |
1152 if (typeof data === "function") { | |
1153 var events = data(node, "events"); | |
1154 for (var type in events) { | |
1155 for (var key in events[type]) { | |
1156 var frameworkListener = events[type][key]; | |
1157 if (typeof frameworkListener === "object" || typeof framewor kListener === "function") { | |
1158 var listener = { | |
1159 handler: frameworkListener.handler || frameworkListe ner, | |
1160 useCapture: true, | |
1161 type: type | |
1162 } | |
1163 push(listeners, listener); | |
1164 } | |
1165 } | |
1166 } | |
1167 } | |
1168 var entry = inspectedGlobalObject.jQuery(node)[0]; | |
1169 if (entry) { | |
1170 var entryEvents = entry["$events"]; | |
1171 for (var type in entryEvents) { | |
1172 var events = entryEvents[type]; | |
1173 for (var key in events) { | |
1174 if (typeof events[key] === "function") { | |
1175 var listener = { | |
1176 handler: events[key], | |
1177 useCapture: true, | |
1178 type: type | |
1179 } | |
1180 push(listeners, listener); | |
1181 } | |
1182 } | |
1183 } | |
1184 } | |
1185 return listeners; | |
1186 }, | |
1187 | |
1188 /** | |
1189 * @param {!Node} node | |
1190 * @return {!Set<function()>} | |
1191 */ | |
1192 frameworkEventHandlers: function(node) | |
1193 { | |
1194 var hasJQuery = (typeof inspectedGlobalObject.jQuery !== 'undefined') && inspectedGlobalObject.jQuery.fn; | |
1195 if (!hasJQuery) | |
1196 return new Set(); | |
1197 var handlers = []; | |
1198 var data = inspectedGlobalObject.jQuery._data || inspectedGlobalObject.j Query.data; | |
1199 if (typeof data === "function") { | |
1200 var nodeData = data(node); | |
1201 if (typeof nodeData.handle === "function") { | |
1202 push(handlers, nodeData.handle); | |
1203 } | |
1204 } | |
1205 var entry = inspectedGlobalObject.jQuery(node)[0]; | |
1206 if (entry) { | |
1207 var entryHandle = entry["$handle"]; | |
1208 push(handlers, entryHandle); | |
1209 } | |
1210 return new Set(handlers); | |
1139 } | 1211 } |
1140 } | 1212 } |
1141 | 1213 |
1142 /** | 1214 /** |
1143 * @type {!InjectedScript} | 1215 * @type {!InjectedScript} |
1144 * @const | 1216 * @const |
1145 */ | 1217 */ |
1146 var injectedScript = new InjectedScript(); | 1218 var injectedScript = new InjectedScript(); |
1147 | 1219 |
1148 /** | 1220 /** |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1842 | 1914 |
1843 /** | 1915 /** |
1844 * @param {!Node} node | 1916 * @param {!Node} node |
1845 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n, remove: function()}>|undefined} | 1917 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n, remove: function()}>|undefined} |
1846 */ | 1918 */ |
1847 getEventListeners: function(node) | 1919 getEventListeners: function(node) |
1848 { | 1920 { |
1849 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod e)); | 1921 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod e)); |
1850 if (!result) | 1922 if (!result) |
1851 return result; | 1923 return result; |
1924 | |
1925 var jQueryListeners = injectedScript.frameworkEventListeners(node); | |
1926 for (var i = 0; i < jQueryListeners.length; ++i) { | |
1927 result[jQueryListeners[i].type] = result[jQueryListeners[i].type] || []; | |
1928 result[jQueryListeners[i].type].push(jQueryListeners[i]); | |
1929 } | |
1852 /** @this {{type: string, listener: function(), useCapture: boolean}} */ | 1930 /** @this {{type: string, listener: function(), useCapture: boolean}} */ |
1853 var removeFunc = function() | 1931 var removeFunc = function() |
1854 { | 1932 { |
1855 node.removeEventListener(this.type, this.listener, this.useCapture); | 1933 node.removeEventListener(this.type, this.listener, this.useCapture); |
1856 } | 1934 } |
1857 for (var type in result) { | 1935 for (var type in result) { |
1858 var listeners = result[type]; | 1936 var listeners = result[type]; |
1859 for (var i = 0, listener; listener = listeners[i]; ++i) { | 1937 for (var i = 0, listener; listener = listeners[i]; ++i) { |
1860 listener["type"] = type; | 1938 listener["type"] = type; |
1861 listener["remove"] = removeFunc; | 1939 listener["remove"] = removeFunc; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 */ | 2009 */ |
1932 _logEvent: function(event) | 2010 _logEvent: function(event) |
1933 { | 2011 { |
1934 inspectedGlobalObject.console.log(event.type, event); | 2012 inspectedGlobalObject.console.log(event.type, event); |
1935 } | 2013 } |
1936 } | 2014 } |
1937 | 2015 |
1938 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 2016 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1939 return injectedScript; | 2017 return injectedScript; |
1940 }) | 2018 }) |
OLD | NEW |