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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js

Issue 1884213003: DevTools: teach SourceMapNamesResolver to resolve "this" object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ids
Patch Set: fix tesst Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 WebInspector.SourceMapNamesResolver = {}; 5 WebInspector.SourceMapNamesResolver = {};
6 6
7 WebInspector.SourceMapNamesResolver._cachedMapSymbol = Symbol("cache"); 7 WebInspector.SourceMapNamesResolver._cachedMapSymbol = Symbol("cache");
8 WebInspector.SourceMapNamesResolver._cachedIdentifiersSymbol = Symbol("cachedIde ntifiers"); 8 WebInspector.SourceMapNamesResolver._cachedIdentifiersSymbol = Symbol("cachedIde ntifiers");
9 9
10 /** 10 /**
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 var text = new WebInspector.Text(content); 281 var text = new WebInspector.Text(content);
282 var textRange = sourceMap.reverseMapTextRange(uiSourceCode.url(), new We bInspector.TextRange(lineNumber, startColumnNumber, lineNumber, endColumnNumber) ); 282 var textRange = sourceMap.reverseMapTextRange(uiSourceCode.url(), new We bInspector.TextRange(lineNumber, startColumnNumber, lineNumber, endColumnNumber) );
283 var originalText = text.extract(textRange); 283 var originalText = text.extract(textRange);
284 if (!originalText) 284 if (!originalText)
285 return Promise.resolve(""); 285 return Promise.resolve("");
286 return WebInspector.SourceMapNamesResolverWorker._instance().evaluatable JavaScriptSubstring(originalText); 286 return WebInspector.SourceMapNamesResolverWorker._instance().evaluatable JavaScriptSubstring(originalText);
287 } 287 }
288 } 288 }
289 289
290 /** 290 /**
291 * @param {?WebInspector.DebuggerModel.CallFrame} callFrame
292 * @return {!Promise<?WebInspector.RemoteObject>}
293 */
294 WebInspector.SourceMapNamesResolver.resolveThisObject = function(callFrame)
295 {
296 if (!callFrame)
297 return Promise.resolve(/** @type {?WebInspector.RemoteObject} */(null));
298 if (!Runtime.experiments.isEnabled("resolveVariableNames"))
299 return Promise.resolve(callFrame.thisObject());
300
301 return WebInspector.SourceMapNamesResolver._resolveScope(callFrame.scopeChai n()[0])
302 .then(onScopeResolved);
303
304 /**
305 * @param {!Map<string, string>} namesMapping
306 * @return {!Promise<?WebInspector.RemoteObject>}
307 */
308 function onScopeResolved(namesMapping)
309 {
310 var thisMappings = namesMapping.inverse().get("this");
311 if (!thisMappings || thisMappings.size !== 1)
312 return Promise.resolve(callFrame.thisObject());
313
314 var thisMapping = thisMappings.valuesArray()[0];
315 var callback;
316 var promise = new Promise(fulfill => callback = fulfill);
317 callFrame.evaluate(thisMapping, "backtrace", false, true, false, true, o nEvaluated.bind(null, callback));
318 return promise;
319 }
320
321 /**
322 * @param {function(!WebInspector.RemoteObject)} callback
323 * @param {?RuntimeAgent.RemoteObject} evaluateResult
324 */
325 function onEvaluated(callback, evaluateResult)
326 {
327 var remoteObject = evaluateResult ? callFrame.target().runtimeModel.crea teRemoteObject(evaluateResult) : callFrame.thisObject();
328 callback(remoteObject);
329 }
330 }
331
332 /**
291 * @param {!WebInspector.DebuggerModel.Scope} scope 333 * @param {!WebInspector.DebuggerModel.Scope} scope
292 * @return {!WebInspector.RemoteObject} 334 * @return {!WebInspector.RemoteObject}
293 */ 335 */
294 WebInspector.SourceMapNamesResolver.resolveScopeInObject = function(scope) 336 WebInspector.SourceMapNamesResolver.resolveScopeInObject = function(scope)
295 { 337 {
296 if (!Runtime.experiments.isEnabled("resolveVariableNames")) 338 if (!Runtime.experiments.isEnabled("resolveVariableNames"))
297 return scope.object(); 339 return scope.object();
298 340
299 var startLocation = scope.startLocation(); 341 var startLocation = scope.startLocation();
300 var endLocation = scope.endLocation(); 342 var endLocation = scope.endLocation();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 681
640 /** 682 /**
641 * @return {!WebInspector.SourceMapNamesResolverWorker} 683 * @return {!WebInspector.SourceMapNamesResolverWorker}
642 */ 684 */
643 WebInspector.SourceMapNamesResolverWorker._instance = function() 685 WebInspector.SourceMapNamesResolverWorker._instance = function()
644 { 686 {
645 if (!WebInspector.SourceMapNamesResolverWorker._instanceObject) 687 if (!WebInspector.SourceMapNamesResolverWorker._instanceObject)
646 WebInspector.SourceMapNamesResolverWorker._instanceObject = new WebInspe ctor.SourceMapNamesResolverWorker(); 688 WebInspector.SourceMapNamesResolverWorker._instanceObject = new WebInspe ctor.SourceMapNamesResolverWorker();
647 return WebInspector.SourceMapNamesResolverWorker._instanceObject; 689 return WebInspector.SourceMapNamesResolverWorker._instanceObject;
648 } 690 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698