OLD | NEW |
---|---|
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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 } | 544 } |
545 | 545 |
546 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); | 546 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); |
547 var handler = this._shortcuts[shortcut]; | 547 var handler = this._shortcuts[shortcut]; |
548 if (handler) { | 548 if (handler) { |
549 handler(); | 549 handler(); |
550 event.preventDefault(); | 550 event.preventDefault(); |
551 } | 551 } |
552 }, | 552 }, |
553 | 553 |
554 /** | |
555 * @param {string} expression | |
556 * @param {boolean} showResultOnly | |
557 */ | |
554 evaluateUsingTextPrompt: function(expression, showResultOnly) | 558 evaluateUsingTextPrompt: function(expression, showResultOnly) |
555 { | 559 { |
556 this._appendCommand(expression, this.prompt.text, false, showResultOnly) ; | 560 this._appendCommand(expression, this.prompt.text, false, showResultOnly) ; |
557 }, | 561 }, |
558 | 562 |
559 _enterKeyPressed: function(event) | 563 _enterKeyPressed: function(event) |
560 { | 564 { |
561 if (event.altKey || event.ctrlKey || event.shiftKey) | 565 if (event.altKey || event.ctrlKey || event.shiftKey) |
562 return; | 566 return; |
563 | 567 |
564 event.consume(true); | 568 event.consume(true); |
565 | 569 |
566 this.prompt.clearAutoComplete(true); | 570 this.prompt.clearAutoComplete(true); |
567 | 571 |
568 var str = this.prompt.text; | 572 var str = this.prompt.text; |
569 if (!str.length) | 573 if (!str.length) |
570 return; | 574 return; |
571 this._appendCommand(str, "", true, false); | 575 this._appendCommand(str, "", true, false); |
572 }, | 576 }, |
573 | 577 |
578 /** | |
579 * @param {WebInspector.RemoteObject} result | |
580 * @param {boolean} wasThrown | |
581 * @param {WebInspector.ConsoleCommand} originatingCommand | |
582 */ | |
574 _printResult: function(result, wasThrown, originatingCommand) | 583 _printResult: function(result, wasThrown, originatingCommand) |
575 { | 584 { |
576 if (!result) | 585 if (!result) |
577 return; | 586 return; |
578 var message = new WebInspector.ConsoleCommandResult(result, wasThrown, o riginatingCommand, this._linkifier); | 587 |
579 WebInspector.console.addMessage(message); | 588 /** |
589 * @param {string=} url | |
590 * @param {number=} lineNumber | |
591 * @param {number=} columnNumber | |
592 */ | |
593 function addMessage(url, lineNumber, columnNumber) | |
594 { | |
595 var message = new WebInspector.ConsoleCommandResult(result, wasThrow n, originatingCommand, this._linkifier, url, lineNumber, columnNumber); | |
596 WebInspector.console.addMessage(message); | |
597 } | |
598 | |
599 if (result.type !== "function") { | |
600 addMessage.call(this); | |
601 return; | |
602 } | |
603 | |
604 DebuggerAgent.getFunctionDetails(result.objectId, didGetDetails.bind(thi s)); | |
605 | |
606 /** | |
607 * @param {?Protocol.Error} error | |
608 * @param {DebuggerAgent.FunctionDetails} response | |
609 */ | |
610 function didGetDetails(error, response) | |
611 { | |
612 if (error) | |
613 console.error(error); | |
pfeldman
2013/08/28 15:46:15
Return early instead?
| |
614 | |
615 var url; | |
616 var lineNumber; | |
617 var columnNumber; | |
618 var rawLocation = response ? response.location : null; | |
619 var script = rawLocation ? WebInspector.debuggerModel.scriptForId(ra wLocation.scriptId) : null; | |
620 if (script && script.sourceURL) { | |
621 url = script.sourceURL; | |
622 lineNumber = rawLocation.lineNumber + 1; | |
623 columnNumber = rawLocation.columnNumber + 1; | |
pfeldman
2013/08/28 15:46:15
Lets remove the mess.
| |
624 } | |
625 addMessage.call(this, url, lineNumber, columnNumber); | |
626 } | |
580 }, | 627 }, |
581 | 628 |
629 /** | |
630 * @param {string} text | |
631 * @param {string} newPromptText | |
632 * @param {boolean} useCommandLineAPI | |
633 * @param {boolean} showResultOnly | |
634 */ | |
582 _appendCommand: function(text, newPromptText, useCommandLineAPI, showResultO nly) | 635 _appendCommand: function(text, newPromptText, useCommandLineAPI, showResultO nly) |
583 { | 636 { |
584 if (!showResultOnly) { | 637 if (!showResultOnly) { |
585 var commandMessage = new WebInspector.ConsoleCommand(text); | 638 var commandMessage = new WebInspector.ConsoleCommand(text); |
586 WebInspector.console.addMessage(commandMessage); | 639 WebInspector.console.addMessage(commandMessage); |
587 } | 640 } |
588 this.prompt.text = newPromptText; | 641 this.prompt.text = newPromptText; |
589 | 642 |
590 function printResult(result, wasThrown) | 643 /** |
644 * @param {WebInspector.RemoteObject} result | |
645 * @param {boolean} wasThrown | |
646 * @param {RuntimeAgent.RemoteObject=} valueResult | |
647 */ | |
648 function printResult(result, wasThrown, valueResult) | |
591 { | 649 { |
592 if (!result) | 650 if (!result) |
593 return; | 651 return; |
594 | 652 |
595 if (!showResultOnly) { | 653 if (!showResultOnly) { |
596 this.prompt.pushHistoryItem(text); | 654 this.prompt.pushHistoryItem(text); |
597 WebInspector.settings.consoleHistory.set(this.prompt.historyData .slice(-30)); | 655 WebInspector.settings.consoleHistory.set(this.prompt.historyData .slice(-30)); |
598 } | 656 } |
599 | 657 |
600 this._printResult(result, wasThrown, commandMessage); | 658 this._printResult(result, wasThrown, commandMessage); |
601 } | 659 } |
602 WebInspector.runtimeModel.evaluate(text, "console", useCommandLineAPI, f alse, false, true, printResult.bind(this)); | 660 WebInspector.runtimeModel.evaluate(text, "console", useCommandLineAPI, f alse, false, true, printResult.bind(this)); |
603 | 661 |
604 WebInspector.userMetrics.ConsoleEvaluated.record(); | 662 WebInspector.userMetrics.ConsoleEvaluated.record(); |
605 }, | 663 }, |
606 | 664 |
607 elementsToRestoreScrollPositionsFor: function() | 665 elementsToRestoreScrollPositionsFor: function() |
608 { | 666 { |
609 return [this.messagesElement]; | 667 return [this.messagesElement]; |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 }, | 1067 }, |
1010 | 1068 |
1011 clearHighlight: function() | 1069 clearHighlight: function() |
1012 { | 1070 { |
1013 var highlightedMessage = this._formattedCommand; | 1071 var highlightedMessage = this._formattedCommand; |
1014 delete this._formattedCommand; | 1072 delete this._formattedCommand; |
1015 this._formatCommand(); | 1073 this._formatCommand(); |
1016 this._element.replaceChild(this._formattedCommand, highlightedMessage); | 1074 this._element.replaceChild(this._formattedCommand, highlightedMessage); |
1017 }, | 1075 }, |
1018 | 1076 |
1077 /** | |
1078 * @param {RegExp} regexObject | |
1079 */ | |
1019 highlightSearchResults: function(regexObject) | 1080 highlightSearchResults: function(regexObject) |
1020 { | 1081 { |
1021 regexObject.lastIndex = 0; | 1082 regexObject.lastIndex = 0; |
1022 var match = regexObject.exec(this.text); | 1083 var match = regexObject.exec(this.text); |
1023 var matchRanges = []; | 1084 var matchRanges = []; |
1024 while (match) { | 1085 while (match) { |
1025 matchRanges.push({ offset: match.index, length: match[0].length }); | 1086 matchRanges.push({ offset: match.index, length: match[0].length }); |
1026 match = regexObject.exec(this.text); | 1087 match = regexObject.exec(this.text); |
1027 } | 1088 } |
1028 WebInspector.highlightSearchResults(this._formattedCommand, matchRanges) ; | 1089 WebInspector.highlightSearchResults(this._formattedCommand, matchRanges) ; |
1029 this._element.scrollIntoViewIfNeeded(); | 1090 this._element.scrollIntoViewIfNeeded(); |
1030 }, | 1091 }, |
1031 | 1092 |
1093 /** | |
1094 * @param {RegExp} regexObject | |
1095 */ | |
1032 matchesRegex: function(regexObject) | 1096 matchesRegex: function(regexObject) |
1033 { | 1097 { |
1034 regexObject.lastIndex = 0; | 1098 regexObject.lastIndex = 0; |
1035 return regexObject.test(this.text); | 1099 return regexObject.test(this.text); |
1036 }, | 1100 }, |
1037 | 1101 |
1038 toMessageElement: function() | 1102 toMessageElement: function() |
1039 { | 1103 { |
1040 if (!this._element) { | 1104 if (!this._element) { |
1041 this._element = document.createElement("div"); | 1105 this._element = document.createElement("div"); |
(...skipping 12 matching lines...) Expand all Loading... | |
1054 this._formattedCommand.className = "console-message-text source-code"; | 1118 this._formattedCommand.className = "console-message-text source-code"; |
1055 this._formattedCommand.textContent = this.text; | 1119 this._formattedCommand.textContent = this.text; |
1056 }, | 1120 }, |
1057 | 1121 |
1058 __proto__: WebInspector.ConsoleMessage.prototype | 1122 __proto__: WebInspector.ConsoleMessage.prototype |
1059 } | 1123 } |
1060 | 1124 |
1061 /** | 1125 /** |
1062 * @extends {WebInspector.ConsoleMessageImpl} | 1126 * @extends {WebInspector.ConsoleMessageImpl} |
1063 * @constructor | 1127 * @constructor |
1064 * @param {boolean} result | 1128 * @param {WebInspector.RemoteObject} result |
1065 * @param {boolean} wasThrown | 1129 * @param {boolean} wasThrown |
1066 * @param {WebInspector.ConsoleCommand} originatingCommand | 1130 * @param {WebInspector.ConsoleCommand} originatingCommand |
1067 * @param {WebInspector.Linkifier} linkifier | 1131 * @param {WebInspector.Linkifier} linkifier |
1132 * @param {string=} url | |
1133 * @param {number=} lineNumber | |
1134 * @param {number=} columnNumber | |
1068 */ | 1135 */ |
1069 WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingComma nd, linkifier) | 1136 WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingComma nd, linkifier, url, lineNumber, columnNumber) |
1070 { | 1137 { |
1071 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : We bInspector.ConsoleMessage.MessageLevel.Log); | 1138 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : We bInspector.ConsoleMessage.MessageLevel.Log); |
1072 this.originatingCommand = originatingCommand; | 1139 this.originatingCommand = originatingCommand; |
1073 WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.Messa geSource.JS, level, "", linkifier, WebInspector.ConsoleMessage.MessageType.Resul t, undefined, undefined, undefined, undefined, [result]); | 1140 WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.Messa geSource.JS, level, "", linkifier, WebInspector.ConsoleMessage.MessageType.Resul t, url, lineNumber, columnNumber, undefined, [result]); |
1074 } | 1141 } |
1075 | 1142 |
1076 WebInspector.ConsoleCommandResult.prototype = { | 1143 WebInspector.ConsoleCommandResult.prototype = { |
1077 /** | 1144 /** |
1078 * @override | 1145 * @override |
1079 * @param {WebInspector.RemoteObject} array | 1146 * @param {WebInspector.RemoteObject} array |
1080 * @return {boolean} | 1147 * @return {boolean} |
1081 */ | 1148 */ |
1082 useArrayPreviewInFormatter: function(array) | 1149 useArrayPreviewInFormatter: function(array) |
1083 { | 1150 { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1161 | 1228 |
1162 /** | 1229 /** |
1163 * @type {?WebInspector.ConsoleView} | 1230 * @type {?WebInspector.ConsoleView} |
1164 */ | 1231 */ |
1165 WebInspector.consoleView = null; | 1232 WebInspector.consoleView = null; |
1166 | 1233 |
1167 WebInspector.ConsoleMessage.create = function(source, level, message, type, url, line, column, repeatCount, parameters, stackTrace, requestId, isOutdated) | 1234 WebInspector.ConsoleMessage.create = function(source, level, message, type, url, line, column, repeatCount, parameters, stackTrace, requestId, isOutdated) |
1168 { | 1235 { |
1169 return new WebInspector.ConsoleMessageImpl(source, level, message, WebInspec tor.consoleView._linkifier, type, url, line, column, repeatCount, parameters, st ackTrace, requestId, isOutdated); | 1236 return new WebInspector.ConsoleMessageImpl(source, level, message, WebInspec tor.consoleView._linkifier, type, url, line, column, repeatCount, parameters, st ackTrace, requestId, isOutdated); |
1170 } | 1237 } |
OLD | NEW |