+2010-12-01 Andrey Kosyakov <caseq@chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: [Resources panel] [HAR] Need a way to save timing data.
+ Re-implementing HAR export functionality that used to be in Resources
+ tab in Network tab.
+ https://bugs.webkit.org/show_bug.cgi?id=45663
+
+ * inspector/front-end/NetworkPanel.js:
+ (WebInspector.NetworkPanel.prototype._createTable):
+ (WebInspector.NetworkPanel.prototype._toggleViewingResourceMode):
+ (WebInspector.NetworkPanel.prototype._contextMenu):
+ (WebInspector.NetworkPanel.prototype._exportAll):
+ (WebInspector.NetworkPanel.prototype._exportResource):
+ (WebInspector.NetworkDataGridNode.prototype.refreshResource):
+ * inspector/front-end/networkPanel.css:
+ (.data-grid table.data tr.revealed.network-item):
+ (.data-grid.filter-other table.data tr.revealed.network-category-other):
+
2010-12-02 Dai Mikurube <dmikurube@google.com>
Reviewed by Kent Tamura.
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
columns.timeline.sort = "ascending";
this._dataGrid = new WebInspector.DataGrid(columns);
+ this._dataGrid.element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
this.containerElement.appendChild(this._dataGrid.element);
this._dataGrid.addEventListener("sorting changed", this._sortItems, this);
this._dataGrid.addEventListener("width changed", this._updateDividersIfNeeded, this);
transferSize += (resource.cached || !resource.transferSize) ? 0 : resource.transferSize;
if (resource.isMainResource)
baseTime = resource.startTime;
- if (resource.endTime > maxTime)
+ if (resource.endTime > maxTime)
maxTime = resource.endTime;
}
var text = String.sprintf(WebInspector.UIString("%d requests"), numRequests);
proceed = false;
} else
proceed = this._timelineGrid.updateDividers(force, this.calculator);
-
+
if (!proceed)
return;
loadDividerPadding.style.left = percent + "%";
this._timelineGrid.addEventDivider(loadDividerPadding);
}
-
+
if (this._mainResourceDOMContentTime !== -1) {
var percent = this.calculator.computePercentageFromEventTime(this._mainResourceDOMContentTime);
var domContentDivider = document.createElement("div");
domContentDivider.className = "network-event-divider network-blue-divider";
-
+
var domContentDividerPadding = document.createElement("div");
domContentDividerPadding.className = "network-event-divider-padding";
domContentDividerPadding.title = WebInspector.UIString("DOMContent event fired");
{
if (this._mainResourceLoadTime === x)
return;
-
+
this._mainResourceLoadTime = x || -1;
// Update the dividers to draw the new line
this._updateDividersIfNeeded(true);
this._mainResourceLoadTime = -1;
this._mainResourceDOMContentTime = -1;
-
+
this._viewsContainerElement.removeChildren();
this._viewsContainerElement.appendChild(this._closeButtonElement);
this._resetSummaryBar();
this._staleResources.push(resource);
this._scheduleRefresh();
-
+
if (!resource)
return;
var widths = {};
widths.name = 100;
this._dataGrid.applyColumnWidthsMap(widths);
+ },
+
+ _contextMenu: function(event)
+ {
+ // createBlobURL is enabled conditionally, do not expose resource export if it's not available.
+ if (typeof window.createObjectURL !== "function" || !Preferences.resourceExportEnabled)
+ return;
+
+ var contextMenu = new WebInspector.ContextMenu();
+ var gridNode = this._dataGrid.dataGridNodeFromNode(event.target);
+ var resource = gridNode && gridNode._resource;
+ if (resource)
+ contextMenu.appendItem(WebInspector.UIString("Export to HAR"), this._exportResource.bind(this, resource));
+ contextMenu.appendItem(WebInspector.UIString("Export all to HAR"), this._exportAll.bind(this));
+ contextMenu.show(event);
+ },
+
+ _exportAll: function()
+ {
+ var harArchive = {
+ log: (new WebInspector.HARLog()).build()
+ }
+ offerFileForDownload(JSON.stringify(harArchive));
+ },
+
+ _exportResource: function(resource)
+ {
+ var har = (new WebInspector.HAREntry(resource)).build();
+ offerFileForDownload(JSON.stringify(har));
}
}
return {start: start, middle: middle, end: end};
},
-
+
computePercentageFromEventTime: function(eventTime)
{
// This function computes a percentage in terms of the total loading time
if (this._resource.cached)
this._graphElement.addStyleClass("resource-cached");
+ this._element.addStyleClass("network-item");
if (!this._element.hasStyleClass("network-category-" + this._resource.category.name)) {
this._element.removeMatchingStyleClasses("network-category-\\w+");
this._element.addStyleClass("network-category-" + this._resource.category.name);
content: "";
}
-.network-sidebar .network-category-images .icon {
- position: relative;
- background-image: url(Images/resourcePlainIcon.png);
- background-repeat: no-repeat;
- content: "";
-}
-
.network-sidebar .data-grid.small .network-category-images .icon {
background-image: url(Images/resourcePlainIconSmall.png);
content: "";
margin-top: 1px;
}
-.data-grid table.data tr.revealed.network-category-documents, .data-grid table.data tr.revealed.network-category-stylesheets,
-.data-grid table.data tr.revealed.network-category-images, .data-grid table.data tr.revealed.network-category-scripts,
-.data-grid table.data tr.revealed.network-category-xhr, .data-grid table.data tr.revealed.network-category-fonts,
-.data-grid table.data tr.revealed.network-category-websockets, .data-grid table.data tr.revealed.network-category-other {
+.data-grid table.data tr.revealed.network-item {
display: none;
}
-.data-grid.filter-all table.data tr.revealed.network-category-documents, .data-grid.filter-documents table.data tr.revealed.network-category-documents,
-.data-grid.filter-all table.data tr.revealed.network-category-stylesheets, .data-grid.filter-stylesheets table.data tr.revealed.network-category-stylesheets,
-.data-grid.filter-all table.data tr.revealed.network-category-images, .data-grid.filter-images table.data tr.revealed.network-category-images,
-.data-grid.filter-all table.data tr.revealed.network-category-scripts, .data-grid.filter-scripts table.data tr.revealed.network-category-scripts,
-.data-grid.filter-all table.data tr.revealed.network-category-xhr, .data-grid.filter-xhr table.data tr.revealed.network-category-xhr,
-.data-grid.filter-all table.data tr.revealed.network-category-fonts, .data-grid.filter-fonts table.data tr.revealed.network-category-fonts,
-.data-grid.filter-all table.data tr.revealed.network-category-websockets, .data-grid.filter-websockets table.data tr.revealed.network-category-websockets,
-.data-grid.filter-all table.data tr.revealed.network-category-other, .data-grid.filter-other table.data tr.revealed.network-category-other {
+.data-grid.filter-all table.data tr.revealed.network-item,
+.data-grid.filter-documents table.data tr.revealed.network-category-documents,
+.data-grid.filter-stylesheets table.data tr.revealed.network-category-stylesheets,
+.data-grid.filter-images table.data tr.revealed.network-category-images,
+.data-grid.filter-scripts table.data tr.revealed.network-category-scripts,
+.data-grid.filter-xhr table.data tr.revealed.network-category-xhr,
+.data-grid.filter-fonts table.data tr.revealed.network-category-fonts,
+.data-grid.filter-websockets table.data tr.revealed.network-category-websockets,
+.data-grid.filter-other table.data tr.revealed.network-category-other {
display: table-row;
}