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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.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) 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 scopeEndPositions[i] = scopeDetails.endPosition ? scopeDetails.endPositi on() : 0; 411 scopeEndPositions[i] = scopeDetails.endPosition ? scopeDetails.endPositi on() : 0;
412 scopeFunctions[i] = scopeDetails.func ? scopeDetails.func() : null; 412 scopeFunctions[i] = scopeDetails.func ? scopeDetails.func() : null;
413 } 413 }
414 414
415 // Calculated lazily. 415 // Calculated lazily.
416 var scopeChain; 416 var scopeChain;
417 var funcMirror; 417 var funcMirror;
418 var location; 418 var location;
419 var scopeStartLocations; 419 var scopeStartLocations;
420 var scopeEndLocations; 420 var scopeEndLocations;
421 var object;
421 422
422 function createLocation(script, pos) 423 function createLocation(script, pos)
423 { 424 {
424 if (!script) 425 if (!script)
425 return null; 426 return null;
426 427
427 location = script.locationFromPosition(pos, true); 428 var location = script.locationFromPosition(pos, true);
428 return { 429 return {
429 "lineNumber": location.line, 430 "lineNumber": location.line,
430 "columnNumber": location.column, 431 "columnNumber": location.column,
431 "scriptId": String(script.id()) 432 "scriptId": String(script.id())
432 } 433 }
433 } 434 }
434 435
435 function lazyScopeChain() 436 function lazyScopeChain()
436 { 437 {
437 if (!scopeChain) { 438 if (!scopeChain) {
(...skipping 20 matching lines...) Expand all
458 scopeTypes.length = scopeChain.length; 459 scopeTypes.length = scopeChain.length;
459 scopeNames.length = scopeChain.length; 460 scopeNames.length = scopeChain.length;
460 scopeObjects = null; // Free for GC. 461 scopeObjects = null; // Free for GC.
461 scopeFunctions = null; 462 scopeFunctions = null;
462 scopeStartPositions = null; 463 scopeStartPositions = null;
463 scopeEndPositions = null; 464 scopeEndPositions = null;
464 } 465 }
465 return scopeChain; 466 return scopeChain;
466 } 467 }
467 468
468 function lazyScopeTypes() 469 function lazyObject()
469 { 470 {
470 if (!scopeChain) 471 if (!object) {
471 lazyScopeChain(); 472 var scopeObjects = lazyScopeChain();
472 return scopeTypes; 473 var script = ensureFuncMirror().script();
473 } 474 var scopes = [];
474 475 for (var i = 0; i < scopeObjects.length; ++i) {
475 function lazyScopeNames() 476 var scope = {
476 { 477 "type": scopeTypes[i],
477 if (!scopeChain) 478 "object": scopeObjects[i],
478 lazyScopeChain(); 479 };
479 return scopeNames; 480 if (scopeNames[i])
480 } 481 scope.name = scopeNames[i];
481 482 if (scopeStartLocations[i])
482 function lazyScopeStartLocations() 483 scope.startLocation = scopeStartLocations[i];
483 { 484 if (scopeEndLocations[i])
484 if (!scopeChain) 485 scope.endLocation = scopeEndLocations[i];
485 lazyScopeChain(); 486 scopes.push(scope);
486 487 }
487 return scopeStartLocations; 488 var functionLocation = ensureFuncMirror().sourceLocation();
488 } 489 object = {
489 490 "functionName": ensureFuncMirror().debugName(),
490 function lazyScopeEndLocations() 491 "location": {
491 { 492 "lineNumber": line(),
492 if (!scopeChain) 493 "columnNumber": column(),
493 lazyScopeChain(); 494 "scriptId": String(script.id())
494 495 },
495 return scopeEndLocations; 496 "functionLocation": {
497 "lineNumber": functionLocation.line,
dgozman 2016/03/23 18:46:31 Previous code checked that there could be no funct
kozy 2016/03/23 19:15:10 Done.
498 "columnNumber": functionLocation.column,
dgozman 2016/03/23 18:46:31 ditto
kozy 2016/03/23 19:15:10 Done.
499 "scriptId": String(script.id())
500 },
501 "this": thisObject,
502 "scopeChain": scopes
503 };
504 if (isAtReturn)
505 object.returnValue = returnValue;
506 }
507 return object;
496 } 508 }
497 509
498 function ensureFuncMirror() 510 function ensureFuncMirror()
499 { 511 {
500 if (!funcMirror) { 512 if (!funcMirror) {
501 funcMirror = MakeMirror(funcObject); 513 funcMirror = MakeMirror(funcObject);
502 if (!funcMirror.isFunction()) 514 if (!funcMirror.isFunction())
503 funcMirror = new UnresolvedFunctionMirror(funcObject); 515 funcMirror = new UnresolvedFunctionMirror(funcObject);
504 } 516 }
505 return funcMirror; 517 return funcMirror;
(...skipping 20 matching lines...) Expand all
526 { 538 {
527 return ensureLocation().column; 539 return ensureLocation().column;
528 } 540 }
529 541
530 function sourceID() 542 function sourceID()
531 { 543 {
532 var script = ensureFuncMirror().script(); 544 var script = ensureFuncMirror().script();
533 return script && script.id(); 545 return script && script.id();
534 } 546 }
535 547
536 function scriptName()
537 {
538 var script = ensureFuncMirror().script();
539 return script && script.name();
540 }
541
542 function functionName()
543 {
544 return ensureFuncMirror().debugName();
545 }
546
547 function functionLine()
548 {
549 var location = ensureFuncMirror().sourceLocation();
550 return location ? location.line : 0;
551 }
552
553 function functionColumn()
554 {
555 var location = ensureFuncMirror().sourceLocation();
556 return location ? location.column : 0;
557 }
558
559 function evaluate(expression) 548 function evaluate(expression)
560 { 549 {
561 return frameMirror.evaluate(expression, false).value(); 550 return frameMirror.evaluate(expression, false).value();
562 } 551 }
563 552
564 function restart() 553 function restart()
565 { 554 {
566 return frameMirror.restart(); 555 return frameMirror.restart();
567 } 556 }
568 557
569 function setVariableValue(scopeNumber, variableName, newValue) 558 function setVariableValue(scopeNumber, variableName, newValue)
570 { 559 {
571 return DebuggerScript._setScopeVariableValue(frameMirror, scopeNumber, v ariableName, newValue); 560 return DebuggerScript._setScopeVariableValue(frameMirror, scopeNumber, v ariableName, newValue);
572 } 561 }
573 562
574 function stepInPositions()
575 {
576 var stepInPositionsV8 = frameMirror.stepInPositions();
577 var stepInPositionsProtocol;
578 if (stepInPositionsV8) {
579 stepInPositionsProtocol = [];
580 var script = ensureFuncMirror().script();
581 if (script) {
582 var scriptId = String(script.id());
583 for (var i = 0; i < stepInPositionsV8.length; i++) {
584 var item = {
585 scriptId: scriptId,
586 lineNumber: stepInPositionsV8[i].position.line,
587 columnNumber: stepInPositionsV8[i].position.column
588 };
589 stepInPositionsProtocol.push(item);
590 }
591 }
592 }
593 return JSON.stringify(stepInPositionsProtocol);
594 }
595
596 return { 563 return {
597 "sourceID": sourceID, 564 "sourceID": sourceID,
598 "line": line, 565 "line": line,
599 "column": column, 566 "column": column,
600 "scriptName": scriptName,
601 "functionName": functionName,
602 "functionLine": functionLine,
603 "functionColumn": functionColumn,
604 "thisObject": thisObject, 567 "thisObject": thisObject,
605 "scopeChain": lazyScopeChain,
606 "scopeType": lazyScopeTypes,
607 "scopeName": lazyScopeNames,
608 "scopeStartLocation": lazyScopeStartLocations,
609 "scopeEndLocation": lazyScopeEndLocations,
610 "evaluate": evaluate, 568 "evaluate": evaluate,
611 "caller": callerFrame, 569 "caller": callerFrame,
612 "restart": restart, 570 "restart": restart,
613 "setVariableValue": setVariableValue, 571 "setVariableValue": setVariableValue,
614 "stepInPositions": stepInPositions,
615 "isAtReturn": isAtReturn, 572 "isAtReturn": isAtReturn,
616 "returnValue": returnValue 573 "object": lazyObject
dgozman 2016/03/23 18:46:31 details
kozy 2016/03/23 19:15:10 Done.
617 }; 574 };
618 } 575 }
619 576
620 DebuggerScript._buildScopeObject = function(scopeType, scopeObject) 577 DebuggerScript._buildScopeObject = function(scopeType, scopeObject)
621 { 578 {
622 var result; 579 var result;
623 switch (scopeType) { 580 switch (scopeType) {
624 case ScopeType.Local: 581 case ScopeType.Local:
625 case ScopeType.Closure: 582 case ScopeType.Closure:
626 case ScopeType.Catch: 583 case ScopeType.Catch:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 "parentPromise": eventData.parentPromise().value(), 615 "parentPromise": eventData.parentPromise().value(),
659 "status": eventData.status() 616 "status": eventData.status()
660 }; 617 };
661 } 618 }
662 619
663 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it. 620 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it.
664 ToggleMirrorCache(false); 621 ToggleMirrorCache(false);
665 622
666 return DebuggerScript; 623 return DebuggerScript;
667 })(); 624 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698