OLD | NEW |
---|---|
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 Loading... | |
43 this._dataGrids = []; | 43 this._dataGrids = []; |
44 /** @type {!Map.<!WebInspector.DataGrid, ?Element>} */ | 44 /** @type {!Map.<!WebInspector.DataGrid, ?Element>} */ |
45 this._dataGridParents = new Map(); | 45 this._dataGridParents = new Map(); |
46 | 46 |
47 this._customFormatters = { | 47 this._customFormatters = { |
48 "object": this._formatParameterAsObject, | 48 "object": this._formatParameterAsObject, |
49 "array": this._formatParameterAsArray, | 49 "array": this._formatParameterAsArray, |
50 "node": this._formatParameterAsNode, | 50 "node": this._formatParameterAsNode, |
51 "string": this._formatParameterAsString | 51 "string": this._formatParameterAsString |
52 }; | 52 }; |
53 | |
54 WebInspector.settings.consoleTimestampsEnabled.addChangeListener(this._conso leTimestampsSettingChanged, this); | |
53 } | 55 } |
54 | 56 |
55 WebInspector.ConsoleViewMessage.prototype = { | 57 WebInspector.ConsoleViewMessage.prototype = { |
56 wasShown: function() | 58 wasShown: function() |
57 { | 59 { |
58 for (var i = 0; this._dataGrids && i < this._dataGrids.length; ++i) { | 60 for (var i = 0; this._dataGrids && i < this._dataGrids.length; ++i) { |
59 var dataGrid = this._dataGrids[i]; | 61 var dataGrid = this._dataGrids[i]; |
60 var parentElement = this._dataGridParents.get(dataGrid) || null; | 62 var parentElement = this._dataGridParents.get(dataGrid) || null; |
61 dataGrid.show(parentElement); | 63 dataGrid.show(parentElement); |
62 dataGrid.updateWidths(); | 64 dataGrid.updateWidths(); |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 | 838 |
837 /** | 839 /** |
838 * @return {boolean} | 840 * @return {boolean} |
839 */ | 841 */ |
840 matchesRegex: function(regexObject) | 842 matchesRegex: function(regexObject) |
841 { | 843 { |
842 regexObject.lastIndex = 0; | 844 regexObject.lastIndex = 0; |
843 return regexObject.test(this._formattedMessageText()) || (!!this._anchor Element && regexObject.test(this._anchorElement.textContent)); | 845 return regexObject.test(this._formattedMessageText()) || (!!this._anchor Element && regexObject.test(this._anchorElement.textContent)); |
844 }, | 846 }, |
845 | 847 |
848 _updateTimestamp: function(show) | |
849 { | |
850 if (!this._element) | |
851 return; | |
852 | |
853 if (show && !this.timestampElement) { | |
854 this.timestampElement = this._element.createChild("span", "console-t imestamp"); | |
855 this.timestampElement.textContent = (new Date(this._message.timestam p)).toConsoleTime(); | |
856 var afterRepeatCountChild = this.repeatCountElement && this.repeatCo untElement.nextSibling; | |
857 this._element.insertBefore(this.timestampElement, afterRepeatCountCh ild || this._element.firstChild); | |
apavlov
2014/03/21 14:47:58
you can add a return; after this line, since the r
| |
858 } | |
859 | |
860 if (!show && this.timestampElement) | |
861 this.timestampElement.remove(); | |
862 }, | |
863 | |
864 _consoleTimestampsSettingChanged: function(event) | |
865 { | |
866 var enabled = /** @type {boolean} */ (event.data); | |
867 this._updateTimestamp(enabled); | |
868 }, | |
869 | |
846 /** | 870 /** |
847 * @return {!Element} | 871 * @return {!Element} |
848 */ | 872 */ |
849 toMessageElement: function() | 873 toMessageElement: function() |
850 { | 874 { |
851 if (this._element) | 875 if (this._element) |
852 return this._element; | 876 return this._element; |
853 | 877 |
854 var element = document.createElement("div"); | 878 var element = document.createElement("div"); |
855 element.message = this; | 879 element.message = this; |
(...skipping 19 matching lines...) Expand all Loading... | |
875 break; | 899 break; |
876 } | 900 } |
877 | 901 |
878 if (this._message.type === WebInspector.ConsoleMessage.MessageType.Start Group || this._message.type === WebInspector.ConsoleMessage.MessageType.StartGro upCollapsed) | 902 if (this._message.type === WebInspector.ConsoleMessage.MessageType.Start Group || this._message.type === WebInspector.ConsoleMessage.MessageType.StartGro upCollapsed) |
879 element.classList.add("console-group-title"); | 903 element.classList.add("console-group-title"); |
880 | 904 |
881 element.appendChild(this.formattedMessage()); | 905 element.appendChild(this.formattedMessage()); |
882 | 906 |
883 if (this._message.repeatCount > 1) | 907 if (this._message.repeatCount > 1) |
884 this.updateRepeatCount(); | 908 this.updateRepeatCount(); |
909 this._updateTimestamp(WebInspector.settings.consoleTimestampsEnabled.get ()); | |
885 | 910 |
886 return element; | 911 return element; |
887 }, | 912 }, |
888 | 913 |
889 _populateStackTraceTreeElement: function(parentTreeElement) | 914 _populateStackTraceTreeElement: function(parentTreeElement) |
890 { | 915 { |
891 for (var i = 0; i < this._message.stackTrace.length; i++) { | 916 for (var i = 0; i < this._message.stackTrace.length; i++) { |
892 var frame = this._message.stackTrace[i]; | 917 var frame = this._message.stackTrace[i]; |
893 | 918 |
894 var content = document.createElementWithClass("div", "stacktrace-ent ry"); | 919 var content = document.createElementWithClass("div", "stacktrace-ent ry"); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 } | 1042 } |
1018 | 1043 |
1019 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; | 1044 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; |
1020 }, | 1045 }, |
1021 | 1046 |
1022 get text() | 1047 get text() |
1023 { | 1048 { |
1024 return this._message.messageText; | 1049 return this._message.messageText; |
1025 } | 1050 } |
1026 } | 1051 } |
OLD | NEW |