Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js

Issue 2482153003: DevTools: Depict network request timings on timeline network pane. (Closed)
Patch Set: Tweaks Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 543
544 var timeWindowRight = this._timeWindowRight; 544 var timeWindowRight = this._timeWindowRight;
545 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._timeTo Pixel; 545 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._timeTo Pixel;
546 var entryTotalTimes = timelineData.entryTotalTimes; 546 var entryTotalTimes = timelineData.entryTotalTimes;
547 var entryStartTimes = timelineData.entryStartTimes; 547 var entryStartTimes = timelineData.entryStartTimes;
548 var entryLevels = timelineData.entryLevels; 548 var entryLevels = timelineData.entryLevels;
549 549
550 var titleIndices = []; 550 var titleIndices = [];
551 var markerIndices = []; 551 var markerIndices = [];
552 var textPadding = this._dataProvider.textPadding(); 552 var textPadding = this._dataProvider.textPadding();
553 var minTextWidth = 2 * textPadding + this._measureWidth(context, '\u2026'); 553 var minTextWidth = 2 * textPadding + WebInspector.measureTextWidth(context, '\u2026');
554 var barHeight = this._barHeight; 554 var barHeight = this._barHeight;
555 var minVisibleBarLevel = Math.max(this._visibleLevelOffsets.upperBound(top) - 1, 0); 555 var minVisibleBarLevel = Math.max(this._visibleLevelOffsets.upperBound(top) - 1, 0);
556 556
557 /** @type {!Map<string, !Array<number>>} */ 557 /** @type {!Map<string, !Array<number>>} */
558 var colorBuckets = new Map(); 558 var colorBuckets = new Map();
559 for (var level = minVisibleBarLevel; level < this._dataProvider.maxStackDept h(); ++level) { 559 for (var level = minVisibleBarLevel; level < this._dataProvider.maxStackDept h(); ++level) {
560 if (this._levelToHeight(level) > top + height) 560 if (this._levelToHeight(level) > top + height)
561 break; 561 break;
562 if (!this._visibleLevels[level]) 562 if (!this._visibleLevels[level])
563 continue; 563 continue;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 var entryIndex = titleIndices[i]; 639 var entryIndex = titleIndices[i];
640 var entryStartTime = entryStartTimes[entryIndex]; 640 var entryStartTime = entryStartTimes[entryIndex];
641 var barX = this._timeToPositionClipped(entryStartTime); 641 var barX = this._timeToPositionClipped(entryStartTime);
642 var barRight = Math.min(this._timeToPositionClipped(entryStartTime + entry TotalTimes[entryIndex]), width) + 1; 642 var barRight = Math.min(this._timeToPositionClipped(entryStartTime + entry TotalTimes[entryIndex]), width) + 1;
643 var barWidth = barRight - barX; 643 var barWidth = barRight - barX;
644 var barLevel = entryLevels[entryIndex]; 644 var barLevel = entryLevels[entryIndex];
645 var barY = this._levelToHeight(barLevel); 645 var barY = this._levelToHeight(barLevel);
646 var text = this._dataProvider.entryTitle(entryIndex); 646 var text = this._dataProvider.entryTitle(entryIndex);
647 if (text && text.length) { 647 if (text && text.length) {
648 context.font = this._dataProvider.entryFont(entryIndex) || defaultFont; 648 context.font = this._dataProvider.entryFont(entryIndex) || defaultFont;
649 text = this._prepareText(context, text, barWidth - 2 * textPadding); 649 text = WebInspector.trimTextMiddle(context, text, barWidth - 2 * textPad ding);
650 } 650 }
651 var unclippedBarX = this._timeToPosition(entryStartTime); 651 var unclippedBarX = this._timeToPosition(entryStartTime);
652 if (this._dataProvider.decorateEntry( 652 if (this._dataProvider.decorateEntry(
653 entryIndex, context, text, barX, barY, barWidth, barHeight, unclip pedBarX, this._timeToPixel)) 653 entryIndex, context, text, barX, barY, barWidth, barHeight, unclip pedBarX, this._timeToPixel))
654 continue; 654 continue;
655 if (!text || !text.length) 655 if (!text || !text.length)
656 continue; 656 continue;
657 context.fillStyle = this._dataProvider.textColor(entryIndex); 657 context.fillStyle = this._dataProvider.textColor(entryIndex);
658 context.fillText(text, barX + textPadding, barY + textBaseHeight); 658 context.fillText(text, barX + textPadding, barY + textBaseHeight);
659 } 659 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 } 815 }
816 } 816 }
817 } 817 }
818 818
819 /** 819 /**
820 * @param {!CanvasRenderingContext2D} context 820 * @param {!CanvasRenderingContext2D} context
821 * @param {!WebInspector.FlameChart.Group} group 821 * @param {!WebInspector.FlameChart.Group} group
822 * @return {number} 822 * @return {number}
823 */ 823 */
824 _labelWidthForGroup(context, group) { 824 _labelWidthForGroup(context, group) {
825 return this._measureWidth(context, group.name) + this._expansionArrowIndent * (group.style.nestingLevel + 1) + 825 return WebInspector.measureTextWidth(context, group.name) + this._expansionA rrowIndent * (group.style.nestingLevel + 1) +
826 2 * this._headerLabelXPadding; 826 2 * this._headerLabelXPadding;
827 } 827 }
828 828
829 /** 829 /**
830 * @param {number} y 830 * @param {number} y
831 * @param {number} startLevel 831 * @param {number} startLevel
832 * @param {number} endLevel 832 * @param {number} endLevel
833 */ 833 */
834 _drawCollapsedOverviewForGroup(y, startLevel, endLevel) { 834 _drawCollapsedOverviewForGroup(y, startLevel, endLevel) {
835 var range = new WebInspector.SegmentedRange(mergeCallback); 835 var range = new WebInspector.SegmentedRange(mergeCallback);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 } 1130 }
1131 1131
1132 /** 1132 /**
1133 * @param {number} level 1133 * @param {number} level
1134 * @return {number} 1134 * @return {number}
1135 */ 1135 */
1136 _levelToHeight(level) { 1136 _levelToHeight(level) {
1137 return this._visibleLevelOffsets[level]; 1137 return this._visibleLevelOffsets[level];
1138 } 1138 }
1139 1139
1140 /**
1141 * @param {!CanvasRenderingContext2D} context
1142 * @param {string} text
1143 * @param {number} maxWidth
1144 * @return {string}
1145 */
1146 _prepareText(context, text, maxWidth) {
1147 var /** @const */ maxLength = 200;
1148 if (maxWidth <= 10)
1149 return '';
1150 if (text.length > maxLength)
1151 text = text.trimMiddle(maxLength);
1152 var textWidth = this._measureWidth(context, text);
1153 if (textWidth <= maxWidth)
1154 return text;
1155
1156 var l = 0;
1157 var r = text.length;
1158 var lv = 0;
1159 var rv = textWidth;
1160 while (l < r && lv !== rv && lv !== maxWidth) {
1161 var m = Math.ceil(l + (r - l) * (maxWidth - lv) / (rv - lv));
1162 var mv = this._measureWidth(context, text.trimMiddle(m));
1163 if (mv <= maxWidth) {
1164 l = m;
1165 lv = mv;
1166 } else {
1167 r = m - 1;
1168 rv = mv;
1169 }
1170 }
1171 text = text.trimMiddle(l);
1172 return text !== '\u2026' ? text : '';
1173 }
1174
1175 /**
1176 * @param {!CanvasRenderingContext2D} context
1177 * @param {string} text
1178 * @return {number}
1179 */
1180 _measureWidth(context, text) {
1181 var /** @const */ maxCacheableLength = 200;
1182 if (text.length > maxCacheableLength)
1183 return context.measureText(text).width;
1184
1185 var font = context.font;
1186 var textWidths = this._textWidth.get(font);
1187 if (!textWidths) {
1188 textWidths = new Map();
1189 this._textWidth.set(font, textWidths);
1190 }
1191 var width = textWidths.get(text);
1192 if (!width) {
1193 width = context.measureText(text).width;
1194 textWidths.set(text, width);
1195 }
1196 return width;
1197 }
1198
1199 _updateBoundaries() { 1140 _updateBoundaries() {
1200 this._totalTime = this._dataProvider.totalTime(); 1141 this._totalTime = this._dataProvider.totalTime();
1201 this._minimumBoundary = this._dataProvider.minimumBoundary(); 1142 this._minimumBoundary = this._dataProvider.minimumBoundary();
1202 1143
1203 var windowWidth = 1; 1144 var windowWidth = 1;
1204 if (this._timeWindowRight !== Infinity) { 1145 if (this._timeWindowRight !== Infinity) {
1205 this._windowLeft = (this._timeWindowLeft - this._minimumBoundary) / this._ totalTime; 1146 this._windowLeft = (this._timeWindowLeft - this._minimumBoundary) / this._ totalTime;
1206 this._windowRight = (this._timeWindowRight - this._minimumBoundary) / this ._totalTime; 1147 this._windowRight = (this._timeWindowRight - this._minimumBoundary) / this ._totalTime;
1207 windowWidth = this._windowRight - this._windowLeft; 1148 windowWidth = this._windowRight - this._windowLeft;
1208 } else if (this._timeWindowLeft === Infinity) { 1149 } else if (this._timeWindowLeft === Infinity) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 } 1545 }
1605 1546
1606 /** 1547 /**
1607 * @override 1548 * @override
1608 * @return {number} 1549 * @return {number}
1609 */ 1550 */
1610 boundarySpan() { 1551 boundarySpan() {
1611 return this._maximumBoundaries - this._minimumBoundaries; 1552 return this._maximumBoundaries - this._minimumBoundaries;
1612 } 1553 }
1613 }; 1554 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698