| 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); |
| 614 addMessage.call(this); |
| 615 return; |
| 616 } |
| 617 |
| 618 var url; |
| 619 var lineNumber; |
| 620 var columnNumber; |
| 621 var script = WebInspector.debuggerModel.scriptForId(response.locatio
n.scriptId); |
| 622 console.assert(script); |
| 623 if (script.sourceURL) { |
| 624 url = script.sourceURL; |
| 625 lineNumber = response.location.lineNumber + 1; |
| 626 columnNumber = response.location.columnNumber + 1; |
| 627 } |
| 628 addMessage.call(this, url, lineNumber, columnNumber); |
| 629 } |
| 580 }, | 630 }, |
| 581 | 631 |
| 632 /** |
| 633 * @param {string} text |
| 634 * @param {string} newPromptText |
| 635 * @param {boolean} useCommandLineAPI |
| 636 * @param {boolean} showResultOnly |
| 637 */ |
| 582 _appendCommand: function(text, newPromptText, useCommandLineAPI, showResultO
nly) | 638 _appendCommand: function(text, newPromptText, useCommandLineAPI, showResultO
nly) |
| 583 { | 639 { |
| 584 if (!showResultOnly) { | 640 if (!showResultOnly) { |
| 585 var commandMessage = new WebInspector.ConsoleCommand(text); | 641 var commandMessage = new WebInspector.ConsoleCommand(text); |
| 586 WebInspector.console.addMessage(commandMessage); | 642 WebInspector.console.addMessage(commandMessage); |
| 587 } | 643 } |
| 588 this.prompt.text = newPromptText; | 644 this.prompt.text = newPromptText; |
| 589 | 645 |
| 590 function printResult(result, wasThrown) | 646 /** |
| 647 * @param {WebInspector.RemoteObject} result |
| 648 * @param {boolean} wasThrown |
| 649 * @param {RuntimeAgent.RemoteObject=} valueResult |
| 650 */ |
| 651 function printResult(result, wasThrown, valueResult) |
| 591 { | 652 { |
| 592 if (!result) | 653 if (!result) |
| 593 return; | 654 return; |
| 594 | 655 |
| 595 if (!showResultOnly) { | 656 if (!showResultOnly) { |
| 596 this.prompt.pushHistoryItem(text); | 657 this.prompt.pushHistoryItem(text); |
| 597 WebInspector.settings.consoleHistory.set(this.prompt.historyData
.slice(-30)); | 658 WebInspector.settings.consoleHistory.set(this.prompt.historyData
.slice(-30)); |
| 598 } | 659 } |
| 599 | 660 |
| 600 this._printResult(result, wasThrown, commandMessage); | 661 this._printResult(result, wasThrown, commandMessage); |
| 601 } | 662 } |
| 602 WebInspector.runtimeModel.evaluate(text, "console", useCommandLineAPI, f
alse, false, true, printResult.bind(this)); | 663 WebInspector.runtimeModel.evaluate(text, "console", useCommandLineAPI, f
alse, false, true, printResult.bind(this)); |
| 603 | 664 |
| 604 WebInspector.userMetrics.ConsoleEvaluated.record(); | 665 WebInspector.userMetrics.ConsoleEvaluated.record(); |
| 605 }, | 666 }, |
| 606 | 667 |
| 607 elementsToRestoreScrollPositionsFor: function() | 668 elementsToRestoreScrollPositionsFor: function() |
| 608 { | 669 { |
| 609 return [this.messagesElement]; | 670 return [this.messagesElement]; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 }, | 1070 }, |
| 1010 | 1071 |
| 1011 clearHighlight: function() | 1072 clearHighlight: function() |
| 1012 { | 1073 { |
| 1013 var highlightedMessage = this._formattedCommand; | 1074 var highlightedMessage = this._formattedCommand; |
| 1014 delete this._formattedCommand; | 1075 delete this._formattedCommand; |
| 1015 this._formatCommand(); | 1076 this._formatCommand(); |
| 1016 this._element.replaceChild(this._formattedCommand, highlightedMessage); | 1077 this._element.replaceChild(this._formattedCommand, highlightedMessage); |
| 1017 }, | 1078 }, |
| 1018 | 1079 |
| 1080 /** |
| 1081 * @param {RegExp} regexObject |
| 1082 */ |
| 1019 highlightSearchResults: function(regexObject) | 1083 highlightSearchResults: function(regexObject) |
| 1020 { | 1084 { |
| 1021 regexObject.lastIndex = 0; | 1085 regexObject.lastIndex = 0; |
| 1022 var match = regexObject.exec(this.text); | 1086 var match = regexObject.exec(this.text); |
| 1023 var matchRanges = []; | 1087 var matchRanges = []; |
| 1024 while (match) { | 1088 while (match) { |
| 1025 matchRanges.push({ offset: match.index, length: match[0].length }); | 1089 matchRanges.push({ offset: match.index, length: match[0].length }); |
| 1026 match = regexObject.exec(this.text); | 1090 match = regexObject.exec(this.text); |
| 1027 } | 1091 } |
| 1028 WebInspector.highlightSearchResults(this._formattedCommand, matchRanges)
; | 1092 WebInspector.highlightSearchResults(this._formattedCommand, matchRanges)
; |
| 1029 this._element.scrollIntoViewIfNeeded(); | 1093 this._element.scrollIntoViewIfNeeded(); |
| 1030 }, | 1094 }, |
| 1031 | 1095 |
| 1096 /** |
| 1097 * @param {RegExp} regexObject |
| 1098 */ |
| 1032 matchesRegex: function(regexObject) | 1099 matchesRegex: function(regexObject) |
| 1033 { | 1100 { |
| 1034 regexObject.lastIndex = 0; | 1101 regexObject.lastIndex = 0; |
| 1035 return regexObject.test(this.text); | 1102 return regexObject.test(this.text); |
| 1036 }, | 1103 }, |
| 1037 | 1104 |
| 1038 toMessageElement: function() | 1105 toMessageElement: function() |
| 1039 { | 1106 { |
| 1040 if (!this._element) { | 1107 if (!this._element) { |
| 1041 this._element = document.createElement("div"); | 1108 this._element = document.createElement("div"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1054 this._formattedCommand.className = "console-message-text source-code"; | 1121 this._formattedCommand.className = "console-message-text source-code"; |
| 1055 this._formattedCommand.textContent = this.text; | 1122 this._formattedCommand.textContent = this.text; |
| 1056 }, | 1123 }, |
| 1057 | 1124 |
| 1058 __proto__: WebInspector.ConsoleMessage.prototype | 1125 __proto__: WebInspector.ConsoleMessage.prototype |
| 1059 } | 1126 } |
| 1060 | 1127 |
| 1061 /** | 1128 /** |
| 1062 * @extends {WebInspector.ConsoleMessageImpl} | 1129 * @extends {WebInspector.ConsoleMessageImpl} |
| 1063 * @constructor | 1130 * @constructor |
| 1064 * @param {boolean} result | 1131 * @param {WebInspector.RemoteObject} result |
| 1065 * @param {boolean} wasThrown | 1132 * @param {boolean} wasThrown |
| 1066 * @param {WebInspector.ConsoleCommand} originatingCommand | 1133 * @param {WebInspector.ConsoleCommand} originatingCommand |
| 1067 * @param {WebInspector.Linkifier} linkifier | 1134 * @param {WebInspector.Linkifier} linkifier |
| 1135 * @param {string=} url |
| 1136 * @param {number=} lineNumber |
| 1137 * @param {number=} columnNumber |
| 1068 */ | 1138 */ |
| 1069 WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingComma
nd, linkifier) | 1139 WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingComma
nd, linkifier, url, lineNumber, columnNumber) |
| 1070 { | 1140 { |
| 1071 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : We
bInspector.ConsoleMessage.MessageLevel.Log); | 1141 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : We
bInspector.ConsoleMessage.MessageLevel.Log); |
| 1072 this.originatingCommand = originatingCommand; | 1142 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]); | 1143 WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.Messa
geSource.JS, level, "", linkifier, WebInspector.ConsoleMessage.MessageType.Resul
t, url, lineNumber, columnNumber, undefined, [result]); |
| 1074 } | 1144 } |
| 1075 | 1145 |
| 1076 WebInspector.ConsoleCommandResult.prototype = { | 1146 WebInspector.ConsoleCommandResult.prototype = { |
| 1077 /** | 1147 /** |
| 1078 * @override | 1148 * @override |
| 1079 * @param {WebInspector.RemoteObject} array | 1149 * @param {WebInspector.RemoteObject} array |
| 1080 * @return {boolean} | 1150 * @return {boolean} |
| 1081 */ | 1151 */ |
| 1082 useArrayPreviewInFormatter: function(array) | 1152 useArrayPreviewInFormatter: function(array) |
| 1083 { | 1153 { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 | 1231 |
| 1162 /** | 1232 /** |
| 1163 * @type {?WebInspector.ConsoleView} | 1233 * @type {?WebInspector.ConsoleView} |
| 1164 */ | 1234 */ |
| 1165 WebInspector.consoleView = null; | 1235 WebInspector.consoleView = null; |
| 1166 | 1236 |
| 1167 WebInspector.ConsoleMessage.create = function(source, level, message, type, url,
line, column, repeatCount, parameters, stackTrace, requestId, isOutdated) | 1237 WebInspector.ConsoleMessage.create = function(source, level, message, type, url,
line, column, repeatCount, parameters, stackTrace, requestId, isOutdated) |
| 1168 { | 1238 { |
| 1169 return new WebInspector.ConsoleMessageImpl(source, level, message, WebInspec
tor.consoleView._linkifier, type, url, line, column, repeatCount, parameters, st
ackTrace, requestId, isOutdated); | 1239 return new WebInspector.ConsoleMessageImpl(source, level, message, WebInspec
tor.consoleView._linkifier, type, url, line, column, repeatCount, parameters, st
ackTrace, requestId, isOutdated); |
| 1170 } | 1240 } |
| OLD | NEW |