diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 6e3509bf..56dab2fa 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -103,7 +103,7 @@ var Text = function(parentEl) { lineHeight : 1 }; - this.$measureSizes = function() { + this.$measureSizes = useragent.isIE || useragent.isOldGecko ? function() { var n = 1000; if (!this.$measureNode) { var measureNode = this.$measureNode = dom.createElement("div"); @@ -130,7 +130,6 @@ var Text = function(parentEl) { container = container.parentNode; container.appendChild(measureNode); } - } // Size and width can be null if the editor is not visible or @@ -150,7 +149,42 @@ var Text = function(parentEl) { // Size and width can be null if the editor is not visible or // detached from the document - if (size.width == 0 && size.height == 0) + if (size.width == 0 || size.height == 0) + return null; + + return size; + } + : function() { + if (!this.$measureNode) { + var measureNode = this.$measureNode = dom.createElement("div"); + var style = measureNode.style; + + style.width = style.height = "auto"; + style.left = style.top = -100 + "px"; + + style.visibility = "hidden"; + style.position = "fixed"; + style.overflow = "visible"; + style.whiteSpace = "nowrap"; + + measureNode.innerHTML = "X"; + + var container = this.element.parentNode; + while (!dom.hasCssClass(container, "ace_editor")) + container = container.parentNode; + container.appendChild(measureNode); + } + + var rect = this.$measureNode.getBoundingClientRect(); + + var size = { + height: rect.height, + width: rect.width + }; + + // Size and width can be null if the editor is not visible or + // detached from the document + if (size.width == 0 || size.height == 0) return null; return size; diff --git a/lib/ace/scrollbar.js b/lib/ace/scrollbar.js index 27b83fee..0bc7e675 100644 --- a/lib/ace/scrollbar.js +++ b/lib/ace/scrollbar.js @@ -83,6 +83,8 @@ var ScrollBar = function(parent) { this.inner.style.height = height + "px"; }; + // TODO: on chrome 17+ after for small zoom levels after this function + // this.element.scrollTop != scrollTop which makes page to scroll up. this.setScrollTop = function(scrollTop) { this.element.scrollTop = scrollTop; };