| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 <link rel="import" href="/tracing/base/base.html"> | 7 <link rel="import" href="/tracing/base/base.html"> |
| 8 <script> | 8 <script> |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 if (!elidedDictForPixWidth) { | 55 if (!elidedDictForPixWidth) { |
| 56 elidedDict.set(pixWidth, new Map()); | 56 elidedDict.set(pixWidth, new Map()); |
| 57 elidedDictForPixWidth = elidedDict.get(pixWidth); | 57 elidedDictForPixWidth = elidedDict.get(pixWidth); |
| 58 } | 58 } |
| 59 | 59 |
| 60 var stringWidthPair = elidedDictForPixWidth.get(sliceDuration); | 60 var stringWidthPair = elidedDictForPixWidth.get(sliceDuration); |
| 61 if (stringWidthPair === undefined) { | 61 if (stringWidthPair === undefined) { |
| 62 var newtitle = title; | 62 var newtitle = title; |
| 63 var elided = false; | 63 var elided = false; |
| 64 while (this.labelWidthWorld(ctx, newtitle, pixWidth) > sliceDuration) { | 64 while (this.labelWidthWorld(ctx, newtitle, pixWidth) > sliceDuration) { |
| 65 if (newtitle.length * 0.75 < 1) | 65 if (newtitle.length * 0.75 < 1) break; |
| 66 break; | |
| 67 newtitle = newtitle.substring(0, newtitle.length * 0.75); | 66 newtitle = newtitle.substring(0, newtitle.length * 0.75); |
| 68 elided = true; | 67 elided = true; |
| 69 } | 68 } |
| 70 | 69 |
| 71 if (elided && newtitle.length > 3) | 70 if (elided && newtitle.length > 3) { |
| 72 newtitle = newtitle.substring(0, newtitle.length - 3) + '...'; | 71 newtitle = newtitle.substring(0, newtitle.length - 3) + '...'; |
| 72 } |
| 73 | 73 |
| 74 stringWidthPair = new ElidedStringWidthPair( | 74 stringWidthPair = new ElidedStringWidthPair( |
| 75 newtitle, this.labelWidth(ctx, newtitle)); | 75 newtitle, this.labelWidth(ctx, newtitle)); |
| 76 elidedDictForPixWidth.set(sliceDuration, stringWidthPair); | 76 elidedDictForPixWidth.set(sliceDuration, stringWidthPair); |
| 77 } | 77 } |
| 78 return stringWidthPair; | 78 return stringWidthPair; |
| 79 }, | 79 }, |
| 80 | 80 |
| 81 quickMeasureText_: function(ctx, text) { | 81 quickMeasureText_: function(ctx, text) { |
| 82 var w = this.textWidthMap.get(text); | 82 var w = this.textWidthMap.get(text); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 function ElidedStringWidthPair(string, width) { | 104 function ElidedStringWidthPair(string, width) { |
| 105 this.string = string; | 105 this.string = string; |
| 106 this.width = width; | 106 this.width = width; |
| 107 } | 107 } |
| 108 | 108 |
| 109 return { | 109 return { |
| 110 ElidedTitleCache, | 110 ElidedTitleCache, |
| 111 }; | 111 }; |
| 112 }); | 112 }); |
| 113 </script> | 113 </script> |
| OLD | NEW |