Diff
Modified: trunk/LayoutTests/ChangeLog (125167 => 125168)
--- trunk/LayoutTests/ChangeLog 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/LayoutTests/ChangeLog 2012-08-09 12:24:47 UTC (rev 125168)
@@ -1,3 +1,15 @@
+2012-08-08 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: display progress bar while loading timeline data
+ https://bugs.webkit.org/show_bug.cgi?id=92762
+
+ Reviewed by Pavel Feldman.
+
+ - fix loading tests to pass mock progress indicator;
+
+ * inspector/timeline/timeline-load-incompatible.html:
+ * inspector/timeline/timeline-load.html:
+
2012-08-09 Allan Sandfeld Jensen <[email protected]>
Floored and truncated rounded confused.
Modified: trunk/LayoutTests/inspector/timeline/timeline-load-incompatible.html (125167 => 125168)
--- trunk/LayoutTests/inspector/timeline/timeline-load-incompatible.html 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/LayoutTests/inspector/timeline/timeline-load-incompatible.html 2012-08-09 12:24:47 UTC (rev 125168)
@@ -11,8 +11,9 @@
InspectorFrontendHost.save = save;
var data = ""
+ var mockProgress = new WebInspector.Progress();
try {
- WebInspector.panels.timeline._model._loadNextChunk(data, 0);
+ WebInspector.panels.timeline._model._loadNextChunk(mockProgress, data, 0);
} catch (e) {
InspectorTest.addResult("failed");
InspectorTest.completeTest();
Modified: trunk/LayoutTests/inspector/timeline/timeline-load.html (125167 => 125168)
--- trunk/LayoutTests/inspector/timeline/timeline-load.html 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/LayoutTests/inspector/timeline/timeline-load.html 2012-08-09 12:24:47 UTC (rev 125168)
@@ -20,7 +20,8 @@
{"startTime":1310749855137.989,"data":{"requestId":49,"url":"http://www.webkit.org/css/purple.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
{"startTime":1310749855138.308,"data":{"requestId":50,"url":"http://www.webkit.org/css/gray.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120}];
- WebInspector.panels.timeline._model._loadNextChunk(data, 0);
+ var mockProgress = new WebInspector.Progress();
+ WebInspector.panels.timeline._model._loadNextChunk(mockProgress, data, 0);
function loadNextChunk()
{
Modified: trunk/Source/WebCore/ChangeLog (125167 => 125168)
--- trunk/Source/WebCore/ChangeLog 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/Source/WebCore/ChangeLog 2012-08-09 12:24:47 UTC (rev 125168)
@@ -1,3 +1,37 @@
+2012-08-08 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: display progress bar while loading timeline data
+ https://bugs.webkit.org/show_bug.cgi?id=92762
+
+ Reviewed by Pavel Feldman.
+
+ - display progress while loading timeline data;
+ - disable status bar buttons while operation is in progress;
+ - ignore save/load/record while operation is in progress;
+ - disable context menu items while operation is in progress;
+ - misc. compilation warning fixes;
+
+ * inspector/front-end/ProgressBar.js:
+ (WebInspector.CompositeProgress.prototype.createSubProgress):
+ * inspector/front-end/TimelineModel.js:
+ (WebInspector.TimelineModel.prototype._loadNextChunk):
+ (WebInspector.TimelineModel.prototype.loadFromFile.parseAndImportData):
+ (WebInspector.TimelineModel.prototype.loadFromFile.onLoad):
+ (WebInspector.TimelineModel.prototype.loadFromFile.onError):
+ (WebInspector.TimelineModel.prototype.loadFromFile.onProgress):
+ (WebInspector.TimelineModel.prototype.loadFromFile):
+ * inspector/front-end/TimelinePanel.js:
+ (WebInspector.TimelinePanel):
+ (WebInspector.TimelinePanel.prototype.get statusBarItems):
+ (WebInspector.TimelinePanel.prototype._createStatusBarItems):
+ (WebInspector.TimelinePanel.prototype._setOperationInProgress):
+ (WebInspector.TimelinePanel.prototype._contextMenu):
+ (WebInspector.TimelinePanel.prototype._saveToFile):
+ (WebInspector.TimelinePanel.prototype._loadFromFile):
+ (WebInspector.TimelinePanel.prototype.get _toggleTimelineButtonClicked):
+ (WebInspector.TimelinePanel.prototype.sidebarResized):
+ * inspector/front-end/utilities.js: added Array.prototype.select(field) to map array of objects to array containing particular field of each object.
+
2012-08-09 Allan Sandfeld Jensen <[email protected]>
Floored and truncated rounded confused.
Modified: trunk/Source/WebCore/inspector/front-end/TimelineModel.js (125167 => 125168)
--- trunk/Source/WebCore/inspector/front-end/TimelineModel.js 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/Source/WebCore/inspector/front-end/TimelineModel.js 2012-08-09 12:24:47 UTC (rev 125168)
@@ -159,26 +159,59 @@
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordAdded, record);
},
- _loadNextChunk: function(data, index)
+ /**
+ * @param {WebInspector.Progress} progress
+ * @param {Array.<Object>} data
+ * @param {number} index
+ */
+ _loadNextChunk: function(progress, data, index)
{
- for (var i = 0; i < 20 && index < data.length; ++i, ++index)
+ if (progress.isCanceled()) {
+ this.reset();
+ progress.done();
+ return;
+ }
+ progress.setWorked(index);
+
+ for (var i = 0; i < 100 && index < data.length; ++i, ++index)
this._addRecord(data[index]);
if (index !== data.length)
- setTimeout(this._loadNextChunk.bind(this, data, index), 0);
+ setTimeout(this._loadNextChunk.bind(this, progress, data, index), 0);
+ else
+ progress.done();
},
- loadFromFile: function(file)
+ /**
+ * @param {!Blob} file
+ * @param {WebInspector.Progress} progress
+ */
+ loadFromFile: function(file, progress)
{
- function onLoad(e)
+ var compositeProgress = new WebInspector.CompositeProgress(progress);
+ var loadingProgress = compositeProgress.createSubProgress(1);
+ var parsingProgress = compositeProgress.createSubProgress(1);
+ var processingProgress = compositeProgress.createSubProgress(1);
+
+ function parseAndImportData(data)
{
- var data = ""
+ var records = JSON.parse(data);
+ parsingProgress.done();
this.reset();
- this._loadNextChunk(data, 1);
+ processingProgress.setTotalWork(records.length);
+ this._loadNextChunk(processingProgress, records, 1);
}
+ function onLoad(e)
+ {
+ loadingProgress.done();
+ parsingProgress.setTotalWork(1);
+ setTimeout(parseAndImportData.bind(this, e.target.result), 0);
+ }
+
function onError(e)
{
+ progress.done();
switch(e.target.error.code) {
case e.target.error.NOT_FOUND_ERR:
WebInspector.log(WebInspector.UIString('Timeline.loadFromFile: File "%s" not found.', file.name));
@@ -193,9 +226,18 @@
}
}
+ function onProgress(e)
+ {
+ if (e.lengthComputable)
+ loadingProgress.setWorked(e.loaded / e.total);
+ }
+
var reader = new FileReader();
reader._onload_ = onLoad.bind(this);
reader._onerror_ = onError;
+ reader._onprogress_ = onProgress;
+ loadingProgress.setTitle(WebInspector.UIString("Loading\u2026"));
+ loadingProgress.setTotalWork(1);
reader.readAsText(file);
},
Modified: trunk/Source/WebCore/inspector/front-end/TimelinePanel.js (125167 => 125168)
--- trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2012-08-09 12:24:47 UTC (rev 125168)
@@ -45,7 +45,7 @@
this._overviewPane.addEventListener(WebInspector.TimelineOverviewPane.Events.ModeChanged, this._overviewModeChanged, this);
this._overviewPane.show(this.element);
- this.element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
+ this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false);
this.element.tabIndex = 0;
this._sidebarBackgroundElement = document.createElement("div");
@@ -102,7 +102,7 @@
var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePresentationModel.shortRecordThreshold);
this._showShortRecordsTitleText = WebInspector.UIString("Show the records that are shorter than %s", shortRecordThresholdTitle);
this._hideShortRecordsTitleText = WebInspector.UIString("Hide the records that are shorter than %s", shortRecordThresholdTitle);
- this._createStatusbarButtons();
+ this._createStatusBarItems();
this._frameMode = false;
this._boundariesAreValid = true;
@@ -202,16 +202,10 @@
get statusBarItems()
{
- var statusBarItems = [
- this.toggleFilterButton.element,
- this.toggleTimelineButton.element,
- this.clearButton.element, this.garbageCollectButton.element,
- this._glueParentButton.element,
- this.statusBarFilters,
+ return this._statusBarButtons.select("element").concat([
+ this._miscStatusBarItems,
this.recordsCounter
- ];
-
- return statusBarItems;
+ ]);
},
defaultFocusedElement: function()
@@ -219,37 +213,46 @@
return this.element;
},
- _createStatusbarButtons: function()
+ _createStatusBarItems: function()
{
+ this._statusBarButtons = [];
+
+ this.toggleFilterButton = new WebInspector.StatusBarButton(this._hideShortRecordsTitleText, "timeline-filter-status-bar-item");
+ this.toggleFilterButton.addEventListener("click", this._toggleFilterButtonClicked, this);
+ this._statusBarButtons.push(this.toggleFilterButton);
+
this.toggleTimelineButton = new WebInspector.StatusBarButton(WebInspector.UIString("Record"), "record-profile-status-bar-item");
this.toggleTimelineButton.addEventListener("click", this._toggleTimelineButtonClicked, this);
+ this._statusBarButtons.push(this.toggleTimelineButton);
this.clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "clear-status-bar-item");
this.clearButton.addEventListener("click", this._clearPanel, this);
+ this._statusBarButtons.push(this.clearButton);
- this.toggleFilterButton = new WebInspector.StatusBarButton(this._hideShortRecordsTitleText, "timeline-filter-status-bar-item");
- this.toggleFilterButton.addEventListener("click", this._toggleFilterButtonClicked, this);
-
this.garbageCollectButton = new WebInspector.StatusBarButton(WebInspector.UIString("Collect Garbage"), "garbage-collect-status-bar-item");
this.garbageCollectButton.addEventListener("click", this._garbageCollectButtonClicked, this);
+ this._statusBarButtons.push(this.garbageCollectButton);
- this.recordsCounter = document.createElement("span");
- this.recordsCounter.className = "timeline-records-counter";
-
this._glueParentButton = new WebInspector.StatusBarButton(WebInspector.UIString("Glue asynchronous events to causes"), "glue-async-status-bar-item");
this._glueParentButton.toggled = true;
this._presentationModel.setGlueRecords(true);
this._glueParentButton.addEventListener("click", this._glueParentButtonClicked, this);
+ this._statusBarButtons.push(this._glueParentButton);
- this.statusBarFilters = document.createElement("div");
- this.statusBarFilters.className = "status-bar-items";
+ this._miscStatusBarItems = document.createElement("div");
+ this._miscStatusBarItems.className = "status-bar-items";
+
+ this._statusBarFilters = this._miscStatusBarItems.createChild("div");
var categories = WebInspector.TimelinePresentationModel.categories();
for (var categoryName in categories) {
var category = categories[categoryName];
if (category.overviewStripGroupIndex < 0)
continue;
- this.statusBarFilters.appendChild(this._createTimelineCategoryStatusBarCheckbox(category, this._onCategoryCheckboxClicked.bind(this, category)));
+ this._statusBarFilters.appendChild(this._createTimelineCategoryStatusBarCheckbox(category, this._onCategoryCheckboxClicked.bind(this, category)));
}
+
+ this.recordsCounter = document.createElement("span");
+ this.recordsCounter.className = "timeline-records-counter";
},
_createTimelineCategoryStatusBarCheckbox: function(category, onCheckboxClicked)
@@ -282,6 +285,19 @@
this._scheduleRefresh(true);
},
+ /**
+ * @param {?WebInspector.ProgressIndicator} indicator
+ */
+ _setOperationInProgress: function(indicator)
+ {
+ this._operationInProgress = !!indicator;
+ for (var i = 0; i < this._statusBarButtons.length; ++i)
+ this._statusBarButtons[i].disabled = this._operationInProgress;
+ this._glueParentButton.disabled = this._operationInProgress || !!this._frameController;
+ this._miscStatusBarItems.removeChildren();
+ this._miscStatusBarItems.appendChild(indicator ? indicator.element : this._statusBarFilters);
+ },
+
_registerShortcuts: function()
{
var shortcut = WebInspector.KeyboardShortcut;
@@ -318,23 +334,30 @@
{
var contextMenu = new WebInspector.ContextMenu();
if (InspectorFrontendHost.canSave())
- contextMenu.appendItem(WebInspector.UIString("Save Timeline data\u2026"), this._saveToFile.bind(this));
- contextMenu.appendItem(WebInspector.UIString("Load Timeline data\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement));
+ contextMenu.appendItem(WebInspector.UIString("Save Timeline data\u2026"), this._saveToFile.bind(this), this._operationInProgress);
+ contextMenu.appendItem(WebInspector.UIString("Load Timeline data\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement), this._operationInProgress);
contextMenu.show(event);
},
_saveToFile: function()
{
+ if (this._operationInProgress)
+ return;
this._model.saveToFile();
},
_loadFromFile: function()
{
+ if (this._operationInProgress)
+ return;
if (this.toggleTimelineButton.toggled) {
this.toggleTimelineButton.toggled = false;
this._model.stopRecord();
}
- this._model.loadFromFile(this._fileSelectorElement.files[0]);
+ var progressIndicator = new WebInspector.ProgressIndicator();
+ progressIndicator.addEventListener(WebInspector.ProgressIndicator.Events.Done, this._setOperationInProgress.bind(this, null));
+ this._setOperationInProgress(progressIndicator);
+ this._model.loadFromFile(this._fileSelectorElement.files[0], progressIndicator);
this._createFileSelector();
},
@@ -466,6 +489,8 @@
_toggleTimelineButtonClicked: function()
{
+ if (this._operationInProgress)
+ return;
if (this.toggleTimelineButton.toggled)
this._model.stopRecord();
else {
@@ -548,7 +573,7 @@
this.onResize();
this._overviewPane.sidebarResized(width);
// Min width = <number of buttons on the left> * 31
- this.statusBarFilters.style.left = Math.max((this.statusBarItems.length + 2) * 31, width) + "px";
+ this._miscStatusBarItems.style.left = Math.max((this._statusBarButtons.length + 3) * 31, width) + "px";
this._memoryStatistics.setSidebarWidth(width);
this._timelineGrid.gridHeaderElement.style.left = width + "px";
},
Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (125167 => 125168)
--- trunk/Source/WebCore/inspector/front-end/utilities.js 2012-08-09 12:20:30 UTC (rev 125167)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js 2012-08-09 12:24:47 UTC (rev 125168)
@@ -384,6 +384,22 @@
}
});
+Object.defineProperty(Array.prototype, "select",
+{
+ /**
+ * @this {Array.<*>}
+ * @param {string} field
+ * @return {Array.<*>}
+ */
+ value: function(field)
+ {
+ var result = new Array(this.length);
+ for (var i = 0; i < this.length; ++i)
+ result[i] = this[i][field];
+ return result;
+ }
+});
+
/**
* @param {*} anObject
* @param {Array.<*>} aList