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

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

Issue 1826623002: [DevTools] Move wrapCallFrames from InjectedScriptSource.js to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-no-scopes
Patch Set: Created 4 years, 9 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 */ 310 */
311 wrapPropertyInArray: function(array, property, groupName, canAccessInspected GlobalObject, forceValueType, generatePreview) 311 wrapPropertyInArray: function(array, property, groupName, canAccessInspected GlobalObject, forceValueType, generatePreview)
312 { 312 {
313 for (var i = 0; i < array.length; ++i) { 313 for (var i = 0; i < array.length; ++i) {
314 if (typeof array[i] === "object" && property in array[i]) 314 if (typeof array[i] === "object" && property in array[i])
315 array[i][property] = this.wrapObject(array[i][property], groupNa me, canAccessInspectedGlobalObject, forceValueType, generatePreview); 315 array[i][property] = this.wrapObject(array[i][property], groupNa me, canAccessInspectedGlobalObject, forceValueType, generatePreview);
316 } 316 }
317 }, 317 },
318 318
319 /** 319 /**
320 * @param {!Array<*>} array
321 * @param {string} groupName
322 * @param {boolean} canAccessInspectedGlobalObject
323 * @param {boolean} forceValueType
324 * @param {boolean} generatePreview
325 */
326 wrapObjectsInArray: function(array, groupName, canAccessInspectedGlobalObjec t, forceValueType, generatePreview)
327 {
328 for (var i = 0; i < array.length; ++i)
329 array[i] = this.wrapObject(array[i], groupName, canAccessInspectedGl obalObject, forceValueType, generatePreview);
330 },
331
332 /**
320 * @param {*} object 333 * @param {*} object
321 * @return {!RuntimeAgent.RemoteObject} 334 * @return {!RuntimeAgent.RemoteObject}
322 */ 335 */
323 _fallbackWrapper: function(object) 336 _fallbackWrapper: function(object)
324 { 337 {
325 var result = { __proto__: null }; 338 var result = { __proto__: null };
326 result.type = typeof object; 339 result.type = typeof object;
327 if (this.isPrimitiveValue(object)) 340 if (this.isPrimitiveValue(object))
328 result.value = object; 341 result.value = object;
329 else 342 else
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 613 }
601 614
602 for (var i = 0; i < jsonMLObject.length; ++i) 615 for (var i = 0; i < jsonMLObject.length; ++i)
603 this._substituteObjectTagsInCustomPreview(objectGroupName, jsonM LObject[i]); 616 this._substituteObjectTagsInCustomPreview(objectGroupName, jsonM LObject[i]);
604 } finally { 617 } finally {
605 this._customPreviewRecursionDepth--; 618 this._customPreviewRecursionDepth--;
606 } 619 }
607 }, 620 },
608 621
609 /** 622 /**
610 * @param {?Object} callFrame
611 * @return {!Array.<!InjectedScript.CallFrameProxy>|boolean}
612 */
613 wrapCallFrames: function(callFrame)
614 {
615 if (!callFrame)
616 return false;
617
618 var result = [];
619 var depth = 0;
620 do {
621 result[depth] = new InjectedScript.CallFrameProxy(depth, callFrame);
622 callFrame = callFrame.caller;
623 ++depth;
624 } while (callFrame);
625 return result;
626 },
627
628 /**
629 * @return {!CommandLineAPI} 623 * @return {!CommandLineAPI}
630 */ 624 */
631 commandLineAPI: function() 625 commandLineAPI: function()
632 { 626 {
633 return new CommandLineAPI(this._commandLineAPIImpl); 627 return new CommandLineAPI(this._commandLineAPIImpl);
634 }, 628 },
635 629
636 /** 630 /**
637 * @param {string} objectGroup 631 * @param {string} objectGroup
638 * @return {!Object} 632 * @return {!Object}
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); 1142 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf);
1149 } 1143 }
1150 return string.substr(0, maxLength) + "\u2026"; 1144 return string.substr(0, maxLength) + "\u2026";
1151 }, 1145 },
1152 1146
1153 __proto__: null 1147 __proto__: null
1154 } 1148 }
1155 1149
1156 /** 1150 /**
1157 * @constructor 1151 * @constructor
1158 * @param {number} ordinal
1159 * @param {!JavaScriptCallFrame} callFrame
1160 */
1161 InjectedScript.CallFrameProxy = function(ordinal, callFrame)
1162 {
1163 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + "}";
1164 this.functionName = callFrame.functionName;
1165 this.functionLocation = { scriptId: toString(callFrame.sourceID), lineNumber : callFrame.functionLine, columnNumber: callFrame.functionColumn, __proto__: nul l };
1166 this.location = { scriptId: toString(callFrame.sourceID), lineNumber: callFr ame.line, columnNumber: callFrame.column, __proto__: null };
1167 this.scopeChain = this._wrapScopeChain(callFrame);
1168 this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace");
1169 if (callFrame.isAtReturn)
1170 this.returnValue = injectedScript._wrapObject(callFrame.returnValue, "ba cktrace");
1171 }
1172
1173 InjectedScript.CallFrameProxy.prototype = {
1174 /**
1175 * @param {!JavaScriptCallFrame} callFrame
1176 * @return {!Array<!DebuggerAgent.Scope>}
1177 */
1178 _wrapScopeChain: function(callFrame)
1179 {
1180 var scopeChain = callFrame.scopeChain;
1181 var scopeChainProxy = [];
1182 for (var i = 0; i < scopeChain.length; ++i)
1183 scopeChainProxy[i] = this._createScopeJson(callFrame.scopeType(i), c allFrame.scopeName(i), scopeChain[i], callFrame.scopeStartLocation(i), callFrame .scopeEndLocation(i) );
1184 return scopeChainProxy;
1185 },
1186
1187 /**
1188 * @param {!DebuggerAgent.ScopeType<string>} scopeType
1189 * @param {string} scopeName
1190 * @param {*} scopeObject
1191 * @param {?DebuggerAgent.Location} startLocation
1192 * @param {?DebuggerAgent.Location} endLocation
1193 * @return {!DebuggerAgent.Scope}
1194 */
1195 _createScopeJson: function(scopeType, scopeName, scopeObject, startLocation, endLocation)
1196 {
1197 var scope = {
1198 object: injectedScript._wrapObject(scopeObject, "backtrace"),
1199 type: scopeType,
1200 __proto__: null
1201 };
1202 if (scopeName)
1203 scope.name = scopeName;
1204
1205 if (startLocation)
1206 scope.startLocation = startLocation;
1207 if (endLocation)
1208 scope.endLocation = endLocation;
1209
1210 return scope;
1211 },
1212
1213 __proto__: null
1214 }
1215
1216 /**
1217 * @constructor
1218 * @param {!CommandLineAPIImpl} commandLineAPIImpl 1152 * @param {!CommandLineAPIImpl} commandLineAPIImpl
1219 */ 1153 */
1220 function CommandLineAPI(commandLineAPIImpl) 1154 function CommandLineAPI(commandLineAPIImpl)
1221 { 1155 {
1222 /** 1156 /**
1223 * @param {string} name The name of the method for which a toString method s hould be generated. 1157 * @param {string} name The name of the method for which a toString method s hould be generated.
1224 * @return {function():string} 1158 * @return {function():string}
1225 */ 1159 */
1226 function customToStringMethod(name) 1160 function customToStringMethod(name)
1227 { 1161 {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 */ 1475 */
1542 _logEvent: function(event) 1476 _logEvent: function(event)
1543 { 1477 {
1544 inspectedGlobalObject.console.log(event.type, event); 1478 inspectedGlobalObject.console.log(event.type, event);
1545 } 1479 }
1546 } 1480 }
1547 1481
1548 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1482 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1549 return injectedScript; 1483 return injectedScript;
1550 }) 1484 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698