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

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

Issue 2623143002: DevTools: insert console message decorations in order
Patch Set: build markers on waasShown Created 3 years, 10 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 22 matching lines...) Expand all
143 this._prompt.element.addEventListener('keydown', this._promptKeyDown.bind(th is), true); 143 this._prompt.element.addEventListener('keydown', this._promptKeyDown.bind(th is), true);
144 144
145 this._consoleHistoryAutocompleteSetting = Common.moduleSetting('consoleHisto ryAutocomplete'); 145 this._consoleHistoryAutocompleteSetting = Common.moduleSetting('consoleHisto ryAutocomplete');
146 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto ryAutocompleteChanged, this); 146 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto ryAutocompleteChanged, this);
147 147
148 var historyData = this._consoleHistorySetting.get(); 148 var historyData = this._consoleHistorySetting.get();
149 this._prompt.history().setHistoryData(historyData); 149 this._prompt.history().setHistoryData(historyData);
150 this._consoleHistoryAutocompleteChanged(); 150 this._consoleHistoryAutocompleteChanged();
151 151
152 this._updateFilterStatus(); 152 this._updateFilterStatus();
153 Common.moduleSetting('consoleTimestampFormat').addChangeListener(this._conso leTimestampsSettingChanged, this); 153 Common.moduleSetting('consoleTimestampFormat').addChangeListener(this._updat eMessageList, this);
154 154
155 this._registerWithMessageSink(); 155 this._registerWithMessageSink();
156 SDK.targetManager.observeTargets(this); 156 SDK.targetManager.observeTargets(this);
157 157
158 this._initConsoleMessages(); 158 this._initConsoleMessages();
159 159
160 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChanged, this); 160 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChanged, this);
161 161
162 this._messagesElement.addEventListener('mousedown', this._updateStickToBotto mOnMouseDown.bind(this), false); 162 this._messagesElement.addEventListener('mousedown', this._updateStickToBotto mOnMouseDown.bind(this), false);
163 this._messagesElement.addEventListener('mouseup', this._updateStickToBottomO nMouseUp.bind(this), false); 163 this._messagesElement.addEventListener('mouseup', this._updateStickToBottomO nMouseUp.bind(this), false);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 level = SDK.ConsoleMessage.MessageLevel.Warning; 313 level = SDK.ConsoleMessage.MessageLevel.Warning;
314 break; 314 break;
315 } 315 }
316 316
317 var consoleMessage = new SDK.ConsoleMessage( 317 var consoleMessage = new SDK.ConsoleMessage(
318 null, SDK.ConsoleMessage.MessageSource.Other, level, message.text, undef ined, undefined, undefined, undefined, 318 null, SDK.ConsoleMessage.MessageSource.Other, level, message.text, undef ined, undefined, undefined, undefined,
319 undefined, undefined, undefined, message.timestamp); 319 undefined, undefined, undefined, message.timestamp);
320 this._addConsoleMessage(consoleMessage); 320 this._addConsoleMessage(consoleMessage);
321 } 321 }
322 322
323 _consoleTimestampsSettingChanged() {
324 this._updateMessageList();
325 this._consoleMessages.forEach(viewMessage => viewMessage.updateTimestamp());
326 }
327
328 _executionContextChanged() { 323 _executionContextChanged() {
329 this._prompt.clearAutocomplete(); 324 this._prompt.clearAutocomplete();
330 if (this._filter._showTargetMessagesCheckbox.checked()) 325 if (this._filter._showTargetMessagesCheckbox.checked())
331 this._updateMessageList(); 326 this._updateMessageList();
332 } 327 }
333 328
334 /** 329 /**
335 * @override 330 * @override
336 */ 331 */
337 willHide() { 332 willHide() {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 534
540 /** 535 /**
541 * @param {!SDK.ConsoleMessage} message 536 * @param {!SDK.ConsoleMessage} message
542 * @return {!Console.ConsoleViewMessage} 537 * @return {!Console.ConsoleViewMessage}
543 */ 538 */
544 _createViewMessage(message) { 539 _createViewMessage(message) {
545 var nestingLevel = this._currentGroup.nestingLevel(); 540 var nestingLevel = this._currentGroup.nestingLevel();
546 switch (message.type) { 541 switch (message.type) {
547 case SDK.ConsoleMessage.MessageType.Command: 542 case SDK.ConsoleMessage.MessageType.Command:
548 return new Console.ConsoleCommand(message, this._linkifier, nestingLevel ); 543 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: 544 case SDK.ConsoleMessage.MessageType.StartGroupCollapsed:
552 case SDK.ConsoleMessage.MessageType.StartGroup: 545 case SDK.ConsoleMessage.MessageType.StartGroup:
553 return new Console.ConsoleGroupViewMessage(message, this._linkifier, nes tingLevel); 546 return new Console.ConsoleGroupViewMessage(message, this._linkifier, nes tingLevel);
554 default: 547 default:
555 return new Console.ConsoleViewMessage(message, this._linkifier, nestingL evel); 548 return new Console.ConsoleViewMessage(message, this._linkifier, nestingL evel);
556 } 549 }
557 } 550 }
558 551
559 _consoleCleared() { 552 _consoleCleared() {
560 this._currentMatchRangeIndex = -1; 553 this._currentMatchRangeIndex = -1;
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 super(message, linkifier, nestingLevel); 1171 super(message, linkifier, nestingLevel);
1179 } 1172 }
1180 1173
1181 /** 1174 /**
1182 * @override 1175 * @override
1183 * @return {!Element} 1176 * @return {!Element}
1184 */ 1177 */
1185 contentElement() { 1178 contentElement() {
1186 if (!this._contentElement) { 1179 if (!this._contentElement) {
1187 this._contentElement = createElementWithClass('div', 'console-user-command '); 1180 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; 1181 this._contentElement.message = this;
1192 1182
1193 this._formattedCommand = createElementWithClass('span', 'source-code'); 1183 this._formattedCommand = createElementWithClass('span', 'source-code');
1194 this._formattedCommand.textContent = this.text.replaceControlCharacters(); 1184 this._formattedCommand.textContent = this.text.replaceControlCharacters();
1195 this._contentElement.appendChild(this._formattedCommand); 1185 this._contentElement.appendChild(this._formattedCommand);
1196 1186
1197 if (this._formattedCommand.textContent.length < Console.ConsoleCommand.Max LengthToIgnoreHighlighter) { 1187 if (this._formattedCommand.textContent.length < Console.ConsoleCommand.Max LengthToIgnoreHighlighter) {
1198 var javascriptSyntaxHighlighter = new UI.SyntaxHighlighter('text/javascr ipt', true); 1188 var javascriptSyntaxHighlighter = new UI.SyntaxHighlighter('text/javascr ipt', true);
1199 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedCommand). then(this._updateSearch.bind(this)); 1189 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedCommand). then(this._updateSearch.bind(this));
1200 } else { 1190 } else {
1201 this._updateSearch(); 1191 this._updateSearch();
1202 } 1192 }
1203
1204 this.updateTimestamp();
1205 } 1193 }
1206 return this._contentElement; 1194 return this._contentElement;
1207 } 1195 }
1208 1196
1209 _updateSearch() { 1197 _updateSearch() {
1210 this.setSearchRegex(this.searchRegex()); 1198 this.setSearchRegex(this.searchRegex());
1211 } 1199 }
1212 }; 1200 };
1213 1201
1214 /** 1202 /**
1215 * The maximum length before strings are considered too long for syntax highligh ting. 1203 * The maximum length before strings are considered too long for syntax highligh ting.
1216 * @const 1204 * @const
1217 * @type {number} 1205 * @type {number}
1218 */ 1206 */
1219 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; 1207 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000;
1220 1208
1221 /** 1209 /**
1222 * @unrestricted 1210 * @unrestricted
1223 */ 1211 */
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 { 1212 Console.ConsoleGroup = class {
1255 /** 1213 /**
1256 * @param {?Console.ConsoleGroup} parentGroup 1214 * @param {?Console.ConsoleGroup} parentGroup
1257 * @param {?Console.ConsoleViewMessage} groupMessage 1215 * @param {?Console.ConsoleViewMessage} groupMessage
1258 */ 1216 */
1259 constructor(parentGroup, groupMessage) { 1217 constructor(parentGroup, groupMessage) {
1260 this._parentGroup = parentGroup; 1218 this._parentGroup = parentGroup;
1261 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; 1219 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0;
1262 this._messagesHidden = 1220 this._messagesHidden =
1263 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p arentGroup.messagesHidden(); 1221 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p arentGroup.messagesHidden();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 return true; 1275 return true;
1318 } 1276 }
1319 return false; 1277 return false;
1320 } 1278 }
1321 }; 1279 };
1322 1280
1323 /** 1281 /**
1324 * @typedef {{messageIndex: number, matchIndex: number}} 1282 * @typedef {{messageIndex: number, matchIndex: number}}
1325 */ 1283 */
1326 Console.ConsoleView.RegexMatchRange; 1284 Console.ConsoleView.RegexMatchRange;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698