| 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 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
| 13 var timelineColumn = WebInspector.NetworkLogViewColumns._defaultColumns.
find(columnConfig => columnConfig.id === "timeline"); |
| 14 timelineColumn.visible = false; |
| 15 timelineColumn.hideable = true; |
| 16 timelineColumn.sortConfig = { |
| 17 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom
parator.bind(null, "startTime") |
| 18 }; |
| 19 } |
| 20 |
| 12 this._networkLogView = networkLogView; | 21 this._networkLogView = networkLogView; |
| 13 | 22 |
| 14 /** @type {!WebInspector.Setting} */ | 23 /** @type {!WebInspector.Setting} */ |
| 15 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo
lumns", {}); | 24 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo
lumns", {}); |
| 16 | 25 |
| 17 /** @type {!Array<!Element>} */ | 26 /** @type {!Array<!Element>} */ |
| 18 this._dropDownColumnSelectors = []; | 27 this._dropDownColumnSelectors = []; |
| 19 | 28 |
| 20 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; | 29 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; |
| 21 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi
s); | 30 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi
s); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 }, | 337 }, |
| 329 { | 338 { |
| 330 id: "latency", | 339 id: "latency", |
| 331 title: WebInspector.UIString("Timeline \u2013 Latency"), | 340 title: WebInspector.UIString("Timeline \u2013 Latency"), |
| 332 sort: WebInspector.DataGrid.Order.Descending, | 341 sort: WebInspector.DataGrid.Order.Descending, |
| 333 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro
pertyComparator.bind(null, "latency"), | 342 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro
pertyComparator.bind(null, "latency"), |
| 334 calculator: WebInspector.NetworkLogViewColumns._calculatorTy
pes.Duration | 343 calculator: WebInspector.NetworkLogViewColumns._calculatorTy
pes.Duration |
| 335 } | 344 } |
| 336 ] | 345 ] |
| 337 } | 346 } |
| 338 }, | 347 } |
| 339 ]; | 348 ]; |
| 340 | 349 |
| 341 /** | 350 /** |
| 342 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | 351 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
| 343 * @return {!WebInspector.DataGrid.ColumnDescriptor} | 352 * @return {!WebInspector.DataGrid.ColumnDescriptor} |
| 344 */ | 353 */ |
| 345 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum
nConfig) | 354 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum
nConfig) |
| 346 { | 355 { |
| 347 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({ | 356 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({ |
| 348 id: columnConfig.id, | 357 id: columnConfig.id, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 399 |
| 391 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ | 400 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ |
| 392 this._calculatorsMap = new Map(); | 401 this._calculatorsMap = new Map(); |
| 393 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT
ypes.Time, timeCalculator); | 402 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT
ypes.Time, timeCalculator); |
| 394 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT
ypes.Duration, durationCalculator); | 403 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorT
ypes.Duration, durationCalculator); |
| 395 | 404 |
| 396 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie
w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this
._onHidePopover.bind(this)); | 405 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie
w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this
._onHidePopover.bind(this)); |
| 397 | 406 |
| 398 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web
Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); | 407 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web
Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); |
| 399 | 408 |
| 400 this._dataGrid.asWidget().show(this._networkLogView.element); | |
| 401 | |
| 402 this._updateColumns(); | 409 this._updateColumns(); |
| 403 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._sortHandler, this); | 410 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._sortHandler, this); |
| 404 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi
zed, this.updateDividersIfNeeded, this); | 411 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi
zed, this.updateDividersIfNeeded, this); |
| 405 | 412 |
| 406 this._timelineGrid = new WebInspector.TimelineGrid(); | 413 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 407 this._timelineGrid.element.classList.add("network-timeline-grid"); | 414 this._timelineGrid.element.classList.add("network-timeline-grid"); |
| 408 this._dataGrid.element.appendChild(this._timelineGrid.element); | 415 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 416 this._dataGrid.element.appendChild(this._timelineGrid.element); |
| 417 |
| 409 this._setupDropdownColumns(); | 418 this._setupDropdownColumns(); |
| 410 | 419 |
| 411 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._
initialSortColumn, WebInspector.DataGrid.Order.Ascending); | 420 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._
initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
| 412 | 421 |
| 413 this._updateRowsSize(); | 422 this._updateRowsSize(); |
| 414 | 423 |
| 415 return this._dataGrid; | 424 return this._dataGrid; |
| 416 }, | 425 }, |
| 417 | 426 |
| 418 _setupDropdownColumns: function() | 427 _setupDropdownColumns: function() |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 if (!oldColumnConfig || (currentColumnConfig && oldHeaderId !== newHeade
rId)) | 693 if (!oldColumnConfig || (currentColumnConfig && oldHeaderId !== newHeade
rId)) |
| 685 return false; | 694 return false; |
| 686 | 695 |
| 687 this._removeCustomHeader(oldHeaderId); | 696 this._removeCustomHeader(oldHeaderId); |
| 688 this._addCustomHeader(newHeaderTitle, newHeaderId, oldIndex); | 697 this._addCustomHeader(newHeaderTitle, newHeaderId, oldIndex); |
| 689 return true; | 698 return true; |
| 690 }, | 699 }, |
| 691 | 700 |
| 692 updateDividersIfNeeded: function() | 701 updateDividersIfNeeded: function() |
| 693 { | 702 { |
| 703 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 704 return; |
| 694 if (!this._networkLogView.isShowing()) { | 705 if (!this._networkLogView.isShowing()) { |
| 695 this._networkLogView.scheduleRefresh(); | 706 this._networkLogView.scheduleRefresh(); |
| 696 return; | 707 return; |
| 697 } | 708 } |
| 698 | 709 |
| 699 var timelineOffset = this._dataGrid.columnOffset("timeline"); | 710 var timelineOffset = this._dataGrid.columnOffset("timeline"); |
| 700 // Position timline grid location. | 711 // Position timline grid location. |
| 701 if (timelineOffset) | 712 if (timelineOffset) |
| 702 this._timelineGrid.element.style.left = timelineOffset + "px"; | 713 this._timelineGrid.element.style.left = timelineOffset + "px"; |
| 703 | 714 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 { | 769 { |
| 759 this._popupLinkifier.reset(); | 770 this._popupLinkifier.reset(); |
| 760 }, | 771 }, |
| 761 | 772 |
| 762 /** | 773 /** |
| 763 * @param {!Array<number>} times | 774 * @param {!Array<number>} times |
| 764 * @param {string} className | 775 * @param {string} className |
| 765 */ | 776 */ |
| 766 addEventDividers: function(times, className) | 777 addEventDividers: function(times, className) |
| 767 { | 778 { |
| 779 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 780 return; |
| 768 for (var i = 0; i < times.length; ++i) { | 781 for (var i = 0; i < times.length; ++i) { |
| 769 var element = createElementWithClass("div", "network-event-divider "
+ className); | 782 var element = createElementWithClass("div", "network-event-divider "
+ className); |
| 770 this._timelineGrid.addEventDivider(element); | 783 this._timelineGrid.addEventDivider(element); |
| 771 this._eventDividers.push({time: times[i], element: element}); | 784 this._eventDividers.push({time: times[i], element: element}); |
| 772 } | 785 } |
| 773 // Update event dividers immediately | 786 // Update event dividers immediately |
| 774 this._updateEventDividers(); | 787 this._updateEventDividers(); |
| 775 // Schedule refresh in case dividers change the calculator span. | 788 // Schedule refresh in case dividers change the calculator span. |
| 776 this._networkLogView.scheduleRefresh(); | 789 this._networkLogView.scheduleRefresh(); |
| 777 }, | 790 }, |
| 778 | 791 |
| 779 _updateEventDividers: function() | 792 _updateEventDividers: function() |
| 780 { | 793 { |
| 794 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 795 return; |
| 781 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol
umns._calculatorTypes.Time); | 796 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol
umns._calculatorTypes.Time); |
| 782 for (var divider of this._eventDividers) { | 797 for (var divider of this._eventDividers) { |
| 783 var timePercent = calculator.computePercentageFromEventTime(divider.
time); | 798 var timePercent = calculator.computePercentageFromEventTime(divider.
time); |
| 784 divider.element.classList.toggle("invisible", timePercent < 0); | 799 divider.element.classList.toggle("invisible", timePercent < 0); |
| 785 divider.element.style.left = timePercent + "%"; | 800 divider.element.style.left = timePercent + "%"; |
| 786 } | 801 } |
| 787 }, | 802 }, |
| 788 | 803 |
| 789 hideEventDividers: function() | 804 hideEventDividers: function() |
| 790 { | 805 { |
| 806 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 807 return; |
| 791 this._timelineGrid.hideEventDividers(); | 808 this._timelineGrid.hideEventDividers(); |
| 792 }, | 809 }, |
| 793 | 810 |
| 794 showEventDividers: function() | 811 showEventDividers: function() |
| 795 { | 812 { |
| 813 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 814 return; |
| 796 this._timelineGrid.showEventDividers(); | 815 this._timelineGrid.showEventDividers(); |
| 797 }, | 816 }, |
| 798 | 817 |
| 799 _updateRowsSize: function() | 818 _updateRowsSize: function() |
| 800 { | 819 { |
| 820 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 821 return; |
| 801 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa
rgeRowsSetting.get()); | 822 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa
rgeRowsSetting.get()); |
| 802 } | 823 } |
| 803 } | 824 } |
| OLD | NEW |