Changeset 70529 in webkit
- Timestamp:
- Oct 26, 2010 9:24:43 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70525 r70529 1 2010-10-25 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Show cookie data in the request headers in network pane 6 https://bugs.webkit.org/show_bug.cgi?id=16531 7 8 * inspector/front-end/CookieItemsView.js: 9 (WebInspector.CookieItemsView): Factor out common cookies grid logic to CookiesTable 10 (WebInspector.CookieItemsView.prototype._populateDataGrid): 11 * inspector/front-end/CookieParser.js: Store cookie type (request/response) within a cookie. 12 (WebInspector.CookieParser.prototype.parseCookie): 13 (WebInspector.CookieParser.prototype.parseSetCookie): 14 (WebInspector.CookieParser.prototype._addCookie): 15 (WebInspector.Cookie): 16 * inspector/front-end/DataGrid.js: 17 (WebInspector.DataGrid.prototype.autoSizeColumns): Optionally, traverse nested nodes when looking for max field widths. 18 (WebInspector.DataGrid.prototype._enumerateChildren): 19 (WebInspector.DataGrid.prototype.updateWidths): Skip attempt to calculate column widths if grid is not attached to DOM tree yet. 20 * inspector/front-end/FontView.js: 21 (WebInspector.FontView.prototype.resize): 22 * inspector/front-end/ResourceView.js: 23 (WebInspector.ResourceView.prototype.resize): 24 (WebInspector.ResourceView.prototype._selectTab): 25 (WebInspector.ResourceView.prototype._selectCookiesTab): 26 (WebInspector.ResourceView.prototype._innerSelectContentTab): 27 (WebInspector.ResourceView.prototype._refreshRequestHeaders): 28 (WebInspector.ResourceView.prototype._refreshResponseHeaders): 29 (WebInspector.ResourceView.prototype._refreshHeaders): 30 (WebInspector.ResourceView.prototype._refreshCookies): 31 (WebInspector.ResourceCookiesTab): 32 (WebInspector.ResourceCookiesTab.prototype.set requestCookies): 33 (WebInspector.ResourceCookiesTab.prototype.set responseCookies): 34 (WebInspector.ResourceCookiesTab.prototype._populateDataGrid): 35 (WebInspector.ResourceCookiesTab.prototype._populateCookies): 36 (WebInspector.ResourceCookiesTab.prototype._createFolder): 37 * inspector/front-end/SourceView.js: 38 (WebInspector.SourceView.prototype.resize): 39 * inspector/front-end/inspector.css: 40 (.resource-view .resource-view-cookies): 41 (.resource-view.headers-visible .resource-view-cookies): 42 (.resource-view-cookies.table .data-grid): 43 (.resource-view-cookies .data-grid .row-group): 44 1 45 2010-10-26 Sheriff Bot <webkit.review.bot@gmail.com> 2 46 -
trunk/WebCore/inspector/front-end/CookieItemsView.js
r70525 r70529 28 28 */ 29 29 30 WebInspector.CookiesTable = function() 31 { 32 WebInspector.View.call(this); 33 34 this.element.addStyleClass("table"); 35 } 36 37 WebInspector.CookiesTable.prototype = { 38 resize: function() 39 { 40 if (!this._dataGrid) 41 return; 42 43 if (this._autoSizingDone) 44 this._dataGrid.updateWidths(); 45 else { 46 this._autoSizingDone = true; 47 this._dataGrid.autoSizeColumns(4, 45, 1); 48 } 49 }, 50 51 _createDataGrid: function(expandable) 52 { 53 var columns = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {} }; 54 columns[0].title = WebInspector.UIString("Name"); 55 columns[0].sortable = true; 56 columns[0].disclosure = expandable; 57 columns[1].title = WebInspector.UIString("Value"); 58 columns[1].sortable = true; 59 columns[2].title = WebInspector.UIString("Domain"); 60 columns[2].sortable = true; 61 columns[3].title = WebInspector.UIString("Path"); 62 columns[3].sortable = true; 63 columns[4].title = WebInspector.UIString("Expires"); 64 columns[4].sortable = true; 65 columns[5].title = WebInspector.UIString("Size"); 66 columns[5].aligned = "right"; 67 columns[5].sortable = true; 68 columns[6].title = WebInspector.UIString("HTTP"); 69 columns[6].aligned = "centered"; 70 columns[6].sortable = true; 71 columns[7].title = WebInspector.UIString("Secure"); 72 columns[7].aligned = "centered"; 73 columns[7].sortable = true; 74 75 var deleteCallback = this._deleteCookieCallback ? this._deleteCookieCallback.bind(this) : null; 76 this._dataGrid = new WebInspector.DataGrid(columns, null, deleteCallback); 77 this._dataGrid.addEventListener("sorting changed", this._populateDataGrid, this); 78 this.element.appendChild(this._dataGrid.element); 79 }, 80 81 _populateCookies: function(parentNode, cookies) 82 { 83 var selectedCookie = this._dataGrid.selectedNode ? this._dataGrid.selectedNode.cookie : null; 84 parentNode.removeChildren(); 85 if (!cookies) 86 return; 87 this._sortCookies(cookies); 88 var totalSize = 0; 89 for (var i = 0; i < cookies.length; ++i) { 90 var cookieNode = this._createGridNode(cookies[i]); 91 parentNode.appendChild(cookieNode); 92 if (selectedCookie === cookies[i]) 93 cookieNode.selected = true; 94 } 95 }, 96 97 _sortCookies: function(cookies) 98 { 99 var sortDirection = this._dataGrid.sortOrder === "ascending" ? 1 : -1; 100 101 function localeCompare(field, cookie1, cookie2) 102 { 103 return sortDirection * (cookie1[field] + "").localeCompare(cookie2[field] + "") 104 } 105 106 function numberCompare(field, cookie1, cookie2) 107 { 108 return sortDirection * (cookie1[field] - cookie2[field]); 109 } 110 111 function expiresCompare(cookie1, cookie2) 112 { 113 if (cookie1.session !== cookie2.session) 114 return sortDirection * (cookie1.session ? 1 : -1); 115 116 if (cookie1.session) 117 return 0; 118 119 return sortDirection * (cookie1.expires - cookie2.expires); 120 } 121 122 var comparator; 123 switch (parseInt(this._dataGrid.sortColumnIdentifier)) { 124 case 0: comparator = localeCompare.bind(this, "name"); break; 125 case 1: comparator = localeCompare.bind(this, "value"); break; 126 case 2: comparator = localeCompare.bind(this, "domain"); break; 127 case 3: comparator = localeCompare.bind(this, "path"); break; 128 case 4: comparator = expiresCompare; break; 129 case 5: comparator = numberCompare.bind(this, "size"); break; 130 case 6: comparator = localeCompare.bind(this, "httpOnly"); break; 131 case 7: comparator = localeCompare.bind(this, "secure"); break; 132 default: localeCompare.bind(this, "name"); 133 } 134 135 cookies.sort(comparator); 136 }, 137 138 _createGridNode: function(cookie) 139 { 140 var data = {}; 141 data[0] = cookie.name; 142 data[1] = cookie.value; 143 data[2] = cookie.domain || ""; 144 data[3] = cookie.path || ""; 145 data[4] = cookie.type === WebInspector.Cookie.Type.Request ? "" : 146 (cookie.session ? WebInspector.UIString("Session") : new Date(cookie.expires).toGMTString()); 147 data[5] = cookie.size; 148 data[6] = (cookie.httpOnly ? "\u2713" : ""); // Checkmark 149 data[7] = (cookie.secure ? "\u2713" : ""); // Checkmark 150 151 var node = new WebInspector.DataGridNode(data); 152 node.cookie = cookie; 153 node.selectable = true; 154 return node; 155 } 156 }; 157 158 WebInspector.CookiesTable.prototype.__proto__ = WebInspector.View.prototype; 159 30 160 WebInspector.CookieItemsView = function(treeElement, cookieDomain) 31 161 { 32 WebInspector. View.call(this);162 WebInspector.CookiesTable.call(this); 33 163 34 164 this.element.addStyleClass("storage-view"); 35 this.element.addStyleClass("table");36 165 37 166 this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString("Delete"), "delete-storage-status-bar-item"); … … 144 273 }, 145 274 146 _createDataGrid: function()147 {148 var columns = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {} };149 columns[0].title = WebInspector.UIString("Name");150 columns[0].sortable = true;151 columns[1].title = WebInspector.UIString("Value");152 columns[1].sortable = true;153 columns[2].title = WebInspector.UIString("Domain");154 columns[2].sortable = true;155 columns[3].title = WebInspector.UIString("Path");156 columns[3].sortable = true;157 columns[4].title = WebInspector.UIString("Expires");158 columns[4].sortable = true;159 columns[5].title = WebInspector.UIString("Size");160 columns[5].aligned = "right";161 columns[5].sortable = true;162 columns[6].title = WebInspector.UIString("HTTP");163 columns[6].aligned = "centered";164 columns[6].sortable = true;165 columns[7].title = WebInspector.UIString("Secure");166 columns[7].aligned = "centered";167 columns[7].sortable = true;168 169 this._dataGrid = new WebInspector.DataGrid(columns, null, this._deleteCookieCallback.bind(this));170 this._dataGrid.addEventListener("sorting changed", this._populateDataGrid, this);171 this.element.appendChild(this._dataGrid.element);172 this._dataGrid.updateWidths();173 },174 175 275 _populateDataGrid: function() 176 276 { 177 var selectedCookie = this._dataGrid.selectedNode ? this._dataGrid.selectedNode.cookie : null; 178 var sortDirection = this._dataGrid.sortOrder === "ascending" ? 1 : -1; 179 180 function localeCompare(field, cookie1, cookie2) 181 { 182 return sortDirection * (cookie1[field] + "").localeCompare(cookie2[field] + "") 183 } 184 185 function numberCompare(field, cookie1, cookie2) 186 { 187 return sortDirection * (cookie1[field] - cookie2[field]); 188 } 189 190 function expiresCompare(cookie1, cookie2) 191 { 192 if (cookie1.session !== cookie2.session) 193 return sortDirection * (cookie1.session ? 1 : -1); 194 195 if (cookie1.session) 196 return 0; 197 198 return sortDirection * (cookie1.expires - cookie2.expires); 199 } 200 201 var comparator; 202 switch (parseInt(this._dataGrid.sortColumnIdentifier)) { 203 case 0: comparator = localeCompare.bind(this, "name"); break; 204 case 1: comparator = localeCompare.bind(this, "value"); break; 205 case 2: comparator = localeCompare.bind(this, "domain"); break; 206 case 3: comparator = localeCompare.bind(this, "path"); break; 207 case 4: comparator = expiresCompare; break; 208 case 5: comparator = numberCompare.bind(this, "size"); break; 209 case 6: comparator = localeCompare.bind(this, "httpOnly"); break; 210 case 7: comparator = localeCompare.bind(this, "secure"); break; 211 default: localeCompare.bind(this, "name"); 212 } 213 214 this._cookies.sort(comparator); 215 216 this._dataGrid.removeChildren(); 217 var nodeToSelect; 218 for (var i = 0; i < this._cookies.length; ++i) { 219 var data = {}; 220 var cookie = this._cookies[i]; 221 data[0] = cookie.name; 222 data[1] = cookie.value; 223 data[2] = cookie.domain; 224 data[3] = cookie.path; 225 data[4] = (cookie.session ? WebInspector.UIString("Session") : new Date(cookie.expires).toGMTString()); 226 data[5] = Number.bytesToString(cookie.size, WebInspector.UIString); 227 data[6] = (cookie.httpOnly ? "\u2713" : ""); // Checkmark 228 data[7] = (cookie.secure ? "\u2713" : ""); // Checkmark 229 230 var node = new WebInspector.DataGridNode(data); 231 node.cookie = cookie; 232 node.selectable = true; 233 this._dataGrid.appendChild(node); 234 if (cookie === selectedCookie) 235 nodeToSelect = node; 236 } 237 if (nodeToSelect) 238 nodeToSelect.selected = true; 239 else 240 this._dataGrid.children[0].selected = true; 277 this._populateCookies(this._dataGrid, this._cookies); 241 278 }, 242 279 … … 274 311 }, 275 312 276 resize: function()277 {278 if (this._dataGrid)279 this._dataGrid.updateWidths();280 },281 282 313 _deleteButtonClicked: function(event) 283 314 { … … 301 332 } 302 333 303 WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.View.prototype; 334 WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.CookiesTable.prototype; 335 -
trunk/WebCore/inspector/front-end/CookieParser.js
r70137 r70529 55 55 this._lastCookie.addAttribute(kv.key.slice(1), kv.value); 56 56 else if (kv.key.toLowerCase() !== "$version" && typeof kv.value === "string") 57 this._addCookie(kv );57 this._addCookie(kv, WebInspector.Cookie.Type.Request); 58 58 this._advanceAndCheckCookieDelimiter(); 59 59 } … … 70 70 this._lastCookie.addAttribute(kv.key, kv.value); 71 71 else 72 this._addCookie(kv );72 this._addCookie(kv, WebInspector.Cookie.Type.Response); 73 73 if (this._advanceAndCheckCookieDelimiter()) 74 74 this._flushCookie(); … … 129 129 }, 130 130 131 _addCookie: function(keyValue )131 _addCookie: function(keyValue, type) 132 132 { 133 133 if (this._lastCookie) 134 134 this._lastCookie.size = keyValue.position - this._lastCookiePosition; 135 // Mozilla bug 169091: Mozilla, IE and Chrome treat si gnle token (w/o "=") as135 // Mozilla bug 169091: Mozilla, IE and Chrome treat single token (w/o "=") as 136 136 // specifying a value for a cookie with empty name. 137 this._lastCookie = keyValue.value ? new WebInspector.Cookie(keyValue.key, keyValue.value ) :138 new WebInspector.Cookie("", keyValue.key );137 this._lastCookie = keyValue.value ? new WebInspector.Cookie(keyValue.key, keyValue.value, type) : 138 new WebInspector.Cookie("", keyValue.key, type); 139 139 this._lastCookiePosition = keyValue.position; 140 140 this._cookies.push(this._lastCookie); … … 152 152 } 153 153 154 WebInspector.Cookie = function(name, value )154 WebInspector.Cookie = function(name, value, type) 155 155 { 156 156 this.name = name; 157 157 this.value = value; 158 this.type = type; 158 159 this._attributes = {}; 159 160 } … … 203 204 } 204 205 } 206 207 WebInspector.Cookie.Type = { 208 Request: 0, 209 Response: 1 210 }; -
trunk/WebCore/inspector/front-end/DataGrid.js
r69948 r70529 309 309 }, 310 310 311 autoSizeColumns: function(minPercent, maxPercent )311 autoSizeColumns: function(minPercent, maxPercent, maxDescentLevel) 312 312 { 313 313 if (minPercent) … … 318 318 widths[columnIdentifier] = (columns[columnIdentifier].title || "").length; 319 319 320 for (var i = 0; i < this.children.length; ++i) { 321 var node = this.children[i]; 320 var children = maxDescentLevel ? this._enumerateChildren(this, [], maxDescentLevel + 1) : this.children; 321 for (var i = 0; i < children.length; ++i) { 322 var node = children[i]; 322 323 for (var columnIdentifier in columns) { 323 324 var text = node.data[columnIdentifier] || ""; … … 372 373 }, 373 374 375 _enumerateChildren: function(rootNode, result, maxLevel) 376 { 377 if (!rootNode.root) 378 result.push(rootNode); 379 if (!maxLevel) 380 return; 381 for (var i = 0; i < rootNode.children.length; ++i) 382 this._enumerateChildren(rootNode.children[i], result, maxLevel - 1); 383 return result; 384 }, 385 374 386 // Updates the widths of the table, including the positions of the column 375 387 // resizers. … … 389 401 var numColumns = headerTableColumns.length; 390 402 391 if (!this._columnWidthsInitialized) { 403 // Do not attempt to use offsetes if we're not attached to the document tree yet. 404 if (!this._columnWidthsInitialized && this.element.offsetWidth) { 392 405 // Give all the columns initial widths now so that during a resize, 393 406 // when the two columns that get resized get a percent value for -
trunk/WebCore/inspector/front-end/FontView.js
r58884 r70529 70 70 { 71 71 this.updateFontPreviewSize(); 72 WebInspector.ResourceView.prototype.resize.call(this); 72 73 }, 73 74 -
trunk/WebCore/inspector/front-end/ResourceView.js
r69947 r70529 140 140 }, 141 141 142 resize: function() 143 { 144 if (this._cookiesView && !this._cookiesView.element.hasStyleClass("hidden")) 145 this._cookiesView.resize(); 146 }, 147 142 148 _selectTab: function() 143 149 { 144 if (this._headersVisible) {145 if (!this.hasContentTab() || WebInspector.applicationSettings.resourceViewTab === "headers")146 this._selectHeadersTab();147 else148 this.selectContentTab();149 }else150 var preferredTab = WebInspector.applicationSettings.resourceViewTab; 151 if (this._headersVisible && this._cookiesView && preferredTab === "cookies") 152 this._selectCookiesTab(); 153 else if (this._headersVisible && (!this.hasContentTab() || preferredTab === "headers")) 154 this._selectHeadersTab(); 155 else 150 156 this._innerSelectContentTab(); 151 157 }, … … 171 177 }, 172 178 179 _selectCookiesTab: function(updatePrefs) 180 { 181 if (updatePrefs) 182 WebInspector.applicationSettings.resourceViewTab = "cookies"; 183 this.tabbedPane.selectTabById("cookies"); 184 this._cookiesView.resize(); 185 }, 186 173 187 _innerSelectContentTab: function() 174 188 { 175 189 this.tabbedPane.selectTabById("content"); 176 if ("resize" in this) 177 this.resize(); 190 this.resize(); 178 191 if (this.hasContentTab()) 179 192 this.contentTabSelected(); … … 284 297 this._refreshHeaders(WebInspector.UIString("Request Headers"), this.resource.sortedRequestHeaders, additionalRow, this.requestHeadersTreeElement); 285 298 this._refreshFormData(); 299 this._refreshCookies(); 286 300 }, 287 301 … … 292 306 additionalRow = {header: "(Challenge Response)", value: this.resource.webSocketChallengeResponse}; 293 307 this._refreshHeaders(WebInspector.UIString("Response Headers"), this.resource.sortedResponseHeaders, additionalRow, this.responseHeadersTreeElement); 308 this._refreshCookies(); 294 309 }, 295 310 … … 348 363 headersTreeElement.appendChild(headerTreeElement); 349 364 } 365 }, 366 367 _refreshCookies: function() 368 { 369 if (!this._cookiesView) { 370 if (!this.resource.requestCookies && !this.resource.responseCookies) 371 return; 372 this._cookiesView = new WebInspector.ResourceCookiesTab(); 373 this.tabbedPane.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView.element, this._selectCookiesTab.bind(this, true)); 374 } 375 this._cookiesView.requestCookies = this.resource.requestCookies; 376 this._cookiesView.responseCookies = this.resource.responseCookies; 350 377 } 351 378 } 352 379 353 380 WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype; 381 382 WebInspector.ResourceCookiesTab = function() 383 { 384 WebInspector.CookiesTable.call(this); 385 this.element.addStyleClass("resource-view-cookies"); 386 this._requestCookies = []; 387 this._responseCookies = []; 388 this._createDataGrid(true); 389 this._requestCookiesNode = this._createFolder(WebInspector.UIString("Request Cookies")); 390 this._responseCookiesNode = this._createFolder(WebInspector.UIString("Response Cookies")); 391 } 392 393 WebInspector.ResourceCookiesTab.prototype = { 394 set requestCookies(cookies) 395 { 396 if (this._requestCookies === cookies) 397 return; 398 this._requestCookies = cookies; 399 this._populateCookies(this._requestCookiesNode, this._requestCookies); 400 }, 401 402 set responseCookies(cookies) 403 { 404 if (this._responseCookies === cookies) 405 return; 406 this._responseCookies = cookies; 407 this._populateCookies(this._responseCookiesNode, this._responseCookies); 408 }, 409 410 _populateDataGrid: function() 411 { 412 this._populateCookies(this._requestCookiesNode, this._requestCookies); 413 this._populateCookies(this._responseCookiesNode, this._responseCookies); 414 }, 415 416 _populateCookies: function(parentNode, cookies) 417 { 418 WebInspector.CookiesTable.prototype._populateCookies.call(this, parentNode, cookies); 419 var totalSize = 0; 420 if (cookies) { 421 for (var i = 0; i < cookies.length; ++i) 422 totalSize += cookies[i].size; 423 } 424 parentNode.expanded = true; 425 parentNode.data[5] = totalSize; 426 parentNode.refresh(); 427 }, 428 429 _createFolder: function(name) 430 { 431 var data = [ name, "", "", "", "", 0, "", "" ]; 432 var node = new WebInspector.DataGridNode(data); 433 node.selectable = true; 434 node.expanded = true; 435 this._dataGrid.appendChild(node); 436 node.element.addStyleClass("row-group"); 437 return node; 438 } 439 }; 440 441 WebInspector.ResourceCookiesTab.prototype.__proto__ = WebInspector.CookiesTable.prototype; -
trunk/WebCore/inspector/front-end/SourceView.js
r70519 r70529 74 74 if (this.localSourceFrame) 75 75 this.localSourceFrame.resize(); 76 WebInspector.ResourceView.prototype.resize.call(this); 76 77 }, 77 78 -
trunk/WebCore/inspector/front-end/inspector.css
r70454 r70529 899 899 } 900 900 901 .resource-view .resource-view-cookies { 902 position: absolute; 903 top: 0; 904 right: 0; 905 left: 0; 906 bottom: 0; 907 overflow: auto; 908 padding: 12px; 909 } 910 911 .resource-view.headers-visible .resource-view-cookies { 912 top: 20px; 913 } 914 915 .resource-view-cookies.table .data-grid { 916 height: 100%; 917 } 918 919 .resource-view-cookies .data-grid .row-group { 920 font-weight: bold; 921 font-size: 11px; 922 } 923 901 924 .webkit-line-gutter-backdrop { 902 925 /* Keep this in sync with view-source.css (.webkit-line-gutter-backdrop) */
Note: See TracChangeset
for help on using the changeset viewer.