if possible append the measure node to the body

to prevent flickering
This commit is contained in:
Fabian Jakobs 2011-02-26 20:44:48 +01:00
commit e18c9cad9f

View file

@ -113,13 +113,17 @@ var Text = function(parentEl) {
// Note: characterWidth can be a float! // Note: characterWidth can be a float!
measureNode.innerHTML = lang.stringRepeat("Xy", n); measureNode.innerHTML = lang.stringRepeat("Xy", n);
if (document.body) {
document.body.appendChild(measureNode);
} else {
var container = this.element.parentNode; var container = this.element.parentNode;
while (!dom.hasCssClass(container, "ace_editor")) while (!dom.hasCssClass(container, "ace_editor"))
container = container.parentNode; container = container.parentNode;
container.appendChild(measureNode); container.appendChild(measureNode);
} }
}
var style = this.$measureNode.style; var style = this.$measureNode.style;
for (var prop in this.$fontStyles) { for (var prop in this.$fontStyles) {
var value = dom.computedStyle(this.element, prop); var value = dom.computedStyle(this.element, prop);