From 0caee61b22ad0391edaa36185f6e39cc12d07fc6 Mon Sep 17 00:00:00 2001 From: mikedeboer Date: Thu, 2 Feb 2012 11:22:46 +0100 Subject: [PATCH] fixed font size flicker between show/hide of editor instances --- build/src/ace-uncompressed.js | 7 ++++++- lib/ace/layer/text.js | 5 +++++ lib/ace/virtual_renderer.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build/src/ace-uncompressed.js b/build/src/ace-uncompressed.js index 52fa9e95..6b742739 100644 --- a/build/src/ace-uncompressed.js +++ b/build/src/ace-uncompressed.js @@ -11975,6 +11975,7 @@ var VirtualRenderer = function(container, theme) { // full if (changes & this.CHANGE_FULL) { + this.$textLayer.checkForSizeChanges(); this.$textLayer.update(this.layerConfig); if (this.showGutter) this.$gutterLayer.update(this.layerConfig); @@ -12950,6 +12951,11 @@ var Text = function(parentEl) { } + // Size and width can be null if the editor is not visible or + // detached from the document + if (!this.element.offsetWidth) + return null; + var style = this.$measureNode.style; var computedStyle = dom.computedStyle(this.element); for (var prop in this.$fontStyles) @@ -12964,7 +12970,6 @@ var Text = function(parentEl) { // detached from the document if (size.width == 0 && size.height == 0) return null; - return size; }; diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 69e917ae..6e3509bf 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -132,6 +132,11 @@ var Text = function(parentEl) { } } + + // Size and width can be null if the editor is not visible or + // detached from the document + if (!this.element.offsetWidth) + return null; var style = this.$measureNode.style; var computedStyle = dom.computedStyle(this.element); diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 2640c898..925e7b4a 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -423,6 +423,7 @@ var VirtualRenderer = function(container, theme) { // full if (changes & this.CHANGE_FULL) { + this.$textLayer.checkForSizeChanges(); this.$textLayer.update(this.layerConfig); if (this.showGutter) this.$gutterLayer.update(this.layerConfig);