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

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

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 WebInspector.targetManager.observeTargets(this); 148 WebInspector.targetManager.observeTargets(this);
149 149
150 this._initConsoleMessages(); 150 this._initConsoleMessages();
151 151
152 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this); 152 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this);
153 153
154 this._messagesElement.addEventListener("mousedown", this._updateStickToBotto mOnMouseDown.bind(this), false); 154 this._messagesElement.addEventListener("mousedown", this._updateStickToBotto mOnMouseDown.bind(this), false);
155 this._messagesElement.addEventListener("mouseup", this._updateStickToBottomO nMouseUp.bind(this), false); 155 this._messagesElement.addEventListener("mouseup", this._updateStickToBottomO nMouseUp.bind(this), false);
156 this._messagesElement.addEventListener("mouseleave", this._updateStickToBott omOnMouseUp.bind(this), false); 156 this._messagesElement.addEventListener("mouseleave", this._updateStickToBott omOnMouseUp.bind(this), false);
157 this._messagesElement.addEventListener("wheel", this._updateStickToBottomOnW heel.bind(this), false); 157 this._messagesElement.addEventListener("wheel", this._updateStickToBottomOnW heel.bind(this), false);
158 } 158 };
159 159
160 WebInspector.ConsoleView.persistedHistorySize = 300; 160 WebInspector.ConsoleView.persistedHistorySize = 300;
161 161
162 WebInspector.ConsoleView.prototype = { 162 WebInspector.ConsoleView.prototype = {
163 /** 163 /**
164 * @return {!WebInspector.SearchableView} 164 * @return {!WebInspector.SearchableView}
165 */ 165 */
166 searchableView: function() 166 searchableView: function()
167 { 167 {
168 return this._searchableView; 168 return this._searchableView;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 */ 445 */
446 function compareTimestamps(viewMessage1, viewMessage2) 446 function compareTimestamps(viewMessage1, viewMessage2)
447 { 447 {
448 return WebInspector.ConsoleMessage.timestampComparator(viewMessage1. consoleMessage(), viewMessage2.consoleMessage()); 448 return WebInspector.ConsoleMessage.timestampComparator(viewMessage1. consoleMessage(), viewMessage2.consoleMessage());
449 } 449 }
450 450
451 if (message.type === WebInspector.ConsoleMessage.MessageType.Command || message.type === WebInspector.ConsoleMessage.MessageType.Result) 451 if (message.type === WebInspector.ConsoleMessage.MessageType.Command || message.type === WebInspector.ConsoleMessage.MessageType.Result)
452 message.timestamp = this._consoleMessages.length ? this._consoleMess ages.peekLast().consoleMessage().timestamp : 0; 452 message.timestamp = this._consoleMessages.length ? this._consoleMess ages.peekLast().consoleMessage().timestamp : 0;
453 var viewMessage = this._createViewMessage(message); 453 var viewMessage = this._createViewMessage(message);
454 message[this._viewMessageSymbol] = viewMessage; 454 message[this._viewMessageSymbol] = viewMessage;
455 var insertAt = this._consoleMessages.upperBound(viewMessage, compareTime stamps) 455 var insertAt = this._consoleMessages.upperBound(viewMessage, compareTime stamps);
456 var insertedInMiddle = insertAt < this._consoleMessages.length; 456 var insertedInMiddle = insertAt < this._consoleMessages.length;
457 this._consoleMessages.splice(insertAt, 0, viewMessage); 457 this._consoleMessages.splice(insertAt, 0, viewMessage);
458 458
459 if (this._urlToMessageCount[message.url]) 459 if (this._urlToMessageCount[message.url])
460 ++this._urlToMessageCount[message.url]; 460 ++this._urlToMessageCount[message.url];
461 else 461 else
462 this._urlToMessageCount[message.url] = 1; 462 this._urlToMessageCount[message.url] = 1;
463 463
464 if (!insertedInMiddle) { 464 if (!insertedInMiddle) {
465 this._appendMessageToEnd(viewMessage); 465 this._appendMessageToEnd(viewMessage);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 this._linkifier.reset(); 561 this._linkifier.reset();
562 }, 562 },
563 563
564 _handleContextMenuEvent: function(event) 564 _handleContextMenuEvent: function(event)
565 { 565 {
566 if (event.target.enclosingNodeOrSelfWithNodeName("a")) 566 if (event.target.enclosingNodeOrSelfWithNodeName("a"))
567 return; 567 return;
568 568
569 var contextMenu = new WebInspector.ContextMenu(event); 569 var contextMenu = new WebInspector.ContextMenu(event);
570 if (event.target.isSelfOrDescendant(this._promptElement)) { 570 if (event.target.isSelfOrDescendant(this._promptElement)) {
571 contextMenu.show() 571 contextMenu.show();
572 return; 572 return;
573 } 573 }
574 574
575 function monitoringXHRItemAction() 575 function monitoringXHRItemAction()
576 { 576 {
577 WebInspector.moduleSetting("monitoringXHREnabled").set(!WebInspector .moduleSetting("monitoringXHREnabled").get()); 577 WebInspector.moduleSetting("monitoringXHREnabled").set(!WebInspector .moduleSetting("monitoringXHREnabled").get());
578 } 578 }
579 contextMenu.appendCheckboxItem(WebInspector.UIString("Log XMLHttpRequest s"), monitoringXHRItemAction, WebInspector.moduleSetting("monitoringXHREnabled") .get()); 579 contextMenu.appendCheckboxItem(WebInspector.UIString("Log XMLHttpRequest s"), monitoringXHRItemAction, WebInspector.moduleSetting("monitoringXHREnabled") .get());
580 580
581 var sourceElement = event.target.enclosingNodeOrSelfWithClass("console-m essage-wrapper"); 581 var sourceElement = event.target.enclosingNodeOrSelfWithClass("console-m essage-wrapper");
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 }, 1047 },
1048 1048
1049 _promptInput: function(event) 1049 _promptInput: function(event)
1050 { 1050 {
1051 // Scroll to the bottom, except when the prompt is the only visible item . 1051 // Scroll to the bottom, except when the prompt is the only visible item .
1052 if (this.itemCount() !== 0 && this._viewport.firstVisibleIndex() !== thi s.itemCount()) 1052 if (this.itemCount() !== 0 && this._viewport.firstVisibleIndex() !== thi s.itemCount())
1053 this._immediatelyScrollToBottom(); 1053 this._immediatelyScrollToBottom();
1054 }, 1054 },
1055 1055
1056 __proto__: WebInspector.VBox.prototype 1056 __proto__: WebInspector.VBox.prototype
1057 } 1057 };
1058 1058
1059 /** 1059 /**
1060 * @constructor 1060 * @constructor
1061 * @extends {WebInspector.Object} 1061 * @extends {WebInspector.Object}
1062 * @param {!WebInspector.ConsoleView} view 1062 * @param {!WebInspector.ConsoleView} view
1063 */ 1063 */
1064 WebInspector.ConsoleViewFilter = function(view) 1064 WebInspector.ConsoleViewFilter = function(view)
1065 { 1065 {
1066 this._messageURLFiltersSetting = WebInspector.settings.createSetting("messag eURLFilters", {}); 1066 this._messageURLFiltersSetting = WebInspector.settings.createSetting("messag eURLFilters", {});
1067 this._messageLevelFiltersSetting = WebInspector.settings.createSetting("mess ageLevelFilters", {}); 1067 this._messageLevelFiltersSetting = WebInspector.settings.createSetting("mess ageLevelFilters", {});
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 /** 1200 /**
1201 * @constructor 1201 * @constructor
1202 * @extends {WebInspector.ConsoleViewMessage} 1202 * @extends {WebInspector.ConsoleViewMessage}
1203 * @param {!WebInspector.ConsoleMessage} message 1203 * @param {!WebInspector.ConsoleMessage} message
1204 * @param {!WebInspector.Linkifier} linkifier 1204 * @param {!WebInspector.Linkifier} linkifier
1205 * @param {number} nestingLevel 1205 * @param {number} nestingLevel
1206 */ 1206 */
1207 WebInspector.ConsoleCommand = function(message, linkifier, nestingLevel) 1207 WebInspector.ConsoleCommand = function(message, linkifier, nestingLevel)
1208 { 1208 {
1209 WebInspector.ConsoleViewMessage.call(this, message, linkifier, nestingLevel) ; 1209 WebInspector.ConsoleViewMessage.call(this, message, linkifier, nestingLevel) ;
1210 } 1210 };
1211 1211
1212 WebInspector.ConsoleCommand.prototype = { 1212 WebInspector.ConsoleCommand.prototype = {
1213 /** 1213 /**
1214 * @override 1214 * @override
1215 * @return {!Element} 1215 * @return {!Element}
1216 */ 1216 */
1217 contentElement: function() 1217 contentElement: function()
1218 { 1218 {
1219 if (!this._contentElement) { 1219 if (!this._contentElement) {
1220 this._contentElement = createElementWithClass("div", "console-user-c ommand"); 1220 this._contentElement = createElementWithClass("div", "console-user-c ommand");
1221 this._contentElement.message = this; 1221 this._contentElement.message = this;
1222 1222
1223 this._formattedCommand = createElementWithClass("span", "console-mes sage-text source-code"); 1223 this._formattedCommand = createElementWithClass("span", "console-mes sage-text source-code");
1224 this._formattedCommand.textContent = this.text.replaceControlCharact ers(); 1224 this._formattedCommand.textContent = this.text.replaceControlCharact ers();
1225 this._contentElement.appendChild(this._formattedCommand); 1225 this._contentElement.appendChild(this._formattedCommand);
1226 1226
1227 if (this._formattedCommand.textContent.length < WebInspector.Console Command.MaxLengthToIgnoreHighlighter) { 1227 if (this._formattedCommand.textContent.length < WebInspector.Console Command.MaxLengthToIgnoreHighlighter) {
1228 var javascriptSyntaxHighlighter = new WebInspector.DOMSyntaxHigh lighter("text/javascript", true); 1228 var javascriptSyntaxHighlighter = new WebInspector.DOMSyntaxHigh lighter("text/javascript", true);
1229 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedC ommand).then(this._updateSearch.bind(this)) 1229 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedC ommand).then(this._updateSearch.bind(this));
1230 } else { 1230 } else {
1231 this._updateSearch(); 1231 this._updateSearch();
1232 } 1232 }
1233 } 1233 }
1234 return this._contentElement; 1234 return this._contentElement;
1235 }, 1235 },
1236 1236
1237 _updateSearch: function() 1237 _updateSearch: function()
1238 { 1238 {
1239 this.setSearchRegex(this.searchRegex()); 1239 this.setSearchRegex(this.searchRegex());
1240 }, 1240 },
1241 1241
1242 __proto__: WebInspector.ConsoleViewMessage.prototype 1242 __proto__: WebInspector.ConsoleViewMessage.prototype
1243 } 1243 };
1244 1244
1245 /** 1245 /**
1246 * The maximum length before strings are considered too long for syntax highligh ting. 1246 * The maximum length before strings are considered too long for syntax highligh ting.
1247 * @const 1247 * @const
1248 * @type {number} 1248 * @type {number}
1249 */ 1249 */
1250 WebInspector.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; 1250 WebInspector.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000;
1251 1251
1252 /** 1252 /**
1253 * @constructor 1253 * @constructor
1254 * @extends {WebInspector.ConsoleViewMessage} 1254 * @extends {WebInspector.ConsoleViewMessage}
1255 * @param {!WebInspector.ConsoleMessage} message 1255 * @param {!WebInspector.ConsoleMessage} message
1256 * @param {!WebInspector.Linkifier} linkifier 1256 * @param {!WebInspector.Linkifier} linkifier
1257 * @param {number} nestingLevel 1257 * @param {number} nestingLevel
1258 */ 1258 */
1259 WebInspector.ConsoleCommandResult = function(message, linkifier, nestingLevel) 1259 WebInspector.ConsoleCommandResult = function(message, linkifier, nestingLevel)
1260 { 1260 {
1261 WebInspector.ConsoleViewMessage.call(this, message, linkifier, nestingLevel) ; 1261 WebInspector.ConsoleViewMessage.call(this, message, linkifier, nestingLevel) ;
1262 } 1262 };
1263 1263
1264 WebInspector.ConsoleCommandResult.prototype = { 1264 WebInspector.ConsoleCommandResult.prototype = {
1265 /** 1265 /**
1266 * @override 1266 * @override
1267 * @return {!Element} 1267 * @return {!Element}
1268 */ 1268 */
1269 contentElement: function() 1269 contentElement: function()
1270 { 1270 {
1271 var element = WebInspector.ConsoleViewMessage.prototype.contentElement.c all(this); 1271 var element = WebInspector.ConsoleViewMessage.prototype.contentElement.c all(this);
1272 element.classList.add("console-user-command-result"); 1272 element.classList.add("console-user-command-result");
1273 this.updateTimestamp(false); 1273 this.updateTimestamp(false);
1274 return element; 1274 return element;
1275 }, 1275 },
1276 1276
1277 __proto__: WebInspector.ConsoleViewMessage.prototype 1277 __proto__: WebInspector.ConsoleViewMessage.prototype
1278 } 1278 };
1279 1279
1280 /** 1280 /**
1281 * @constructor 1281 * @constructor
1282 * @param {?WebInspector.ConsoleGroup} parentGroup 1282 * @param {?WebInspector.ConsoleGroup} parentGroup
1283 * @param {?WebInspector.ConsoleViewMessage} groupMessage 1283 * @param {?WebInspector.ConsoleViewMessage} groupMessage
1284 */ 1284 */
1285 WebInspector.ConsoleGroup = function(parentGroup, groupMessage) 1285 WebInspector.ConsoleGroup = function(parentGroup, groupMessage)
1286 { 1286 {
1287 this._parentGroup = parentGroup; 1287 this._parentGroup = parentGroup;
1288 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; 1288 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0;
1289 this._messagesHidden = groupMessage && groupMessage.collapsed() || this._par entGroup && this._parentGroup.messagesHidden(); 1289 this._messagesHidden = groupMessage && groupMessage.collapsed() || this._par entGroup && this._parentGroup.messagesHidden();
1290 } 1290 };
1291 1291
1292 /** 1292 /**
1293 * @return {!WebInspector.ConsoleGroup} 1293 * @return {!WebInspector.ConsoleGroup}
1294 */ 1294 */
1295 WebInspector.ConsoleGroup.createTopGroup = function() 1295 WebInspector.ConsoleGroup.createTopGroup = function()
1296 { 1296 {
1297 return new WebInspector.ConsoleGroup(null, null); 1297 return new WebInspector.ConsoleGroup(null, null);
1298 } 1298 };
1299 1299
1300 WebInspector.ConsoleGroup.prototype = { 1300 WebInspector.ConsoleGroup.prototype = {
1301 /** 1301 /**
1302 * @return {boolean} 1302 * @return {boolean}
1303 */ 1303 */
1304 messagesHidden: function() 1304 messagesHidden: function()
1305 { 1305 {
1306 return this._messagesHidden; 1306 return this._messagesHidden;
1307 }, 1307 },
1308 1308
1309 /** 1309 /**
1310 * @return {number} 1310 * @return {number}
1311 */ 1311 */
1312 nestingLevel: function() 1312 nestingLevel: function()
1313 { 1313 {
1314 return this._nestingLevel; 1314 return this._nestingLevel;
1315 }, 1315 },
1316 1316
1317 /** 1317 /**
1318 * @return {?WebInspector.ConsoleGroup} 1318 * @return {?WebInspector.ConsoleGroup}
1319 */ 1319 */
1320 parentGroup: function() 1320 parentGroup: function()
1321 { 1321 {
1322 return this._parentGroup || this; 1322 return this._parentGroup || this;
1323 }, 1323 },
1324 } 1324 };
1325 1325
1326 /** 1326 /**
1327 * @return {!WebInspector.ConsoleView} 1327 * @return {!WebInspector.ConsoleView}
1328 */ 1328 */
1329 WebInspector.ConsoleView.instance = function() 1329 WebInspector.ConsoleView.instance = function()
1330 { 1330 {
1331 if (!WebInspector.ConsoleView._instance) 1331 if (!WebInspector.ConsoleView._instance)
1332 WebInspector.ConsoleView._instance = new WebInspector.ConsoleView(); 1332 WebInspector.ConsoleView._instance = new WebInspector.ConsoleView();
1333 return WebInspector.ConsoleView._instance; 1333 return WebInspector.ConsoleView._instance;
1334 } 1334 };
1335 1335
1336 WebInspector.ConsoleView.clearConsole = function() 1336 WebInspector.ConsoleView.clearConsole = function()
1337 { 1337 {
1338 for (var target of WebInspector.targetManager.targets()) { 1338 for (var target of WebInspector.targetManager.targets()) {
1339 target.runtimeModel.discardConsoleEntries(); 1339 target.runtimeModel.discardConsoleEntries();
1340 target.consoleModel.requestClearMessages(); 1340 target.consoleModel.requestClearMessages();
1341 } 1341 }
1342 } 1342 };
1343 1343
1344 /** 1344 /**
1345 * @constructor 1345 * @constructor
1346 * @implements {WebInspector.ActionDelegate} 1346 * @implements {WebInspector.ActionDelegate}
1347 */ 1347 */
1348 WebInspector.ConsoleView.ActionDelegate = function() 1348 WebInspector.ConsoleView.ActionDelegate = function()
1349 { 1349 {
1350 } 1350 };
1351 1351
1352 WebInspector.ConsoleView.ActionDelegate.prototype = { 1352 WebInspector.ConsoleView.ActionDelegate.prototype = {
1353 /** 1353 /**
1354 * @override 1354 * @override
1355 * @param {!WebInspector.Context} context 1355 * @param {!WebInspector.Context} context
1356 * @param {string} actionId 1356 * @param {string} actionId
1357 * @return {boolean} 1357 * @return {boolean}
1358 */ 1358 */
1359 handleAction: function(context, actionId) 1359 handleAction: function(context, actionId)
1360 { 1360 {
1361 switch (actionId) { 1361 switch (actionId) {
1362 case "console.show": 1362 case "console.show":
1363 WebInspector.console.show(); 1363 WebInspector.console.show();
1364 return true; 1364 return true;
1365 case "console.clear": 1365 case "console.clear":
1366 WebInspector.ConsoleView.clearConsole(); 1366 WebInspector.ConsoleView.clearConsole();
1367 return true; 1367 return true;
1368 case "console.clear.history": 1368 case "console.clear.history":
1369 WebInspector.ConsoleView.instance()._clearHistory(); 1369 WebInspector.ConsoleView.instance()._clearHistory();
1370 return true; 1370 return true;
1371 } 1371 }
1372 return false; 1372 return false;
1373 } 1373 }
1374 } 1374 };
1375 1375
1376 /** 1376 /**
1377 * @typedef {{messageIndex: number, matchIndex: number}} 1377 * @typedef {{messageIndex: number, matchIndex: number}}
1378 */ 1378 */
1379 WebInspector.ConsoleView.RegexMatchRange; 1379 WebInspector.ConsoleView.RegexMatchRange;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698