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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 this._viewport.setStickToBottom(true); | 100 this._viewport.setStickToBottom(true); |
101 this._viewport.contentElement().classList.add('console-group', 'console-grou
p-messages'); | 101 this._viewport.contentElement().classList.add('console-group', 'console-grou
p-messages'); |
102 this._contentsElement.appendChild(this._viewport.element); | 102 this._contentsElement.appendChild(this._viewport.element); |
103 this._messagesElement = this._viewport.element; | 103 this._messagesElement = this._viewport.element; |
104 this._messagesElement.id = 'console-messages'; | 104 this._messagesElement.id = 'console-messages'; |
105 this._messagesElement.classList.add('monospace'); | 105 this._messagesElement.classList.add('monospace'); |
106 this._messagesElement.addEventListener('click', this._messagesClicked.bind(t
his), true); | 106 this._messagesElement.addEventListener('click', this._messagesClicked.bind(t
his), true); |
107 | 107 |
108 this._viewportThrottler = new Common.Throttler(50); | 108 this._viewportThrottler = new Common.Throttler(50); |
109 | 109 |
110 this._filterStatusMessageElement = createElementWithClass('div', 'console-me
ssage'); | 110 this._filterStatusMessageElement = createElementWithClass('div', 'console-me
ssage-wrapper'); |
111 this._messagesElement.insertBefore(this._filterStatusMessageElement, this._m
essagesElement.firstChild); | 111 this._messagesElement.insertBefore(this._filterStatusMessageElement, this._m
essagesElement.firstChild); |
112 this._filterStatusTextElement = this._filterStatusMessageElement.createChild
('span', 'console-info'); | 112 this._filterStatusTextElement = this._filterStatusMessageElement.createChild
('span', 'console-info'); |
113 this._filterStatusMessageElement.createTextChild(' '); | 113 this._filterStatusMessageElement.createTextChild(' '); |
114 | 114 |
115 this._topGroup = Console.ConsoleGroup.createTopGroup(); | 115 this._topGroup = Console.ConsoleGroup.createTopGroup(); |
116 this._currentGroup = this._topGroup; | 116 this._currentGroup = this._topGroup; |
117 | 117 |
118 this._promptElement = this._messagesElement.createChild('div', 'source-code'
); | 118 this._promptElement = this._messagesElement.createChild('div', 'source-code'
); |
119 var promptIcon = UI.Icon.create('smallicon-text-prompt', 'console-prompt-ico
n'); | 119 var promptIcon = UI.Icon.create('smallicon-text-prompt', 'console-prompt-ico
n'); |
120 this._promptElement.appendChild(promptIcon); | 120 this._promptElement.appendChild(promptIcon); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 /** | 540 /** |
541 * @param {!SDK.ConsoleMessage} message | 541 * @param {!SDK.ConsoleMessage} message |
542 * @return {!Console.ConsoleViewMessage} | 542 * @return {!Console.ConsoleViewMessage} |
543 */ | 543 */ |
544 _createViewMessage(message) { | 544 _createViewMessage(message) { |
545 var nestingLevel = this._currentGroup.nestingLevel(); | 545 var nestingLevel = this._currentGroup.nestingLevel(); |
546 switch (message.type) { | 546 switch (message.type) { |
547 case SDK.ConsoleMessage.MessageType.Command: | 547 case SDK.ConsoleMessage.MessageType.Command: |
548 return new Console.ConsoleCommand(message, this._linkifier, nestingLevel
); | 548 return new Console.ConsoleCommand(message, this._linkifier, nestingLevel
); |
549 case SDK.ConsoleMessage.MessageType.Result: | |
550 return new Console.ConsoleCommandResult(message, this._linkifier, nestin
gLevel); | |
551 case SDK.ConsoleMessage.MessageType.StartGroupCollapsed: | 549 case SDK.ConsoleMessage.MessageType.StartGroupCollapsed: |
552 case SDK.ConsoleMessage.MessageType.StartGroup: | 550 case SDK.ConsoleMessage.MessageType.StartGroup: |
553 return new Console.ConsoleGroupViewMessage(message, this._linkifier, nes
tingLevel); | 551 return new Console.ConsoleGroupViewMessage(message, this._linkifier, nes
tingLevel); |
554 default: | 552 default: |
555 return new Console.ConsoleViewMessage(message, this._linkifier, nestingL
evel); | 553 return new Console.ConsoleViewMessage(message, this._linkifier, nestingL
evel); |
556 } | 554 } |
557 } | 555 } |
558 | 556 |
559 _consoleCleared() { | 557 _consoleCleared() { |
560 this._currentMatchRangeIndex = -1; | 558 this._currentMatchRangeIndex = -1; |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 super(message, linkifier, nestingLevel); | 1176 super(message, linkifier, nestingLevel); |
1179 } | 1177 } |
1180 | 1178 |
1181 /** | 1179 /** |
1182 * @override | 1180 * @override |
1183 * @return {!Element} | 1181 * @return {!Element} |
1184 */ | 1182 */ |
1185 contentElement() { | 1183 contentElement() { |
1186 if (!this._contentElement) { | 1184 if (!this._contentElement) { |
1187 this._contentElement = createElementWithClass('div', 'console-user-command
'); | 1185 this._contentElement = createElementWithClass('div', 'console-user-command
'); |
1188 var icon = UI.Icon.create('smallicon-user-command', 'command-result-icon')
; | |
1189 this._contentElement.appendChild(icon); | |
1190 | |
1191 this._contentElement.message = this; | 1186 this._contentElement.message = this; |
1192 | 1187 |
1193 this._formattedCommand = createElementWithClass('span', 'source-code'); | 1188 this._formattedCommand = createElementWithClass('span', 'source-code'); |
1194 this._formattedCommand.textContent = this.text.replaceControlCharacters(); | 1189 this._formattedCommand.textContent = this.text.replaceControlCharacters(); |
1195 this._contentElement.appendChild(this._formattedCommand); | 1190 this._contentElement.appendChild(this._formattedCommand); |
1196 | 1191 |
1197 if (this._formattedCommand.textContent.length < Console.ConsoleCommand.Max
LengthToIgnoreHighlighter) { | 1192 if (this._formattedCommand.textContent.length < Console.ConsoleCommand.Max
LengthToIgnoreHighlighter) { |
1198 var javascriptSyntaxHighlighter = new UI.SyntaxHighlighter('text/javascr
ipt', true); | 1193 var javascriptSyntaxHighlighter = new UI.SyntaxHighlighter('text/javascr
ipt', true); |
1199 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedCommand).
then(this._updateSearch.bind(this)); | 1194 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedCommand).
then(this._updateSearch.bind(this)); |
1200 } else { | 1195 } else { |
1201 this._updateSearch(); | 1196 this._updateSearch(); |
1202 } | 1197 } |
1203 | |
1204 this.updateTimestamp(); | |
1205 } | 1198 } |
1206 return this._contentElement; | 1199 return this._contentElement; |
1207 } | 1200 } |
1208 | 1201 |
1209 _updateSearch() { | 1202 _updateSearch() { |
1210 this.setSearchRegex(this.searchRegex()); | 1203 this.setSearchRegex(this.searchRegex()); |
1211 } | 1204 } |
1212 }; | 1205 }; |
1213 | 1206 |
1214 /** | 1207 /** |
1215 * The maximum length before strings are considered too long for syntax highligh
ting. | 1208 * The maximum length before strings are considered too long for syntax highligh
ting. |
1216 * @const | 1209 * @const |
1217 * @type {number} | 1210 * @type {number} |
1218 */ | 1211 */ |
1219 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; | 1212 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; |
1220 | 1213 |
1221 /** | 1214 /** |
1222 * @unrestricted | 1215 * @unrestricted |
1223 */ | 1216 */ |
1224 Console.ConsoleCommandResult = class extends Console.ConsoleViewMessage { | |
1225 /** | |
1226 * @param {!SDK.ConsoleMessage} message | |
1227 * @param {!Components.Linkifier} linkifier | |
1228 * @param {number} nestingLevel | |
1229 */ | |
1230 constructor(message, linkifier, nestingLevel) { | |
1231 super(message, linkifier, nestingLevel); | |
1232 } | |
1233 | |
1234 /** | |
1235 * @override | |
1236 * @return {!Element} | |
1237 */ | |
1238 contentElement() { | |
1239 var element = super.contentElement(); | |
1240 if (!element.classList.contains('console-user-command-result')) { | |
1241 element.classList.add('console-user-command-result'); | |
1242 if (this.consoleMessage().level === SDK.ConsoleMessage.MessageLevel.Info)
{ | |
1243 var icon = UI.Icon.create('smallicon-command-result', 'command-result-ic
on'); | |
1244 element.insertBefore(icon, element.firstChild); | |
1245 } | |
1246 } | |
1247 return element; | |
1248 } | |
1249 }; | |
1250 | |
1251 /** | |
1252 * @unrestricted | |
1253 */ | |
1254 Console.ConsoleGroup = class { | 1217 Console.ConsoleGroup = class { |
1255 /** | 1218 /** |
1256 * @param {?Console.ConsoleGroup} parentGroup | 1219 * @param {?Console.ConsoleGroup} parentGroup |
1257 * @param {?Console.ConsoleViewMessage} groupMessage | 1220 * @param {?Console.ConsoleViewMessage} groupMessage |
1258 */ | 1221 */ |
1259 constructor(parentGroup, groupMessage) { | 1222 constructor(parentGroup, groupMessage) { |
1260 this._parentGroup = parentGroup; | 1223 this._parentGroup = parentGroup; |
1261 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; | 1224 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; |
1262 this._messagesHidden = | 1225 this._messagesHidden = |
1263 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p
arentGroup.messagesHidden(); | 1226 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p
arentGroup.messagesHidden(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 return true; | 1280 return true; |
1318 } | 1281 } |
1319 return false; | 1282 return false; |
1320 } | 1283 } |
1321 }; | 1284 }; |
1322 | 1285 |
1323 /** | 1286 /** |
1324 * @typedef {{messageIndex: number, matchIndex: number}} | 1287 * @typedef {{messageIndex: number, matchIndex: number}} |
1325 */ | 1288 */ |
1326 Console.ConsoleView.RegexMatchRange; | 1289 Console.ConsoleView.RegexMatchRange; |
OLD | NEW |