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

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

Issue 2623143002: DevTools: insert console message decorations in order
Patch Set: a 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) 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 this._repeatCount = 1; 43 this._repeatCount = 1;
44 this._closeGroupDecorationCount = 0; 44 this._closeGroupDecorationCount = 0;
45 this._nestingLevel = nestingLevel; 45 this._nestingLevel = nestingLevel;
46 46
47 /** @type {?DataGrid.DataGrid} */ 47 /** @type {?DataGrid.DataGrid} */
48 this._dataGrid = null; 48 this._dataGrid = null;
49 this._previewFormatter = new Components.RemoteObjectPreviewFormatter(); 49 this._previewFormatter = new Components.RemoteObjectPreviewFormatter();
50 this._searchRegex = null; 50 this._searchRegex = null;
51 /** @type {?UI.Icon} */ 51 /** @type {?UI.Icon} */
52 this._messageLevelIcon = null; 52 this._messageLevelIcon = null;
53 /** @type {!Element|undefined} */
54 this._timestampElement;
luoe 2017/01/28 01:01:22 Drive by
55 /** @type {!Element|undefined} */
56 this._contextIcon;
53 } 57 }
54 58
55 /** 59 /**
56 * @return {?SDK.Target} 60 * @return {?SDK.Target}
57 */ 61 */
58 _target() { 62 _target() {
59 return this.consoleMessage().target(); 63 return this.consoleMessage().target();
60 } 64 }
61 65
62 /** 66 /**
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 return regexObject.test(text); 821 return regexObject.test(text);
818 } 822 }
819 823
820 updateTimestamp() { 824 updateTimestamp() {
821 if (!this._contentElement) 825 if (!this._contentElement)
822 return; 826 return;
823 827
824 var format = Common.moduleSetting('consoleTimestampFormat').get(); 828 var format = Common.moduleSetting('consoleTimestampFormat').get();
825 if (format !== Console.ConsoleViewMessage.TimestampFormat.None) { 829 if (format !== Console.ConsoleViewMessage.TimestampFormat.None) {
826 var timestampText = formatTimestamp(this._message.timestamp, format); 830 var timestampText = formatTimestamp(this._message.timestamp, format);
827 if (!this._timestampElement) 831 if (!this._timestampElement) {
828 this._timestampElement = createElementWithClass('span', 'console-timesta mp'); 832 this._timestampElement = createElementWithClass('span', 'console-timesta mp');
833 this._contentElement.insertBefore(this._timestampElement, this._contentE lement.firstChild);
834 }
luoe 2017/01/28 01:01:22 Drive by change
829 this._timestampElement.textContent = timestampText + ' '; 835 this._timestampElement.textContent = timestampText + ' ';
830 this._timestampElement.title = timestampText; 836 this._timestampElement.title = timestampText;
831 this._contentElement.insertBefore(this._timestampElement, this._contentEle ment.firstChild);
832 } else if (this._timestampElement) { 837 } else if (this._timestampElement) {
833 this._timestampElement.remove(); 838 this._timestampElement.remove();
834 delete this._timestampElement; 839 delete this._timestampElement;
835 } 840 }
836 841
837 /** 842 /**
838 * @param {number} timestamp 843 * @param {number} timestamp
839 * @param {!Console.ConsoleViewMessage.TimestampFormat} format 844 * @param {!Console.ConsoleViewMessage.TimestampFormat} format
840 * @return {string} 845 * @return {string}
841 */ 846 */
(...skipping 12 matching lines...) Expand all
854 * @return {string} 859 * @return {string}
855 */ 860 */
856 function leadZero(value, length) { 861 function leadZero(value, length) {
857 var valueString = value.toString(); 862 var valueString = value.toString();
858 var padding = length - valueString.length; 863 var padding = length - valueString.length;
859 return padding <= 0 ? valueString : '0'.repeat(padding) + valueString; 864 return padding <= 0 ? valueString : '0'.repeat(padding) + valueString;
860 } 865 }
861 } 866 }
862 } 867 }
863 868
869 updateContextLabel() {
870 var target = this._target();
871 if (!this._contentElement || !target)
872 return;
873
874 var show = Common.moduleSetting('consoleContextLabelsEnabled').get();
875 if (show && !this._contextIcon) {
876 var subTargetsManager = SDK.SubTargetsManager.fromTarget(target);
877 var mainTarget = target.targetManager().mainTarget();
878 var targetInfo;
879 if (subTargetsManager)
880 targetInfo = subTargetsManager.targetInfo(target);
881 else if (mainTarget && mainTarget.subTargetsManager)
882 targetInfo = mainTarget.subTargetsManager.targetInfo(target);
883 var targetType = targetInfo ? targetInfo.type : null;
884 var messageContext = target.runtimeModel.executionContext(this._message.ex ecutionContextId);
885
886 if (messageContext && messageContext.frameId && !Console.ConsoleContextSel ector.isTopContext(messageContext)) {
887 if (messageContext.isDefault)
888 this._contextIcon = UI.Icon.create('smallicon-frame', 'console-context -icon');
889 else
890 this._contextIcon = UI.Icon.create('smallicon-extension', 'console-con text-icon');
891 } else if (targetType === 'service_worker' || targetType === 'worker') {
892 this._contextIcon = UI.Icon.create('smallicon-worker', 'console-context- icon');
893 }
894
895 if (this._contextIcon) {
896 var subTargetName = subTargetsManager ? subTargetsManager.target().name( ) : null;
897 var title = subTargetName || target.name();
898 if (messageContext)
899 title = Console.ConsoleContextSelector.titleForContext(messageContext) .trim();
900 this._contextIcon.title = title;
901 this._contentElement.insertBefore(this._contextIcon, this._contentElemen t.firstChild);
902 }
903 } else if (this._contextIcon && !show) {
904 this._contextIcon.remove();
905 delete this._contextIcon;
906 }
907 }
908
864 /** 909 /**
865 * @return {number} 910 * @return {number}
866 */ 911 */
867 nestingLevel() { 912 nestingLevel() {
868 return this._nestingLevel; 913 return this._nestingLevel;
869 } 914 }
870 915
871 resetCloseGroupDecorationCount() { 916 resetCloseGroupDecorationCount() {
872 if (!this._closeGroupDecorationCount) 917 if (!this._closeGroupDecorationCount)
873 return; 918 return;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 consoleMessage.type === SDK.ConsoleMessa ge.MessageType.Trace || 958 consoleMessage.type === SDK.ConsoleMessa ge.MessageType.Trace ||
914 consoleMessage.level === SDK.ConsoleMess age.MessageLevel.Warning); 959 consoleMessage.level === SDK.ConsoleMess age.MessageLevel.Warning);
915 if (target && shouldIncludeTrace) 960 if (target && shouldIncludeTrace)
916 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target , this._linkifier); 961 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target , this._linkifier);
917 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table) 962 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table)
918 formattedMessage = this._buildTableMessage(this._message); 963 formattedMessage = this._buildTableMessage(this._message);
919 else 964 else
920 formattedMessage = this._buildMessage(consoleMessage); 965 formattedMessage = this._buildMessage(consoleMessage);
921 contentElement.appendChild(formattedMessage); 966 contentElement.appendChild(formattedMessage);
922 967
968 this.updateContextLabel();
923 this.updateTimestamp(); 969 this.updateTimestamp();
924 return this._contentElement; 970 return this._contentElement;
925 } 971 }
926 972
927 /** 973 /**
928 * @return {!Element} 974 * @return {!Element}
929 */ 975 */
930 toMessageElement() { 976 toMessageElement() {
931 if (this._element) 977 if (this._element)
932 return this._element; 978 return this._element;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 toMessageElement() { 1293 toMessageElement() {
1248 if (!this._element) { 1294 if (!this._element) {
1249 super.toMessageElement(); 1295 super.toMessageElement();
1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1296 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1297 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1252 this.setCollapsed(this._collapsed); 1298 this.setCollapsed(this._collapsed);
1253 } 1299 }
1254 return this._element; 1300 return this._element;
1255 } 1301 }
1256 }; 1302 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698