| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 /** | 1017 /** |
| 1018 * @override | 1018 * @override |
| 1019 * @param {number} index | 1019 * @param {number} index |
| 1020 * @param {!CanvasRenderingContext2D} context | 1020 * @param {!CanvasRenderingContext2D} context |
| 1021 * @param {?string} text | 1021 * @param {?string} text |
| 1022 * @param {number} barX | 1022 * @param {number} barX |
| 1023 * @param {number} barY | 1023 * @param {number} barY |
| 1024 * @param {number} barWidth | 1024 * @param {number} barWidth |
| 1025 * @param {number} barHeight | 1025 * @param {number} barHeight |
| 1026 * @param {number} unclippedBarX | 1026 * @param {number} unclippedBarX |
| 1027 * @param {number} timeToPixels | 1027 * @param {number} timeToPixelRatio |
| 1028 * @return {boolean} | 1028 * @return {boolean} |
| 1029 */ | 1029 */ |
| 1030 decorateEntry(index, context, text, barX, barY, barWidth, barHeight, unclipped
BarX, timeToPixels) { | 1030 decorateEntry(index, context, text, barX, barY, barWidth, barHeight, unclipped
BarX, timeToPixelRatio) { |
| 1031 var minTransferWidthPx = 2; | 1031 const request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (t
his._requests[index]); |
| 1032 var request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (thi
s._requests[index]); | 1032 if (!request.timing) |
| 1033 var startTime = request.startTime; | 1033 return false; |
| 1034 var endTime = request.endTime; | 1034 |
| 1035 var lastX = unclippedBarX; | 1035 /** |
| 1036 context.fillStyle = 'hsla(0, 0%, 100%, 0.6)'; | 1036 * @param {number} time |
| 1037 for (var i = 0; i < request.children.length; ++i) { | 1037 * @return {number} |
| 1038 var event = request.children[i]; | 1038 */ |
| 1039 var t0 = event.startTime; | 1039 function timeToPixel(time) { |
| 1040 var t1 = event.endTime || event.startTime; | 1040 return Math.floor(unclippedBarX + (time - startTime) * timeToPixelRatio); |
| 1041 var x0 = Math.floor(unclippedBarX + (t0 - startTime) * timeToPixels - 1); | |
| 1042 var x1 = Math.floor(unclippedBarX + (t1 - startTime) * timeToPixels + 1); | |
| 1043 if (x0 > lastX) | |
| 1044 context.fillRect(lastX, barY, x0 - lastX, barHeight); | |
| 1045 lastX = x1; | |
| 1046 } | 1041 } |
| 1047 var endX = unclippedBarX + (endTime - startTime) * timeToPixels; | 1042 |
| 1048 if (endX > lastX) | 1043 const minBarWidthPx = 2; |
| 1049 context.fillRect(lastX, barY, Math.min(endX - lastX, 1e5), barHeight); | 1044 const startTime = request.startTime; |
| 1045 const endTime = request.endTime; |
| 1046 const requestTime = request.timing.requestTime * 1000; |
| 1047 const sendStart = Math.max(timeToPixel(requestTime + request.timing.sendStar
t), unclippedBarX); |
| 1048 const headersEnd = Math.max(timeToPixel(requestTime + request.timing.receive
HeadersEnd), sendStart); |
| 1049 const finish = Math.max(timeToPixel(request.finishTime || endTime), headersE
nd + minBarWidthPx); |
| 1050 const end = Math.max(timeToPixel(endTime), finish); |
| 1051 |
| 1052 context.fillStyle = 'hsla(0, 100%, 100%, 0.8)'; |
| 1053 context.fillRect(sendStart + 0.5, barY + 0.5, headersEnd - sendStart - 0.5,
barHeight - 2); |
| 1054 context.fillStyle = 'white'; |
| 1055 context.fillRect(barX, barY - 0.5, sendStart - barX, barHeight); |
| 1056 context.fillRect(finish, barY - 0.5, barX + barWidth - finish, barHeight); |
| 1057 |
| 1058 /** |
| 1059 * @param {number} begin |
| 1060 * @param {number} end |
| 1061 * @param {number} y |
| 1062 */ |
| 1063 function drawTick(begin, end, y) { |
| 1064 const tickHeightPx = 6; |
| 1065 context.moveTo(begin, y - tickHeightPx / 2); |
| 1066 context.lineTo(begin, y + tickHeightPx / 2); |
| 1067 context.moveTo(begin, y); |
| 1068 context.lineTo(end, y); |
| 1069 } |
| 1070 |
| 1071 const lineWidth = window.devicePixelRatio; |
| 1072 const subpixelOffset = lineWidth & 1 ? 0.5 : 0; |
| 1073 context.lineWidth = lineWidth; |
| 1074 context.strokeStyle = '#ccc'; |
| 1075 const lineY = Math.floor(barY + barHeight / 2) + subpixelOffset; |
| 1076 const leftTick = Math.floor(unclippedBarX) + subpixelOffset; |
| 1077 drawTick(leftTick, sendStart, lineY); |
| 1078 const rightTick = end - subpixelOffset; |
| 1079 drawTick(rightTick, finish, lineY); |
| 1080 context.stroke(); |
| 1081 |
| 1050 if (typeof request.priority === 'string') { | 1082 if (typeof request.priority === 'string') { |
| 1051 var color = this._colorForPriority(request.priority); | 1083 const color = this._colorForPriority(request.priority); |
| 1052 if (color) { | 1084 if (color) { |
| 1053 context.fillStyle = 'hsl(0, 0%, 100%)'; | |
| 1054 context.fillRect(barX, barY, 4, 4); | |
| 1055 context.fillStyle = color; | 1085 context.fillStyle = color; |
| 1056 context.fillRect(barX, barY, 3, 3); | 1086 context.fillRect(sendStart + 0.5, barY + 0.5, 3.5, 3.5); |
| 1057 } | 1087 } |
| 1058 } | 1088 } |
| 1059 return false; | 1089 |
| 1090 const textStart = Math.max(sendStart, 0); |
| 1091 const textWidth = finish - textStart; |
| 1092 const minTextWidthPx = 20; |
| 1093 const textPadding = 6; |
| 1094 if (textWidth >= minTextWidthPx) { |
| 1095 const text = this.entryTitle(index); |
| 1096 if (text && text.length) { |
| 1097 context.fillStyle = '#333'; |
| 1098 const trimmedText = WebInspector.trimTextMiddle(context, text, textWidth
- 2 * textPadding); |
| 1099 const textBaseHeight = barHeight - this.textBaseline(); |
| 1100 context.fillText(trimmedText, textStart + textPadding, barY + textBaseHe
ight); |
| 1101 } |
| 1102 } |
| 1103 |
| 1104 return true; |
| 1060 } | 1105 } |
| 1061 | 1106 |
| 1062 /** | 1107 /** |
| 1063 * @override | 1108 * @override |
| 1064 * @param {number} index | 1109 * @param {number} index |
| 1065 * @return {boolean} | 1110 * @return {boolean} |
| 1066 */ | 1111 */ |
| 1067 forceDecoration(index) { | 1112 forceDecoration(index) { |
| 1068 return true; | 1113 return true; |
| 1069 } | 1114 } |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 WebInspector.TimelineFlameChartView.Selection = class { | 1480 WebInspector.TimelineFlameChartView.Selection = class { |
| 1436 /** | 1481 /** |
| 1437 * @param {!WebInspector.TimelineSelection} selection | 1482 * @param {!WebInspector.TimelineSelection} selection |
| 1438 * @param {number} entryIndex | 1483 * @param {number} entryIndex |
| 1439 */ | 1484 */ |
| 1440 constructor(selection, entryIndex) { | 1485 constructor(selection, entryIndex) { |
| 1441 this.timelineSelection = selection; | 1486 this.timelineSelection = selection; |
| 1442 this.entryIndex = entryIndex; | 1487 this.entryIndex = entryIndex; |
| 1443 } | 1488 } |
| 1444 }; | 1489 }; |
| OLD | NEW |