Diff
Modified: trunk/LayoutTests/ChangeLog (124877 => 124878)
--- trunk/LayoutTests/ChangeLog 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/LayoutTests/ChangeLog 2012-08-07 11:52:32 UTC (rev 124878)
@@ -1,3 +1,13 @@
+2012-08-07 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: implement reusable progress bar
+ https://bugs.webkit.org/show_bug.cgi?id=93267
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/progress-bar-expected.txt: Added.
+ * inspector/progress-bar.html: Added.
+
2012-08-07 Allan Sandfeld Jensen <[email protected]>
Unreviewed gardening. Rebased affected subpixel-sensitive tests after r124745.
Added: trunk/LayoutTests/inspector/progress-bar-expected.txt (0 => 124878)
--- trunk/LayoutTests/inspector/progress-bar-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/progress-bar-expected.txt 2012-08-07 11:52:32 UTC (rev 124878)
@@ -0,0 +1,27 @@
+Tests inspector's composite progress bar.
+
+Testing CompositeProgress with a single subprogress:
+progress: `undefined' 0 out of 1 done.
+progress: `cuckooing' 0 out of 1 done.
+progress: `cuckooing' 0.1 out of 1 done.
+progress: `meowing' 0.2 out of 1 done.
+progress indicator: done
+progress: `meowing' 1 out of 1 done.
+Testing CompositeProgress with multiple subprogresses:
+progress: `undefined' 0 out of 1 done.
+progress: `cuckooing' 0.05 out of 1 done.
+progress: `cuckooing' 0.05 out of 1 done.
+progress: `barking' 0.275 out of 1 done.
+progress: `meowing' 0.5 out of 1 done.
+progress: `meowing' 0.875 out of 1 done.
+progress indicator: done
+progress: `meowing' 1 out of 1 done.
+Testing isCanceled:
+Testing nested subprogresses:
+progress: `undefined' 0 out of 1 done.
+progress: `undefined' 0 out of 1 done.
+progress: `undefined' 0.1 out of 1 done.
+progress: `meowing' 0.5 out of 1 done.
+progress indicator: done
+progress: `meowing' 1 out of 1 done.
+
Property changes on: trunk/LayoutTests/inspector/progress-bar-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/progress-bar.html (0 => 124878)
--- trunk/LayoutTests/inspector/progress-bar.html (rev 0)
+++ trunk/LayoutTests/inspector/progress-bar.html 2012-08-07 11:52:32 UTC (rev 124878)
@@ -0,0 +1,168 @@
+<html>
+<head>
+<script src=""
+<script type="text/_javascript_">
+
+function initialize_ProgressBarTest()
+{
+
+InspectorTest.MockProgressIndicator = function()
+{
+}
+
+InspectorTest.MockProgressIndicator.prototype = {
+ // Implementation of WebInspector.Progress interface.
+ isCanceled: function()
+ {
+ return this._isCanceled;
+ },
+
+ done: function()
+ {
+ InspectorTest.addResult("progress indicator: done");
+ },
+
+ setTotalWork: function(totalWork)
+ {
+ this._totalWork = totalWork;
+ },
+
+ setWorked: function(worked, title)
+ {
+ this._worked = worked;
+ if (typeof title !== "undefined")
+ this._title = title;
+ },
+
+ setTitle: function(title)
+ {
+ this._title = title;
+ },
+
+ // Test methods.
+ cancel: function()
+ {
+ this._isCanceled = true;
+ },
+
+ dump: function()
+ {
+ const roundFactor = 10000;
+
+ var worked = this._worked;
+ var totalWork = this._totalWork;
+
+ if (typeof worked === "number")
+ worked = Math.round(worked * roundFactor) / roundFactor;
+ if (typeof totalWork === "number")
+ totalWork = Math.round(totalWork * roundFactor) / roundFactor;
+
+ InspectorTest.addResult("progress: `" + this._title + "' " + worked + " out of " + totalWork + " done.");
+ }
+}
+
+}
+
+var test = function()
+{
+ (function testOneSubProgress()
+ {
+ var indicator = new InspectorTest.MockProgressIndicator();
+ var composite = new WebInspector.CompositeProgress(indicator);
+ var subProgress = composite.createSubProgress();
+
+ InspectorTest.addResult("Testing CompositeProgress with a single subprogress:");
+ indicator.dump();
+ subProgress.setTitle("cuckooing");
+ subProgress.setWorked(10);
+ indicator.dump();
+ subProgress.setTotalWork(100);
+ indicator.dump();
+ subProgress.setWorked(20, "meowing");
+ indicator.dump();
+ subProgress.done();
+ indicator.dump();
+ })();
+
+ (function testMultipleSubProgresses()
+ {
+ var indicator = new InspectorTest.MockProgressIndicator();
+ var composite = new WebInspector.CompositeProgress(indicator);
+ var subProgress1 = composite.createSubProgress();
+ var subProgress2 = composite.createSubProgress(3);
+
+ InspectorTest.addResult("Testing CompositeProgress with multiple subprogresses:");
+ indicator.dump();
+
+ subProgress1.setTitle("cuckooing");
+ subProgress1.setTotalWork(100);
+ subProgress1.setWorked(20);
+ indicator.dump();
+
+ subProgress2.setWorked(10);
+ indicator.dump();
+
+ subProgress2.setTotalWork(10);
+ subProgress2.setWorked(3, "barking");
+ indicator.dump();
+
+ subProgress1.setWorked(50, "meowing");
+ subProgress2.setWorked(5);
+ indicator.dump();
+
+ subProgress2.done();
+ indicator.dump();
+
+ subProgress1.done();
+ indicator.dump();
+ })();
+
+ (function testCancel()
+ {
+ var indicator = new InspectorTest.MockProgressIndicator();
+ var composite = new WebInspector.CompositeProgress(indicator);
+ var subProgress1 = composite.createSubProgress();
+
+ InspectorTest.addResult("Testing isCanceled:");
+ InspectorTest.assertTrue(!subProgress1.isCanceled(), "progress should not be canceled");
+ indicator.cancel();
+ InspectorTest.assertTrue(subProgress1.isCanceled(), "progress should be canceled");
+ })();
+
+ (function testNested()
+ {
+ var indicator = new InspectorTest.MockProgressIndicator();
+ var composite0 = new WebInspector.CompositeProgress(indicator);
+ var subProgress01 = composite0.createSubProgress();
+ var composite1 = new WebInspector.CompositeProgress(subProgress01);
+ var subProgress11 = composite1.createSubProgress(10); // Weight should have no effect.
+
+ InspectorTest.addResult("Testing nested subprogresses:");
+ indicator.dump();
+
+ subProgress11.setWorked(10);
+ indicator.dump();
+
+ subProgress11.setTotalWork(100);
+ indicator.dump();
+
+ subProgress11.setWorked(50, "meowing");
+ indicator.dump();
+
+ InspectorTest.assertTrue(!subProgress11.isCanceled());
+ indicator.cancel();
+ InspectorTest.assertTrue(subProgress11.isCanceled());
+
+ subProgress11.done();
+ indicator.dump();
+ })();
+
+ InspectorTest.completeTest();
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests inspector's composite progress bar.</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/progress-bar.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (124877 => 124878)
--- trunk/Source/WebCore/ChangeLog 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/ChangeLog 2012-08-07 11:52:32 UTC (rev 124878)
@@ -1,3 +1,56 @@
+2012-08-06 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: implement reusable progress bar
+ https://bugs.webkit.org/show_bug.cgi?id=93267
+
+ - Generic progress bar implementation to be used
+ by various long-running operations in inspector.
+
+ Test: inspector/progress-bar.html
+
+ Reviewed by Pavel Feldman.
+
+ * WebCore.gypi: Added ProgressBar.js
+ * WebCore.vcproj/WebCore.vcproj: ditto.
+ * inspector/compile-front-end.py: ditto.
+ * inspector/front-end/AdvancedSearchController.js: renamed style for stop button.
+ (WebInspector.SearchView):
+ * inspector/front-end/ProgressBar.js: Added.
+ (WebInspector.Progress): Interface for both ProgressIndicator and SubProgress.
+ (WebInspector.Progress.prototype.setTotalWork):
+ (WebInspector.Progress.prototype.setTitle):
+ (WebInspector.Progress.prototype.setWorked):
+ (WebInspector.Progress.prototype.done):
+ (WebInspector.Progress.prototype.isCanceled):
+ (WebInspector.ProgressIndicator): A UI control that implements Progress.
+ (WebInspector.ProgressIndicator.prototype.show):
+ (WebInspector.ProgressIndicator.prototype.hide):
+ (WebInspector.ProgressIndicator.prototype.done):
+ (WebInspector.ProgressIndicator.prototype._cancel):
+ (WebInspector.ProgressIndicator.prototype.isCanceled):
+ (WebInspector.ProgressIndicator.prototype.setTitle):
+ (WebInspector.ProgressIndicator.prototype.setTotalWork):
+ (WebInspector.ProgressIndicator.prototype.setWorked):
+ (WebInspector.CompositeProgress): A progress bar that is composed of several SubProgress bars and uses a Progress to display total progress of all tasks.
+ (WebInspector.CompositeProgress.prototype._childDone):
+ (WebInspector.CompositeProgress.prototype.createSubProgress):
+ (WebInspector.CompositeProgress.prototype._update):
+ (WebInspector.SubProgress): A child of CompositeProgress, implements Progress interface.
+ (WebInspector.SubProgress.prototype.isCanceled):
+ (WebInspector.SubProgress.prototype.setTitle):
+ (WebInspector.SubProgress.prototype.done):
+ (WebInspector.SubProgress.prototype.setTotalWork):
+ (WebInspector.SubProgress.prototype.setWorked):
+ * inspector/front-end/WebKit.qrc: Added ProgressBar.js
+ * inspector/front-end/inspector.css:
+ (.progress-bar-stop-button-item):
+ (.progress-bar-stop-button .glyph):
+ (.progress-bar-container):
+ (.progress-bar-container span):
+ (.progress-bar-container progress):
+ (.progress-bar-container button.status-bar-item):
+ * inspector/front-end/inspector.html:
+
2012-08-07 Peter Rybin <[email protected]>
Web Inspector: display function scope in UI
Modified: trunk/Source/WebCore/WebCore.gypi (124877 => 124878)
--- trunk/Source/WebCore/WebCore.gypi 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/WebCore.gypi 2012-08-07 11:52:32 UTC (rev 124878)
@@ -6361,6 +6361,7 @@
'inspector/front-end/ProfileDataGridTree.js',
'inspector/front-end/ProfileLauncherView.js',
'inspector/front-end/ProfilesPanel.js',
+ 'inspector/front-end/ProgressBar.js',
'inspector/front-end/PropertiesSection.js',
'inspector/front-end/PropertiesSidebarPane.js',
'inspector/front-end/RawSourceCode.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (124877 => 124878)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-08-07 11:52:32 UTC (rev 124878)
@@ -75862,6 +75862,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\ProgressBar.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\PropertiesSection.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/compile-front-end.py (124877 => 124878)
--- trunk/Source/WebCore/inspector/compile-front-end.py 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/inspector/compile-front-end.py 2012-08-07 11:52:32 UTC (rev 124878)
@@ -130,6 +130,7 @@
"Panel.js",
"PanelEnablerView.js",
"Popover.js",
+ "ProgressBar.js",
"PropertiesSection.js",
"SearchController.js",
"Section.js",
Modified: trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js (124877 => 124878)
--- trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js 2012-08-07 11:52:32 UTC (rev 124878)
@@ -215,8 +215,8 @@
this._searchProgressElement.className = "search-status-bar-progress";
this._searchStopButtonItem = document.createElement("div");
- this._searchStopButtonItem.className = "search-status-bar-stop-button-item";
- this._searchStopStatusBarButton = new WebInspector.StatusBarButton(WebInspector.UIString("Stop search"), "search-status-bar-stop-button");
+ this._searchStopButtonItem.className = "progress-bar-stop-button-item";
+ this._searchStopStatusBarButton = new WebInspector.StatusBarButton(WebInspector.UIString("Stop search"), "progress-bar-stop-button");
this._searchStopButtonItem.appendChild(this._searchStopStatusBarButton.element);
this._searchStopStatusBarButton.addEventListener("click", this._searchStopButtonPressed, this);
Added: trunk/Source/WebCore/inspector/front-end/ProgressBar.js (0 => 124878)
--- trunk/Source/WebCore/inspector/front-end/ProgressBar.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/ProgressBar.js 2012-08-07 11:52:32 UTC (rev 124878)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @interface
+ */
+WebInspector.Progress = function()
+{
+}
+
+WebInspector.Progress.prototype = {
+ /**
+ * @param {number} totalWork
+ */
+ setTotalWork: function(totalWork) { },
+
+ /**
+ * @param {string} title
+ */
+ setTitle: function(title) { },
+
+ /**
+ * @param {number} worked
+ * @param {string=} title
+ */
+ setWorked: function(worked, title) { },
+
+ done: function() { },
+
+ /**
+ * @return {boolean}
+ */
+ isCanceled: function() { return false; }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.Progress}
+ * @extends {WebInspector.Object}
+ */
+WebInspector.ProgressIndicator = function()
+{
+ this.element = document.createElement("div");
+ this.element.className = "progress-bar-container";
+ this._labelElement = this.element.createChild("span");
+ this._progressElement = this.element.createChild("progress");
+ this._stopButton = new WebInspector.StatusBarButton(WebInspector.UIString("Cancel"), "progress-bar-stop-button");
+ this._stopButton.addEventListener("click", this._cancel, this);
+ this.element.appendChild(this._stopButton.element);
+ this._isCanceled = false;
+}
+
+WebInspector.ProgressIndicator.Events = {
+ Done: "Done"
+}
+
+WebInspector.ProgressIndicator.prototype = {
+ /**
+ * @param {Element} parent
+ */
+ show: function(parent)
+ {
+ parent.appendChild(this.element);
+ },
+
+ hide: function()
+ {
+ var parent = this.element.parentElement;
+ if (parent)
+ parent.removeChild(this.element);
+ },
+
+ done: function()
+ {
+ this.hide();
+ this.dispatchEventToListeners(WebInspector.ProgressIndicator.Events.Done);
+ },
+
+ _cancel: function()
+ {
+ this._isCanceled = true;
+ },
+
+ isCanceled: function()
+ {
+ return this._isCanceled;
+ },
+
+ /**
+ * @param {string} title
+ */
+ setTitle: function(title)
+ {
+ this._labelElement.textContent = title;
+ },
+
+ /**
+ * @param {number} totalWork
+ */
+ setTotalWork: function(totalWork)
+ {
+ this._progressElement.max = totalWork;
+ },
+
+ /**
+ * @param {number} worked
+ * @param {string=} title
+ */
+ setWorked: function(worked, title)
+ {
+ this._progressElement.value = worked;
+ if (title)
+ this.setTitle(title);
+ }
+}
+
+WebInspector.ProgressIndicator.prototype.__proto__ = WebInspector.Object.prototype;
+
+/**
+ * @constructor
+ * @param {WebInspector.Progress} parent
+ */
+WebInspector.CompositeProgress = function(parent)
+{
+ this._parent = parent;
+ this._children = [];
+ this._childrenDone = 0;
+ this._parent.setTotalWork(1);
+ this._parent.setWorked(0);
+}
+
+WebInspector.CompositeProgress.prototype = {
+ _childDone: function()
+ {
+ if (++this._childrenDone === this._children.length)
+ this._parent.done();
+ },
+
+ /**
+ * @param {number=} weight
+ * @param {number=} totalWork
+ */
+ createSubProgress: function(weight, totalWork)
+ {
+ var child = new WebInspector.SubProgress(this, weight, totalWork);
+ this._children.push(child);
+ return child;
+ },
+
+ _update: function()
+ {
+ var totalWeights = 0;
+ var done = 0;
+
+ for (var i = 0; i < this._children.length; ++i) {
+ var child = this._children[i];
+ if (child._totalWork)
+ done += child._weight * child._worked / child._totalWork;
+ totalWeights += child._weight;
+ }
+ this._parent.setWorked(done / totalWeights);
+ }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.Progress}
+ * @param {WebInspector.CompositeProgress} composite
+ * @param {number=} weight
+ * @param {number=} totalWork
+ */
+WebInspector.SubProgress = function(composite, weight)
+{
+ this._composite = composite;
+ this._weight = weight || 1;
+ this._worked = 0;
+}
+
+WebInspector.SubProgress.prototype = {
+ /**
+ * @return {boolean}
+ */
+ isCanceled: function()
+ {
+ return this._composite._parent.isCanceled();
+ },
+
+ /**
+ * @param {string} title
+ */
+ setTitle: function(title)
+ {
+ this._composite._parent.setTitle(title);
+ },
+
+ done: function()
+ {
+ this.setWorked(this._totalWork);
+ this._composite._childDone();
+ },
+
+ /**
+ * @param {number} totalWork
+ */
+ setTotalWork: function(totalWork)
+ {
+ this._totalWork = totalWork;
+ this._composite._update();
+ },
+
+ /**
+ * @param {number} worked
+ * @param {string=} title
+ */
+ setWorked: function(worked, title)
+ {
+ this._worked = worked;
+ if (typeof title !== "undefined")
+ this.setTitle(title);
+ this._composite._update();
+ }
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/ProgressBar.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (124877 => 124878)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-08-07 11:52:32 UTC (rev 124878)
@@ -114,6 +114,7 @@
<file>ProfileDataGridTree.js</file>
<file>ProfileLauncherView.js</file>
<file>ProfilesPanel.js</file>
+ <file>ProgressBar.js</file>
<file>PropertiesSection.js</file>
<file>PropertiesSidebarPane.js</file>
<file>RawSourceCode.js</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (124877 => 124878)
--- trunk/Source/WebCore/inspector/front-end/inspector.css 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css 2012-08-07 11:52:32 UTC (rev 124878)
@@ -2593,13 +2593,13 @@
margin-top: 6px;
}
-.search-status-bar-stop-button-item {
+.progress-bar-stop-button-item {
width: 19px;
height: 24px;
overflow: hidden;
}
-.search-status-bar-stop-button .glyph {
+.progress-bar-stop-button .glyph {
-webkit-mask-position: -96px -48px;
background-color: rgb(216, 0, 0) !important;
}
@@ -2876,3 +2876,23 @@
font-size: 11px;
height: auto;
}
+
+.progress-bar-container {
+ display: -webkit-flex;
+ margin: 0 8px;
+ -webkit-flex: 1 0;
+}
+
+.progress-bar-container span {
+ padding: 6px;
+}
+
+.progress-bar-container progress {
+ margin-top: 8px;
+ -webkit-flex: 1 0;
+}
+
+.progress-bar-container button.status-bar-item {
+ border-left: none;
+ margin-top: 1px;
+}
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (124877 => 124878)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2012-08-07 11:34:46 UTC (rev 124877)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2012-08-07 11:52:32 UTC (rev 124878)
@@ -225,6 +225,7 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
</head>
<body class="detached" id="-webkit-web-inspector">
<div id="toolbar">