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 | 8 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator |
9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator | 9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator |
10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting | 10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 /** @type {!Array<!Element>} */ | 28 /** @type {!Array<!Element>} */ |
29 this._dropDownColumnSelectors = []; | 29 this._dropDownColumnSelectors = []; |
30 | 30 |
31 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; | 31 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; |
32 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); | 32 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); |
33 | 33 |
34 /** @type {!Array<{time: number, element: !Element}>} */ | 34 /** @type {!Array<{time: number, element: !Element}>} */ |
35 this._eventDividers = []; | 35 this._eventDividers = []; |
36 | 36 |
37 /** @type {!Map<string, !Array<number>>} */ | |
38 this._shownEventDividers = new Map(); | |
dgozman
2016/10/28 18:35:38
Why not just |_eventDividers|? The naming is confu
allada
2016/10/28 21:09:07
Done.
| |
39 /** @type {!Array<number>} */ | |
40 this._filmStripDividers = []; | |
41 this._eventDividersShown = false; | |
42 | |
37 this._gridMode = true; | 43 this._gridMode = true; |
38 | 44 |
39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ | 45 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ |
40 this._columns = []; | 46 this._columns = []; |
41 | 47 |
42 /** @type {?WebInspector.TimelineGrid} */ | 48 /** @type {?WebInspector.TimelineGrid} */ |
43 this._timelineGrid = null; | 49 this._timelineGrid = null; |
44 this._timelineHeaderElement = null; | 50 this._timelineHeaderElement = null; |
45 this._timelineRequestsAreStale = false; | 51 this._timelineRequestsAreStale = false; |
46 this._timelineScrollerWidthIsStale = true; | 52 this._timelineScrollerWidthIsStale = true; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 title: WebInspector.UIString("Timeline \u2013 Latency"), | 359 title: WebInspector.UIString("Timeline \u2013 Latency"), |
354 sort: WebInspector.DataGrid.Order.Descending, | 360 sort: WebInspector.DataGrid.Order.Descending, |
355 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "latency"), | 361 sortingFunction: WebInspector.NetworkDataGridNode.RequestPro pertyComparator.bind(null, "latency"), |
356 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration | 362 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration |
357 } | 363 } |
358 ] | 364 ] |
359 } | 365 } |
360 } | 366 } |
361 ]; | 367 ]; |
362 | 368 |
369 WebInspector.NetworkLogViewColumns._filmStripDividerColor = "#fccc49"; | |
370 | |
363 /** | 371 /** |
364 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | 372 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
365 * @return {!WebInspector.DataGrid.ColumnDescriptor} | 373 * @return {!WebInspector.DataGrid.ColumnDescriptor} |
366 */ | 374 */ |
367 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum nConfig) | 375 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum nConfig) |
368 { | 376 { |
369 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({ | 377 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({ |
370 id: columnConfig.id, | 378 id: columnConfig.id, |
371 title: columnConfig.title, | 379 title: columnConfig.title, |
372 sortable: columnConfig.sortable, | 380 sortable: columnConfig.sortable, |
(...skipping 12 matching lines...) Expand all Loading... | |
385 willHide: function() | 393 willHide: function() |
386 { | 394 { |
387 this._popoverHelper.hidePopover(); | 395 this._popoverHelper.hidePopover(); |
388 }, | 396 }, |
389 | 397 |
390 reset: function() | 398 reset: function() |
391 { | 399 { |
392 if (this._popoverHelper) | 400 if (this._popoverHelper) |
393 this._popoverHelper.hidePopover(); | 401 this._popoverHelper.hidePopover(); |
394 this._timelineGrid.removeEventDividers(); | 402 this._timelineGrid.removeEventDividers(); |
403 this._shownEventDividers.clear(); | |
404 this._filmStripDividers = []; | |
395 this.updateDividersIfNeeded(); | 405 this.updateDividersIfNeeded(); |
396 }, | 406 }, |
397 | 407 |
398 _setupDataGrid: function() | 408 _setupDataGrid: function() |
399 { | 409 { |
400 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; | 410 var defaultColumns = WebInspector.NetworkLogViewColumns._defaultColumns; |
401 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol umnConfig; | 411 var defaultColumnConfig = WebInspector.NetworkLogViewColumns._defaultCol umnConfig; |
402 | 412 |
403 this._columns = /** @type {!Array<!WebInspector.NetworkLogViewColumns.De scriptor>} */ ([]); | 413 this._columns = /** @type {!Array<!WebInspector.NetworkLogViewColumns.De scriptor>} */ ([]); |
404 for (var currentConfigColumn of defaultColumns) { | 414 for (var currentConfigColumn of defaultColumns) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 if (this._timelineScrollerWidthIsStale) { | 507 if (this._timelineScrollerWidthIsStale) { |
498 this._timelineScrollerWidthIsStale = false; | 508 this._timelineScrollerWidthIsStale = false; |
499 this._timelineColumn.setRightPadding(this._timelineScroller.offsetWi dth - this._timelineScrollerContent.offsetWidth); | 509 this._timelineColumn.setRightPadding(this._timelineScroller.offsetWi dth - this._timelineScrollerContent.offsetWidth); |
500 } | 510 } |
501 }, | 511 }, |
502 | 512 |
503 _redrawTimelineColumn: function() | 513 _redrawTimelineColumn: function() |
504 { | 514 { |
505 if (!this._timelineRequestsAreStale) { | 515 if (!this._timelineRequestsAreStale) { |
506 this._updateScrollerWidthIfNeeded(); | 516 this._updateScrollerWidthIfNeeded(); |
507 this._timelineColumn.update(this._activeScroller.scrollTop); | 517 this._timelineColumn.update(this._activeScroller.scrollTop, this._ev entDividersShown ? this._shownEventDividers : undefined); |
508 return; | 518 return; |
509 } | 519 } |
510 var currentNode = this._dataGrid.rootNode(); | 520 var currentNode = this._dataGrid.rootNode(); |
511 var requestData = { | 521 var requestData = { |
512 requests: [], | 522 requests: [], |
513 navigationRequest: null | 523 navigationRequest: null |
514 }; | 524 }; |
515 while (currentNode = currentNode.traverseNextNode(true)) { | 525 while (currentNode = currentNode.traverseNextNode(true)) { |
516 if (currentNode.isNavigationRequest()) | 526 if (currentNode.isNavigationRequest()) |
517 requestData.navigationRequest = currentNode.request(); | 527 requestData.navigationRequest = currentNode.request(); |
518 requestData.requests.push(currentNode.request()); | 528 requestData.requests.push(currentNode.request()); |
519 } | 529 } |
520 this._timelineColumn.update(this._activeScroller.scrollTop, requestData) ; | 530 this._timelineColumn.update(this._activeScroller.scrollTop, this._shownE ventDividers, requestData); |
521 }, | 531 }, |
522 | 532 |
523 /** | 533 /** |
524 * @param {?WebInspector.NetworkRequest} request | 534 * @param {?WebInspector.NetworkRequest} request |
525 */ | 535 */ |
526 setHoveredRequest: function(request) | 536 setHoveredRequest: function(request) |
527 { | 537 { |
528 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 538 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
529 this._timelineColumn.setHoveredRequest(request); | 539 this._timelineColumn.setHoveredRequest(request); |
530 }, | 540 }, |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 { | 997 { |
988 this._popupLinkifier.reset(); | 998 this._popupLinkifier.reset(); |
989 }, | 999 }, |
990 | 1000 |
991 /** | 1001 /** |
992 * @param {!Array<number>} times | 1002 * @param {!Array<number>} times |
993 * @param {string} className | 1003 * @param {string} className |
994 */ | 1004 */ |
995 addEventDividers: function(times, className) | 1005 addEventDividers: function(times, className) |
996 { | 1006 { |
997 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 1007 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
1008 // TODO(allada) When we remove old timeline remove this and pass in the color. | |
1009 var color = "transparent"; | |
1010 switch (className) { | |
1011 case "network-frame-divider": | |
1012 color = WebInspector.NetworkLogViewColumns._filmStripDividerColo r; | |
1013 this._filmStripDividers = this._filmStripDividers.concat(times); | |
1014 return; | |
1015 case "network-blue-divider": | |
1016 color = "hsla(240, 100%, 80%, 0.7)"; | |
1017 break; | |
1018 case "network-red-divider": | |
1019 color = "rgba(255, 0, 0, 0.5)"; | |
1020 break; | |
1021 } | |
1022 var currentTimes = this._shownEventDividers.get(color) || []; | |
1023 this._shownEventDividers.set(color, currentTimes.concat(times)); | |
1024 | |
1025 this._networkLogView.scheduleRefresh(); | |
998 return; | 1026 return; |
1027 } | |
1028 | |
999 for (var i = 0; i < times.length; ++i) { | 1029 for (var i = 0; i < times.length; ++i) { |
1000 var element = createElementWithClass("div", "network-event-divider " + className); | 1030 var element = createElementWithClass("div", "network-event-divider " + className); |
1001 this._timelineGrid.addEventDivider(element); | 1031 this._timelineGrid.addEventDivider(element); |
1002 this._eventDividers.push({time: times[i], element: element}); | 1032 this._eventDividers.push({time: times[i], element: element}); |
1003 } | 1033 } |
1004 // Update event dividers immediately | 1034 // Update event dividers immediately |
1005 this._updateEventDividers(); | 1035 this._updateEventDividers(); |
1006 // Schedule refresh in case dividers change the calculator span. | 1036 // Schedule refresh in case dividers change the calculator span. |
1007 this._networkLogView.scheduleRefresh(); | 1037 this._networkLogView.scheduleRefresh(); |
1008 }, | 1038 }, |
1009 | 1039 |
1010 _updateEventDividers: function() | 1040 _updateEventDividers: function() |
1011 { | 1041 { |
1012 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 1042 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
1013 return; | 1043 return; |
1014 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol umns._calculatorTypes.Time); | 1044 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogViewCol umns._calculatorTypes.Time); |
1015 for (var divider of this._eventDividers) { | 1045 for (var divider of this._eventDividers) { |
1016 var timePercent = calculator.computePercentageFromEventTime(divider. time); | 1046 var timePercent = calculator.computePercentageFromEventTime(divider. time); |
1017 divider.element.classList.toggle("invisible", timePercent < 0); | 1047 divider.element.classList.toggle("invisible", timePercent < 0); |
1018 divider.element.style.left = timePercent + "%"; | 1048 divider.element.style.left = timePercent + "%"; |
1019 } | 1049 } |
1020 }, | 1050 }, |
1021 | 1051 |
1022 hideEventDividers: function() | 1052 hideEventDividers: function() |
1023 { | 1053 { |
1024 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 1054 this._eventDividersShown = true; |
1055 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | |
1056 this._redrawTimelineColumn(); | |
1025 return; | 1057 return; |
1058 } | |
1026 this._timelineGrid.hideEventDividers(); | 1059 this._timelineGrid.hideEventDividers(); |
1027 }, | 1060 }, |
1028 | 1061 |
1029 showEventDividers: function() | 1062 showEventDividers: function() |
1030 { | 1063 { |
1031 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 1064 this._eventDividersShown = false; |
1065 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | |
1066 this._redrawTimelineColumn(); | |
1032 return; | 1067 return; |
1068 } | |
1033 this._timelineGrid.showEventDividers(); | 1069 this._timelineGrid.showEventDividers(); |
1034 }, | 1070 }, |
1035 | 1071 |
1036 /** | 1072 /** |
1037 * @param {number} time | 1073 * @param {number} time |
1038 */ | 1074 */ |
1039 selectFilmStripFrame: function(time) | 1075 selectFilmStripFrame: function(time) |
1040 { | 1076 { |
1077 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | |
1078 this._shownEventDividers.delete(WebInspector.NetworkLogViewColumns._ filmStripDividerColor); | |
1079 for (var dividertime of this._filmStripDividers) { | |
1080 if (dividertime === time) | |
1081 this._shownEventDividers.set(WebInspector.NetworkLogViewColu mns._filmStripDividerColor, [time]); | |
1082 } | |
1083 this._redrawTimelineColumn(); | |
1084 return; | |
1085 } | |
1041 for (var divider of this._eventDividers) | 1086 for (var divider of this._eventDividers) |
1042 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); | 1087 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); |
1043 }, | 1088 }, |
1044 | 1089 |
1045 clearFilmStripFrame: function() | 1090 clearFilmStripFrame: function() |
1046 { | 1091 { |
1092 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | |
1093 this._shownEventDividers.delete(WebInspector.NetworkLogViewColumns._ filmStripDividerColor); | |
1094 this._redrawTimelineColumn(); | |
1095 return; | |
1096 } | |
1047 for (var divider of this._eventDividers) | 1097 for (var divider of this._eventDividers) |
1048 divider.element.classList.toggle("network-frame-divider-selected", f alse); | 1098 divider.element.classList.toggle("network-frame-divider-selected", f alse); |
1049 } | 1099 } |
1050 }; | 1100 }; |
OLD | NEW |