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

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

Issue 2238003002: DevTools: migrate sources panel sidebar to views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: followed up on the watch test. Created 4 years, 4 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointAdded, this._breakpointAdded, this); 53 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointAdded, this._breakpointAdded, this);
54 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointRemoved, this._breakpointRemoved, this); 54 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointRemoved, this._breakpointRemoved, this);
55 55
56 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.Source MappingChanged, this._onSourceMappingChanged, this); 56 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.Source MappingChanged, this._onSourceMappingChanged, this);
57 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.Workin gCopyChanged, this._workingCopyChanged, this); 57 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.Workin gCopyChanged, this._workingCopyChanged, this);
58 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.Workin gCopyCommitted, this._workingCopyCommitted, this); 58 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.Workin gCopyCommitted, this._workingCopyCommitted, this);
59 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.TitleC hanged, this._showBlackboxInfobarIfNeeded, this); 59 this.uiSourceCode().addEventListener(WebInspector.UISourceCode.Events.TitleC hanged, this._showBlackboxInfobarIfNeeded, this);
60 60
61 /** @type {!Map.<!WebInspector.Target, !WebInspector.ResourceScriptFile>}*/ 61 /** @type {!Map.<!WebInspector.Target, !WebInspector.ResourceScriptFile>}*/
62 this._scriptFileForTarget = new Map(); 62 this._scriptFileForTarget = new Map();
63 this._registerShortcuts();
64 var targets = WebInspector.targetManager.targets(); 63 var targets = WebInspector.targetManager.targets();
65 for (var i = 0; i < targets.length; ++i) { 64 for (var i = 0; i < targets.length; ++i) {
66 var scriptFile = WebInspector.debuggerWorkspaceBinding.scriptFile(uiSour ceCode, targets[i]); 65 var scriptFile = WebInspector.debuggerWorkspaceBinding.scriptFile(uiSour ceCode, targets[i]);
67 if (scriptFile) 66 if (scriptFile)
68 this._updateScriptFile(targets[i]); 67 this._updateScriptFile(targets[i]);
69 } 68 }
70 69
71 if (this._scriptFileForTarget.size || uiSourceCode.extension() === "js" || u iSourceCode.project().type() === WebInspector.projectTypes.Snippets) 70 if (this._scriptFileForTarget.size || uiSourceCode.extension() === "js" || u iSourceCode.project().type() === WebInspector.projectTypes.Snippets)
72 this._compiler = new WebInspector.JavaScriptCompiler(this); 71 this._compiler = new WebInspector.JavaScriptCompiler(this);
73 72
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 }, 183 },
185 184
186 _hideBlackboxInfobar: function() 185 _hideBlackboxInfobar: function()
187 { 186 {
188 if (!this._blackboxInfobar) 187 if (!this._blackboxInfobar)
189 return; 188 return;
190 this._blackboxInfobar.dispose(); 189 this._blackboxInfobar.dispose();
191 delete this._blackboxInfobar; 190 delete this._blackboxInfobar;
192 }, 191 },
193 192
194 _registerShortcuts: function()
195 {
196 var shortcutKeys = WebInspector.ShortcutsScreen.SourcesPanelShortcuts;
197 for (var i = 0; i < shortcutKeys.EvaluateSelectionInConsole.length; ++i) {
198 var keyDescriptor = shortcutKeys.EvaluateSelectionInConsole[i];
199 this.addShortcut(keyDescriptor.key, this._evaluateSelectionInConsole .bind(this));
200 }
201 for (var i = 0; i < shortcutKeys.AddSelectionToWatch.length; ++i) {
202 var keyDescriptor = shortcutKeys.AddSelectionToWatch[i];
203 this.addShortcut(keyDescriptor.key, this._addCurrentSelectionToWatch .bind(this));
204 }
205 },
206
207 _addCurrentSelectionToWatch: function()
208 {
209 var textSelection = this.textEditor.selection();
210 if (textSelection && !textSelection.isEmpty())
211 this._innerAddToWatch(this.textEditor.copyRange(textSelection));
212 return true;
213 },
214
215 /**
216 * @param {string} expression
217 */
218 _innerAddToWatch: function(expression)
219 {
220 this._scriptsPanel.addToWatch(expression);
221 },
222
223 /**
224 * @return {boolean}
225 */
226 _evaluateSelectionInConsole: function()
227 {
228 var selection = this.textEditor.selection();
229 if (!selection || selection.isEmpty())
230 return true;
231 this._evaluateInConsole(this.textEditor.copyRange(selection));
232 return true;
233 },
234
235 /**
236 * @param {string} expression
237 */
238 _evaluateInConsole: function(expression)
239 {
240 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E xecutionContext);
241 if (currentExecutionContext)
242 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionC ontext, expression);
243 },
244
245 /** 193 /**
246 * @override 194 * @override
247 */ 195 */
248 wasShown: function() 196 wasShown: function()
249 { 197 {
250 WebInspector.UISourceCodeFrame.prototype.wasShown.call(this); 198 WebInspector.UISourceCodeFrame.prototype.wasShown.call(this);
251 if (this._executionLocation && this.loaded) { 199 if (this._executionLocation && this.loaded) {
252 // We need CodeMirrorTextEditor to be initialized prior to this call . @see crbug.com/499889 200 // We need CodeMirrorTextEditor to be initialized prior to this call . @see crbug.com/499889
253 setImmediate(this._generateValuesInSource.bind(this)); 201 setImmediate(this._generateValuesInSource.bind(this));
254 } 202 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 257 }
310 return new Promise(populate.bind(this)); 258 return new Promise(populate.bind(this));
311 }, 259 },
312 260
313 /** 261 /**
314 * @override 262 * @override
315 * @return {!Promise} 263 * @return {!Promise}
316 */ 264 */
317 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) 265 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
318 { 266 {
319 var textSelection = this.textEditor.selection();
320 if (textSelection && !textSelection.isEmpty()) {
321 var selection = this.textEditor.copyRange(textSelection);
322 var addToWatchLabel = WebInspector.UIString.capitalize("Add to ^watc h");
323 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection));
324 var evaluateLabel = WebInspector.UIString.capitalize("Evaluate in ^c onsole");
325 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection));
326 contextMenu.appendSeparator();
327 }
328
329 /** 267 /**
330 * @param {!WebInspector.ResourceScriptFile} scriptFile 268 * @param {!WebInspector.ResourceScriptFile} scriptFile
331 */ 269 */
332 function addSourceMapURL(scriptFile) 270 function addSourceMapURL(scriptFile)
333 { 271 {
334 WebInspector.AddSourceMapURLDialog.show(addSourceMapURLDialogCallbac k.bind(null, scriptFile)); 272 WebInspector.AddSourceMapURLDialog.show(addSourceMapURLDialogCallbac k.bind(null, scriptFile));
335 } 273 }
336 274
337 /** 275 /**
338 * @param {!WebInspector.ResourceScriptFile} scriptFile 276 * @param {!WebInspector.ResourceScriptFile} scriptFile
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 startColumn: token.startColumn, 479 startColumn: token.startColumn,
542 endColumn: token.endColumn - 1 480 endColumn: token.endColumn - 1
543 }; 481 };
544 482
545 return anchorBox; 483 return anchorBox;
546 }, 484 },
547 485
548 _resolveObjectForPopover: function(anchorBox, showCallback, objectGroupName) 486 _resolveObjectForPopover: function(anchorBox, showCallback, objectGroupName)
549 { 487 {
550 var target = WebInspector.context.flavor(WebInspector.Target); 488 var target = WebInspector.context.flavor(WebInspector.Target);
551 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 489 var selectedCallFrame = WebInspector.context.flavor(WebInspector.Debugge rModel.CallFrame);
552 if (!debuggerModel || !debuggerModel.isPaused()) { 490 if (!selectedCallFrame) {
553 this._popoverHelper.hidePopover(); 491 this._popoverHelper.hidePopover();
554 return; 492 return;
555 } 493 }
556 var lineNumber = anchorBox.highlight.lineNumber; 494 var lineNumber = anchorBox.highlight.lineNumber;
557 var startHighlight = anchorBox.highlight.startColumn; 495 var startHighlight = anchorBox.highlight.startColumn;
558 var endHighlight = anchorBox.highlight.endColumn; 496 var endHighlight = anchorBox.highlight.endColumn;
559 var line = this.textEditor.line(lineNumber); 497 var line = this.textEditor.line(lineNumber);
560 if (!anchorBox.forSelection) { 498 if (!anchorBox.forSelection) {
561 while (startHighlight > 1 && line.charAt(startHighlight - 1) === "." ) { 499 while (startHighlight > 1 && line.charAt(startHighlight - 1) === "." ) {
562 var token = this.textEditor.tokenAtTextPosition(lineNumber, star tHighlight - 2); 500 var token = this.textEditor.tokenAtTextPosition(lineNumber, star tHighlight - 2);
563 if (!token || !token.type) { 501 if (!token || !token.type) {
564 this._popoverHelper.hidePopover(); 502 this._popoverHelper.hidePopover();
565 return; 503 return;
566 } 504 }
567 startHighlight = token.startColumn; 505 startHighlight = token.startColumn;
568 } 506 }
569 } 507 }
570 var evaluationText = line.substring(startHighlight, endHighlight + 1); 508 var evaluationText = line.substring(startHighlight, endHighlight + 1);
571 var selectedCallFrame = /** @type {!WebInspector.DebuggerModel.CallFrame }*/ (debuggerModel.selectedCallFrame());
572
573 WebInspector.SourceMapNamesResolver.resolveExpression(selectedCallFrame, evaluationText, this.uiSourceCode(), lineNumber, startHighlight, endHighlight). then(onResolve.bind(this)); 509 WebInspector.SourceMapNamesResolver.resolveExpression(selectedCallFrame, evaluationText, this.uiSourceCode(), lineNumber, startHighlight, endHighlight). then(onResolve.bind(this));
574 510
575 /** 511 /**
576 * @param {?string=} text 512 * @param {?string=} text
577 * @this {WebInspector.JavaScriptSourceFrame} 513 * @this {WebInspector.JavaScriptSourceFrame}
578 */ 514 */
579 function onResolve(text) 515 function onResolve(text)
580 { 516 {
581 selectedCallFrame.evaluate(text || evaluationText, objectGroupName, false, true, false, false, showObjectPopover.bind(this)); 517 selectedCallFrame.evaluate(text || evaluationText, objectGroupName, false, true, false, false, showObjectPopover.bind(this));
582 } 518 }
583 519
584 /** 520 /**
585 * @param {?RuntimeAgent.RemoteObject} result 521 * @param {?RuntimeAgent.RemoteObject} result
586 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails 522 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails
587 * @this {WebInspector.JavaScriptSourceFrame} 523 * @this {WebInspector.JavaScriptSourceFrame}
588 */ 524 */
589 function showObjectPopover(result, exceptionDetails) 525 function showObjectPopover(result, exceptionDetails)
590 { 526 {
591 var target = WebInspector.context.flavor(WebInspector.Target); 527 var target = WebInspector.context.flavor(WebInspector.Target);
592 if (selectedCallFrame.target() !== target || !debuggerModel.isPaused () || !result) { 528 var potentiallyUpdatedCallFrame = WebInspector.context.flavor(WebIns pector.DebuggerModel.CallFrame);
529 if (selectedCallFrame !== potentiallyUpdatedCallFrame || !result) {
593 this._popoverHelper.hidePopover(); 530 this._popoverHelper.hidePopover();
594 return; 531 return;
595 } 532 }
596 this._popoverAnchorBox = anchorBox; 533 this._popoverAnchorBox = anchorBox;
597 showCallback(target.runtimeModel.createRemoteObject(result), !!excep tionDetails, this._popoverAnchorBox); 534 showCallback(target.runtimeModel.createRemoteObject(result), !!excep tionDetails, this._popoverAnchorBox);
598 // Popover may have been removed by showCallback(). 535 // Popover may have been removed by showCallback().
599 if (this._popoverAnchorBox) { 536 if (this._popoverAnchorBox) {
600 var highlightRange = new WebInspector.TextRange(lineNumber, star tHighlight, lineNumber, endHighlight); 537 var highlightRange = new WebInspector.TextRange(lineNumber, star tHighlight, lineNumber, endHighlight);
601 this._popoverAnchorBox._highlightDescriptor = this.textEditor.hi ghlightRange(highlightRange, "source-frame-eval-expression"); 538 this._popoverAnchorBox._highlightDescriptor = this.textEditor.hi ghlightRange(highlightRange, "source-frame-eval-expression");
602 } 539 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 650 }
714 }, 651 },
715 652
716 _generateValuesInSource: function() 653 _generateValuesInSource: function()
717 { 654 {
718 if (!WebInspector.moduleSetting("inlineVariableValues").get()) 655 if (!WebInspector.moduleSetting("inlineVariableValues").get())
719 return; 656 return;
720 var executionContext = WebInspector.context.flavor(WebInspector.Executio nContext); 657 var executionContext = WebInspector.context.flavor(WebInspector.Executio nContext);
721 if (!executionContext) 658 if (!executionContext)
722 return; 659 return;
723 var callFrame = executionContext.debuggerModel.selectedCallFrame(); 660 var callFrame = WebInspector.context.flavor(WebInspector.DebuggerModel.C allFrame);
724 if (!callFrame) 661 if (!callFrame)
725 return; 662 return;
726 663
727 var localScope = callFrame.localScope(); 664 var localScope = callFrame.localScope();
728 var functionLocation = callFrame.functionLocation(); 665 var functionLocation = callFrame.functionLocation();
729 if (localScope && functionLocation) 666 if (localScope && functionLocation)
730 WebInspector.SourceMapNamesResolver.resolveScopeInObject(localScope) .getAllProperties(false, this._prepareScopeVariables.bind(this, callFrame)); 667 WebInspector.SourceMapNamesResolver.resolveScopeInObject(localScope) .getAllProperties(false, this._prepareScopeVariables.bind(this, callFrame));
731 668
732 if (this._clearValueWidgetsTimer) { 669 if (this._clearValueWidgetsTimer) {
733 clearTimeout(this._clearValueWidgetsTimer); 670 clearTimeout(this._clearValueWidgetsTimer);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 this.uiSourceCode().removeEventListener(WebInspector.UISourceCode.Events .WorkingCopyChanged, this._workingCopyChanged, this); 1067 this.uiSourceCode().removeEventListener(WebInspector.UISourceCode.Events .WorkingCopyChanged, this._workingCopyChanged, this);
1131 this.uiSourceCode().removeEventListener(WebInspector.UISourceCode.Events .WorkingCopyCommitted, this._workingCopyCommitted, this); 1068 this.uiSourceCode().removeEventListener(WebInspector.UISourceCode.Events .WorkingCopyCommitted, this._workingCopyCommitted, this);
1132 this.uiSourceCode().removeEventListener(WebInspector.UISourceCode.Events .TitleChanged, this._showBlackboxInfobarIfNeeded, this); 1069 this.uiSourceCode().removeEventListener(WebInspector.UISourceCode.Events .TitleChanged, this._showBlackboxInfobarIfNeeded, this);
1133 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListene r(this._showBlackboxInfobarIfNeeded, this); 1070 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListene r(this._showBlackboxInfobarIfNeeded, this);
1134 WebInspector.moduleSetting("skipContentScripts").removeChangeListener(th is._showBlackboxInfobarIfNeeded, this); 1071 WebInspector.moduleSetting("skipContentScripts").removeChangeListener(th is._showBlackboxInfobarIfNeeded, this);
1135 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); 1072 WebInspector.UISourceCodeFrame.prototype.dispose.call(this);
1136 }, 1073 },
1137 1074
1138 __proto__: WebInspector.UISourceCodeFrame.prototype 1075 __proto__: WebInspector.UISourceCodeFrame.prototype
1139 } 1076 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698