[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8
pfeldman at chromium.org
pfeldman at chromium.org
Wed Feb 10 22:16:53 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 2f11c621e860e86336a172d49b19486f907a025e
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Feb 5 19:22:43 2010 +0000
2010-02-04 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: group cookies by frame, show total
cookies size, allow sorting cookie table.
https://bugs.webkit.org/show_bug.cgi?id=34617
* English.lproj/localizedStrings.js:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::deleteCookie):
* inspector/front-end/CookieItemsView.js:
(WebInspector.CookieItemsView):
(WebInspector.CookieItemsView.prototype.update):
(WebInspector.CookieItemsView.prototype._updateWithCookies):
(WebInspector.CookieItemsView.prototype._cookiesForDomain):
(WebInspector.CookieItemsView.prototype.dataGridForCookies):
(WebInspector.CookieItemsView.prototype._createNodes):
(WebInspector.CookieItemsView.prototype._sortData.localeCompare):
(WebInspector.CookieItemsView.prototype._sortData.numberCompare):
(WebInspector.CookieItemsView.prototype._sortData.expiresCompare):
(WebInspector.CookieItemsView.prototype._sortData):
* inspector/front-end/StoragePanel.js:
(WebInspector.StoragePanel.prototype.showCookies):
(WebInspector.CookieSidebarTreeElement):
(WebInspector.CookieSidebarTreeElement.prototype.onselect):
(WebInspector.CookieSidebarTreeElement.prototype.get subtitle):
(WebInspector.CookieSidebarTreeElement.prototype.set subtitle):
* inspector/front-end/inspector.js:
(WebInspector.updateResource):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index baa5c71..aef45c3 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-02-04 Pavel Feldman <pfeldman at chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ Web Inspector: group cookies by frame, show total
+ cookies size, allow sorting cookie table.
+
+ https://bugs.webkit.org/show_bug.cgi?id=34617
+
+ * English.lproj/localizedStrings.js:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::deleteCookie):
+ * inspector/front-end/CookieItemsView.js:
+ (WebInspector.CookieItemsView):
+ (WebInspector.CookieItemsView.prototype.update):
+ (WebInspector.CookieItemsView.prototype._updateWithCookies):
+ (WebInspector.CookieItemsView.prototype._cookiesForDomain):
+ (WebInspector.CookieItemsView.prototype.dataGridForCookies):
+ (WebInspector.CookieItemsView.prototype._createNodes):
+ (WebInspector.CookieItemsView.prototype._sortData.localeCompare):
+ (WebInspector.CookieItemsView.prototype._sortData.numberCompare):
+ (WebInspector.CookieItemsView.prototype._sortData.expiresCompare):
+ (WebInspector.CookieItemsView.prototype._sortData):
+ * inspector/front-end/StoragePanel.js:
+ (WebInspector.StoragePanel.prototype.showCookies):
+ (WebInspector.CookieSidebarTreeElement):
+ (WebInspector.CookieSidebarTreeElement.prototype.onselect):
+ (WebInspector.CookieSidebarTreeElement.prototype.get subtitle):
+ (WebInspector.CookieSidebarTreeElement.prototype.set subtitle):
+ * inspector/front-end/inspector.js:
+ (WebInspector.updateResource):
+
2010-02-05 Maxime Simone <simon.maxime at gmail.com>
Reviewed by David Levin.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 637d4a6..9196692 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index 369450e..351c771 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -1802,7 +1802,7 @@ void InspectorController::deleteCookie(const String& cookieName, const String& d
for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) {
Document* document = it->second->frame()->document();
if (document->url().host() == domain)
- WebCore::deleteCookie(document, document->cookieURL(), cookieName);
+ WebCore::deleteCookie(document, it->second->requestURL(), cookieName);
}
}
diff --git a/WebCore/inspector/front-end/CookieItemsView.js b/WebCore/inspector/front-end/CookieItemsView.js
index e4d6018..3af9c2e 100644
--- a/WebCore/inspector/front-end/CookieItemsView.js
+++ b/WebCore/inspector/front-end/CookieItemsView.js
@@ -27,7 +27,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-WebInspector.CookieItemsView = function(cookieDomain)
+WebInspector.CookieItemsView = function(treeElement, cookieDomain)
{
WebInspector.View.call(this);
@@ -41,6 +41,7 @@ WebInspector.CookieItemsView = function(cookieDomain)
this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
+ this._treeElement = treeElement;
this._cookieDomain = cookieDomain;
}
@@ -65,51 +66,61 @@ WebInspector.CookieItemsView.prototype = {
update: function()
{
this.element.removeChildren();
+ WebInspector.Cookies.getCookiesAsync(this._updateWithCookies.bind(this));
+ },
- var self = this;
- function callback(allCookies, isAdvanced) {
- var cookies = self._cookiesForDomain(allCookies);
- var dataGrid = (isAdvanced ? self.dataGridForCookies(cookies) : self.simpleDataGridForCookies(cookies));
- if (dataGrid) {
- self._dataGrid = dataGrid;
- self.element.appendChild(dataGrid.element);
- self._dataGrid.updateWidths();
- if (isAdvanced)
- self.deleteButton.visible = true;
- } else {
- var emptyMsgElement = document.createElement("div");
- emptyMsgElement.className = "storage-table-empty";
- emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies.");
- self.element.appendChild(emptyMsgElement);
- self._dataGrid = null;
- self.deleteButton.visible = false;
- }
+ _updateWithCookies: function(allCookies, isAdvanced)
+ {
+ var cookies = this._cookiesForDomain(allCookies, isAdvanced);
+ var dataGrid = (isAdvanced ? this.dataGridForCookies(cookies) : this.simpleDataGridForCookies(cookies));
+ if (dataGrid) {
+ this._dataGrid = dataGrid;
+ this.element.appendChild(dataGrid.element);
+ this._dataGrid.updateWidths();
+ if (isAdvanced)
+ this.deleteButton.visible = true;
+ } else {
+ var emptyMsgElement = document.createElement("div");
+ emptyMsgElement.className = "storage-table-empty";
+ emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies.");
+ this.element.appendChild(emptyMsgElement);
+ this._dataGrid = null;
+ this.deleteButton.visible = false;
}
-
- WebInspector.Cookies.getCookiesAsync(callback);
},
- _cookiesForDomain: function(allCookies)
+ _cookiesForDomain: function(allCookies, isAdvanced)
{
var cookiesForDomain = [];
var resourceURLsForDocumentURL = [];
+ var totalSize = 0;
for (var id in WebInspector.resources) {
var resource = WebInspector.resources[id];
- var match = resource.url.match(WebInspector.URLRegExp);
+ var match = resource.documentURL.match(WebInspector.URLRegExp);
if (match && match[2] === this._cookieDomain)
resourceURLsForDocumentURL.push(resource.url);
}
for (var i = 0; i < allCookies.length; ++i) {
+ var pushed = false;
+ var size = allCookies[i].size;
for (var j = 0; j < resourceURLsForDocumentURL.length; ++j) {
var resourceURL = resourceURLsForDocumentURL[j];
if (WebInspector.Cookies.cookieMatchesResourceURL(allCookies[i], resourceURL)) {
- cookiesForDomain.push(allCookies[i]);
- break;
+ totalSize += size;
+ if (!pushed) {
+ pushed = true;
+ cookiesForDomain.push(allCookies[i]);
+ }
}
}
}
+
+ if (isAdvanced) {
+ this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), cookiesForDomain.length,
+ Number.bytesToString(totalSize, WebInspector.UIString));
+ }
return cookiesForDomain;
},
@@ -124,50 +135,31 @@ WebInspector.CookieItemsView.prototype = {
var columns = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {} };
columns[0].title = WebInspector.UIString("Name");
columns[0].width = columns[0].title.length;
+ columns[0].sortable = true;
columns[1].title = WebInspector.UIString("Value");
columns[1].width = columns[1].title.length;
+ columns[1].sortable = true;
columns[2].title = WebInspector.UIString("Domain");
columns[2].width = columns[2].title.length;
+ columns[2].sortable = true;
columns[3].title = WebInspector.UIString("Path");
columns[3].width = columns[3].title.length;
+ columns[3].sortable = true;
columns[4].title = WebInspector.UIString("Expires");
columns[4].width = columns[4].title.length;
+ columns[4].sortable = true;
columns[5].title = WebInspector.UIString("Size");
columns[5].width = columns[5].title.length;
columns[5].aligned = "right";
+ columns[5].sortable = true;
columns[6].title = WebInspector.UIString("HTTP");
columns[6].width = columns[6].title.length;
columns[6].aligned = "centered";
+ columns[6].sortable = true;
columns[7].title = WebInspector.UIString("Secure");
columns[7].width = columns[7].title.length;
columns[7].aligned = "centered";
-
- function updateDataAndColumn(index, value) {
- data[index] = value;
- if (value.length > columns[index].width)
- columns[index].width = value.length;
- }
-
- var data;
- var nodes = [];
- for (var i = 0; i < cookies.length; ++i) {
- var cookie = cookies[i];
- data = {};
-
- updateDataAndColumn(0, cookie.name);
- updateDataAndColumn(1, cookie.value);
- updateDataAndColumn(2, cookie.domain);
- updateDataAndColumn(3, cookie.path);
- updateDataAndColumn(4, (cookie.session ? WebInspector.UIString("Session") : cookie.expires.toGMTString()));
- updateDataAndColumn(5, Number.bytesToString(cookie.size, WebInspector.UIString));
- updateDataAndColumn(6, (cookie.httpOnly ? "\u2713" : "")); // Checkmark
- updateDataAndColumn(7, (cookie.secure ? "\u2713" : "")); // Checkmark
-
- var node = new WebInspector.DataGridNode(data, false);
- node.cookie = cookie;
- node.selectable = true;
- nodes.push(node);
- }
+ columns[7].sortable = true;
var totalColumnWidths = 0;
for (var columnIdentifier in columns)
@@ -211,15 +203,95 @@ WebInspector.CookieItemsView.prototype = {
columns[columnIdentifier].width += "%";
var dataGrid = new WebInspector.DataGrid(columns, null, this._deleteCookieCallback.bind(this));
- var length = nodes.length;
- for (var i = 0; i < length; ++i)
+ var nodes = this._createNodes(dataGrid, cookies);
+ for (var i = 0; i < nodes.length; ++i)
dataGrid.appendChild(nodes[i]);
- if (length > 0)
+ if (nodes.length)
nodes[0].selected = true;
+ dataGrid.addEventListener("sorting changed", this._sortData.bind(this, dataGrid, cookies));
return dataGrid;
},
+ _createNodes: function(dataGrid, cookies)
+ {
+ function updateDataAndColumn(data, index, value) {
+ data[index] = value;
+ if (value.length > dataGrid.columns[index].width)
+ dataGrid.columns[index].width = value.length;
+ }
+
+ var nodes = [];
+ for (var i = 0; i < cookies.length; ++i) {
+ var data = {};
+ var cookie = cookies[i];
+
+ updateDataAndColumn(data, 0, cookie.name);
+ updateDataAndColumn(data, 1, cookie.value);
+ updateDataAndColumn(data, 2, cookie.domain);
+ updateDataAndColumn(data, 3, cookie.path);
+ updateDataAndColumn(data, 4, (cookie.session ? WebInspector.UIString("Session") : cookie.expires.toGMTString()));
+ updateDataAndColumn(data, 5, Number.bytesToString(cookie.size, WebInspector.UIString));
+ updateDataAndColumn(data, 6, (cookie.httpOnly ? "\u2713" : "")); // Checkmark
+ updateDataAndColumn(data, 7, (cookie.secure ? "\u2713" : "")); // Checkmark
+
+ var node = new WebInspector.DataGridNode(data);
+ node.cookie = cookie;
+ node.selectable = true;
+ nodes.push(node);
+ }
+ return nodes;
+ },
+
+ _sortData: function(dataGrid, cookies)
+ {
+ var sortDirection = dataGrid.sortOrder === "ascending" ? 1 : -1;
+
+ function localeCompare(field, cookie1, cookie2)
+ {
+ return sortDirection * (cookie1[field] + "").localeCompare(cookie2[field] + "")
+ }
+
+ function numberCompare(field, cookie1, cookie2)
+ {
+ return sortDirection * (cookie1[field] - cookie2[field]);
+ }
+
+ function expiresCompare(cookie1, cookie2)
+ {
+ if (cookie1.session !== cookie2.session)
+ return sortDirection * (cookie1.session ? 1 : -1);
+
+ if (cookie1.session)
+ return 0;
+
+ return sortDirection * (cookie1.expires.getTime() - cookie2.expires.getTime());
+ }
+
+ var comparator;
+ switch (parseInt(dataGrid.sortColumnIdentifier)) {
+ case 0: comparator = localeCompare.bind(this, "name"); break;
+ case 1: comparator = localeCompare.bind(this, "value"); break;
+ case 2: comparator = localeCompare.bind(this, "domain"); break;
+ case 3: comparator = localeCompare.bind(this, "path"); break;
+ case 4: comparator = expiresCompare; break;
+ case 5: comparator = numberCompare.bind(this, "size"); break;
+ case 6: comparator = localeCompare.bind(this, "httpOnly"); break;
+ case 7: comparator = localeCompare.bind(this, "secure"); break;
+ default: localeCompare.bind(this, "name");
+ }
+
+ cookies.sort(comparator);
+ var nodes = this._createNodes(dataGrid, cookies);
+
+ dataGrid.removeChildren();
+ for (var i = 0; i < nodes.length; ++i)
+ dataGrid.appendChild(nodes[i]);
+
+ if (nodes.length)
+ nodes[0].selected = true;
+ },
+
simpleDataGridForCookies: function(cookies)
{
if (!cookies.length)
diff --git a/WebCore/inspector/front-end/StoragePanel.js b/WebCore/inspector/front-end/StoragePanel.js
index dee4442..18bc98f 100644
--- a/WebCore/inspector/front-end/StoragePanel.js
+++ b/WebCore/inspector/front-end/StoragePanel.js
@@ -220,14 +220,14 @@ WebInspector.StoragePanel.prototype = {
this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]);
},
- showCookies: function(cookieDomain)
+ showCookies: function(treeElement, cookieDomain)
{
if (this.visibleView)
this.visibleView.hide();
var view = this._cookieViews[cookieDomain];
if (!view) {
- view = new WebInspector.CookieItemsView(cookieDomain);
+ view = new WebInspector.CookieItemsView(treeElement, cookieDomain);
this._cookieViews[cookieDomain] = view;
}
@@ -507,6 +507,7 @@ WebInspector.CookieSidebarTreeElement = function(cookieDomain)
{
WebInspector.SidebarTreeElement.call(this, "cookie-sidebar-tree-item", cookieDomain, "", null, false);
this._cookieDomain = cookieDomain;
+ this._subtitle = "";
this.refreshTitles();
}
@@ -514,9 +515,9 @@ WebInspector.CookieSidebarTreeElement = function(cookieDomain)
WebInspector.CookieSidebarTreeElement.prototype = {
onselect: function()
{
- WebInspector.panels.storage.showCookies(this._cookieDomain);
+ WebInspector.panels.storage.showCookies(this, this._cookieDomain);
},
-
+
get mainTitle()
{
return this._cookieDomain ? this._cookieDomain : WebInspector.UIString("Local Files");
@@ -529,12 +530,13 @@ WebInspector.CookieSidebarTreeElement.prototype = {
get subtitle()
{
- return "";
+ return this._subtitle;
},
set subtitle(x)
{
- // Do nothing.
+ this._subtitle = x;
+ this.refreshTitles();
}
}
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 7604b87..e44ee3c 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -1046,7 +1046,12 @@ WebInspector.updateResource = function(identifier, payload)
if (resource.mainResource)
this.mainResource = resource;
- this._addCookieDomain(resource.domain);
+ var match = payload.documentURL.match(WebInspector.URLRegExp);
+ if (match) {
+ var protocol = match[1].toLowerCase();
+ if (protocol.indexOf("http") === 0 || protocol === "file")
+ this._addCookieDomain(protocol === "file" ? "" : match[2]);
+ }
}
if (payload.didResponseChange) {
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list