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

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

Issue 1918323002: [DevTools] Simplified DebuggerScript._buildScopeObject (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | third_party/WebKit/Source/platform/v8_inspector/debugger_script_externs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 return numbers; 388 return numbers;
389 389
390 for (var i = 0; i < breakpoints.length; i++) { 390 for (var i = 0; i < breakpoints.length; i++) {
391 var breakpoint = breakpoints[i]; 391 var breakpoint = breakpoints[i];
392 var scriptBreakPoint = breakpoint.script_break_point(); 392 var scriptBreakPoint = breakpoint.script_break_point();
393 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n umber()); 393 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n umber());
394 } 394 }
395 return numbers; 395 return numbers;
396 } 396 }
397 397
398 // NOTE: This function is performance critical, as it can be run on every
399 // statement that generates an async event (like addEventListener) to support
400 // asynchronous call stacks. Thus, when possible, initialize the data lazily.
401 /** 398 /**
402 * @param {!FrameMirror} frameMirror 399 * @param {!FrameMirror} frameMirror
403 * @return {!JavaScriptCallFrame} 400 * @return {!JavaScriptCallFrame}
404 */ 401 */
405 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) 402 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror)
406 { 403 {
407 // Stuff that can not be initialized lazily (i.e. valid while paused with a valid break_id). 404 // Stuff that can not be initialized lazily (i.e. valid while paused with a valid break_id).
408 // The frameMirror and scopeMirror can be accessed only while paused on the debugger. 405 // The frameMirror and scopeMirror can be accessed only while paused on the debugger.
409 var frameDetails = frameMirror.details(); 406 var frameDetails = frameMirror.details();
410 407
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 }; 656 };
660 } 657 }
661 658
662 /** 659 /**
663 * @param {number} scopeType 660 * @param {number} scopeType
664 * @param {!Object} scopeObject 661 * @param {!Object} scopeObject
665 * @return {!Object|undefined} 662 * @return {!Object|undefined}
666 */ 663 */
667 DebuggerScript._buildScopeObject = function(scopeType, scopeObject) 664 DebuggerScript._buildScopeObject = function(scopeType, scopeObject)
668 { 665 {
669 var result; 666 // Almost always Script scope will be empty, so just filter out that noise.
670 switch (scopeType) { 667 // Also drop empty Block scopes, should we get any.
671 case ScopeType.Local: 668 if (scopeType === ScopeType.Script || scopeType === ScopeType.Block) {
672 case ScopeType.Closure: 669 if (Object.getOwnPropertyNames(scopeObject).length === 0)
673 case ScopeType.Catch: 670 return undefined;
674 case ScopeType.Block:
675 case ScopeType.Script:
676 // For transient objects we create a "persistent" copy that contains
677 // the same properties.
678 // Reset scope object prototype to null so that the proto properties
679 // don't appear in the local scope section.
680 var properties = /** @type {!ObjectMirror} */(MakeMirror(scopeObject, tr ue /* transient */)).properties();
681 // Almost always Script scope will be empty, so just filter out that noi se.
682 // Also drop empty Block scopes, should we get any.
683 if (!properties.length && (scopeType === ScopeType.Script || scopeType = == ScopeType.Block))
684 break;
685 result = { __proto__: null };
686 for (var j = 0; j < properties.length; j++) {
687 var name = properties[j].name();
688 if (name.length === 0 || name.charAt(0) === ".")
689 continue; // Skip internal variables like ".arguments" and varia bles with empty name
690 result[name] = properties[j].value_;
691 }
692 break;
693 case ScopeType.Global:
694 case ScopeType.With:
695 result = scopeObject;
696 break;
697 } 671 }
698 return result; 672 return scopeObject;
699 } 673 }
700 674
701 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it. 675 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it.
702 ToggleMirrorCache(false); 676 ToggleMirrorCache(false);
703 677
704 return DebuggerScript; 678 return DebuggerScript;
705 })(); 679 })();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/v8_inspector/debugger_script_externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698