Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.NetworkLogView} networkLogView | 7 * @param {!WebInspector.NetworkLogView} networkLogView |
| 8 * @param {!WebInspector.Setting} networkLogLargeRowsSetting | 8 * @param {!WebInspector.Setting} networkLogLargeRowsSetting |
| 9 */ | 9 */ |
| 10 WebInspector.NetworkLogViewColumns = function(networkLogView, networkLogLargeRow sSetting) | 10 WebInspector.NetworkLogViewColumns = function(networkLogView, networkLogLargeRow sSetting) |
| 11 { | 11 { |
| 12 this._networkLogView = networkLogView; | 12 this._networkLogView = networkLogView; |
| 13 | 13 |
| 14 var defaultColumnsVisibility = WebInspector.NetworkLogViewColumns._defaultCo lumnsVisibility; | |
| 15 /** @type {!WebInspector.Setting} */ | 14 /** @type {!WebInspector.Setting} */ |
| 16 this._columnsVisibilitySetting = WebInspector.settings.createSetting("networ kLogColumnsVisibility", defaultColumnsVisibility); | 15 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo lumns", {}); |
| 17 var savedColumnsVisibility = this._columnsVisibilitySetting.get(); | 16 |
| 18 /** @type {!Object.<boolean>} */ | 17 /** @type {!Array<!Element>} */ |
| 19 var columnsVisibility = {}; | 18 this._dropDownColumnSelectors = []; |
| 20 for (var columnId in defaultColumnsVisibility) | |
| 21 columnsVisibility[columnId] = savedColumnsVisibility.hasOwnProperty(colu mnId) ? savedColumnsVisibility[columnId] : defaultColumnsVisibility[columnId]; | |
| 22 this._columnsVisibilitySetting.set(columnsVisibility); | |
| 23 | 19 |
| 24 networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, this); | 20 networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, this); |
| 25 | 21 |
| 26 /** @type {!Array<{time: number, element: !Element}>} */ | 22 /** @type {!Array<{time: number, element: !Element}>} */ |
| 27 this._eventDividers = []; | 23 this._eventDividers = []; |
| 28 | 24 |
| 29 this._gridMode = true; | 25 this._gridMode = true; |
| 30 | 26 |
| 31 /** @type {?WebInspector.DataGrid} */ | 27 /** @type {?WebInspector.DataGrid} */ |
| 32 this._dataGrid = null; | 28 this._dataGrid = null; |
| 33 /** @type {!Array.<!WebInspector.ColumnConfig>} */ | 29 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ |
| 34 this._columns = []; | 30 this._columns = []; |
| 35 /** @type {!Object.<string, function(!WebInspector.NetworkDataGridNode, !Web Inspector.NetworkDataGridNode) : number>} */ | |
| 36 this._sortingFunctions = {}; | |
| 37 /** @type {!Object.<string, !WebInspector.NetworkTimeCalculator>} */ | |
| 38 this._calculators = {}; | |
| 39 /** @type {?Element} */ | |
| 40 this._timelineSortSelector = null; | |
| 41 | 31 |
| 42 /** @type {?WebInspector.TimelineGrid} */ | 32 /** @type {?WebInspector.TimelineGrid} */ |
| 43 this._timelineGrid = null; | 33 this._timelineGrid = null; |
| 44 | 34 |
| 45 /** @type {!WebInspector.Linkifier} */ | 35 /** @type {!WebInspector.Linkifier} */ |
| 46 this._popupLinkifier = new WebInspector.Linkifier(); | 36 this._popupLinkifier = new WebInspector.Linkifier(); |
| 47 } | 37 } |
| 48 | 38 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; |
| 49 WebInspector.NetworkLogViewColumns._responseHeaderColumns = ["Cache-Control", "C onnection", "Content-Encoding", "Content-Length", "ETag", "Keep-Alive", "Last-Mo dified", "Server", "Vary"]; | |
| 50 WebInspector.NetworkLogViewColumns._defaultColumnsVisibility = { | |
| 51 method: false, status: true, protocol: false, scheme: false, domain: false, remoteAddress: false, type: true, initiator: true, cookies: false, setCookies: f alse, size: true, time: true, priority: false, connectionId: false, | |
| 52 "Cache-Control": false, "Connection": false, "Content-Encoding": false, "Con tent-Length": false, "ETag": false, "Keep-Alive": false, "Last-Modified": false, "Server": false, "Vary": false | |
| 53 }; | |
| 54 | 39 |
| 55 /** | 40 /** |
| 56 * @typedef {{ | 41 * @typedef {{ |
| 57 * id: string, | 42 * id: string, |
| 58 * title: string, | 43 * title: string, |
| 59 * titleDOMFragment: !DocumentFragment, | 44 * subtitle: (string|null), |
| 60 * sortable: boolean, | 45 * visible: boolean, |
| 61 * weight: number, | 46 * weight: number, |
| 62 * sort: (?WebInspector.DataGrid.Order|undefined), | 47 * hideable: boolean, |
| 63 * align: (?WebInspector.DataGrid.Align|undefined), | 48 * nonSelectable: boolean, |
| 49 * sortable: boolean, | |
| 50 * align: (?WebInspector.DataGrid.Align|undefined), | |
| 51 * isResponseHeader: boolean, | |
| 52 * sortConfig: !WebInspector.NetworkLogViewColumns.SortConfig | |
| 64 * }} | 53 * }} |
| 65 */ | 54 */ |
| 66 WebInspector.ColumnConfig; | 55 WebInspector.NetworkLogViewColumns.Descriptor; |
| 67 | 56 |
| 68 /** @type {!Object.<string, string>} */ | 57 /** |
| 69 WebInspector.NetworkLogViewColumns._columnTitles = { | 58 * @typedef {{ |
| 70 "name": WebInspector.UIString("Name"), | 59 * sortingFunction: (!function(!WebInspector.NetworkDataGridNode, !WebInspec tor.NetworkDataGridNode):number|undefined), |
| 71 "method": WebInspector.UIString("Method"), | 60 * entries: (!Array.<!WebInspector.DataGrid.ColumnDescriptor>|undefined) |
| 72 "status": WebInspector.UIString("Status"), | 61 * }} |
| 73 "protocol": WebInspector.UIString("Protocol"), | 62 */ |
| 74 "scheme": WebInspector.UIString("Scheme"), | 63 WebInspector.NetworkLogViewColumns.SortConfig; |
| 75 "domain": WebInspector.UIString("Domain"), | 64 |
| 76 "remoteAddress": WebInspector.UIString("Remote Address"), | 65 /** @enum {string} */ |
| 77 "type": WebInspector.UIString("Type"), | 66 WebInspector.NetworkLogViewColumns._calculatorTypes = { |
| 78 "initiator": WebInspector.UIString("Initiator"), | 67 Duration: "Duration", |
| 79 "cookies": WebInspector.UIString("Cookies"), | 68 Time: "Time" |
| 80 "setCookies": WebInspector.UIString("Set-Cookies"), | |
| 81 "size": WebInspector.UIString("Size"), | |
| 82 "time": WebInspector.UIString("Time"), | |
| 83 "connectionId": WebInspector.UIString("Connection Id"), | |
| 84 "priority": WebInspector.UIString("Priority"), | |
| 85 "timeline": WebInspector.UIString("Timeline"), | |
| 86 | |
| 87 // Response header columns | |
| 88 "Cache-Control": WebInspector.UIString("Cache-Control"), | |
| 89 "Connection": WebInspector.UIString("Connection"), | |
| 90 "Content-Encoding": WebInspector.UIString("Content-Encoding"), | |
| 91 "Content-Length": WebInspector.UIString("Content-Length"), | |
| 92 "ETag": WebInspector.UIString("ETag"), | |
| 93 "Keep-Alive": WebInspector.UIString("Keep-Alive"), | |
| 94 "Last-Modified": WebInspector.UIString("Last-Modified"), | |
| 95 "Server": WebInspector.UIString("Server"), | |
| 96 "Vary": WebInspector.UIString("Vary") | |
| 97 }; | 69 }; |
| 98 | 70 |
| 71 /** | |
| 72 * @type {!Object} column | |
| 73 */ | |
| 74 WebInspector.NetworkLogViewColumns._defaultColumnConfig = { | |
| 75 subtitle: null, | |
| 76 visible: false, | |
| 77 weight: 6, | |
| 78 sortable: true, | |
| 79 hideable: true, | |
| 80 nonSelectable: true, | |
| 81 isResponseHeader: false | |
| 82 }; | |
| 83 | |
| 84 /** | |
| 85 * @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} column | |
| 86 */ | |
| 87 WebInspector.NetworkLogViewColumns._defaultColumns = [ | |
| 88 { | |
| 89 id: "name", | |
| 90 title: WebInspector.UIString("Name"), | |
| 91 subtitle: WebInspector.UIString("Path"), | |
| 92 visible: true, | |
| 93 weight: 20, | |
| 94 hideable: false, | |
| 95 nonSelectable: false, | |
| 96 sortConfig: { | |
| 97 sortingFunction: WebInspector.NetworkDataGridNode.NameComparator | |
| 98 } | |
| 99 }, | |
| 100 { | |
| 101 id: "method", | |
| 102 title: WebInspector.UIString("Method"), | |
| 103 sortConfig: { | |
| 104 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "requestMethod") | |
| 105 } | |
| 106 }, | |
| 107 { | |
| 108 id: "status", | |
| 109 title: WebInspector.UIString("Status"), | |
| 110 visible: true, | |
| 111 subtitle: WebInspector.UIString("Text"), | |
| 112 sortConfig: { | |
| 113 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "statusCode") | |
| 114 } | |
| 115 }, | |
| 116 { | |
| 117 id: "protocol", | |
| 118 title: WebInspector.UIString("Protocol"), | |
| 119 sortConfig: { | |
| 120 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "protocol") | |
| 121 } | |
| 122 }, | |
| 123 { | |
| 124 id: "scheme", | |
| 125 title: WebInspector.UIString("Scheme"), | |
| 126 sortConfig: { | |
| 127 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "scheme") | |
| 128 } | |
| 129 }, | |
| 130 { | |
| 131 id: "domain", | |
| 132 title: WebInspector.UIString("Domain"), | |
| 133 sortConfig: { | |
| 134 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "domain") | |
| 135 } | |
| 136 }, | |
| 137 { | |
| 138 id: "remoteaddress", | |
| 139 title: WebInspector.UIString("Remote Address"), | |
| 140 weight: 10, | |
| 141 align: WebInspector.DataGrid.Align.Right, | |
| 142 sortConfig: { | |
| 143 sortingFunction: WebInspector.NetworkDataGridNode.RemoteAddressCompa rator | |
| 144 } | |
| 145 }, | |
| 146 { | |
| 147 id: "type", | |
| 148 title: WebInspector.UIString("Type"), | |
| 149 visible: true, | |
| 150 sortConfig: { | |
| 151 sortingFunction: WebInspector.NetworkDataGridNode.TypeComparator | |
| 152 } | |
| 153 }, | |
| 154 { | |
| 155 id: "initiator", | |
| 156 title: WebInspector.UIString("Initiator"), | |
| 157 visible: true, | |
| 158 weight: 10, | |
| 159 sortConfig: { | |
| 160 sortingFunction: WebInspector.NetworkDataGridNode.InitiatorComparato r | |
| 161 } | |
| 162 }, | |
| 163 { | |
| 164 id: "cookies", | |
| 165 title: WebInspector.UIString("Cookies"), | |
| 166 align: WebInspector.DataGrid.Align.Right, | |
| 167 sortConfig: { | |
| 168 sortingFunction: WebInspector.NetworkDataGridNode.RequestCookiesCoun tComparator | |
| 169 } | |
| 170 }, | |
| 171 { | |
| 172 id: "setcookies", | |
| 173 title: WebInspector.UIString("Set Cookies"), | |
| 174 align: WebInspector.DataGrid.Align.Right, | |
| 175 sortConfig: { | |
| 176 sortingFunction: WebInspector.NetworkDataGridNode.ResponseCookiesCou ntComparator | |
| 177 } | |
| 178 }, | |
| 179 { | |
| 180 id: "size", | |
| 181 title: WebInspector.UIString("Size"), | |
| 182 visible: true, | |
| 183 subtitle: WebInspector.UIString("Content"), | |
| 184 align: WebInspector.DataGrid.Align.Right, | |
| 185 sortConfig: { | |
| 186 sortingFunction: WebInspector.NetworkDataGridNode.SizeComparator | |
| 187 } | |
| 188 }, | |
| 189 { | |
| 190 id: "time", | |
| 191 title: WebInspector.UIString("Time"), | |
| 192 visible: true, | |
| 193 subtitle: WebInspector.UIString("Latency"), | |
| 194 align: WebInspector.DataGrid.Align.Right, | |
| 195 sortConfig: { | |
| 196 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "duration") | |
| 197 } | |
| 198 }, | |
| 199 { | |
| 200 id: "priority", | |
| 201 title: WebInspector.UIString("Priority"), | |
| 202 sortConfig: { | |
| 203 sortingFunction: WebInspector.NetworkDataGridNode.InitialPriorityCom parator | |
| 204 } | |
| 205 }, | |
| 206 { | |
| 207 id: "connectionid", | |
| 208 title: WebInspector.UIString("Connection ID"), | |
| 209 sortConfig: { | |
| 210 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "connectionId") | |
| 211 } | |
| 212 }, | |
| 213 { | |
| 214 id: "timeline", | |
| 215 title: WebInspector.UIString("Timeline"), | |
| 216 visible: true, | |
| 217 weight: 40, | |
| 218 sortable: false, | |
| 219 hideable: false, | |
| 220 sortConfig: { | |
| 221 entries: [ | |
| 222 { | |
| 223 id: "starttime", | |
| 224 title: WebInspector.UIString("Timeline \u2013 Start Time"), | |
| 225 sort: WebInspector.DataGrid.Order.Ascending, | |
| 226 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "startTime"), | |
| 227 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 228 }, | |
| 229 { | |
| 230 id: "responsetime", | |
| 231 title: WebInspector.UIString("Timeline \u2013 Response Time" ), | |
| 232 sort: WebInspector.DataGrid.Order.Ascending, | |
| 233 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "responseReceivedTime"), | |
| 234 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 235 }, | |
| 236 { | |
| 237 id: "endtime", | |
| 238 title: WebInspector.UIString("Timeline \u2013 End Time"), | |
| 239 sort: WebInspector.DataGrid.Order.Ascending, | |
| 240 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "endTime"), | |
| 241 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Time | |
| 242 }, | |
| 243 { | |
| 244 id: "duration", | |
| 245 title: WebInspector.UIString("Timeline \u2013 Total Duration "), | |
| 246 sort: WebInspector.DataGrid.Order.Descending, | |
| 247 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "duration"), | |
| 248 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | |
| 249 }, | |
| 250 { | |
| 251 id: "latency", | |
| 252 title: WebInspector.UIString("Timeline \u2013 Latency"), | |
| 253 sort: WebInspector.DataGrid.Order.Descending, | |
| 254 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "latency"), | |
| 255 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | |
| 256 } | |
| 257 ] | |
| 258 } | |
| 259 }, | |
| 260 { | |
| 261 id: "cache-control", | |
| 262 isResponseHeader: true, | |
| 263 title: WebInspector.UIString("Cache-Control"), | |
| 264 sortConfig: { | |
| 265 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "cache-control") | |
| 266 } | |
| 267 }, | |
| 268 { | |
| 269 id: "connection", | |
| 270 isResponseHeader: true, | |
| 271 title: WebInspector.UIString("Connection"), | |
| 272 sortConfig: { | |
| 273 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "connection") | |
| 274 } | |
| 275 }, | |
| 276 { | |
| 277 id: "content-encoding", | |
| 278 isResponseHeader: true, | |
| 279 title: WebInspector.UIString("Content-Encoding"), | |
| 280 sortConfig: { | |
| 281 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "content-encoding") | |
| 282 } | |
| 283 }, | |
| 284 { | |
| 285 id: "content-length", | |
| 286 isResponseHeader: true, | |
| 287 title: WebInspector.UIString("Content-Length"), | |
| 288 align: WebInspector.DataGrid.Align.Right, | |
| 289 sortConfig: { | |
| 290 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderNumb erComparator.bind(null, "content-length") | |
| 291 } | |
| 292 }, | |
| 293 { | |
| 294 id: "etag", | |
| 295 isResponseHeader: true, | |
| 296 title: WebInspector.UIString("ETag"), | |
| 297 sortConfig: { | |
| 298 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "etag") | |
| 299 } | |
| 300 }, | |
| 301 { | |
| 302 id: "keep-alive", | |
| 303 isResponseHeader: true, | |
| 304 title: WebInspector.UIString("Keep-Alive"), | |
| 305 sortConfig: { | |
| 306 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "keep-alive") | |
| 307 } | |
| 308 }, | |
| 309 { | |
| 310 id: "last-modified", | |
| 311 isResponseHeader: true, | |
| 312 title: WebInspector.UIString("Last-Modified"), | |
| 313 sortConfig: { | |
| 314 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderDate Comparator.bind(null, "last-modified") | |
| 315 } | |
| 316 }, | |
| 317 { | |
| 318 id: "server", | |
| 319 isResponseHeader: true, | |
| 320 title: WebInspector.UIString("Server"), | |
| 321 sortConfig: { | |
| 322 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "server") | |
| 323 } | |
| 324 }, | |
| 325 { | |
| 326 id: "vary", | |
| 327 isResponseHeader: true, | |
| 328 title: WebInspector.UIString("Vary"), | |
| 329 sortConfig: { | |
| 330 sortingFunction: WebInspector.NetworkDataGridNode.ResponseHeaderStri ngComparator.bind(null, "vary") | |
| 331 } | |
| 332 } | |
| 333 ]; | |
| 334 | |
| 335 WebInspector.NetworkLogViewColumns._saveableConfigs = ["visible", "title"]; | |
|
dgozman
2016/07/15 23:47:50
I think we'd better copy them explicitly.
allada
2016/07/25 23:05:53
I am fairly ok with doing so, but I am certain it
dgozman
2016/07/27 17:47:56
Let's do copyFromOneToAnother() with explicit assi
allada
2016/08/01 22:54:10
Decided to inline it since both functions are next
| |
| 336 | |
| 99 WebInspector.NetworkLogViewColumns.prototype = { | 337 WebInspector.NetworkLogViewColumns.prototype = { |
| 100 willHide: function() | 338 willHide: function() |
| 101 { | 339 { |
| 102 this._popoverHelper.hidePopover(); | 340 this._popoverHelper.hidePopover(); |
| 103 }, | 341 }, |
| 104 | 342 |
| 105 reset: function() | 343 reset: function() |
| 106 { | 344 { |
| 107 if (this._popoverHelper) | 345 if (this._popoverHelper) |
| 108 this._popoverHelper.hidePopover(); | 346 this._popoverHelper.hidePopover(); |
| 109 this._timelineGrid.removeEventDividers(); | 347 this._timelineGrid.removeEventDividers(); |
| 110 this.updateDividersIfNeeded(); | 348 this.updateDividersIfNeeded(); |
| 111 }, | 349 }, |
| 112 | 350 |
| 113 /** | 351 /** |
| 114 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator | 352 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator |
| 115 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or | 353 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat or |
| 116 * @return {!WebInspector.SortableDataGrid} dataGrid | 354 * @return {!WebInspector.SortableDataGrid} dataGrid |
| 117 */ | 355 */ |
| 118 createGrid: function(timeCalculator, durationCalculator) | 356 createGrid: function(timeCalculator, durationCalculator) |
| 119 { | 357 { |
| 120 this._createSortingFunctions(); | 358 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; |
| 359 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol umnConfig; | |
| 360 | |
| 361 this._columns = /** @type {!Array.<!WebInspector.NetworkLogViewColumns.D escriptor>} */ ([]); | |
| 362 for (var currentConfigColumn of defaultColumns) { | |
| 363 var columnConfig = /** @type {!WebInspector.NetworkLogViewColumns.De scriptor} */ (Object.assign(/** @type {!Object} */ ({}), defaultColumnConfig, cu rrentConfigColumn)); | |
| 364 columnConfig.id = columnConfig.id; | |
| 365 if (columnConfig.subtitle) | |
| 366 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC onfig.title, columnConfig.subtitle); | |
| 367 this._columns.push(columnConfig); | |
| 368 } | |
| 369 this._loadColumns(); | |
| 370 | |
| 371 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ | |
| 372 this._calculatorsMap = new Map(); | |
| 373 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT ypes.Time, timeCalculator); | |
| 374 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT ypes.Duration, durationCalculator); | |
| 375 | |
| 121 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); | 376 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); |
| 122 | 377 |
| 123 this._calculators.timeline = timeCalculator; | |
| 124 this._calculators.startTime = timeCalculator; | |
| 125 this._calculators.endTime = timeCalculator; | |
| 126 this._calculators.responseTime = timeCalculator; | |
| 127 this._calculators.duration = durationCalculator; | |
| 128 this._calculators.latency = durationCalculator; | |
| 129 | |
| 130 var columns = []; | |
| 131 columns.push({ | |
| 132 id: "name", | |
| 133 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Na me"), WebInspector.UIString("Path")), | |
| 134 title: WebInspector.NetworkLogViewColumns._columnTitles["name"], | |
| 135 weight: 20 | |
| 136 }); | |
| 137 | |
| 138 columns.push({ | |
| 139 id: "method", | |
| 140 title: WebInspector.NetworkLogViewColumns._columnTitles["method"], | |
| 141 weight: 6 | |
| 142 }); | |
| 143 | |
| 144 columns.push({ | |
| 145 id: "status", | |
| 146 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("St atus"), WebInspector.UIString("Text")), | |
| 147 title: WebInspector.NetworkLogViewColumns._columnTitles["status"], | |
| 148 weight: 6 | |
| 149 }); | |
| 150 | |
| 151 columns.push({ | |
| 152 id: "protocol", | |
| 153 title: WebInspector.NetworkLogViewColumns._columnTitles["protocol"], | |
| 154 weight: 6 | |
| 155 }); | |
| 156 | |
| 157 columns.push({ | |
| 158 id: "scheme", | |
| 159 title: WebInspector.NetworkLogViewColumns._columnTitles["scheme"], | |
| 160 weight: 6 | |
| 161 }); | |
| 162 | |
| 163 columns.push({ | |
| 164 id: "domain", | |
| 165 title: WebInspector.NetworkLogViewColumns._columnTitles["domain"], | |
| 166 weight: 6 | |
| 167 }); | |
| 168 | |
| 169 columns.push({ | |
| 170 id: "remoteAddress", | |
| 171 title: WebInspector.NetworkLogViewColumns._columnTitles["remoteAddre ss"], | |
| 172 weight: 10, | |
| 173 align: WebInspector.DataGrid.Align.Right | |
| 174 }); | |
| 175 | |
| 176 columns.push({ | |
| 177 id: "type", | |
| 178 title: WebInspector.NetworkLogViewColumns._columnTitles["type"], | |
| 179 weight: 6 | |
| 180 }); | |
| 181 | |
| 182 columns.push({ | |
| 183 id: "initiator", | |
| 184 title: WebInspector.NetworkLogViewColumns._columnTitles["initiator"] , | |
| 185 weight: 10 | |
| 186 }); | |
| 187 | |
| 188 columns.push({ | |
| 189 id: "cookies", | |
| 190 title: WebInspector.NetworkLogViewColumns._columnTitles["cookies"], | |
| 191 weight: 6, | |
| 192 align: WebInspector.DataGrid.Align.Right | |
| 193 }); | |
| 194 | |
| 195 columns.push({ | |
| 196 id: "setCookies", | |
| 197 title: WebInspector.NetworkLogViewColumns._columnTitles["setCookies" ], | |
| 198 weight: 6, | |
| 199 align: WebInspector.DataGrid.Align.Right | |
| 200 }); | |
| 201 | |
| 202 columns.push({ | |
| 203 id: "size", | |
| 204 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Si ze"), WebInspector.UIString("Content")), | |
| 205 title: WebInspector.NetworkLogViewColumns._columnTitles["size"], | |
| 206 weight: 6, | |
| 207 align: WebInspector.DataGrid.Align.Right | |
| 208 }); | |
| 209 | |
| 210 columns.push({ | |
| 211 id: "time", | |
| 212 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Ti me"), WebInspector.UIString("Latency")), | |
| 213 title: WebInspector.NetworkLogViewColumns._columnTitles["time"], | |
| 214 weight: 6, | |
| 215 align: WebInspector.DataGrid.Align.Right | |
| 216 }); | |
| 217 | |
| 218 columns.push({ | |
| 219 id: "priority", | |
| 220 title: WebInspector.NetworkLogViewColumns._columnTitles["priority"], | |
| 221 weight: 6 | |
| 222 }); | |
| 223 | |
| 224 columns.push({ | |
| 225 id: "connectionId", | |
| 226 title: WebInspector.NetworkLogViewColumns._columnTitles["connectionI d"], | |
| 227 weight: 6 | |
| 228 }); | |
| 229 | |
| 230 var responseHeaderColumns = WebInspector.NetworkLogViewColumns._response HeaderColumns; | |
| 231 for (var i = 0; i < responseHeaderColumns.length; ++i) { | |
| 232 var headerName = responseHeaderColumns[i]; | |
| 233 var descriptor = { | |
| 234 id: headerName, | |
| 235 title: WebInspector.NetworkLogViewColumns._columnTitles[headerNa me], | |
| 236 weight: 6 | |
| 237 }; | |
| 238 if (headerName === "Content-Length") | |
| 239 descriptor.align = WebInspector.DataGrid.Align.Right; | |
| 240 columns.push(descriptor); | |
| 241 } | |
| 242 | |
| 243 columns.push({ | |
| 244 id: "timeline", | |
| 245 title: WebInspector.NetworkLogViewColumns._columnTitles["timeline"], | |
| 246 sortable: false, | |
| 247 weight: 40, | |
| 248 sort: WebInspector.DataGrid.Order.Ascending | |
| 249 }); | |
| 250 | |
| 251 for (var column of columns) { | |
| 252 column.sortable = column.id !== "timeline"; | |
| 253 column.nonSelectable = column.id !== "name"; | |
| 254 } | |
| 255 this._columns = columns; | |
| 256 | |
| 257 this._networkLogView.switchViewMode(true); | |
|
dgozman
2016/07/15 23:47:50
Where did this call go?
allada
2016/07/25 23:05:53
the needed function this was executing was _update
| |
| 258 | |
| 259 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); | 378 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); |
| 260 | 379 |
| 261 this._dataGrid.asWidget().show(this._networkLogView.element); | 380 this._dataGrid.asWidget().show(this._networkLogView.element); |
| 262 | 381 |
| 382 this._updateColumns(); | |
| 383 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this); | |
| 384 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
| 385 | |
| 263 this._timelineGrid = new WebInspector.TimelineGrid(); | 386 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 264 this._timelineGrid.element.classList.add("network-timeline-grid"); | 387 this._timelineGrid.element.classList.add("network-timeline-grid"); |
| 265 this._dataGrid.element.appendChild(this._timelineGrid.element); | 388 this._dataGrid.element.appendChild(this._timelineGrid.element); |
| 389 this._setupDropdownColumns(); | |
| 266 | 390 |
| 267 this._updateColumns(); | 391 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
| 268 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); | |
| 269 this._dataGrid.sortNodes(this._sortingFunctions.startTime, false); | |
| 270 this._patchTimelineHeader(); | |
| 271 | |
| 272 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
| 273 | 392 |
| 274 return this._dataGrid; | 393 return this._dataGrid; |
| 275 }, | 394 }, |
| 276 | 395 |
| 277 _createSortingFunctions: function() | 396 _setupDropdownColumns: function() |
| 278 { | 397 { |
| 279 this._sortingFunctions.name = WebInspector.NetworkDataGridNode.NameCompa rator; | 398 for (var columnConfig of this._columns) { |
| 280 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "requestMethod"); | 399 if (!columnConfig.sortConfig || !columnConfig.sortConfig.entries) |
| 281 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "statusCode"); | 400 continue; |
| 282 this._sortingFunctions.protocol = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "protocol"); | 401 var select = createElement("select"); |
| 283 this._sortingFunctions.scheme = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "scheme"); | 402 var placeHolderOption = select.createChild("option"); |
| 284 this._sortingFunctions.domain = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "domain"); | 403 placeHolderOption.classList.add("hidden"); |
| 285 this._sortingFunctions.remoteAddress = WebInspector.NetworkDataGridNode. RemoteAddressComparator; | 404 for (var entry of columnConfig.sortConfig.entries) { |
| 286 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.TypeCompa rator; | 405 var option = select.createChild("option"); |
| 287 this._sortingFunctions.initiator = WebInspector.NetworkDataGridNode.Init iatorComparator; | 406 option.value = entry.id; |
| 288 this._sortingFunctions.cookies = WebInspector.NetworkDataGridNode.Reques tCookiesCountComparator; | 407 option.label = entry.title; |
| 289 this._sortingFunctions.setCookies = WebInspector.NetworkDataGridNode.Res ponseCookiesCountComparator; | 408 select.appendChild(option); |
| 290 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeCompa rator; | 409 } |
| 291 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.RequestPr opertyComparator.bind(null, "duration"); | 410 var header = this._dataGrid.headerTableHeader(columnConfig.id); |
| 292 this._sortingFunctions.connectionId = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "connectionId"); | 411 header.replaceChild(select, header.firstChild); |
| 293 this._sortingFunctions.priority = WebInspector.NetworkDataGridNode.Initi alPriorityComparator; | 412 header.createChild("div", "sort-order-icon-container").createChild(" div", "sort-order-icon"); |
| 294 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "startTime"); | 413 columnConfig.selectBox = select; |
| 295 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.Requ estPropertyComparator.bind(null, "startTime"); | 414 select.addEventListener("change", this._sortByDropdownItem.bind(this , columnConfig), false); |
| 296 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "endTime"); | 415 this._dropDownColumnSelectors.push(select); |
| 297 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "responseReceivedTime"); | 416 } |
| 298 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "duration"); | |
| 299 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "latency"); | |
| 300 | |
| 301 this._sortingFunctions["Cache-Control"] = WebInspector.NetworkDataGridNo de.ResponseHeaderStringComparator.bind(null, "Cache-Control"); | |
| 302 this._sortingFunctions["Connection"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Connection"); | |
| 303 this._sortingFunctions["Content-Encoding"] = WebInspector.NetworkDataGri dNode.ResponseHeaderStringComparator.bind(null, "Content-Encoding"); | |
| 304 this._sortingFunctions["Content-Length"] = WebInspector.NetworkDataGridN ode.ResponseHeaderNumberComparator.bind(null, "Content-Length"); | |
| 305 this._sortingFunctions["ETag"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "ETag"); | |
| 306 this._sortingFunctions["Keep-Alive"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Keep-Alive"); | |
| 307 this._sortingFunctions["Last-Modified"] = WebInspector.NetworkDataGridNo de.ResponseHeaderDateComparator.bind(null, "Last-Modified"); | |
| 308 this._sortingFunctions["Server"] = WebInspector.NetworkDataGridNode.Resp onseHeaderStringComparator.bind(null, "Server"); | |
| 309 this._sortingFunctions["Vary"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "Vary"); | |
| 310 }, | 417 }, |
| 311 | 418 |
| 312 _sortItems: function() | 419 sort: function() |
|
dgozman
2016/07/15 23:47:50
sortByCurrentColumn
allada
2016/07/25 23:05:53
Done.
| |
| 313 { | 420 { |
| 314 this._networkLogView.removeAllNodeHighlights(); | 421 this._sortHandler(); |
| 422 }, | |
| 423 | |
| 424 _sortHandler: function() | |
| 425 { | |
| 315 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); | 426 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); |
| 316 if (!columnIdentifier) | 427 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnIdentifier); |
| 428 if (!columnConfig) | |
| 317 return; | 429 return; |
| 318 if (columnIdentifier === "timeline") { | 430 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { |
| 319 this._sortByTimeline(); | 431 this._sortByDropdownItem(columnConfig); |
| 320 return; | 432 return; |
| 321 } | 433 } |
| 322 var sortingFunction = this._sortingFunctions[columnIdentifier]; | 434 if (!columnConfig.sortConfig.sortingFunction) |
| 323 if (!sortingFunction) | |
| 324 return; | 435 return; |
| 325 | 436 |
| 326 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); | 437 this._networkLogView.removeAllNodeHighlights(); |
| 327 this._timelineSortSelector.selectedIndex = 0; | 438 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending()); |
|
dgozman
2016/07/15 23:47:50
Where did this go?
allada
2016/07/25 23:05:53
See comment below about selectedIndex
| |
| 328 this._networkLogView.dataGridSorted(); | 439 this._networkLogView.dataGridSorted(); |
| 329 }, | 440 }, |
| 330 | 441 |
| 331 _sortByTimeline: function() | 442 /** |
| 443 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | |
| 444 */ | |
| 445 _sortByDropdownItem: function(columnConfig) | |
| 332 { | 446 { |
| 333 this._networkLogView.removeAllNodeHighlights(); | 447 this._networkLogView.removeAllNodeHighlights(); |
| 334 var selectedIndex = this._timelineSortSelector.selectedIndex; | 448 var selectedIndex = columnConfig.selectBox.selectedIndex; |
| 335 if (!selectedIndex) | 449 if (!selectedIndex) |
| 336 selectedIndex = 1; // Sort by start time by default. | 450 selectedIndex = 1; // Sort by first item by default. |
| 337 var selectedOption = this._timelineSortSelector[selectedIndex]; | 451 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder. |
| 452 var selectedOption = columnConfig.selectBox[selectedIndex]; | |
| 338 var value = selectedOption.value; | 453 var value = selectedOption.value; |
| 339 | 454 |
| 340 this._networkLogView.setCalculator(this._calculators[value]); | 455 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction); |
| 341 var sortingFunction = this._sortingFunctions[value]; | 456 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort)); |
| 342 this._dataGrid.sortNodes(sortingFunction); | 457 if (selectedItemConfig.calculator) |
| 343 | 458 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator)); |
| 459 columnConfig.selectBox.options[0].label = selectedItemConfig.title; | |
| 460 columnConfig.selectBox.selectedIndex = 0; | |
| 344 this._networkLogView.dataGridSorted(); | 461 this._networkLogView.dataGridSorted(); |
| 345 | |
| 346 this._dataGrid.markColumnAsSortedBy("timeline", selectedOption.sortOrder ); | |
| 347 }, | |
| 348 | |
| 349 _patchTimelineHeader: function() | |
| 350 { | |
| 351 var timelineSorting = createElement("select"); | |
| 352 | |
| 353 var option = createElement("option"); | |
| 354 option.value = "startTime"; | |
| 355 option.label = WebInspector.UIString("Timeline"); | |
| 356 option.disabled = true; | |
| 357 timelineSorting.appendChild(option); | |
| 358 | |
| 359 option = createElement("option"); | |
| 360 option.value = "startTime"; | |
| 361 option.label = WebInspector.UIString("Timeline \u2013 Start Time"); | |
| 362 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 363 timelineSorting.appendChild(option); | |
| 364 | |
| 365 option = createElement("option"); | |
| 366 option.value = "responseTime"; | |
| 367 option.label = WebInspector.UIString("Timeline \u2013 Response Time"); | |
| 368 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 369 timelineSorting.appendChild(option); | |
| 370 | |
| 371 option = createElement("option"); | |
| 372 option.value = "endTime"; | |
| 373 option.label = WebInspector.UIString("Timeline \u2013 End Time"); | |
| 374 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
| 375 timelineSorting.appendChild(option); | |
| 376 | |
| 377 option = createElement("option"); | |
| 378 option.value = "duration"; | |
| 379 option.label = WebInspector.UIString("Timeline \u2013 Total Duration"); | |
| 380 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
| 381 timelineSorting.appendChild(option); | |
| 382 | |
| 383 option = createElement("option"); | |
| 384 option.value = "latency"; | |
| 385 option.label = WebInspector.UIString("Timeline \u2013 Latency"); | |
| 386 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
| 387 timelineSorting.appendChild(option); | |
| 388 | |
| 389 var header = this._dataGrid.headerTableHeader("timeline"); | |
| 390 header.replaceChild(timelineSorting, header.firstChild); | |
| 391 header.createChild("div", "sort-order-icon-container").createChild("div" , "sort-order-icon"); | |
| 392 | |
| 393 timelineSorting.selectedIndex = 1; | |
|
dgozman
2016/07/15 23:47:50
Where did this go?
allada
2016/07/25 23:05:53
The way it works with the drop down timeline chang
| |
| 394 timelineSorting.addEventListener("click", function(event) { event.consum e(); }, false); | |
| 395 timelineSorting.addEventListener("change", this._sortByTimeline.bind(thi s), false); | |
| 396 this._timelineSortSelector = timelineSorting; | |
| 397 }, | 462 }, |
| 398 | 463 |
| 399 _updateColumns: function() | 464 _updateColumns: function() |
| 400 { | 465 { |
| 401 if (!this._dataGrid) | 466 if (!this._dataGrid) |
| 402 return; | 467 return; |
| 403 var gridMode = this._gridMode; | 468 var gridMode = this._gridMode; |
| 404 var visibleColumns = {"name": true}; | 469 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({}); |
| 405 if (gridMode) | 470 if (this._columns[0].id !== "name") { |
|
dgozman
2016/07/15 23:47:50
Can we avoid this? If name is initially first and
allada
2016/07/25 23:05:53
I did this in prep to allow re-ordering of columns
dgozman
2016/07/27 17:47:56
Let's do isMutable(column).
allada
2016/08/01 22:54:10
Since the next patch will be introducing custom co
| |
| 406 visibleColumns["timeline"] = true; | 471 var index = this._columns.findIndex(columnConfig => columnConfig.id === "name"); |
| 472 var columnConfig = this._columns.splice(index, 1)[0]; | |
| 473 this._columns.unshift(columnConfig); | |
| 474 } | |
| 475 if (this._columns[this._columns.length - 1].id !== "timeline") { | |
| 476 var index = this._columns.findIndex(columnConfig => columnConfig.id === "timeline"); | |
| 477 var columnConfig = this._columns.splice(index, 1)[0]; | |
| 478 this._columns.push(columnConfig); | |
| 479 } | |
| 407 if (gridMode) { | 480 if (gridMode) { |
| 408 var columnsVisibility = this._columnsVisibilitySetting.get(); | 481 for (var columnConfig of this._columns) |
| 409 for (var columnIdentifier in columnsVisibility) | 482 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable) |
|
dgozman
2016/07/15 23:47:50
Semicolons please! Can we fix this once and foreve
allada
2016/07/25 23:05:53
Done.
| |
| 410 visibleColumns[columnIdentifier] = columnsVisibility[columnIdent ifier]; | 483 } else { |
| 484 visibleColumns = {"name": true}; | |
| 411 } | 485 } |
| 412 | |
| 413 this._dataGrid.setColumnsVisiblity(visibleColumns); | 486 this._dataGrid.setColumnsVisiblity(visibleColumns); |
| 414 }, | 487 }, |
| 415 | 488 |
| 416 /** | 489 /** |
| 417 * @param {boolean} gridMode | 490 * @param {boolean} gridMode |
| 418 */ | 491 */ |
| 419 switchViewMode: function(gridMode) | 492 switchViewMode: function(gridMode) |
| 420 { | 493 { |
| 421 if (this._gridMode === gridMode) | 494 if (this._gridMode === gridMode) |
| 422 return; | 495 return; |
| 423 this._gridMode = gridMode; | 496 this._gridMode = gridMode; |
| 424 | 497 |
| 425 if (gridMode) { | 498 if (gridMode) { |
| 426 if (this._dataGrid.selectedNode) | 499 if (this._dataGrid.selectedNode) |
| 427 this._dataGrid.selectedNode.selected = false; | 500 this._dataGrid.selectedNode.selected = false; |
| 428 } else { | 501 } else { |
| 429 this._networkLogView.removeAllNodeHighlights(); | 502 this._networkLogView.removeAllNodeHighlights(); |
| 430 this._popoverHelper.hidePopover(); | 503 this._popoverHelper.hidePopover(); |
| 431 } | 504 } |
| 432 | 505 |
| 433 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | 506 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); |
| 434 this._updateColumns(); | 507 this._updateColumns(); |
| 435 }, | 508 }, |
| 436 | 509 |
| 437 /** | 510 /** |
| 438 * @param {string} columnIdentifier | 511 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
| 439 */ | 512 */ |
| 440 _toggleColumnVisibility: function(columnIdentifier) | 513 _toggleColumnVisibility: function(columnConfig) |
| 441 { | 514 { |
| 442 var columnsVisibility = this._columnsVisibilitySetting.get(); | 515 this._loadColumns(); |
| 443 columnsVisibility[columnIdentifier] = !columnsVisibility[columnIdentifie r]; | 516 columnConfig.visible = !columnConfig.visible; |
| 444 this._columnsVisibilitySetting.set(columnsVisibility); | 517 this._saveColumns(); |
| 445 | |
| 446 this._updateColumns(); | 518 this._updateColumns(); |
| 447 }, | 519 }, |
| 448 | 520 |
| 449 /** | 521 _saveColumns: function() |
| 450 * @return {!Array.<string>} | |
| 451 */ | |
| 452 _getConfigurableColumnIDs: function() | |
| 453 { | 522 { |
| 454 if (this._configurableColumnIDs) | 523 var saveableSettings = {}; |
| 455 return this._configurableColumnIDs; | 524 var keys = WebInspector.NetworkLogViewColumns._saveableConfigs; |
| 525 for (var columnConfig of this._columns) { | |
| 526 var saveObject = {}; | |
| 527 for (var key of keys) { | |
| 528 if (columnConfig.hasOwnProperty(key)) | |
| 529 saveObject[key] = columnConfig[key]; | |
| 530 } | |
| 531 saveableSettings[columnConfig.id] = saveObject; | |
| 532 } | |
| 533 this._persistantSettings.set(saveableSettings); | |
| 534 }, | |
| 456 | 535 |
| 457 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | 536 _loadColumns: function() |
| 458 function compare(id1, id2) | 537 { |
| 459 { | 538 var savedSettings = this._persistantSettings.get(); |
| 460 return columnTitles[id1].compareTo(columnTitles[id2]); | 539 var allowedSettings = WebInspector.NetworkLogViewColumns._saveableConfig s; |
| 540 var columnIds = Object.keys(savedSettings); | |
| 541 for (var columnId of columnIds) { | |
| 542 var setting = savedSettings[columnId]; | |
| 543 var columnConfig = this._columns.find(columnConfig => columnConfig.i d === columnId); | |
| 544 if (!columnConfig) | |
| 545 continue; | |
| 546 | |
| 547 for (var settingName of allowedSettings) { | |
| 548 if (setting.hasOwnProperty(settingName)) | |
| 549 columnConfig[settingName] = setting[settingName]; | |
| 550 } | |
| 461 } | 551 } |
| 462 | |
| 463 var columnIDs = Object.keys(this._columnsVisibilitySetting.get()); | |
| 464 this._configurableColumnIDs = columnIDs.sort(compare); | |
| 465 return this._configurableColumnIDs; | |
| 466 }, | 552 }, |
| 467 | 553 |
| 468 /** | 554 /** |
| 469 * @param {string} title | 555 * @param {string} title |
| 470 * @param {string} subtitle | 556 * @param {string} subtitle |
| 471 * @return {!DocumentFragment} | 557 * @return {!DocumentFragment} |
| 472 */ | 558 */ |
| 473 _makeHeaderFragment: function(title, subtitle) | 559 _makeHeaderFragment: function(title, subtitle) |
| 474 { | 560 { |
| 475 var fragment = createDocumentFragment(); | 561 var fragment = createDocumentFragment(); |
| 476 fragment.createTextChild(title); | 562 fragment.createTextChild(title); |
| 477 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; | 563 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; |
| 478 subtitleDiv.createTextChild(subtitle); | 564 subtitleDiv.createTextChild(subtitle); |
| 479 return fragment; | 565 return fragment; |
| 480 }, | 566 }, |
| 481 | 567 |
| 482 /** | 568 /** |
| 483 * @param {!Event} event | 569 * @param {!Event} event |
| 484 * @return {boolean} | 570 * @return {boolean} |
| 485 */ | 571 */ |
| 486 contextMenu: function(event) | 572 contextMenu: function(event) |
| 487 { | 573 { |
| 488 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) | 574 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) |
| 489 return false; | 575 return false; |
| 490 | 576 |
| 577 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable); | |
| 491 var contextMenu = new WebInspector.ContextMenu(event); | 578 var contextMenu = new WebInspector.ContextMenu(event); |
| 579 columnConfigs.filter(columnConfig => !columnConfig.isResponseHeader) | |
|
dgozman
2016/07/15 23:47:50
I'm pretty sure that replacing these two fancy fun
allada
2016/07/25 23:05:53
Done.
| |
| 580 .forEach(appendMenuItem.bind(this, contextMenu)); | |
| 492 | 581 |
| 493 var columnsVisibility = this._columnsVisibilitySetting.get(); | 582 contextMenu.appendSeparator(); |
| 494 var columnIDs = this._getConfigurableColumnIDs(); | 583 |
| 495 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | 584 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers")); |
| 496 for (var i = 0; i < columnIDs.length; ++i) { | 585 |
| 497 var columnIdentifier = columnIDs[i]; | 586 columnConfigs.filter(columnConfig => columnConfig.isResponseHeader) |
| 498 contextMenu.appendCheckboxItem(columnTitles[columnIdentifier], this. _toggleColumnVisibility.bind(this, columnIdentifier), !!columnsVisibility[column Identifier]); | 587 .forEach(appendMenuItem.bind(this, responseSubMenu)); |
| 499 } | 588 |
| 500 contextMenu.show(); | 589 contextMenu.show(); |
| 501 return true; | 590 return true; |
| 591 | |
| 592 /** | |
| 593 * @param {!WebInspector.ContextMenu|!WebInspector.ContextSubMenuItem} c ontextMenu | |
| 594 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | |
| 595 * @this {WebInspector.NetworkLogViewColumns} | |
| 596 */ | |
| 597 function appendMenuItem(contextMenu, columnConfig) | |
| 598 { | |
| 599 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible); | |
| 600 } | |
| 502 }, | 601 }, |
| 503 | 602 |
| 504 updateDividersIfNeeded: function() | 603 updateDividersIfNeeded: function() |
| 505 { | 604 { |
| 506 if (!this._networkLogView.isShowing()) { | 605 if (!this._networkLogView.isShowing()) { |
| 507 this._networkLogView.scheduleRefresh(); | 606 this._networkLogView.scheduleRefresh(); |
| 508 return; | 607 return; |
| 509 } | 608 } |
| 510 | 609 |
| 511 var timelineOffset = this._dataGrid.columnOffset("timeline"); | 610 var timelineOffset = this._dataGrid.columnOffset("timeline"); |
| 512 // Position timline grid location. | 611 // Position timline grid location. |
| 513 if (timelineOffset) | 612 if (timelineOffset) |
| 514 this._timelineGrid.element.style.left = timelineOffset + "px"; | 613 this._timelineGrid.element.style.left = timelineOffset + "px"; |
| 515 | 614 |
| 516 var calculator = this._networkLogView.calculator(); | 615 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol umns._calculatorTypes.Time); |
| 517 calculator.setDisplayWindow(this._timelineGrid.dividersElement.clientWid th); | 616 calculator.setDisplayWindow(this._timelineGrid.dividersElement.clientWid th); |
| 518 this._timelineGrid.updateDividers(calculator, 75); | 617 this._timelineGrid.updateDividers(calculator, 75); |
| 519 | 618 |
| 520 if (calculator.startAtZero) { | 619 if (calculator.startAtZero) { |
| 521 // If our current sorting method starts at zero, that means it shows all | 620 // If our current sorting method starts at zero, that means it shows all |
| 522 // requests starting at the same point, and so onLoad event and DOMC ontent | 621 // requests starting at the same point, and so onLoad event and DOMC ontent |
| 523 // event lines really wouldn't make much sense here, so don't render them. | 622 // event lines really wouldn't make much sense here, so don't render them. |
| 524 return; | 623 return; |
| 525 } | 624 } |
| 526 | 625 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 this._eventDividers.push({time: times[i], element: element}); | 682 this._eventDividers.push({time: times[i], element: element}); |
| 584 } | 683 } |
| 585 // Update event dividers immediately | 684 // Update event dividers immediately |
| 586 this._updateEventDividers(); | 685 this._updateEventDividers(); |
| 587 // Schedule refresh in case dividers change the calculator span. | 686 // Schedule refresh in case dividers change the calculator span. |
| 588 this._networkLogView.scheduleRefresh(); | 687 this._networkLogView.scheduleRefresh(); |
| 589 }, | 688 }, |
| 590 | 689 |
| 591 _updateEventDividers: function() | 690 _updateEventDividers: function() |
| 592 { | 691 { |
| 593 var calculator = this._networkLogView.calculator(); | 692 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol umns._calculatorTypes.Time);; |
|
dgozman
2016/07/15 23:47:50
extra semicolon!
allada
2016/07/25 23:05:53
Done.
| |
| 594 for (var divider of this._eventDividers) { | 693 for (var divider of this._eventDividers) { |
| 595 var timePercent = calculator.computePercentageFromEventTime(divider. time); | 694 var timePercent = calculator.computePercentageFromEventTime(divider. time); |
| 596 divider.element.classList.toggle("invisible", timePercent < 0); | 695 divider.element.classList.toggle("invisible", timePercent < 0); |
| 597 divider.element.style.left = timePercent + "%"; | 696 divider.element.style.left = timePercent + "%"; |
| 598 } | 697 } |
| 599 }, | 698 }, |
| 600 | 699 |
| 601 hideEventDividers: function() | 700 hideEventDividers: function() |
| 602 { | 701 { |
| 603 this._timelineGrid.hideEventDividers(); | 702 this._timelineGrid.hideEventDividers(); |
| 604 }, | 703 }, |
| 605 | 704 |
| 606 showEventDividers: function() | 705 showEventDividers: function() |
| 607 { | 706 { |
| 608 this._timelineGrid.showEventDividers(); | 707 this._timelineGrid.showEventDividers(); |
| 609 }, | 708 }, |
| 610 | 709 |
| 611 /** | 710 /** |
| 612 * @param {!WebInspector.Event} event | 711 * @param {!WebInspector.Event} event |
| 613 */ | 712 */ |
| 614 _updateRowsSize: function(event) | 713 _updateRowsSize: function(event) |
| 615 { | 714 { |
| 616 this._timelineGrid.element.classList.toggle("small", !event.data); | 715 this._timelineGrid.element.classList.toggle("small", !event.data); |
| 617 } | 716 } |
| 618 } | 717 } |
| OLD | NEW |