Changeset 252652 in webkit
- Timestamp:
- Nov 19, 2019 2:55:04 PM (4 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r252637 r252652 1 2019-11-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Local Overrides: the placeholder for the MIME type, status code, and status text is the same as the placeholder URL 4 https://bugs.webkit.org/show_bug.cgi?id=204330 5 6 Reviewed by Joseph Pecoraro. 7 8 * UserInterface/Views/LocalResourceOverridePopover.js: 9 (WI.LocalResourceOverridePopover.prototype.get serializedData): 10 (WI.LocalResourceOverridePopover.prototype.show): 11 (WI.LocalResourceOverridePopover.prototype._createEditor): 12 * UserInterface/Views/LocalResourceOverridePopover.css: 13 (.popover .local-resource-override-popover-content .data-grid tr.header-content-type > :matches(.name-column, .value-column)): Added. 14 Replace the hardcoded `placeholder` with an optional `options` object that can include a 15 `placeholder` value, allowing each caller to customize what is shown. Disallow selecting the 16 "Content-Type" header since it's automatically populated, even if there is no set value for 17 the MIME type or URL (e.g. inferred from placeholders). 18 Drive-by: if a `CodeMirror` has no value, attempt to use it's placeholder instead. 19 Drive-by: replace generic `dataGrid` with more specific `this._headersDataGrid`, which is 20 more clear given how many `WI.DataGrid` are created by this class. 21 22 * UserInterface/Views/DataGridNode.js: 23 (WI.DataGridNode.prototype.get selectable): 24 (WI.PlaceholderDataGridNode): 25 * UserInterface/Views/DataGrid.js: 26 (WI.DataGrid.createSortableDataGrid): 27 * UserInterface/Views/DOMStorageContentView.js: 28 (WI.DOMStorageContentView.prototype.itemAdded): 29 (WI.DOMStorageContentView.prototype._populate): 30 * UserInterface/Views/EditableDataGridNode.js: 31 (WI.EditableDataGridNode): Deleted. 32 * UserInterface/Views/HeapSnapshotClassDataGridNode.js: 33 (WI.HeapSnapshotClassDataGridNode): 34 * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js: 35 (WI.HeapSnapshotInstanceDataGridNode): 36 * UserInterface/Views/HeapSnapshotInstanceFetchMoreDataGridNode.js: 37 (WI.HeapSnapshotInstanceFetchMoreDataGridNode): 38 * UserInterface/Views/ProfileDataGridNode.js: 39 (WI.ProfileDataGridNode): 40 * UserInterface/Views/RecordingStateDetailsSidebarPanel.js: 41 (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D): 42 (WI.RecordingStateDetailsSidebarPanel): 43 * UserInterface/Views/ResourceDetailsSidebarPanel.js: 44 (WI.ResourceDetailsSidebarPanel.prototype._createNameValueDataGrid.addDataGridNode): 45 * UserInterface/Views/TimelineDataGridNode.js: 46 (WI.TimelineDataGridNode): 47 Rework constructor of `WI.DataGridNode` to accept an `options`-style object as its second 48 parameter, instead of separate parameters for each configurable property. Now that this is 49 able to be done via a single parameter, add support for marking a `WI.DataGridNode` as not 50 being selectable. 51 1 52 2019-11-19 Brian Burg <bburg@apple.com> 2 53 -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMStorageContentView.js
r245486 r252652 99 99 } 100 100 101 this._dataGrid.appendChild(new WI.DataGridNode({key, value, originalValue} , false));101 this._dataGrid.appendChild(new WI.DataGridNode({key, value, originalValue})); 102 102 this._sortDataGrid(); 103 103 } … … 146 146 let originalValue = value; 147 147 value = this._truncateValue(value); 148 let node = new WI.DataGridNode({key, value, originalValue} , false);148 let node = new WI.DataGridNode({key, value, originalValue}); 149 149 this._dataGrid.appendChild(node); 150 150 } -
trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js
r249655 r252652 178 178 data[columnNames[j]] = values[numColumns * i + j]; 179 179 180 var node = new WI.DataGridNode(data , false);180 var node = new WI.DataGridNode(data); 181 181 dataGrid.appendChild(node); 182 182 } -
trunk/Source/WebInspectorUI/UserInterface/Views/DataGridNode.js
r249504 r252652 26 26 WI.DataGridNode = class DataGridNode extends WI.Object 27 27 { 28 constructor(data, hasChildren, classNames)28 constructor(data, {selectable, copyable, editable, hasChildren, classNames} = {}) 29 29 { 30 30 super(); … … 33 33 this._hidden = false; 34 34 this._selected = false; 35 this._copyable = true; 36 this._editable = true; 35 this._selectable = selectable !== undefined ? selectable : true; 36 this._copyable = copyable !== undefined ? copyable : true; 37 this._editable = editable !== undefined ? editable : true; 37 38 this._shouldRefreshChildren = true; 38 39 this._data = data || {}; … … 69 70 get selectable() 70 71 { 71 return this._element && !this._hidden ;72 return this._element && !this._hidden && this._selectable; 72 73 } 73 74 … … 771 772 constructor(data) 772 773 { 773 super(data , false);774 super(data); 774 775 this.isPlaceholderNode = true; 775 776 } -
trunk/Source/WebInspectorUI/UserInterface/Views/EditableDataGridNode.js
r220119 r252652 26 26 WI.EditableDataGridNode = class EditableDataGridNode extends WI.DataGridNode 27 27 { 28 constructor(data)29 {30 const hasChildren = false;31 super(data, hasChildren);32 }33 34 28 // Public 35 29 -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js
r241787 r252652 28 28 constructor(data, tree) 29 29 { 30 super(data, true);30 super(data, {hasChildren: true}); 31 31 32 32 this._data = data; -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js
r248898 r252652 31 31 let hasChildren = node.hasChildren && node.className !== "string"; 32 32 33 super(node, hasChildren); 33 // FIXME: Make instance grid nodes copyable. 34 super(node, {hasChildren, copyable: false}); 34 35 35 36 console.assert(node instanceof WI.HeapSnapshotNodeProxy); … … 41 42 this._edge = edge || null; 42 43 this._base = base || null; 43 44 // FIXME: Make instance grid nodes copyable.45 this.copyable = false;46 44 47 45 if (hasChildren) -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceFetchMoreDataGridNode.js
r220119 r252652 28 28 constructor(tree, batchCount, remainingCount, fetchCallback) 29 29 { 30 super( {}, false);30 super(); 31 31 32 32 console.assert(typeof batchCount === "number"); -
trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.css
r252614 r252652 91 91 } 92 92 93 .popover .local-resource-override-popover-content .data-grid tr.header-content-type > :matches(.name-column, .value-column) { 94 opacity: 0.5; 95 } 96 93 97 .popover .local-resource-override-popover-content .add-header { 94 98 margin-top: 8px; -
trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.js
r252614 r252652 65 65 // the popover doesn't have to have an additional state for "pass through". 66 66 67 let mimeType = this._mimeTypeCodeMirror.getValue() ;67 let mimeType = this._mimeTypeCodeMirror.getValue() || this._mimeTypeCodeMirror.getOption("placeholder"); 68 68 if (!mimeType) 69 69 return null; 70 70 71 71 let statusCode = parseInt(this._statusCodeCodeMirror.getValue()); 72 if (isNaN(statusCode)) 73 statusCode = parseInt(this._statusCodeCodeMirror.getOption("placeholder")); 72 74 if (isNaN(statusCode) || statusCode < 0) 73 75 return null; 74 76 75 let statusText = this._statusTextCodeMirror.getValue() ;77 let statusText = this._statusTextCodeMirror.getValue() || this._statusTextCodeMirror.getOption("placeholder"); 76 78 if (!statusText) 77 79 return null; … … 119 121 let localResource = localResourceOverride ? localResourceOverride.localResource : null; 120 122 121 let url = localResource ? localResource.url : ""; 122 let mimeType = localResource ? localResource.mimeType : ""; 123 let statusCode = localResource ? String(localResource.statusCode) : ""; 124 let statusText = localResource ? localResource.statusText : ""; 123 let data = {}; 124 let resourceData = {}; 125 if (localResource) { 126 data.url = resourceData.url = localResource.url; 127 data.mimeType = resourceData.mimeType = localResource.mimeType; 128 data.statusCode = resourceData.statusCode = String(localResource.statusCode); 129 data.statusText = resourceData.statusText = localResource.statusText; 130 } 131 132 if (!data.url) 133 data.url = this._defaultURL(); 134 if (!data.mimeType) 135 data.mimeType = "text/javascript"; 136 if (!data.statusCode || data.statusCode === "NaN") 137 data.statusCode = "200"; 138 if (!data.statusText) 139 data.statusText = WI.HTTPUtilities.statusTextForStatusCode(parseInt(data.statusCode)); 140 125 141 let responseHeaders = localResource ? localResource.responseHeaders : {}; 126 127 if (!url)128 url = this._defaultURL();129 if (!mimeType)130 mimeType = "text/javascript";131 if (!statusCode || statusCode === "NaN")132 statusCode = "200";133 if (!statusText)134 statusText = WI.HTTPUtilities.statusTextForStatusCode(parseInt(statusCode));135 142 136 143 let popoverContentElement = document.createElement("div"); … … 139 146 let table = popoverContentElement.appendChild(document.createElement("table")); 140 147 141 let createRow = (label, id, text, placeholder) => {148 let createRow = (label, id, value, placeholder) => { 142 149 let row = table.appendChild(document.createElement("tr")); 143 150 let headerElement = row.appendChild(document.createElement("th")); … … 150 157 editorElement.classList.add("editor", id); 151 158 152 let codeMirror = this._createEditor(editorElement, text, placeholder);159 let codeMirror = this._createEditor(editorElement, {value, placeholder}); 153 160 let inputField = codeMirror.getInputField(); 154 161 inputField.id = `local-resource-override-popover-${id}-input-field`; … … 158 165 }; 159 166 160 let urlRow = createRow(WI.UIString("URL"), "url", url, url || "http://example.com/index.html");167 let urlRow = createRow(WI.UIString("URL"), "url", resourceData.url || "", data.url); 161 168 this._urlCodeMirror = urlRow.codeMirror; 162 169 … … 168 175 if (!isRegex) { 169 176 let url = this._urlCodeMirror.getValue(); 170 const schemes = ["http:", "https:", "file:"]; 171 if (!schemes.some((scheme) => url.toLowerCase().startsWith(scheme))) 172 this._urlCodeMirror.setValue("http://" + url); 177 if (url) { 178 const schemes = ["http:", "https:", "file:"]; 179 if (!schemes.some((scheme) => url.toLowerCase().startsWith(scheme))) 180 this._urlCodeMirror.setValue("http://" + url); 181 } 173 182 } 174 183 }; … … 199 208 } 200 209 201 let mimeTypeRow = createRow(WI.UIString("MIME Type"), "mime", mimeType, mimeType || "text/html");210 let mimeTypeRow = createRow(WI.UIString("MIME Type"), "mime", resourceData.mimeType || "", data.mimeType); 202 211 this._mimeTypeCodeMirror = mimeTypeRow.codeMirror; 203 212 204 let statusCodeRow = createRow(WI.UIString("Status"), "status", statusCode, statusCode || "200");213 let statusCodeRow = createRow(WI.UIString("Status"), "status", resourceData.statusCode || "", data.statusCode); 205 214 this._statusCodeCodeMirror = statusCodeRow.codeMirror; 206 215 207 216 let statusTextEditorElement = statusCodeRow.dataElement.appendChild(document.createElement("div")); 208 217 statusTextEditorElement.className = "editor status-text"; 209 this._statusTextCodeMirror = this._createEditor(statusTextEditorElement, statusText, statusText || "OK");218 this._statusTextCodeMirror = this._createEditor(statusTextEditorElement, {value: resourceData.statusText || "", placeholder: data.statusText}); 210 219 211 220 let editCallback = () => {}; … … 215 224 216 225 let siblingToSelect = node.nextSibling || node.previousSibling; 217 dataGrid.removeChild(node);226 this._headersDataGrid.removeChild(node); 218 227 if (siblingToSelect) 219 228 siblingToSelect.select(); 220 229 221 dataGrid.updateLayoutIfNeeded();230 this._headersDataGrid.updateLayoutIfNeeded(); 222 231 this.update(); 223 232 }; … … 233 242 }; 234 243 235 let dataGrid =this._headersDataGrid = new WI.DataGrid(columns, {editCallback, deleteCallback});236 dataGrid.inline = true;237 dataGrid.variableHeightRows = true;238 dataGrid.copyTextDelimiter = ": ";239 240 function addDataGridNodeForHeader(name, value){241 let node = new WI.DataGridNode({name, value} );242 dataGrid.appendChild(node);244 this._headersDataGrid = new WI.DataGrid(columns, {editCallback, deleteCallback}); 245 this._headersDataGrid.inline = true; 246 this._headersDataGrid.variableHeightRows = true; 247 this._headersDataGrid.copyTextDelimiter = ": "; 248 249 let addDataGridNodeForHeader = (name, value, options = {}) => { 250 let node = new WI.DataGridNode({name, value}, options); 251 this._headersDataGrid.appendChild(node); 243 252 return node; 244 } 245 246 let contentTypeDataGridNode = addDataGridNodeForHeader("Content-Type", mimeType); 247 contentTypeDataGridNode.editable = false; 253 }; 254 255 let contentTypeDataGridNode = addDataGridNodeForHeader("Content-Type", data.mimeType, {selectable: false, editable: false, classNames: ["header-content-type"]}); 248 256 249 257 for (let name in responseHeaders) { … … 260 268 let headersLabel = headersHeader.appendChild(document.createElement("label")); 261 269 headersLabel.textContent = WI.UIString("Headers"); 262 headersData.appendChild( dataGrid.element);263 dataGrid.updateLayoutIfNeeded();270 headersData.appendChild(this._headersDataGrid.element); 271 this._headersDataGrid.updateLayoutIfNeeded(); 264 272 265 273 let addHeaderButton = headersData.appendChild(document.createElement("button")); … … 268 276 addHeaderButton.addEventListener("click", (event) => { 269 277 let newNode = new WI.DataGridNode({name: "Header", value: "value"}); 270 dataGrid.appendChild(newNode);271 dataGrid.updateLayoutIfNeeded();278 this._headersDataGrid.appendChild(newNode); 279 this._headersDataGrid.updateLayoutIfNeeded(); 272 280 this.update(); 273 dataGrid.startEditingNode(newNode);281 this._headersDataGrid.startEditingNode(newNode); 274 282 }); 275 283 276 284 let incrementStatusCode = () => { 277 285 let x = parseInt(this._statusCodeCodeMirror.getValue()); 286 if (isNaN(x)) 287 x = parseInt(this._statusCodeCodeMirror.getOption("placeholder")); 278 288 if (isNaN(x) || x >= 999) 279 289 return; … … 294 304 let decrementStatusCode = () => { 295 305 let x = parseInt(this._statusCodeCodeMirror.getValue()); 306 if (isNaN(x)) 307 x = parseInt(this._statusCodeCodeMirror.getOption("placeholder")); 296 308 if (isNaN(x) || x <= 0) 297 309 return; … … 323 335 this._statusCodeCodeMirror.on("change", (cm) => { 324 336 let statusCode = parseInt(cm.getValue()); 337 if (isNaN(statusCode)) { 338 this._statusTextCodeMirror.setValue(""); 339 return; 340 } 341 325 342 let statusText = WI.HTTPUtilities.statusTextForStatusCode(statusCode); 326 343 this._statusTextCodeMirror.setValue(statusText); … … 346 363 // Update Content-Type header when mimeType changes. 347 364 this._mimeTypeCodeMirror.on("change", (cm) => { 348 let mimeType = cm.getValue() ;365 let mimeType = cm.getValue() || cm.getOption("placeholder"); 349 366 contentTypeDataGridNode.data = {name: "Content-Type", value: mimeType}; 350 367 }); … … 371 388 // Private 372 389 373 _createEditor(element, value, placeholder)390 _createEditor(element, options = {}) 374 391 { 375 392 let codeMirror = WI.CodeMirrorEditor.create(element, { … … 378 395 mode: "text/plain", 379 396 matchBrackets: true, 380 placeholder,381 397 scrollbarStyle: null, 382 value,398 ...options, 383 399 }); 384 400 -
trunk/Source/WebInspectorUI/UserInterface/Views/ProfileDataGridNode.js
r238743 r252652 28 28 constructor(callingContextTreeNode, tree) 29 29 { 30 super(callingContextTreeNode, false); 30 // FIXME: Make profile data grid nodes copyable. 31 super(callingContextTreeNode, {copyable: false}); 31 32 32 33 this._node = callingContextTreeNode; … … 35 36 this._childrenToChargeToSelf = new Set; 36 37 this._extraSelfTimeFromChargedChildren = 0; 37 38 // FIXME: Make profile data grid nodes copyable.39 this.copyable = false;40 38 41 39 this.addEventListener("populate", this._populate, this); -
trunk/Source/WebInspectorUI/UserInterface/Views/RecordingStateDetailsSidebarPanel.js
r241875 r252652 169 169 classNames.push("non-standard"); 170 170 171 const hasChildren = false; 172 dataGrid.appendChild(new WI.DataGridNode({name, value}, hasChildren, classNames)); 171 dataGrid.appendChild(new WI.DataGridNode({name, value}, {classNames})); 173 172 } 174 173 -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js
r251227 r252652 451 451 console.assert(!nodeValue.value || typeof nodeValue.value === "string"); 452 452 453 var node = new WI.DataGridNode({name: nodeValue.name, value: nodeValue.value || ""} , false);453 var node = new WI.DataGridNode({name: nodeValue.name, value: nodeValue.value || ""}); 454 454 dataGrid.appendChild(node); 455 455 } -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGridNode.js
r251959 r252652 26 26 WI.TimelineDataGridNode = class TimelineDataGridNode extends WI.DataGridNode 27 27 { 28 constructor(records, options = {}) 29 { 30 super({}, options.hasChildren); 31 32 this.copyable = false; 28 constructor(records, {hasChildren, includesGraph, graphDataSource} = {}) 29 { 30 super({}, {hasChildren, copyable: false}); 33 31 34 32 this._records = records; 35 this._includesGraph = options.includesGraph || false;36 this._graphDataSource = options.graphDataSource || null;33 this._includesGraph = includesGraph || false; 34 this._graphDataSource = graphDataSource || null; 37 35 this._cachedData = null; 38 36
Note: See TracChangeset
for help on using the changeset viewer.