Merge pull request #712 from nightwing/subpixel

Subpixel positioning
This commit is contained in:
Fabian Jakobs 2012-04-11 10:04:51 -07:00
commit 72ca7d98d5
3 changed files with 50 additions and 10 deletions

View file

@ -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");
@ -113,7 +113,7 @@ var Text = function(parentEl) {
style.left = style.top = (-n * 40) + "px";
style.visibility = "hidden";
style.position = "absolute";
style.position = "fixed";
style.overflow = "visible";
style.whiteSpace = "nowrap";
@ -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,46 @@ 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 (container && !dom.hasCssClass(container, "ace_editor"))
container = container.parentNode;
if (!container)
return this.$measureNode = null;
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;

View file

@ -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;
};

View file

@ -22,21 +22,21 @@ var tests = [
require("ace/layer/text_test"),
require("ace/lib/event_emitter_test"),
require("ace/mode/coffee/parser_test"),
require("ace/mode/coffee_tokenizer_test"),
require("ace/mode/coffee_highlight_rules_test"),
require("ace/mode/coldfusion_test"),
require("ace/mode/css_test"),
require("ace/mode/css_tokenizer_test"),
require("ace/mode/css_highlight_rules_test"),
require("ace/mode/css_worker"),
require("ace/mode/html_test"),
require("ace/mode/html_tokenizer_test"),
require("ace/mode/html_highlight_rules_test"),
require("ace/mode/javascript_test"),
require("ace/mode/javascript_tokenizer_test"),
require("ace/mode/javascript_highlight_rules_test"),
require("ace/mode/javascript_worker_test"),
require("ace/mode/python_test"),
require("ace/mode/ruby_tokenizer_test"),
require("ace/mode/ruby_highlight_rules_test"),
require("ace/mode/text_test"),
require("ace/mode/xml_test"),
require("ace/mode/xml_tokenizer_test"),
require("ace/mode/xml_highlight_rules_test"),
require("ace/mode/folding/cstyle_test"),
require("ace/mode/folding/html_test"),
require("ace/mode/folding/pythonic_test"),