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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 23532018: Files.app: Extract the TextMeasure class to a new file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment. Created 7 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/main_scripts.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index bab9f52f63461b1926f4842ff5da24d03234bd5a..eca548ba91b6bb62dd64f189c2207d8d4ba320dd 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -70,50 +70,6 @@ var DialogType = {
};
/**
- * TextMeasure constructor.
- *
- * TextMeasure is a measure for text that returns the width of text. This
- * class has a dummy span element. When measuring the width of text, it sets
- * the text to the element and obtains the element's size by
- * getBoundingClientRect.
- *
- * @constructor
- * @param {HTMLElement} element Element that has styles of measured text. The
- * width of text is mesures like as it is rendered in this element.
- */
-var TextMeasure = function(element) {
- var doc = element.ownerDocument;
- this.dummySpan_ = doc.createElement('span');
- this.dummySpan_ = doc.getElementsByTagName('body')[0].
- appendChild(this.dummySpan_);
- this.dummySpan_.style.position = 'absolute';
- this.dummySpan_.style.visibility = 'hidden';
- var styles = window.getComputedStyle(element, '');
- var stylesToBeCopied = [
- 'fontSize',
- 'fontStyle',
- 'fontWeight',
- 'fontFamily',
- 'letterSpacing'
- ];
- for (var i = 0; i < stylesToBeCopied.length; i++) {
- this.dummySpan_.style[stylesToBeCopied[i]] = styles[stylesToBeCopied[i]];
- }
-};
-
-/**
- * Measures the widht of text.
- *
- * @param {string} text Text that is measured the width.
- * @return {number} Width of the specified text.
- */
-TextMeasure.prototype.getWidth = function(text) {
- this.dummySpan_.innerText = text;
- var rect = this.dummySpan_.getBoundingClientRect();
- return rect ? rect.width : 0;
-};
-
-/**
* @param {string} type Dialog type.
* @return {boolean} Whether the type is modal.
*/
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/main_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698