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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js

Issue 1653053002: Devtools: parse variables scopes and sourcemap them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js
diff --git a/third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js b/third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js
index 551e091f790030ea20215208e902fa93dd6d1973..b9397d2b1a248b889ec6951ee916898c19a30395 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js
+++ b/third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js
@@ -395,34 +395,68 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame, in
var scopeTypes = new Array(scopeMirrors.length);
var scopeObjects = new Array(scopeMirrors.length);
var scopeNames = new Array(scopeMirrors.length);
+ var scopeStartPositions = new Array(scopeMirrors.length);
+ var scopeEndPositions = new Array(scopeMirrors.length);
+ var scopeFunctions = new Array(scopeMirrors.length);
for (var i = 0; i < scopeMirrors.length; ++i) {
var scopeDetails = scopeMirrors[i].details();
scopeTypes[i] = scopeDetails.type();
scopeObjects[i] = scopeDetails.object();
scopeNames[i] = scopeDetails.name();
+ scopeStartPositions[i] = scopeDetails.startPosition();
+ scopeEndPositions[i] = scopeDetails.endPosition();
+ scopeFunctions[i] = scopeDetails.func();
}
// Calculated lazily.
var scopeChain;
var funcMirror;
var location;
+ var scopeStartLocations;
+ var scopeEndLocations;
+
+ function createLocation(script, pos)
+ {
+ if (!script)
+ return null;
+
+ location = script.locationFromPosition(pos, true);
+ return {
+ "lineNumber": location.line,
+ "columnNumber": location.column,
+ "scriptId": String(script.id())
+ }
+ }
function lazyScopeChain()
{
if (!scopeChain) {
scopeChain = [];
+ scopeStartLocations = [];
+ scopeEndLocations = [];
for (var i = 0, j = 0; i < scopeObjects.length; ++i) {
- var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i], scopeObjects[i], scopeNames[i]);
+ var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i], scopeObjects[i]);
if (scopeObject) {
scopeTypes[j] = scopeTypes[i];
scopeNames[j] = scopeNames[i];
scopeChain[j] = scopeObject;
+
+ var funcMirror = MakeMirror(scopeFunctions[i]);
+ if (!funcMirror.isFunction())
+ funcMirror = new UnresolvedFunctionMirror(funcObject);
+
+ var script = funcMirror.script();
+ scopeStartLocations[j] = createLocation(script, scopeStartPositions[i]);
+ scopeEndLocations[j] = createLocation(script, scopeEndPositions[i]);
++j;
}
}
scopeTypes.length = scopeChain.length;
scopeNames.length = scopeChain.length;
scopeObjects = null; // Free for GC.
+ scopeFunctions = null;
+ scopeStartPositions = null;
+ scopeEndPositions = null;
}
return scopeChain;
}
@@ -441,6 +475,22 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame, in
return scopeNames;
}
+ function lazyScopeStartLocations()
+ {
+ if (!scopeChain)
+ lazyScopeChain();
+
+ return scopeStartLocations;
+ }
+
+ function lazyScopeEndLocations()
+ {
+ if (!scopeChain)
+ lazyScopeChain();
+
+ return scopeEndLocations;
+ }
+
function ensureFuncMirror()
{
if (!funcMirror) {
@@ -551,6 +601,8 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame, in
"scopeChain": lazyScopeChain,
"scopeType": lazyScopeTypes,
"scopeName": lazyScopeNames,
+ "scopeStartLocation": lazyScopeStartLocations,
+ "scopeEndLocation": lazyScopeEndLocations,
"evaluate": evaluate,
"caller": callerFrame,
"restart": restart,

Powered by Google App Engine
This is Rietveld 408576698