https://bugs.webkit.org/show_bug.cgi?id=109141
Patch by Eugene Klyuchnikov <eustas@chromium.org> on 2013-02-11
Reviewed by Vsevolod Vlasov.
1) Make deleteCookie method static and move to WebInspector.Cookie
2) Replace resfreshCallback getter/setter in DataGrid with
constructor parameter
* inspector/front-end/CookieItemsView.js: Adopt changes.
* inspector/front-end/CookieParser.js:
(WebInspector.Cookie.prototype.remove): Moved from CookiesTable.
* inspector/front-end/CookiesTable.js: Adopt changes.
* inspector/front-end/DataGrid.js:
Replace setter with constructor parameter.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142441
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-02-11 Eugene Klyuchnikov <eustas@chromium.org>
+
+ Web Inspector: [Resources] Prefactorings in DataGrid and CookieTable
+ https://bugs.webkit.org/show_bug.cgi?id=109141
+
+ Reviewed by Vsevolod Vlasov.
+
+ 1) Make deleteCookie method static and move to WebInspector.Cookie
+ 2) Replace resfreshCallback getter/setter in DataGrid with
+ constructor parameter
+
+ * inspector/front-end/CookieItemsView.js: Adopt changes.
+ * inspector/front-end/CookieParser.js:
+ (WebInspector.Cookie.prototype.remove): Moved from CookiesTable.
+ * inspector/front-end/CookiesTable.js: Adopt changes.
+ * inspector/front-end/DataGrid.js:
+ Replace setter with constructor parameter.
+
2013-02-11 John J. Barton <johnjbarton@chromium.org>
Web Inspector: Don't throw exceptions in WebInspector.Color
}
if (!this._cookiesTable)
- this._cookiesTable = isAdvanced ? new WebInspector.CookiesTable(false, this._deleteCookie.bind(this), this._update.bind(this)) : new WebInspector.SimpleCookiesTable();
+ this._cookiesTable = isAdvanced ? new WebInspector.CookiesTable(false, this._update.bind(this)) : new WebInspector.SimpleCookiesTable();
this._cookiesTable.setCookies(this._cookies);
this._emptyView.detach();
return cookies;
},
- /**
- * @param {!WebInspector.Cookie} cookie
- */
- _deleteCookie: function(cookie)
- {
- PageAgent.deleteCookie(cookie.name(), (cookie.secure() ? "https://" : "http://") + cookie.domain() + cookie.path());
- this._update();
- },
-
_deleteButtonClicked: function()
{
var selectedCookie = this._cookiesTable.selectedCookie();
- if (selectedCookie)
- this._deleteCookie(selectedCookie);
+ if (selectedCookie) {
+ selectedCookie.remove();
+ this._update();
+ }
},
_refreshButtonClicked: function(event)
addAttribute: function(key, value)
{
this._attributes[key.toLowerCase()] = value;
+ },
+
+ /**
+ * @param {function(?Protocol.Error)=} callback
+ */
+ remove: function(callback)
+ {
+ PageAgent.deleteCookie(this.name(), (this.secure() ? "https://" : "http://") + this.domain() + this.path(), callback);
}
}
* @constructor
* @extends {WebInspector.View}
* @param {boolean} expandable
- * @param {function(!WebInspector.Cookie)=} deleteCallback
* @param {function()=} refreshCallback
*/
-WebInspector.CookiesTable = function(expandable, deleteCallback, refreshCallback)
+WebInspector.CookiesTable = function(expandable, refreshCallback)
{
WebInspector.View.call(this);
this.element.className = "fill";
+ var readOnly = expandable;
+ this._refreshCallback = refreshCallback;
+
var columns = {name: {}, value: {}, domain: {}, path: {}, expires: {}, size: {}, httpOnly: {}, secure: {}};
columns.name.title = WebInspector.UIString("Name");
columns.name.sortable = true;
columns.secure.sortable = true;
columns.secure.width = "7%";
- this._dataGrid = new WebInspector.DataGrid(columns, undefined, deleteCallback ? this._onDeleteFromGrid.bind(this, deleteCallback) : undefined);
+ this._dataGrid = new WebInspector.DataGrid(columns, null, readOnly ? null : this._onDeleteCookie.bind(this), refreshCallback);
this._dataGrid.addEventListener("sorting changed", this._rebuildTable, this);
- this._dataGrid.refreshCallback = refreshCallback;
this._nextSelectedCookie = /** @type {?WebInspector.Cookie} */ (null);
return node;
},
- _onDeleteFromGrid: function(deleteCallback, node)
+ _onDeleteCookie: function(node)
{
var cookie = node.cookie;
var neighbour = node.traverseNextNode() || node.traversePreviousNode();
if (neighbour)
this._nextSelectedCookie = neighbour.cookie;
- deleteCallback(cookie);
+ cookie.remove();
+ if (this._refreshCallback)
+ this._refreshCallback();
},
__proto__: WebInspector.View.prototype
/**
* @constructor
* @extends {WebInspector.View}
- * @param {function(WebInspector.DataGridNode, string, string, string)=} editCallback
- * @param {function(WebInspector.DataGridNode)=} deleteCallback
+ * @param {?function(WebInspector.DataGridNode, string, string, string)=} editCallback
+ * @param {?function(WebInspector.DataGridNode)=} deleteCallback
+ * @param {?function()=} refreshCallback
*/
-WebInspector.DataGrid = function(columns, editCallback, deleteCallback)
+WebInspector.DataGrid = function(columns, editCallback, deleteCallback, refreshCallback)
{
WebInspector.View.call(this);
this.registerRequiredCSS("dataGrid.css");
// FIXME: Add a createCallback which is different from editCallback and has different
// behavior when creating a new node.
- if (editCallback) {
+ if (editCallback)
this._dataTable.addEventListener("dblclick", this._ondblclick.bind(this), false);
- this._editCallback = editCallback;
- }
- if (deleteCallback)
- this._deleteCallback = deleteCallback;
+ this._editCallback = editCallback;
+ this._deleteCallback = deleteCallback;
+ this._refreshCallback = refreshCallback;
this.aligned = {};
return this._rootNode;
},
- get refreshCallback()
- {
- return this._refreshCallback;
- },
-
- set refreshCallback(refreshCallback)
- {
- this._refreshCallback = refreshCallback;
- },
-
_ondblclick: function(event)
{
if (this._editing || this._editingNode)