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