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 } | 1139 }, |
1140 | |
1141 /** | |
1142 * @param {string} prefix | |
1143 * @param {!Error} error | |
1144 */ | |
1145 _logError: function(prefix, error) | |
1146 { | |
1147 Promise.resolve().then(inspectedGlobalObject.console.error.bind(inspecte dGlobalObject.console, prefix + error.message)); | |
1148 }, | |
1149 | |
1150 /** | |
1151 * @param {!Object} object | |
1152 * @return {!Array<!{type: string, listener: function(), useCapture: boolean }>} | |
1153 */ | |
1154 frameworksEventListeners: function(object) | |
yurys
2015/08/13 23:49:06
frameworkEventListeners
kozy
2015/08/14 17:07:03
frameworkUserEventListeners
| |
1155 { | |
1156 if (isArrayLike(inspectedGlobalObject["devtoolsFrameworksEventListeners" ])) { | |
1157 var listeners = []; | |
1158 var getters = inspectedGlobalObject["devtoolsFrameworksEventListener s"]; | |
1159 for (var i = 0; i < getters.length; ++i) { | |
1160 try { | |
1161 if (typeof getters[i] === "function") | |
1162 listeners = concat(listeners, getters[i](object)); | |
1163 } catch (e) { | |
1164 this._logError("Resolving Frameworks Event Listeners Failed: ", e); | |
1165 } | |
1166 } | |
1167 return listeners; | |
1168 } | |
1169 return []; | |
1170 }, | |
1171 | |
1172 /** | |
1173 * @param {!Object} object | |
1174 * @return {!Set<function()>} | |
1175 */ | |
1176 frameworksEventHandlers: function(object) | |
1177 { | |
1178 if (isArrayLike(inspectedGlobalObject["devtoolsFrameworksEventHandlers"] )) { | |
1179 var handlers = []; | |
1180 var getters = inspectedGlobalObject["devtoolsFrameworksEventHandlers "]; | |
yurys
2015/08/13 23:49:06
Please extract common part.
kozy
2015/08/14 17:07:03
Done.
| |
1181 for (var i = 0; i < getters.length; ++i) { | |
1182 try { | |
1183 if (typeof getters[i] === "function") | |
1184 handlers = concat(handlers, getters[i](object)); | |
1185 } catch (e) { | |
1186 this._logError("Resolving Frameworks Event Handlers Failed: ", e); | |
1187 } | |
1188 } | |
1189 return new Set(handlers); | |
1190 } | |
1191 return new Set(); | |
1192 }, | |
1140 } | 1193 } |
1141 | 1194 |
1142 /** | 1195 /** |
1143 * @type {!InjectedScript} | 1196 * @type {!InjectedScript} |
1144 * @const | 1197 * @const |
1145 */ | 1198 */ |
1146 var injectedScript = new InjectedScript(); | 1199 var injectedScript = new InjectedScript(); |
1147 | 1200 |
1148 /** | 1201 /** |
1149 * @constructor | 1202 * @constructor |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 InjectedScript.RemoteObject.prototype = { | 1267 InjectedScript.RemoteObject.prototype = { |
1215 | 1268 |
1216 /** | 1269 /** |
1217 * @param {*} object | 1270 * @param {*} object |
1218 * @param {string=} objectGroupName | 1271 * @param {string=} objectGroupName |
1219 * @param {*=} customObjectConfig | 1272 * @param {*=} customObjectConfig |
1220 * @return {?RuntimeAgent.CustomPreview} | 1273 * @return {?RuntimeAgent.CustomPreview} |
1221 */ | 1274 */ |
1222 _customPreview: function(object, objectGroupName, customObjectConfig) | 1275 _customPreview: function(object, objectGroupName, customObjectConfig) |
1223 { | 1276 { |
1224 /** | |
1225 * @param {!Error} error | |
1226 */ | |
1227 function logError(error) | |
1228 { | |
1229 Promise.resolve().then(inspectedGlobalObject.console.error.bind(insp ectedGlobalObject.console, "Custom Formatter Failed: " + error.message)); | |
1230 } | |
1231 | |
1232 try { | 1277 try { |
1233 var formatters = inspectedGlobalObject["devtoolsFormatters"]; | 1278 var formatters = inspectedGlobalObject["devtoolsFormatters"]; |
1234 if (!formatters || !isArrayLike(formatters)) | 1279 if (!formatters || !isArrayLike(formatters)) |
yurys
2015/08/13 23:49:06
Drop !formatter check?
kozy
2015/08/14 17:07:03
typeof null === "object" in js
| |
1235 return null; | 1280 return null; |
1236 | 1281 |
1237 for (var i = 0; i < formatters.length; ++i) { | 1282 for (var i = 0; i < formatters.length; ++i) { |
1238 try { | 1283 try { |
1239 var formatted = formatters[i].header(object, customObjectCon fig); | 1284 var formatted = formatters[i].header(object, customObjectCon fig); |
1240 if (!formatted) | 1285 if (!formatted) |
1241 continue; | 1286 continue; |
1242 | 1287 |
1243 var hasBody = formatters[i].hasBody(object, customObjectConf ig); | 1288 var hasBody = formatters[i].hasBody(object, customObjectConf ig); |
1244 injectedScript._substituteObjectTagsInCustomPreview(objectGr oupName, formatted); | 1289 injectedScript._substituteObjectTagsInCustomPreview(objectGr oupName, formatted); |
1245 var formatterObjectId = injectedScript._bind(formatters[i], objectGroupName); | 1290 var formatterObjectId = injectedScript._bind(formatters[i], objectGroupName); |
1246 var result = {header: JSON.stringify(formatted), hasBody: !! hasBody, formatterObjectId: formatterObjectId}; | 1291 var result = {header: JSON.stringify(formatted), hasBody: !! hasBody, formatterObjectId: formatterObjectId}; |
1247 if (customObjectConfig) | 1292 if (customObjectConfig) |
1248 result["configObjectId"] = injectedScript._bind(customOb jectConfig, objectGroupName); | 1293 result["configObjectId"] = injectedScript._bind(customOb jectConfig, objectGroupName); |
1249 return result; | 1294 return result; |
1250 } catch (e) { | 1295 } catch (e) { |
1251 logError(e); | 1296 injectedScript._logError("Custom Formatter Failed: ", e); |
1252 } | 1297 } |
1253 } | 1298 } |
1254 } catch (e) { | 1299 } catch (e) { |
1255 logError(e); | 1300 injectedScript._logError("Custom Formatter Failed: ", e); |
1256 } | 1301 } |
1257 return null; | 1302 return null; |
1258 }, | 1303 }, |
1259 | 1304 |
1260 /** | 1305 /** |
1261 * @return {!RuntimeAgent.ObjectPreview} preview | 1306 * @return {!RuntimeAgent.ObjectPreview} preview |
1262 */ | 1307 */ |
1263 _createEmptyPreview: function() | 1308 _createEmptyPreview: function() |
1264 { | 1309 { |
1265 var preview = { | 1310 var preview = { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1842 | 1887 |
1843 /** | 1888 /** |
1844 * @param {!Node} node | 1889 * @param {!Node} node |
1845 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n, remove: function()}>|undefined} | 1890 * @return {!Array.<!{type: string, listener: function(), useCapture: boolea n, remove: function()}>|undefined} |
1846 */ | 1891 */ |
1847 getEventListeners: function(node) | 1892 getEventListeners: function(node) |
1848 { | 1893 { |
1849 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod e)); | 1894 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod e)); |
1850 if (!result) | 1895 if (!result) |
1851 return result; | 1896 return result; |
1897 | |
1898 var jQueryListeners = injectedScript.frameworksEventListeners(node); | |
1899 for (var i = 0; i < jQueryListeners.length; ++i) { | |
1900 result[jQueryListeners[i].type] = result[jQueryListeners[i].type] || []; | |
1901 result[jQueryListeners[i].type].push(jQueryListeners[i]); | |
1902 } | |
1903 | |
1852 /** @this {{type: string, listener: function(), useCapture: boolean}} */ | 1904 /** @this {{type: string, listener: function(), useCapture: boolean}} */ |
1853 var removeFunc = function() | 1905 var removeFunc = function() |
1854 { | 1906 { |
1855 node.removeEventListener(this.type, this.listener, this.useCapture); | 1907 node.removeEventListener(this.type, this.listener, this.useCapture); |
1856 } | 1908 } |
1857 for (var type in result) { | 1909 for (var type in result) { |
1858 var listeners = result[type]; | 1910 var listeners = result[type]; |
1859 for (var i = 0, listener; listener = listeners[i]; ++i) { | 1911 for (var i = 0, listener; listener = listeners[i]; ++i) { |
1860 listener["type"] = type; | 1912 listener["type"] = type; |
1861 listener["remove"] = removeFunc; | 1913 listener["remove"] = removeFunc; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 */ | 1983 */ |
1932 _logEvent: function(event) | 1984 _logEvent: function(event) |
1933 { | 1985 { |
1934 inspectedGlobalObject.console.log(event.type, event); | 1986 inspectedGlobalObject.console.log(event.type, event); |
1935 } | 1987 } |
1936 } | 1988 } |
1937 | 1989 |
1938 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1990 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1939 return injectedScript; | 1991 return injectedScript; |
1940 }) | 1992 }) |
OLD | NEW |