Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js |
| index 69db11cb23998f8bce90cacd5f99e0517b845656..471f3738be4d3a2f74a1c842e081c894b8eb182b 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js |
| @@ -1212,7 +1212,6 @@ WebInspector.FlameChart.prototype = { |
| context.font = this._dataProvider.entryFont(entryIndex); |
| text = this._prepareText(context, text, barWidth - 2 * textPadding); |
| } |
| - |
| if (this._dataProvider.decorateEntry(entryIndex, context, text, barX, barY, barWidth, barHeight)) |
| continue; |
| if (!text || !text.length) |
| @@ -1447,27 +1446,38 @@ WebInspector.FlameChart.prototype = { |
| /** |
| * @param {!CanvasRenderingContext2D} context |
| - * @param {string} title |
| - * @param {number} maxSize |
| + * @param {string} text |
| + * @param {number} maxWidth |
| * @return {string} |
| */ |
| - _prepareText: function(context, title, maxSize) |
| - { |
| - var titleWidth = this._measureWidth(context, title); |
| - if (maxSize >= titleWidth) |
| - return title; |
| - |
| - var l = 2; |
| - var r = title.length; |
| - while (l < r) { |
| - var m = (l + r) >> 1; |
| - if (this._measureWidth(context, title.trimMiddle(m)) <= maxSize) |
| - l = m + 1; |
| - else |
| - r = m; |
| + _prepareText: function(context, text, maxWidth) |
| + { |
| + var /** @const */ maxLength = 200; |
| + if (maxWidth <= 10) |
| + return ""; |
| + if (text.length > maxLength) |
| + text = text.trimMiddle(maxLength); |
| + var textWidth = this._measureWidth(context, text); |
| + if (textWidth <= maxWidth) |
| + return text; |
| + |
| + var l = 0; |
| + var r = text.length; |
| + var lv = 0; |
| + var rv = textWidth; |
| + while (l < r && lv !== rv && lv !== maxWidth) { |
| + var m = Math.ceil(l + (r - l) * (maxWidth - lv) / (rv - lv)); |
| + var mv = this._measureWidth(context, text.trimMiddle(m)); |
| + if (mv <= maxWidth) { |
| + l = m; |
| + lv = mv; |
| + } else { |
| + r = m - 1; |
| + rv = mv; |
| + } |
| } |
| - title = title.trimMiddle(r - 1); |
| - return title !== "\u2026" ? title : ""; |
| + text = text.trimMiddle(l); |
| + return text !== "\u2026" ? text : ""; |
| }, |
| /** |
| @@ -1477,7 +1487,7 @@ WebInspector.FlameChart.prototype = { |
| */ |
| _measureWidth: function(context, text) |
| { |
| - if (text.length > 20) |
| + if (text.length > 200) |
|
caseq
2015/12/03 00:01:46
extract constant?
alph
2015/12/03 00:14:26
Done.
|
| return context.measureText(text).width; |
| var font = context.font; |