Commit 4115037d authored by hirono@chromium.org's avatar hirono@chromium.org

Files.app: Move the position of dummy element for measuring the size of text.

BUG=392981
TEST=manually

Review URL: https://codereview.chromium.org/419063004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285536 0039d316-1c4b-4281-b951-d872f2087c98
parent cb2440f5
......@@ -3,6 +3,7 @@
* found in the LICENSE file. */
/* The order of z-index:
* - -1: text-measure
* - 2: drag-selection-border
* - 3: preview-panel
* - 500: scrollbar
......@@ -1964,3 +1965,11 @@ menuitem#thumbnail-view[lead]:not([disabled]) {
#progress-center li:not(.cancelable) button.cancel {
visibility: hidden;
}
.text-measure {
pointer-events: none;
position: absolute;
top: 0;
visibility: hidden;
z-index: -1;
}
......@@ -17,26 +17,29 @@
* width of text is measures 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';
this.dummySpan_ = createElementWithClassName('span', 'text-measure');
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]];
for (var i = 0; i < TextMeasure.STYLES_TO_BE_COPYED.length; i++) {
var name = TextMeasure.STYLES_TO_BE_COPYED[i];
this.dummySpan_.style[name] = styles[name];
}
element.ownerDocument.body.appendChild(this.dummySpan_);
Object.seal(this);
};
/**
* Style names to be copied to the measured dummy span.
* @type {Array.<String>}
* @const
*/
TextMeasure.STYLES_TO_BE_COPYED = Object.freeze([
'fontSize',
'fontStyle',
'fontWeight',
'fontFamily',
'letterSpacing'
]);
/**
* Measures the width of text.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment