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.NetworkTransferTimeCalculator} timeCalculator |
| 9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator |
8 * @param {!WebInspector.Setting} networkLogLargeRowsSetting | 10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting |
9 */ | 11 */ |
10 WebInspector.NetworkLogViewColumns = function(networkLogView, networkLogLargeRow
sSetting) | 12 WebInspector.NetworkLogViewColumns = function(networkLogView, timeCalculator, du
rationCalculator, networkLogLargeRowsSetting) |
11 { | 13 { |
12 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | 14 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
13 var timelineColumn = WebInspector.NetworkLogViewColumns._defaultColumns.
find(columnConfig => columnConfig.id === "timeline"); | 15 var timelineColumn = WebInspector.NetworkLogViewColumns._defaultColumns.
find(columnConfig => columnConfig.id === "timeline"); |
14 timelineColumn.visible = false; | 16 timelineColumn.visible = false; |
15 timelineColumn.hideable = true; | 17 timelineColumn.hideable = true; |
16 timelineColumn.sortConfig = { | 18 timelineColumn.sortConfig = { |
17 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom
parator.bind(null, "startTime") | 19 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom
parator.bind(null, "startTime") |
18 }; | 20 }; |
19 } | 21 } |
20 | 22 |
21 this._networkLogView = networkLogView; | 23 this._networkLogView = networkLogView; |
22 | 24 |
23 /** @type {!WebInspector.Setting} */ | 25 /** @type {!WebInspector.Setting} */ |
24 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo
lumns", {}); | 26 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo
lumns", {}); |
25 | 27 |
26 /** @type {!Array<!Element>} */ | 28 /** @type {!Array<!Element>} */ |
27 this._dropDownColumnSelectors = []; | 29 this._dropDownColumnSelectors = []; |
28 | 30 |
29 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; | 31 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; |
30 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi
s); | 32 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi
s); |
31 | 33 |
32 /** @type {!Array<{time: number, element: !Element}>} */ | 34 /** @type {!Array<{time: number, element: !Element}>} */ |
33 this._eventDividers = []; | 35 this._eventDividers = []; |
34 | 36 |
35 this._gridMode = true; | 37 this._gridMode = true; |
36 | 38 |
37 /** @type {?WebInspector.DataGrid} */ | |
38 this._dataGrid = null; | |
39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ | 39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ |
40 this._columns = []; | 40 this._columns = []; |
41 | 41 |
42 /** @type {?WebInspector.TimelineGrid} */ | 42 /** @type {?WebInspector.TimelineGrid} */ |
43 this._timelineGrid = null; | 43 this._timelineGrid = null; |
44 | 44 |
45 /** @type {!WebInspector.Linkifier} */ | 45 /** @type {!WebInspector.Linkifier} */ |
46 this._popupLinkifier = new WebInspector.Linkifier(); | 46 this._popupLinkifier = new WebInspector.Linkifier(); |
| 47 |
| 48 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ |
| 49 this._calculatorsMap = new Map(); |
| 50 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes
.Time, timeCalculator); |
| 51 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes
.Duration, durationCalculator); |
| 52 |
| 53 this._setupDataGrid(); |
47 }; | 54 }; |
48 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; | 55 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; |
49 | 56 |
50 /** | 57 /** |
51 * @typedef {{ | 58 * @typedef {{ |
52 * id: string, | 59 * id: string, |
53 * title: string, | 60 * title: string, |
54 * titleDOMFragment: (!DocumentFragment|undefined), | 61 * titleDOMFragment: (!DocumentFragment|undefined), |
55 * subtitle: (string|null), | 62 * subtitle: (string|null), |
56 * visible: boolean, | 63 * visible: boolean, |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 }, | 377 }, |
371 | 378 |
372 reset: function() | 379 reset: function() |
373 { | 380 { |
374 if (this._popoverHelper) | 381 if (this._popoverHelper) |
375 this._popoverHelper.hidePopover(); | 382 this._popoverHelper.hidePopover(); |
376 this._timelineGrid.removeEventDividers(); | 383 this._timelineGrid.removeEventDividers(); |
377 this.updateDividersIfNeeded(); | 384 this.updateDividersIfNeeded(); |
378 }, | 385 }, |
379 | 386 |
380 /** | 387 _setupDataGrid: function() |
381 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator | |
382 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculat
or | |
383 * @return {!WebInspector.SortableDataGrid} dataGrid | |
384 */ | |
385 createGrid: function(timeCalculator, durationCalculator) | |
386 { | 388 { |
387 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; | 389 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; |
388 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol
umnConfig; | 390 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol
umnConfig; |
389 | 391 |
390 this._columns = /** @type {!Array<!WebInspector.NetworkLogViewColumns.De
scriptor>} */ ([]); | 392 this._columns = /** @type {!Array<!WebInspector.NetworkLogViewColumns.De
scriptor>} */ ([]); |
391 for (var currentConfigColumn of defaultColumns) { | 393 for (var currentConfigColumn of defaultColumns) { |
392 var columnConfig = /** @type {!WebInspector.NetworkLogViewColumns.De
scriptor} */ (Object.assign(/** @type {!Object} */ ({}), defaultColumnConfig, cu
rrentConfigColumn)); | 394 var columnConfig = /** @type {!WebInspector.NetworkLogViewColumns.De
scriptor} */ (Object.assign(/** @type {!Object} */ ({}), defaultColumnConfig, cu
rrentConfigColumn)); |
393 columnConfig.id = columnConfig.id; | 395 columnConfig.id = columnConfig.id; |
394 if (columnConfig.subtitle) | 396 if (columnConfig.subtitle) |
395 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC
onfig.title, columnConfig.subtitle); | 397 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC
onfig.title, columnConfig.subtitle); |
396 this._columns.push(columnConfig); | 398 this._columns.push(columnConfig); |
397 } | 399 } |
398 this._loadColumns(); | 400 this._loadColumns(); |
399 | 401 |
400 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ | |
401 this._calculatorsMap = new Map(); | |
402 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT
ypes.Time, timeCalculator); | |
403 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT
ypes.Duration, durationCalculator); | |
404 | |
405 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie
w.element); | 402 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie
w.element); |
406 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this
), this._showPopover.bind(this), this._onHidePopover.bind(this)); | 403 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this
), this._showPopover.bind(this), this._onHidePopover.bind(this)); |
| 404 |
407 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web
Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); | 405 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web
Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); |
408 | 406 |
409 this._updateColumns(); | 407 this._updateColumns(); |
410 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._sortHandler, this); | 408 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._sortHandler, this); |
411 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi
zed, this.updateDividersIfNeeded, this); | 409 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi
zed, this.updateDividersIfNeeded, this); |
412 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu
.bind(this)); | 410 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu
.bind(this)); |
413 | 411 |
414 this._timelineGrid = new WebInspector.TimelineGrid(); | 412 this._timelineGrid = new WebInspector.TimelineGrid(); |
415 this._timelineGrid.element.classList.add("network-timeline-grid"); | 413 this._timelineGrid.element.classList.add("network-timeline-grid"); |
416 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 414 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
417 this._dataGrid.element.appendChild(this._timelineGrid.element); | 415 this._dataGrid.element.appendChild(this._timelineGrid.element); |
418 | 416 |
419 this._setupDropdownColumns(); | 417 this._setupDropdownColumns(); |
420 | 418 |
421 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._
initialSortColumn, WebInspector.DataGrid.Order.Ascending); | 419 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._
initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
422 | 420 |
423 this._updateRowsSize(); | 421 this._updateRowsSize(); |
424 | 422 |
| 423 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
| 424 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo
rkPanelSplitViewTimeline"); |
| 425 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); |
| 426 } |
| 427 }, |
| 428 |
| 429 /** |
| 430 * @param {!Element} element |
| 431 */ |
| 432 show: function(element) |
| 433 { |
| 434 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 435 this._splitWidget.show(element); |
| 436 else |
| 437 this._dataGrid.asWidget().show(element); |
| 438 }, |
| 439 |
| 440 /** |
| 441 * @return {!WebInspector.SplitWidget} |
| 442 */ |
| 443 splitWidget: function() |
| 444 { |
| 445 // This is a temporary function used until the move of timelinecolumn in
to NetworkLogViewColumns is done. |
| 446 return this._splitWidget; |
| 447 }, |
| 448 |
| 449 /** |
| 450 * @return {!WebInspector.SortableDataGrid} dataGrid |
| 451 */ |
| 452 dataGrid: function() |
| 453 { |
425 return this._dataGrid; | 454 return this._dataGrid; |
426 }, | 455 }, |
427 | 456 |
428 _setupDropdownColumns: function() | 457 _setupDropdownColumns: function() |
429 { | 458 { |
430 for (var columnConfig of this._columns) { | 459 for (var columnConfig of this._columns) { |
431 if (!columnConfig.sortConfig || !columnConfig.sortConfig.entries) | 460 if (!columnConfig.sortConfig || !columnConfig.sortConfig.entries) |
432 continue; | 461 continue; |
433 var select = createElement("select"); | 462 var select = createElement("select"); |
434 var placeHolderOption = select.createChild("option"); | 463 var placeHolderOption = select.createChild("option"); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 if (gridMode) { | 548 if (gridMode) { |
520 if (this._dataGrid.selectedNode) | 549 if (this._dataGrid.selectedNode) |
521 this._dataGrid.selectedNode.selected = false; | 550 this._dataGrid.selectedNode.selected = false; |
522 } else { | 551 } else { |
523 this._networkLogView.removeAllNodeHighlights(); | 552 this._networkLogView.removeAllNodeHighlights(); |
524 this._popoverHelper.hidePopover(); | 553 this._popoverHelper.hidePopover(); |
525 } | 554 } |
526 | 555 |
527 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | 556 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); |
528 this._updateColumns(); | 557 this._updateColumns(); |
| 558 |
| 559 |
| 560 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 561 return; |
| 562 // TODO(allada) Move this code into the code above. |
| 563 if (gridMode) |
| 564 this._splitWidget.showBoth(); |
| 565 else |
| 566 this._splitWidget.hideMain(); |
529 }, | 567 }, |
530 | 568 |
531 /** | 569 /** |
532 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | 570 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
533 */ | 571 */ |
534 _toggleColumnVisibility: function(columnConfig) | 572 _toggleColumnVisibility: function(columnConfig) |
535 { | 573 { |
536 this._loadColumns(); | 574 this._loadColumns(); |
537 columnConfig.visible = !columnConfig.visible; | 575 columnConfig.visible = !columnConfig.visible; |
538 this._saveColumns(); | 576 this._saveColumns(); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 for (var divider of this._eventDividers) | 872 for (var divider of this._eventDividers) |
835 divider.element.classList.toggle("network-frame-divider-selected", f
alse); | 873 divider.element.classList.toggle("network-frame-divider-selected", f
alse); |
836 }, | 874 }, |
837 | 875 |
838 _updateRowsSize: function() | 876 _updateRowsSize: function() |
839 { | 877 { |
840 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 878 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
841 return; | 879 return; |
842 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa
rgeRowsSetting.get()); | 880 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa
rgeRowsSetting.get()); |
843 } | 881 } |
844 }; | 882 }; |
OLD | NEW |