Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (252651 => 252652)
--- trunk/Source/WebInspectorUI/ChangeLog 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/ChangeLog 2019-11-19 22:55:04 UTC (rev 252652)
@@ -1,3 +1,54 @@
+2019-11-19 Devin Rousso <[email protected]>
+
+ Web Inspector: Local Overrides: the placeholder for the MIME type, status code, and status text is the same as the placeholder URL
+ https://bugs.webkit.org/show_bug.cgi?id=204330
+
+ Reviewed by Joseph Pecoraro.
+
+ * UserInterface/Views/LocalResourceOverridePopover.js:
+ (WI.LocalResourceOverridePopover.prototype.get serializedData):
+ (WI.LocalResourceOverridePopover.prototype.show):
+ (WI.LocalResourceOverridePopover.prototype._createEditor):
+ * UserInterface/Views/LocalResourceOverridePopover.css:
+ (.popover .local-resource-override-popover-content .data-grid tr.header-content-type > :matches(.name-column, .value-column)): Added.
+ Replace the hardcoded `placeholder` with an optional `options` object that can include a
+ `placeholder` value, allowing each caller to customize what is shown. Disallow selecting the
+ "Content-Type" header since it's automatically populated, even if there is no set value for
+ the MIME type or URL (e.g. inferred from placeholders).
+ Drive-by: if a `CodeMirror` has no value, attempt to use it's placeholder instead.
+ Drive-by: replace generic `dataGrid` with more specific `this._headersDataGrid`, which is
+ more clear given how many `WI.DataGrid` are created by this class.
+
+ * UserInterface/Views/DataGridNode.js:
+ (WI.DataGridNode.prototype.get selectable):
+ (WI.PlaceholderDataGridNode):
+ * UserInterface/Views/DataGrid.js:
+ (WI.DataGrid.createSortableDataGrid):
+ * UserInterface/Views/DOMStorageContentView.js:
+ (WI.DOMStorageContentView.prototype.itemAdded):
+ (WI.DOMStorageContentView.prototype._populate):
+ * UserInterface/Views/EditableDataGridNode.js:
+ (WI.EditableDataGridNode): Deleted.
+ * UserInterface/Views/HeapSnapshotClassDataGridNode.js:
+ (WI.HeapSnapshotClassDataGridNode):
+ * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
+ (WI.HeapSnapshotInstanceDataGridNode):
+ * UserInterface/Views/HeapSnapshotInstanceFetchMoreDataGridNode.js:
+ (WI.HeapSnapshotInstanceFetchMoreDataGridNode):
+ * UserInterface/Views/ProfileDataGridNode.js:
+ (WI.ProfileDataGridNode):
+ * UserInterface/Views/RecordingStateDetailsSidebarPanel.js:
+ (WI.RecordingStateDetailsSidebarPanel.prototype._generateDetailsCanvas2D):
+ (WI.RecordingStateDetailsSidebarPanel):
+ * UserInterface/Views/ResourceDetailsSidebarPanel.js:
+ (WI.ResourceDetailsSidebarPanel.prototype._createNameValueDataGrid.addDataGridNode):
+ * UserInterface/Views/TimelineDataGridNode.js:
+ (WI.TimelineDataGridNode):
+ Rework constructor of `WI.DataGridNode` to accept an `options`-style object as its second
+ parameter, instead of separate parameters for each configurable property. Now that this is
+ able to be done via a single parameter, add support for marking a `WI.DataGridNode` as not
+ being selectable.
+
2019-11-19 Brian Burg <[email protected]>
[Cocoa] Add _WKInspector SPI to set diagnostic logging delegate for a local Web Inspector
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMStorageContentView.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMStorageContentView.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMStorageContentView.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -98,7 +98,7 @@
return;
}
- this._dataGrid.appendChild(new WI.DataGridNode({key, value, originalValue}, false));
+ this._dataGrid.appendChild(new WI.DataGridNode({key, value, originalValue}));
this._sortDataGrid();
}
@@ -145,7 +145,7 @@
let originalValue = value;
value = this._truncateValue(value);
- let node = new WI.DataGridNode({key, value, originalValue}, false);
+ let node = new WI.DataGridNode({key, value, originalValue});
this._dataGrid.appendChild(node);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -177,7 +177,7 @@
for (var j = 0; j < columnNames.length; ++j)
data[columnNames[j]] = values[numColumns * i + j];
- var node = new WI.DataGridNode(data, false);
+ var node = new WI.DataGridNode(data);
dataGrid.appendChild(node);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -25,7 +25,7 @@
WI.DataGridNode = class DataGridNode extends WI.Object
{
- constructor(data, hasChildren, classNames)
+ constructor(data, {selectable, copyable, editable, hasChildren, classNames} = {})
{
super();
@@ -32,8 +32,9 @@
this._expanded = false;
this._hidden = false;
this._selected = false;
- this._copyable = true;
- this._editable = true;
+ this._selectable = selectable !== undefined ? selectable : true;
+ this._copyable = copyable !== undefined ? copyable : true;
+ this._editable = editable !== undefined ? editable : true;
this._shouldRefreshChildren = true;
this._data = data || {};
this.hasChildren = hasChildren || false;
@@ -68,7 +69,7 @@
get selectable()
{
- return this._element && !this._hidden;
+ return this._element && !this._hidden && this._selectable;
}
get copyable()
@@ -770,7 +771,7 @@
{
constructor(data)
{
- super(data, false);
+ super(data);
this.isPlaceholderNode = true;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/EditableDataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/EditableDataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/EditableDataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -25,12 +25,6 @@
WI.EditableDataGridNode = class EditableDataGridNode extends WI.DataGridNode
{
- constructor(data)
- {
- const hasChildren = false;
- super(data, hasChildren);
- }
-
// Public
get element()
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -27,7 +27,7 @@
{
constructor(data, tree)
{
- super(data, true);
+ super(data, {hasChildren: true});
this._data = data;
this._tree = tree;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -30,7 +30,8 @@
// Don't treat strings as having child nodes, even if they have a Structure.
let hasChildren = node.hasChildren && node.className !== "string";
- super(node, hasChildren);
+ // FIXME: Make instance grid nodes copyable.
+ super(node, {hasChildren, copyable: false});
console.assert(node instanceof WI.HeapSnapshotNodeProxy);
console.assert(!edge || edge instanceof WI.HeapSnapshotEdgeProxy);
@@ -41,9 +42,6 @@
this._edge = edge || null;
this._base = base || null;
- // FIXME: Make instance grid nodes copyable.
- this.copyable = false;
-
if (hasChildren)
this.addEventListener("populate", this._populate, this);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceFetchMoreDataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceFetchMoreDataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceFetchMoreDataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -27,7 +27,7 @@
{
constructor(tree, batchCount, remainingCount, fetchCallback)
{
- super({}, false);
+ super();
console.assert(typeof batchCount === "number");
console.assert(typeof remainingCount === "number");
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.css (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.css 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.css 2019-11-19 22:55:04 UTC (rev 252652)
@@ -90,6 +90,10 @@
-webkit-margin-start: 12px;
}
+.popover .local-resource-override-popover-content .data-grid tr.header-content-type > :matches(.name-column, .value-column) {
+ opacity: 0.5;
+}
+
.popover .local-resource-override-popover-content .add-header {
margin-top: 8px;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverridePopover.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -64,15 +64,17 @@
// network values through, but lets require them for overrides so that
// the popover doesn't have to have an additional state for "pass through".
- let mimeType = this._mimeTypeCodeMirror.getValue();
+ let mimeType = this._mimeTypeCodeMirror.getValue() || this._mimeTypeCodeMirror.getOption("placeholder");
if (!mimeType)
return null;
let statusCode = parseInt(this._statusCodeCodeMirror.getValue());
+ if (isNaN(statusCode))
+ statusCode = parseInt(this._statusCodeCodeMirror.getOption("placeholder"));
if (isNaN(statusCode) || statusCode < 0)
return null;
- let statusText = this._statusTextCodeMirror.getValue();
+ let statusText = this._statusTextCodeMirror.getValue() || this._statusTextCodeMirror.getOption("placeholder");
if (!statusText)
return null;
@@ -118,27 +120,32 @@
let localResource = localResourceOverride ? localResourceOverride.localResource : null;
- let url = "" ? localResource.url : "";
- let mimeType = localResource ? localResource.mimeType : "";
- let statusCode = localResource ? String(localResource.statusCode) : "";
- let statusText = localResource ? localResource.statusText : "";
+ let data = ""
+ let resourceData = {};
+ if (localResource) {
+ data.url = "" = localResource.url;
+ data.mimeType = resourceData.mimeType = localResource.mimeType;
+ data.statusCode = resourceData.statusCode = String(localResource.statusCode);
+ data.statusText = resourceData.statusText = localResource.statusText;
+ }
+
+ if (!data.url)
+ data.url = ""
+ if (!data.mimeType)
+ data.mimeType = "text/_javascript_";
+ if (!data.statusCode || data.statusCode === "NaN")
+ data.statusCode = "200";
+ if (!data.statusText)
+ data.statusText = WI.HTTPUtilities.statusTextForStatusCode(parseInt(data.statusCode));
+
let responseHeaders = localResource ? localResource.responseHeaders : {};
- if (!url)
- url = ""
- if (!mimeType)
- mimeType = "text/_javascript_";
- if (!statusCode || statusCode === "NaN")
- statusCode = "200";
- if (!statusText)
- statusText = WI.HTTPUtilities.statusTextForStatusCode(parseInt(statusCode));
-
let popoverContentElement = document.createElement("div");
popoverContentElement.className = "local-resource-override-popover-content";
let table = popoverContentElement.appendChild(document.createElement("table"));
- let createRow = (label, id, text, placeholder) => {
+ let createRow = (label, id, value, placeholder) => {
let row = table.appendChild(document.createElement("tr"));
let headerElement = row.appendChild(document.createElement("th"));
let dataElement = row.appendChild(document.createElement("td"));
@@ -149,7 +156,7 @@
let editorElement = dataElement.appendChild(document.createElement("div"));
editorElement.classList.add("editor", id);
- let codeMirror = this._createEditor(editorElement, text, placeholder);
+ let codeMirror = this._createEditor(editorElement, {value, placeholder});
let inputField = codeMirror.getInputField();
inputField.id = `local-resource-override-popover-${id}-input-field`;
labelElement.setAttribute("for", inputField.id);
@@ -157,7 +164,7 @@
return {codeMirror, dataElement};
};
- let urlRow = createRow(WI.UIString("URL"), "url", url, url || "http://example.com/index.html");
+ let urlRow = createRow(WI.UIString("URL"), "url", resourceData.url || "", data.url);
this._urlCodeMirror = urlRow.codeMirror;
let updateURLCodeMirrorMode = () => {
@@ -167,9 +174,11 @@
if (!isRegex) {
let url = ""
- const schemes = ["http:", "https:", "file:"];
- if (!schemes.some((scheme) => url.toLowerCase().startsWith(scheme)))
- this._urlCodeMirror.setValue("http://" + url);
+ if (url) {
+ const schemes = ["http:", "https:", "file:"];
+ if (!schemes.some((scheme) => url.toLowerCase().startsWith(scheme)))
+ this._urlCodeMirror.setValue("http://" + url);
+ }
}
};
@@ -198,15 +207,15 @@
isRegexLabel.append(WI.UIString("Regular _expression_"));
}
- let mimeTypeRow = createRow(WI.UIString("MIME Type"), "mime", mimeType, mimeType || "text/html");
+ let mimeTypeRow = createRow(WI.UIString("MIME Type"), "mime", resourceData.mimeType || "", data.mimeType);
this._mimeTypeCodeMirror = mimeTypeRow.codeMirror;
- let statusCodeRow = createRow(WI.UIString("Status"), "status", statusCode, statusCode || "200");
+ let statusCodeRow = createRow(WI.UIString("Status"), "status", resourceData.statusCode || "", data.statusCode);
this._statusCodeCodeMirror = statusCodeRow.codeMirror;
let statusTextEditorElement = statusCodeRow.dataElement.appendChild(document.createElement("div"));
statusTextEditorElement.className = "editor status-text";
- this._statusTextCodeMirror = this._createEditor(statusTextEditorElement, statusText, statusText || "OK");
+ this._statusTextCodeMirror = this._createEditor(statusTextEditorElement, {value: resourceData.statusText || "", placeholder: data.statusText});
let editCallback = () => {};
let deleteCallback = (node) => {
@@ -214,11 +223,11 @@
return;
let siblingToSelect = node.nextSibling || node.previousSibling;
- dataGrid.removeChild(node);
+ this._headersDataGrid.removeChild(node);
if (siblingToSelect)
siblingToSelect.select();
- dataGrid.updateLayoutIfNeeded();
+ this._headersDataGrid.updateLayoutIfNeeded();
this.update();
};
@@ -232,19 +241,18 @@
},
};
- let dataGrid = this._headersDataGrid = new WI.DataGrid(columns, {editCallback, deleteCallback});
- dataGrid.inline = true;
- dataGrid.variableHeightRows = true;
- dataGrid.copyTextDelimiter = ": ";
+ this._headersDataGrid = new WI.DataGrid(columns, {editCallback, deleteCallback});
+ this._headersDataGrid.inline = true;
+ this._headersDataGrid.variableHeightRows = true;
+ this._headersDataGrid.copyTextDelimiter = ": ";
- function addDataGridNodeForHeader(name, value) {
- let node = new WI.DataGridNode({name, value});
- dataGrid.appendChild(node);
+ let addDataGridNodeForHeader = (name, value, options = {}) => {
+ let node = new WI.DataGridNode({name, value}, options);
+ this._headersDataGrid.appendChild(node);
return node;
- }
+ };
- let contentTypeDataGridNode = addDataGridNodeForHeader("Content-Type", mimeType);
- contentTypeDataGridNode.editable = false;
+ let contentTypeDataGridNode = addDataGridNodeForHeader("Content-Type", data.mimeType, {selectable: false, editable: false, classNames: ["header-content-type"]});
for (let name in responseHeaders) {
if (name.toLowerCase() === "content-type")
@@ -259,8 +267,8 @@
let headersData = headersRow.appendChild(document.createElement("td"));
let headersLabel = headersHeader.appendChild(document.createElement("label"));
headersLabel.textContent = WI.UIString("Headers");
- headersData.appendChild(dataGrid.element);
- dataGrid.updateLayoutIfNeeded();
+ headersData.appendChild(this._headersDataGrid.element);
+ this._headersDataGrid.updateLayoutIfNeeded();
let addHeaderButton = headersData.appendChild(document.createElement("button"));
addHeaderButton.className = "add-header";
@@ -267,14 +275,16 @@
addHeaderButton.textContent = WI.UIString("Add Header");
addHeaderButton.addEventListener("click", (event) => {
let newNode = new WI.DataGridNode({name: "Header", value: "value"});
- dataGrid.appendChild(newNode);
- dataGrid.updateLayoutIfNeeded();
+ this._headersDataGrid.appendChild(newNode);
+ this._headersDataGrid.updateLayoutIfNeeded();
this.update();
- dataGrid.startEditingNode(newNode);
+ this._headersDataGrid.startEditingNode(newNode);
});
let incrementStatusCode = () => {
let x = parseInt(this._statusCodeCodeMirror.getValue());
+ if (isNaN(x))
+ x = parseInt(this._statusCodeCodeMirror.getOption("placeholder"));
if (isNaN(x) || x >= 999)
return;
@@ -293,6 +303,8 @@
let decrementStatusCode = () => {
let x = parseInt(this._statusCodeCodeMirror.getValue());
+ if (isNaN(x))
+ x = parseInt(this._statusCodeCodeMirror.getOption("placeholder"));
if (isNaN(x) || x <= 0)
return;
@@ -322,6 +334,11 @@
// Update statusText when statusCode changes.
this._statusCodeCodeMirror.on("change", (cm) => {
let statusCode = parseInt(cm.getValue());
+ if (isNaN(statusCode)) {
+ this._statusTextCodeMirror.setValue("");
+ return;
+ }
+
let statusText = WI.HTTPUtilities.statusTextForStatusCode(statusCode);
this._statusTextCodeMirror.setValue(statusText);
});
@@ -345,7 +362,7 @@
// Update Content-Type header when mimeType changes.
this._mimeTypeCodeMirror.on("change", (cm) => {
- let mimeType = cm.getValue();
+ let mimeType = cm.getValue() || cm.getOption("placeholder");
contentTypeDataGridNode.data = "" "Content-Type", value: mimeType};
});
@@ -370,7 +387,7 @@
// Private
- _createEditor(element, value, placeholder)
+ _createEditor(element, options = {})
{
let codeMirror = WI.CodeMirrorEditor.create(element, {
extraKeys: {"Tab": false, "Shift-Tab": false},
@@ -377,9 +394,8 @@
lineWrapping: false,
mode: "text/plain",
matchBrackets: true,
- placeholder,
scrollbarStyle: null,
- value,
+ ...options,
});
codeMirror.addKeyMap({
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProfileDataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ProfileDataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProfileDataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -27,7 +27,8 @@
{
constructor(callingContextTreeNode, tree)
{
- super(callingContextTreeNode, false);
+ // FIXME: Make profile data grid nodes copyable.
+ super(callingContextTreeNode, {copyable: false});
this._node = callingContextTreeNode;
this._tree = tree;
@@ -35,9 +36,6 @@
this._childrenToChargeToSelf = new Set;
this._extraSelfTimeFromChargedChildren = 0;
- // FIXME: Make profile data grid nodes copyable.
- this.copyable = false;
-
this.addEventListener("populate", this._populate, this);
this._updateChildrenForModifiers();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RecordingStateDetailsSidebarPanel.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/RecordingStateDetailsSidebarPanel.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RecordingStateDetailsSidebarPanel.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -168,8 +168,7 @@
if (name.startsWith("webkit"))
classNames.push("non-standard");
- const hasChildren = false;
- dataGrid.appendChild(new WI.DataGridNode({name, value}, hasChildren, classNames));
+ dataGrid.appendChild(new WI.DataGridNode({name, value}, {classNames}));
}
dataGrid.updateLayoutIfNeeded();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -450,7 +450,7 @@
console.assert(typeof nodeValue.name === "string");
console.assert(!nodeValue.value || typeof nodeValue.value === "string");
- var node = new WI.DataGridNode({name: nodeValue.name, value: nodeValue.value || ""}, false);
+ var node = new WI.DataGridNode({name: nodeValue.name, value: nodeValue.value || ""});
dataGrid.appendChild(node);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGridNode.js (252651 => 252652)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGridNode.js 2019-11-19 22:31:11 UTC (rev 252651)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGridNode.js 2019-11-19 22:55:04 UTC (rev 252652)
@@ -25,15 +25,13 @@
WI.TimelineDataGridNode = class TimelineDataGridNode extends WI.DataGridNode
{
- constructor(records, options = {})
+ constructor(records, {hasChildren, includesGraph, graphDataSource} = {})
{
- super({}, options.hasChildren);
+ super({}, {hasChildren, copyable: false});
- this.copyable = false;
-
this._records = records;
- this._includesGraph = options.includesGraph || false;
- this._graphDataSource = options.graphDataSource || null;
+ this._includesGraph = includesGraph || false;
+ this._graphDataSource = graphDataSource || null;
this._cachedData = null;
if (this._graphDataSource) {