Web Inspector: add all Resource panel views to the compilation.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Oct 2011 16:12:03 +0000 (16:12 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Oct 2011 16:12:03 +0000 (16:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69526

Reviewed by Yury Semikhatsky.

* inspector/compile-front-end.sh:
* inspector/front-end/CookieItemsView.js:
(WebInspector.CookieItemsView.prototype._contextMenu):
(WebInspector.Cookies.cookieMatchesResourceURL):
* inspector/front-end/CookiesTable.js:
(WebInspector.CookiesTable):
(WebInspector.CookiesTable.prototype._onDeleteFromGrid):
* inspector/front-end/DOMStorageItemsView.js:
(WebInspector.DOMStorageItemsView.prototype._dataGridForDOMStorageEntries):
* inspector/front-end/DataGrid.js:
(WebInspector.DataGrid.createSortableDataGrid.sortDataGrid.comparator):
(WebInspector.DataGrid.createSortableDataGrid.sortDataGrid):
(WebInspector.DataGrid.createSortableDataGrid):
* inspector/front-end/DatabaseQueryView.js:
(WebInspector.DatabaseQueryView.prototype._queryFinished):
* inspector/front-end/DatabaseTableView.js:
(WebInspector.DatabaseTableView.prototype._queryFinished):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.reset):
(WebInspector.ResourcesPanel.prototype.showDatabase):
* inspector/front-end/TextPrompt.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96815 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/compile-front-end.sh
Source/WebCore/inspector/front-end/CookieItemsView.js
Source/WebCore/inspector/front-end/CookiesTable.js
Source/WebCore/inspector/front-end/DOMStorageItemsView.js
Source/WebCore/inspector/front-end/DataGrid.js
Source/WebCore/inspector/front-end/DatabaseQueryView.js
Source/WebCore/inspector/front-end/DatabaseTableView.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/TextPrompt.js

index 1d73904..6d343c0 100644 (file)
@@ -1,3 +1,32 @@
+2011-10-06  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: add all Resource panel views to the compilation.
+        https://bugs.webkit.org/show_bug.cgi?id=69526
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/compile-front-end.sh:
+        * inspector/front-end/CookieItemsView.js:
+        (WebInspector.CookieItemsView.prototype._contextMenu):
+        (WebInspector.Cookies.cookieMatchesResourceURL):
+        * inspector/front-end/CookiesTable.js:
+        (WebInspector.CookiesTable):
+        (WebInspector.CookiesTable.prototype._onDeleteFromGrid):
+        * inspector/front-end/DOMStorageItemsView.js:
+        (WebInspector.DOMStorageItemsView.prototype._dataGridForDOMStorageEntries):
+        * inspector/front-end/DataGrid.js:
+        (WebInspector.DataGrid.createSortableDataGrid.sortDataGrid.comparator):
+        (WebInspector.DataGrid.createSortableDataGrid.sortDataGrid):
+        (WebInspector.DataGrid.createSortableDataGrid):
+        * inspector/front-end/DatabaseQueryView.js:
+        (WebInspector.DatabaseQueryView.prototype._queryFinished):
+        * inspector/front-end/DatabaseTableView.js:
+        (WebInspector.DatabaseTableView.prototype._queryFinished):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.reset):
+        (WebInspector.ResourcesPanel.prototype.showDatabase):
+        * inspector/front-end/TextPrompt.js:
+
 2011-10-06  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r96791.
index a632167..7bdec42 100755 (executable)
@@ -107,9 +107,13 @@ java -jar ~/closure/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --warn
         --js Source/WebCore/inspector/front-end/UIUtils.js \
         --js Source/WebCore/inspector/front-end/View.js \
         --js Source/WebCore/inspector/front-end/WelcomeView.js \
-    --module jsmodule_inspector:20:jsmodule_sdk,jsmodule_ui \
+    --module jsmodule_inspector:24:jsmodule_sdk,jsmodule_ui \
         --js Source/WebCore/inspector/front-end/ConsoleMessage.js \
         --js Source/WebCore/inspector/front-end/ConsoleView.js \
+        --js Source/WebCore/inspector/front-end/CookieItemsView.js \
+        --js Source/WebCore/inspector/front-end/DatabaseQueryView.js \
+        --js Source/WebCore/inspector/front-end/DatabaseTableView.js \
+        --js Source/WebCore/inspector/front-end/DOMStorageItemsView.js \
         --js Source/WebCore/inspector/front-end/ElementsTreeOutline.js \
         --js Source/WebCore/inspector/front-end/FontView.js \
         --js Source/WebCore/inspector/front-end/ImageView.js \
