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

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

Issue 2651843003: DevTools: update console timestamp style (Closed)
Patch Set: Created 3 years, 11 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 /** 809 /**
810 * @return {boolean} 810 * @return {boolean}
811 */ 811 */
812 matchesFilterRegex(regexObject) { 812 matchesFilterRegex(regexObject) {
813 regexObject.lastIndex = 0; 813 regexObject.lastIndex = 0;
814 var text = this.contentElement().deepTextContent(); 814 var text = this.contentElement().deepTextContent();
815 return regexObject.test(text); 815 return regexObject.test(text);
816 } 816 }
817 817
818 /** 818 /**
819 * @param {boolean} show 819 * @param {!Console.ConsoleViewMessage.TimestampFormat} format
820 */ 820 */
821 updateTimestamp(show) { 821 updateTimestamp(format) {
822 if (!this._contentElement) 822 if (!this._contentElement)
823 return; 823 return;
824 824
825 if (show && !this.timestampElement) { 825 var show = format !== Console.ConsoleViewMessage.TimestampFormat.None;
826 this.timestampElement = createElementWithClass('span', 'console-timestamp' ); 826 if (show) {
827 this.timestampElement.textContent = (new Date(this._message.timestamp)).to ConsoleTime() + ' '; 827 var timestamp = (new Date(this._message.timestamp)).toConsoleTime();
chenwilliam 2017/01/24 03:32:13 Instead of extending the Date prototype... you can
luoe 2017/01/24 23:16:19 Done.
828 var timestampText = timestamp.hourMinuteSecond;
829 if (format === Console.ConsoleViewMessage.TimestampFormat.Full)
830 timestampText = timestamp.yearMonthDay + ' ' + timestampText;
831 if (!this.timestampElement)
832 this.timestampElement = createElementWithClass('span', 'console-timestam p');
833 this.timestampElement.textContent = timestampText + ' ';
834 this.timestampElement.title = timestampText;
828 this._contentElement.insertBefore(this.timestampElement, this._contentElem ent.firstChild); 835 this._contentElement.insertBefore(this.timestampElement, this._contentElem ent.firstChild);
829 return; 836 } else if (!show && this.timestampElement) {
830 }
831
832 if (!show && this.timestampElement) {
833 this.timestampElement.remove(); 837 this.timestampElement.remove();
834 delete this.timestampElement; 838 delete this.timestampElement;
835 } 839 }
836 } 840 }
837 841
838 /** 842 /**
839 * @return {number} 843 * @return {number}
840 */ 844 */
841 nestingLevel() { 845 nestingLevel() {
842 return this._nestingLevel; 846 return this._nestingLevel;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 consoleMessage.type === SDK.ConsoleMessa ge.MessageType.Trace || 892 consoleMessage.type === SDK.ConsoleMessa ge.MessageType.Trace ||
889 consoleMessage.level === SDK.ConsoleMess age.MessageLevel.Warning); 893 consoleMessage.level === SDK.ConsoleMess age.MessageLevel.Warning);
890 if (target && shouldIncludeTrace) 894 if (target && shouldIncludeTrace)
891 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target , this._linkifier); 895 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target , this._linkifier);
892 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table) 896 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table)
893 formattedMessage = this._buildTableMessage(this._message); 897 formattedMessage = this._buildTableMessage(this._message);
894 else 898 else
895 formattedMessage = this._buildMessage(consoleMessage); 899 formattedMessage = this._buildMessage(consoleMessage);
896 contentElement.appendChild(formattedMessage); 900 contentElement.appendChild(formattedMessage);
897 901
898 this.updateTimestamp(Common.moduleSetting('consoleTimestampsEnabled').get()) ; 902 this.updateTimestamp(Common.moduleSetting('consoleTimestampFormat').get());
899 return this._contentElement; 903 return this._contentElement;
900 } 904 }
901 905
902 /** 906 /**
903 * @return {!Element} 907 * @return {!Element}
904 */ 908 */
905 toMessageElement() { 909 toMessageElement() {
906 if (this._element) 910 if (this._element)
907 return this._element; 911 return this._element;
908 912
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 repeatCount() { 980 repeatCount() {
977 return this._repeatCount || 1; 981 return this._repeatCount || 1;
978 } 982 }
979 983
980 resetIncrementRepeatCount() { 984 resetIncrementRepeatCount() {
981 this._repeatCount = 1; 985 this._repeatCount = 1;
982 if (!this._repeatCountElement) 986 if (!this._repeatCountElement)
983 return; 987 return;
984 988
985 this._repeatCountElement.remove(); 989 this._repeatCountElement.remove();
990 if (this._contentElement)
991 this._contentElement.classList.remove('repeated-message');
986 delete this._repeatCountElement; 992 delete this._repeatCountElement;
987 } 993 }
988 994
989 incrementRepeatCount() { 995 incrementRepeatCount() {
990 this._repeatCount++; 996 this._repeatCount++;
991 this._showRepeatCountElement(); 997 this._showRepeatCountElement();
992 } 998 }
993 999
994 _showRepeatCountElement() { 1000 _showRepeatCountElement() {
995 if (!this._contentElement) 1001 if (!this._contentElement)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } 1168 }
1163 1169
1164 if (start !== string.length) 1170 if (start !== string.length)
1165 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs tring(start))); 1171 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs tring(start)));
1166 1172
1167 return formattedResult; 1173 return formattedResult;
1168 } 1174 }
1169 }; 1175 };
1170 1176
1171 /** 1177 /**
1178 * @enum {string}
1179 */
1180 Console.ConsoleViewMessage.TimestampFormat = {
1181 None: 'none',
1182 Full: 'full',
1183 Short: 'short'
1184 };
1185
1186 /**
1172 * @unrestricted 1187 * @unrestricted
1173 */ 1188 */
1174 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage { 1189 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage {
1175 /** 1190 /**
1176 * @param {!SDK.ConsoleMessage} consoleMessage 1191 * @param {!SDK.ConsoleMessage} consoleMessage
1177 * @param {!Components.Linkifier} linkifier 1192 * @param {!Components.Linkifier} linkifier
1178 * @param {number} nestingLevel 1193 * @param {number} nestingLevel
1179 */ 1194 */
1180 constructor(consoleMessage, linkifier, nestingLevel) { 1195 constructor(consoleMessage, linkifier, nestingLevel) {
1181 console.assert(consoleMessage.isGroupStartMessage()); 1196 console.assert(consoleMessage.isGroupStartMessage());
(...skipping 26 matching lines...) Expand all
1208 toMessageElement() { 1223 toMessageElement() {
1209 if (!this._element) { 1224 if (!this._element) {
1210 super.toMessageElement(); 1225 super.toMessageElement();
1211 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1226 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1212 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1227 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1213 this.setCollapsed(this._collapsed); 1228 this.setCollapsed(this._collapsed);
1214 } 1229 }
1215 return this._element; 1230 return this._element;
1216 } 1231 }
1217 }; 1232 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698