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

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

Issue 2918993003: DevTools: allow shallow array values in console.table (Closed)
Patch Set: ac Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-format-table-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 var badgeElement = this._buildMessageBadge(); 123 var badgeElement = this._buildMessageBadge();
124 if (badgeElement) 124 if (badgeElement)
125 formattedMessage.appendChild(badgeElement); 125 formattedMessage.appendChild(badgeElement);
126 126
127 var table = this._message.parameters && this._message.parameters.length ? th is._message.parameters[0] : null; 127 var table = this._message.parameters && this._message.parameters.length ? th is._message.parameters[0] : null;
128 if (table) 128 if (table)
129 table = this._parameterToRemoteObject(table); 129 table = this._parameterToRemoteObject(table);
130 if (!table || !table.preview) 130 if (!table || !table.preview)
131 return formattedMessage; 131 return formattedMessage;
132 132
133 var rawValueColumnSymbol = Symbol('rawValueColumn');
133 var columnNames = []; 134 var columnNames = [];
134 var preview = table.preview; 135 var preview = table.preview;
135 var rows = []; 136 var rows = [];
136 for (var i = 0; i < preview.properties.length; ++i) { 137 for (var i = 0; i < preview.properties.length; ++i) {
137 var rowProperty = preview.properties[i]; 138 var rowProperty = preview.properties[i];
138 var rowPreview = rowProperty.valuePreview; 139 var rowSubProperties;
139 if (!rowPreview) 140 if (rowProperty.valuePreview)
141 rowSubProperties = rowProperty.valuePreview.properties;
142 else if (rowProperty.value)
143 rowSubProperties = [{name: rawValueColumnSymbol, type: rowProperty.type, value: rowProperty.value}];
144 else
140 continue; 145 continue;
141 146
142 var rowValue = {}; 147 var rowValue = {};
143 const maxColumnsToRender = 20; 148 const maxColumnsToRender = 20;
144 for (var j = 0; j < rowPreview.properties.length; ++j) { 149 for (var j = 0; j < rowSubProperties.length; ++j) {
145 var cellProperty = rowPreview.properties[j]; 150 var cellProperty = rowSubProperties[j];
146 var columnRendered = columnNames.indexOf(cellProperty.name) !== -1; 151 var columnRendered = columnNames.indexOf(cellProperty.name) !== -1;
147 if (!columnRendered) { 152 if (!columnRendered) {
148 if (columnNames.length === maxColumnsToRender) 153 if (columnNames.length === maxColumnsToRender)
149 continue; 154 continue;
150 columnRendered = true; 155 columnRendered = true;
151 columnNames.push(cellProperty.name); 156 columnNames.push(cellProperty.name);
152 } 157 }
153 158
154 if (columnRendered) { 159 if (columnRendered) {
155 var cellElement = this._renderPropertyPreviewOrAccessor(table, [rowPro perty, cellProperty]); 160 var cellElement = this._renderPropertyPreviewOrAccessor(table, [rowPro perty, cellProperty]);
156 cellElement.classList.add('console-message-nowrap-below'); 161 cellElement.classList.add('console-message-nowrap-below');
157 rowValue[cellProperty.name] = cellElement; 162 rowValue[cellProperty.name] = cellElement;
158 } 163 }
159 } 164 }
160 rows.push([rowProperty.name, rowValue]); 165 rows.push([rowProperty.name, rowValue]);
161 } 166 }
162 167
163 var flatValues = []; 168 var flatValues = [];
164 for (var i = 0; i < rows.length; ++i) { 169 for (var i = 0; i < rows.length; ++i) {
165 var rowName = rows[i][0]; 170 var rowName = rows[i][0];
166 var rowValue = rows[i][1]; 171 var rowValue = rows[i][1];
167 flatValues.push(rowName); 172 flatValues.push(rowName);
168 for (var j = 0; j < columnNames.length; ++j) 173 for (var j = 0; j < columnNames.length; ++j)
169 flatValues.push(rowValue[columnNames[j]]); 174 flatValues.push(rowValue[columnNames[j]]);
170 } 175 }
171 columnNames.unshift(Common.UIString('(index)')); 176 columnNames.unshift(Common.UIString('(index)'));
177 var columnDisplayNames = columnNames.map(name => name === rawValueColumnSymb ol ? Common.UIString('Value') : name);
172 178
173 if (flatValues.length) { 179 if (flatValues.length) {
174 this._dataGrid = DataGrid.SortableDataGrid.create(columnNames, flatValues) ; 180 this._dataGrid = DataGrid.SortableDataGrid.create(columnDisplayNames, flat Values);
175 this._dataGrid.setStriped(true); 181 this._dataGrid.setStriped(true);
176 182
177 var formattedResult = createElementWithClass('span', 'console-message-text '); 183 var formattedResult = createElementWithClass('span', 'console-message-text ');
178 var tableElement = formattedResult.createChild('div', 'console-message-for matted-table'); 184 var tableElement = formattedResult.createChild('div', 'console-message-for matted-table');
179 var dataGridContainer = tableElement.createChild('span'); 185 var dataGridContainer = tableElement.createChild('span');
180 tableElement.appendChild(this._formatParameter(table, true, false)); 186 tableElement.appendChild(this._formatParameter(table, true, false));
181 dataGridContainer.appendChild(this._dataGrid.element); 187 dataGridContainer.appendChild(this._dataGrid.element);
182 formattedMessage.appendChild(formattedResult); 188 formattedMessage.appendChild(formattedResult);
183 this._dataGrid.renderInline(); 189 this._dataGrid.renderInline();
184 } 190 }
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 } 1284 }
1279 return this._element; 1285 return this._element;
1280 } 1286 }
1281 }; 1287 };
1282 1288
1283 /** 1289 /**
1284 * @const 1290 * @const
1285 * @type {number} 1291 * @type {number}
1286 */ 1292 */
1287 Console.ConsoleViewMessage.MaxLengthForLinks = 40; 1293 Console.ConsoleViewMessage.MaxLengthForLinks = 40;
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-format-table-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698