OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 /** | 861 /** |
862 * @return {string} | 862 * @return {string} |
863 */ | 863 */ |
864 get description() | 864 get description() |
865 { | 865 { |
866 if (this._cachedDescription) | 866 if (this._cachedDescription) |
867 return this._cachedDescription; | 867 return this._cachedDescription; |
868 | 868 |
869 /** | 869 /** |
870 * @param {!WebInspector.RemoteObjectProperty} property | 870 * @param {!WebInspector.RemoteObjectProperty} property |
| 871 * @return {string} |
| 872 * @this {WebInspector.LocalJSONObject} |
871 */ | 873 */ |
872 function formatArrayItem(property) | 874 function formatArrayItem(property) |
873 { | 875 { |
874 return property.value.description; | 876 return this._formatValue(property.value); |
875 } | 877 } |
876 | 878 |
877 /** | 879 /** |
878 * @param {!WebInspector.RemoteObjectProperty} property | 880 * @param {!WebInspector.RemoteObjectProperty} property |
| 881 * @return {string} |
| 882 * @this {WebInspector.LocalJSONObject} |
879 */ | 883 */ |
880 function formatObjectItem(property) | 884 function formatObjectItem(property) |
881 { | 885 { |
882 return property.name + ":" + property.value.description; | 886 var name = property.name; |
| 887 if (/^\s|\s$|^$|\n/.test(name)) |
| 888 name = "\"" + name.replace(/\n/g, "\u21B5") + "\""; |
| 889 return name + ": " + this._formatValue(property.value); |
883 } | 890 } |
884 | 891 |
885 if (this.type === "object") { | 892 if (this.type === "object") { |
886 switch (this.subtype) { | 893 switch (this.subtype) { |
887 case "array": | 894 case "array": |
888 this._cachedDescription = this._concatenate("[", "]", formatArra
yItem); | 895 this._cachedDescription = this._concatenate("[", "]", formatArra
yItem.bind(this)); |
889 break; | 896 break; |
890 case "date": | 897 case "date": |
891 this._cachedDescription = "" + this._value; | 898 this._cachedDescription = "" + this._value; |
892 break; | 899 break; |
893 case "null": | 900 case "null": |
894 this._cachedDescription = "null"; | 901 this._cachedDescription = "null"; |
895 break; | 902 break; |
896 default: | 903 default: |
897 this._cachedDescription = this._concatenate("{", "}", formatObje
ctItem); | 904 this._cachedDescription = this._concatenate("{", "}", formatObje
ctItem.bind(this)); |
898 } | 905 } |
899 } else | 906 } else { |
900 this._cachedDescription = String(this._value); | 907 this._cachedDescription = String(this._value); |
| 908 } |
901 | 909 |
902 return this._cachedDescription; | 910 return this._cachedDescription; |
903 }, | 911 }, |
904 | 912 |
905 /** | 913 /** |
| 914 * @param {?WebInspector.RemoteObject} value |
| 915 * @return {string} |
| 916 */ |
| 917 _formatValue: function(value) |
| 918 { |
| 919 if (!value) |
| 920 return "undefined"; |
| 921 var description = value.description || ""; |
| 922 if (value.type === "string") |
| 923 return "\"" + description.replace(/\n/g, "\u21B5") + "\""; |
| 924 return description; |
| 925 }, |
| 926 |
| 927 /** |
906 * @param {string} prefix | 928 * @param {string} prefix |
907 * @param {string} suffix | 929 * @param {string} suffix |
908 * @param {function (!WebInspector.RemoteObjectProperty)} formatProperty | 930 * @param {function(!WebInspector.RemoteObjectProperty)} formatProperty |
909 * @return {string} | 931 * @return {string} |
910 */ | 932 */ |
911 _concatenate: function(prefix, suffix, formatProperty) | 933 _concatenate: function(prefix, suffix, formatProperty) |
912 { | 934 { |
913 const previewChars = 100; | 935 var previewChars = 100; |
914 | 936 |
915 var buffer = prefix; | 937 var buffer = prefix; |
916 var children = this._children(); | 938 var children = this._children(); |
917 for (var i = 0; i < children.length; ++i) { | 939 for (var i = 0; i < children.length; ++i) { |
918 var itemDescription = formatProperty(children[i]); | 940 var itemDescription = formatProperty(children[i]); |
919 if (buffer.length + itemDescription.length > previewChars) { | 941 if (buffer.length + itemDescription.length > previewChars) { |
920 buffer += ",\u2026"; | 942 buffer += ",\u2026"; |
921 break; | 943 break; |
922 } | 944 } |
923 if (i) | 945 if (i) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 result = functionDeclaration.apply(target, rawArgs); | 1084 result = functionDeclaration.apply(target, rawArgs); |
1063 } catch (e) { | 1085 } catch (e) { |
1064 result = null; | 1086 result = null; |
1065 } | 1087 } |
1066 | 1088 |
1067 callback(result); | 1089 callback(result); |
1068 }, | 1090 }, |
1069 | 1091 |
1070 __proto__: WebInspector.RemoteObject.prototype | 1092 __proto__: WebInspector.RemoteObject.prototype |
1071 } | 1093 } |
| 1094 |
| 1095 /** |
| 1096 * @constructor |
| 1097 * @extends {WebInspector.LocalJSONObject} |
| 1098 * @param {*} value |
| 1099 */ |
| 1100 WebInspector.MapEntryLocalJSONObject = function(value) |
| 1101 { |
| 1102 WebInspector.LocalJSONObject.call(this, value); |
| 1103 } |
| 1104 |
| 1105 WebInspector.MapEntryLocalJSONObject.prototype = { |
| 1106 /** |
| 1107 * @return {string} |
| 1108 */ |
| 1109 get description() |
| 1110 { |
| 1111 if (!this._cachedDescription) { |
| 1112 var children = this._children(); |
| 1113 this._cachedDescription = "{" + this._formatValue(children[0].value)
+ " => " + this._formatValue(children[1].value) + "}"; |
| 1114 } |
| 1115 return this._cachedDescription; |
| 1116 }, |
| 1117 |
| 1118 __proto__: WebInspector.LocalJSONObject.prototype |
| 1119 } |
OLD | NEW |