| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * TextMeasure constructor. | 8 * TextMeasure constructor. |
| 9 * | 9 * |
| 10 * TextMeasure is a measure for text that returns the width of text. This | 10 * TextMeasure is a measure for text that returns the width of text. This |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 * Measures the width of text. | 41 * Measures the width of text. |
| 42 * | 42 * |
| 43 * @param {string} text Text that is measured the width. | 43 * @param {string} text Text that is measured the width. |
| 44 * @return {number} Width of the specified text. | 44 * @return {number} Width of the specified text. |
| 45 */ | 45 */ |
| 46 TextMeasure.prototype.getWidth = function(text) { | 46 TextMeasure.prototype.getWidth = function(text) { |
| 47 this.dummySpan_.innerText = text; | 47 this.dummySpan_.innerText = text; |
| 48 var rect = this.dummySpan_.getBoundingClientRect(); | 48 var rect = this.dummySpan_.getBoundingClientRect(); |
| 49 return rect ? rect.width : 0; | 49 return rect ? rect.width : 0; |
| 50 }; | 50 }; |
| OLD | NEW |