@@ -139,10 +143,6 @@ java -jar ~/closure/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --warn
 # StylesSidebarPane
 #
 # [Resources]
-# CookieItemsView
-# DatabaseQueryView
-# DatabaseTableView
-# DOMStorageItemsView
 # ResourcesPanel
 # 
 # [Network]
index 519b4e5..0cbf6ea 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.View}
+ */
 WebInspector.CookieItemsView = function(treeElement, cookieDomain)
 {
     WebInspector.View.call(this);
@@ -155,7 +159,7 @@ WebInspector.CookieItemsView.prototype = {
         this._update();
     },
 
-    _contextMenu: function()
+    _contextMenu: function(event)
     {
         if (!this._cookies.length) {
             var contextMenu = new WebInspector.ContextMenu();
@@ -167,6 +171,9 @@ WebInspector.CookieItemsView.prototype = {
 
 WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.View.prototype;
 
+/**
+ * @constructor
+ */
 WebInspector.SimpleCookiesTable = function()
 {
     this.element = document.createElement("div");
@@ -249,7 +256,7 @@ WebInspector.Cookies.buildCookiesFromString = function(rawCookieString)
 WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL)
 {
     var url = resourceURL.asParsedURL();
-    if (!url || !this.cookieDomainMatchesResourceDomain(cookie.domain, url.host))
+    if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.domain, url.host))
         return false;
     return (url.path.indexOf(cookie.path) === 0
         && (!cookie.port || url.port == cookie.port)
index 3ef2c8b..71fdbf7 100644 (file)
@@ -67,13 +67,12 @@ WebInspector.CookiesTable = function(cookieDomain, expandable, deleteCallback, r
     columns[7].sortable = true;
     columns[7].width = "7%";
 
-    this._dataGrid = new WebInspector.DataGrid(columns, null, deleteCallback ? this._onDeleteFromGrid.bind(this) : null);
+    this._dataGrid = new WebInspector.DataGrid(columns, undefined, deleteCallback ? this._onDeleteFromGrid.bind(this, deleteCallback) : undefined);
     this._dataGrid.addEventListener("sorting changed", this._rebuildTable, this);
     this._dataGrid.refreshCallback = refreshCallback;
 
     this.element = this._dataGrid.element;
     this._data = [];
-    this._deleteCallback = deleteCallback;
 }
 
 WebInspector.CookiesTable.prototype = {
@@ -207,8 +206,8 @@ WebInspector.CookiesTable.prototype = {
         return node;
     },
 
-    _onDeleteFromGrid: function(node)
+    _onDeleteFromGrid: function(deleteCallback, node)
     {
-        this._deleteCallback(node.cookie);
+        deleteCallback(node.cookie);
     }
 }
index 95e4a13..88e9a04 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.View}
+ */
 WebInspector.DOMStorageItemsView = function(domStorage)
 {
     WebInspector.View.call(this);
@@ -107,7 +111,7 @@ WebInspector.DOMStorageItemsView.prototype = {
         }
 
         var dataGrid = new WebInspector.DataGrid(columns, this._editingCallback.bind(this), this._deleteCallback.bind(this));
-        var length = nodes.length;
+        length = nodes.length;
         for (var i = 0; i < length; ++i)
             dataGrid.appendChild(nodes[i]);
         dataGrid.addCreationNode(false);
index 4e4a129..aa9c4df 100644 (file)
@@ -26,6 +26,8 @@
 /**
  * @constructor
  * @extends {WebInspector.Object}
+ * @param {function(WebInspector.DataGridNode, number, string, string)=} editCallback
+ * @param {function(WebInspector.DataGridNode)=} deleteCallback
  */
 WebInspector.DataGrid = function(columns, editCallback, deleteCallback)
 {
@@ -158,6 +160,82 @@ WebInspector.DataGrid = function(columns, editCallback, deleteCallback)
     this._columnWidthsInitialized = false;
 }
 
+/**
+ * @param {Array.<string>} columnNames
+ * @param {Array.<string>} values
+ */
+WebInspector.DataGrid.createSortableDataGrid = function(columnNames, values)
+{
+    var numColumns = columnNames.length;
+    if (!numColumns)
+        return null;
+
+    var columns = {};
+
+    for (var i = 0; i < columnNames.length; ++i) {
+        var column = {};
+        column.width = columnNames[i].length;
+        column.title = columnNames[i];
+        column.sortable = true;
+
+        columns[columnNames[i]] = column;
+    }
+
+    var nodes = [];
+    for (var i = 0; i < values.length / numColumns; ++i) {
+        var data = {};
+        for (var j = 0; j < columnNames.length; ++j)
+            data[columnNames[j]] = values[numColumns * i + j];
+
+        var node = new WebInspector.DataGridNode(data, false);
+        node.selectable = false;
+        nodes.push(node);
+    }
+
+    var dataGrid = new WebInspector.DataGrid(columns);
+    var length = nodes.length;
+    for (var i = 0; i < length; ++i)
+        dataGrid.appendChild(nodes[i]);
+
+    dataGrid.addEventListener("sorting changed", sortDataGrid, this);
+
+    function sortDataGrid()
+    {
+        var nodes = dataGrid.children.slice();
+        var sortColumnIdentifier = dataGrid.sortColumnIdentifier;
+        var sortDirection = dataGrid.sortOrder === "ascending" ? 1 : -1;
+        var columnIsNumeric = true;
+
+        for (var i = 0; i < nodes.length; i++) {
+            if (isNaN(Number(nodes[i].data[sortColumnIdentifier])))
+                columnIsNumeric = false;
+        }
+
+        function comparator(dataGridNode1, dataGridNode2)
+        {
+            var item1 = dataGridNode1.data[sortColumnIdentifier];
+            var item2 = dataGridNode2.data[sortColumnIdentifier];
+
+            var comparison;
+            if (columnIsNumeric) {
+                // Sort numbers based on comparing their values rather than a lexicographical comparison.
+                var number1 = parseFloat(item1);
+                var number2 = parseFloat(item2);
+                comparison = number1 < number2 ? -1 : (number1 > number2 ? 1 : 0);
+            } else
+                comparison = item1 < item2 ? -1 : (item1 > item2 ? 1 : 0);
+
+            return sortDirection * comparison;
+        }
+
+        nodes.sort(comparator);
+        dataGrid.removeChildren();
+        for (var i = 0; i < nodes.length; i++)
+            dataGrid.appendChild(nodes[i]);
+    }
+    return dataGrid;
+}
+
 WebInspector.DataGrid.prototype = {
     get refreshCallback()
     {
@@ -334,6 +412,9 @@ WebInspector.DataGrid.prototype = {
         return this._dataTableBody;
     },
 
+    /**
+     * @param {number=} maxDescentLevel
+     */
     autoSizeColumns: function(minPercent, maxPercent, maxDescentLevel)
     {
         if (minPercent)
index 92ecc67..69207cf 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.View}
+ */
 WebInspector.DatabaseQueryView = function(database)
 {
     WebInspector.View.call(this);
@@ -45,6 +49,10 @@ WebInspector.DatabaseQueryView = function(database)
     this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), " ");
 }
 
+WebInspector.DatabaseQueryView.Events = {
+    SchemaUpdated: "SchemaUpdated"
+}
+
 WebInspector.DatabaseQueryView.prototype = {
     show: function(parentElement)
     {
@@ -139,7 +147,7 @@ WebInspector.DatabaseQueryView.prototype = {
 
     _queryFinished: function(query, columnNames, values)
     {
-        var dataGrid = WebInspector.panels.resources.dataGridForResult(columnNames, values);
+        var dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, values);
         var trimmedQuery = query.trim();
 
         if (dataGrid) {
@@ -149,7 +157,7 @@ WebInspector.DatabaseQueryView.prototype = {
         }
 
         if (trimmedQuery.match(/^create /i) || trimmedQuery.match(/^drop table /i))
-            WebInspector.panels.resources.updateDatabaseTables(this.database);
+            this.dispatchEventToListeners(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this.database);
     },
 
     _queryError: function(query, error)
@@ -164,6 +172,9 @@ WebInspector.DatabaseQueryView.prototype = {
         this._appendQueryResult(query, message, "error");
     },
 
+    /**
+     * @param {string=} resultClassName
+     */
     _appendQueryResult: function(query, result, resultClassName)
     {
         var element = document.createElement("div");
index 843c11a..bad6137 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @constructor
+ * @extends {WebInspector.View}
+ */
 WebInspector.DatabaseTableView = function(database, tableName)
 {
     WebInspector.View.call(this);
@@ -58,7 +62,7 @@ WebInspector.DatabaseTableView.prototype = {
     {
         this.element.removeChildren();
 
-        var dataGrid = WebInspector.panels.resources.dataGridForResult(columnNames, values);
+        var dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, values);
         if (!dataGrid) {
             this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("The ā€œ%sā€\ntable is empty.", this.tableName));
             this._emptyView.show(this.element);
index 2ca9d01..1d2705b 100644 (file)
@@ -138,6 +138,8 @@ WebInspector.ResourcesPanel.prototype = {
         for (var i = 0; i < this._databases.length; ++i) {
             var database = this._databases[i];
             delete database._tableViews;
+            if (database._queryView)
+                database._queryView.removeEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
             delete database._queryView;
         }
         this._databases = [];
@@ -432,6 +434,7 @@ WebInspector.ResourcesPanel.prototype = {
             if (!view) {
                 view = new WebInspector.DatabaseQueryView(database);
                 database._queryView = view;
+                view.addEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
             }
         }
 
@@ -509,8 +512,10 @@ WebInspector.ResourcesPanel.prototype = {
         delete this.visibleView;
     },
 
-    updateDatabaseTables: function(database)
+    _updateDatabaseTables: function(event)
     {
+        var database = event.data;
+
         if (!database || !database._databasesTreeElement)
             return;
 
@@ -538,78 +543,6 @@ WebInspector.ResourcesPanel.prototype = {
         database.getTableNames(tableNamesCallback);
     },
 
-    dataGridForResult: function(columnNames, values)
-    {
-        var numColumns = columnNames.length;
-        if (!numColumns)
-            return null;
-
-        var columns = {};
-
-        for (var i = 0; i < columnNames.length; ++i) {
-            var column = {};
-            column.width = columnNames[i].length;
-            column.title = columnNames[i];
-            column.sortable = true;
-
-            columns[columnNames[i]] = column;
-        }
-
-        var nodes = [];
-        for (var i = 0; i < values.length / numColumns; ++i) {
-            var data = {};
-            for (var j = 0; j < columnNames.length; ++j)
-                data[columnNames[j]] = values[numColumns * i + j];
-
-            var node = new WebInspector.DataGridNode(data, false);
-            node.selectable = false;
-            nodes.push(node);
-        }
-
-        var dataGrid = new WebInspector.DataGrid(columns);
-        var length = nodes.length;
-        for (var i = 0; i < length; ++i)
-            dataGrid.appendChild(nodes[i]);
-
-        dataGrid.addEventListener("sorting changed", this._sortDataGrid.bind(this, dataGrid), this);
-        return dataGrid;
-    },
-
-    _sortDataGrid: function(dataGrid)
-    {
-        var nodes = dataGrid.children.slice();
-        var sortColumnIdentifier = dataGrid.sortColumnIdentifier;
-        var sortDirection = dataGrid.sortOrder === "ascending" ? 1 : -1;
-        var columnIsNumeric = true;
-
-        for (var i = 0; i < nodes.length; i++) {
-            if (isNaN(Number(nodes[i].data[sortColumnIdentifier])))
-                columnIsNumeric = false;
-        }
-
-        function comparator(dataGridNode1, dataGridNode2)
-        {
-            var item1 = dataGridNode1.data[sortColumnIdentifier];
-            var item2 = dataGridNode2.data[sortColumnIdentifier];
-
-            var comparison;
-            if (columnIsNumeric) {
-                // Sort numbers based on comparing their values rather than a lexicographical comparison.
-                var number1 = parseFloat(item1);
-                var number2 = parseFloat(item2);
-                comparison = number1 < number2 ? -1 : (number1 > number2 ? 1 : 0);
-            } else
-                comparison = item1 < item2 ? -1 : (item1 > item2 ? 1 : 0);
-
-            return sortDirection * comparison;
-        }
-
-        nodes.sort(comparator);
-        dataGrid.removeChildren();
-        for (var i = 0; i < nodes.length; i++)
-            dataGrid.appendChild(nodes[i]);
-    },
-
     updateDOMStorage: function(storageId)
     {
         var domStorage = this._domStorageForId(storageId);
index abc031b..fd0dbb0 100644 (file)
@@ -151,6 +151,9 @@ WebInspector.TextPrompt.prototype = {
         return true;
     },
 
+    /**
+     * @param {boolean=} includeTimeout
+     */
     clearAutoComplete: function(includeTimeout)
     {
         if (includeTimeout && "_completeTimeout" in this) {