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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js

Issue 2236033002: [DevTools] Simplify evaluation callbacks on frontend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-was-thrown
Patch Set: addressed comments 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) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 this._prompt.clearAutoComplete(true); 767 this._prompt.clearAutoComplete(true);
768 768
769 var str = this._prompt.text(); 769 var str = this._prompt.text();
770 if (!str.length) 770 if (!str.length)
771 return; 771 return;
772 this._appendCommand(str, true); 772 this._appendCommand(str, true);
773 }, 773 },
774 774
775 /** 775 /**
776 * @param {?WebInspector.RemoteObject} result 776 * @param {?WebInspector.RemoteObject} result
777 * @param {boolean} wasThrown
778 * @param {!WebInspector.ConsoleMessage} originatingConsoleMessage 777 * @param {!WebInspector.ConsoleMessage} originatingConsoleMessage
779 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails 778 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails
780 */ 779 */
781 _printResult: function(result, wasThrown, originatingConsoleMessage, excepti onDetails) 780 _printResult: function(result, originatingConsoleMessage, exceptionDetails)
782 { 781 {
783 if (!result) 782 if (!result)
784 return; 783 return;
785 784
786 var level = wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log; 785 var level = !!exceptionDetails ? WebInspector.ConsoleMessage.MessageLeve l.Error : WebInspector.ConsoleMessage.MessageLevel.Log;
787 var message; 786 var message;
788 if (!wasThrown) 787 if (!exceptionDetails)
789 message = new WebInspector.ConsoleMessage(result.target(), WebInspec tor.ConsoleMessage.MessageSource.JS, level, "", WebInspector.ConsoleMessage.Mess ageType.Result, undefined, undefined, undefined, undefined, [result]); 788 message = new WebInspector.ConsoleMessage(result.target(), WebInspec tor.ConsoleMessage.MessageSource.JS, level, "", WebInspector.ConsoleMessage.Mess ageType.Result, undefined, undefined, undefined, undefined, [result]);
790 else 789 else
791 message = new WebInspector.ConsoleMessage(result.target(), WebInspec tor.ConsoleMessage.MessageSource.JS, level, exceptionDetails.text, WebInspector. ConsoleMessage.MessageType.Result, undefined, exceptionDetails.lineNumber, excep tionDetails.columnNumber, undefined, [WebInspector.UIString("Uncaught"), result] , exceptionDetails.stackTrace, undefined, undefined, exceptionDetails.scriptId); 790 message = new WebInspector.ConsoleMessage(result.target(), WebInspec tor.ConsoleMessage.MessageSource.JS, level, exceptionDetails.text, WebInspector. ConsoleMessage.MessageType.Result, undefined, exceptionDetails.lineNumber, excep tionDetails.columnNumber, undefined, [WebInspector.UIString("Uncaught"), result] , exceptionDetails.stackTrace, undefined, undefined, exceptionDetails.scriptId);
792 message.setOriginatingMessage(originatingConsoleMessage); 791 message.setOriginatingMessage(originatingConsoleMessage);
793 result.target().consoleModel.addMessage(message); 792 result.target().consoleModel.addMessage(message);
794 }, 793 },
795 794
796 /** 795 /**
797 * @param {string} text 796 * @param {string} text
798 * @param {boolean} useCommandLineAPI 797 * @param {boolean} useCommandLineAPI
799 */ 798 */
800 _appendCommand: function(text, useCommandLineAPI) 799 _appendCommand: function(text, useCommandLineAPI)
801 { 800 {
802 this._prompt.setText(""); 801 this._prompt.setText("");
803 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E xecutionContext); 802 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E xecutionContext);
804 if (currentExecutionContext) { 803 if (currentExecutionContext) {
805 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionC ontext, text, useCommandLineAPI); 804 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionC ontext, text, useCommandLineAPI);
806 if (WebInspector.inspectorView.currentPanel() && WebInspector.inspec torView.currentPanel().name === "console") 805 if (WebInspector.inspectorView.currentPanel() && WebInspector.inspec torView.currentPanel().name === "console")
807 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Ac tion.CommandEvaluatedInConsolePanel); 806 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Ac tion.CommandEvaluatedInConsolePanel);
808 } 807 }
809 }, 808 },
810 809
811 /** 810 /**
812 * @param {!WebInspector.Event} event 811 * @param {!WebInspector.Event} event
813 */ 812 */
814 _commandEvaluated: function(event) 813 _commandEvaluated: function(event)
815 { 814 {
816 var data = /** @type {{result: ?WebInspector.RemoteObject, wasThrown: bo olean, text: string, commandMessage: !WebInspector.ConsoleMessage, exceptionDeta ils: (?RuntimeAgent.ExceptionDetails|undefined)}} */ (event.data); 815 var data = /** @type {{result: ?WebInspector.RemoteObject, text: string, commandMessage: !WebInspector.ConsoleMessage, exceptionDetails: (!RuntimeAgent. ExceptionDetails|undefined)}} */ (event.data);
817 this._prompt.history().pushHistoryItem(data.text); 816 this._prompt.history().pushHistoryItem(data.text);
818 this._consoleHistorySetting.set(this._prompt.history().historyData().sli ce(-WebInspector.ConsoleView.persistedHistorySize)); 817 this._consoleHistorySetting.set(this._prompt.history().historyData().sli ce(-WebInspector.ConsoleView.persistedHistorySize));
819 this._printResult(data.result, data.wasThrown, data.commandMessage, data .exceptionDetails); 818 this._printResult(data.result, data.commandMessage, data.exceptionDetail s);
820 }, 819 },
821 820
822 /** 821 /**
823 * @override 822 * @override
824 * @return {!Array.<!Element>} 823 * @return {!Array.<!Element>}
825 */ 824 */
826 elementsToRestoreScrollPositionsFor: function() 825 elementsToRestoreScrollPositionsFor: function()
827 { 826 {
828 return [this._messagesElement]; 827 return [this._messagesElement];
829 }, 828 },
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 return true; 1329 return true;
1331 } 1330 }
1332 return false; 1331 return false;
1333 } 1332 }
1334 } 1333 }
1335 1334
1336 /** 1335 /**
1337 * @typedef {{messageIndex: number, matchIndex: number}} 1336 * @typedef {{messageIndex: number, matchIndex: number}}
1338 */ 1337 */
1339 WebInspector.ConsoleView.RegexMatchRange; 1338 WebInspector.ConsoleView.RegexMatchRange;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698