position textarea with bottom/right since otherwise firefox 21+ scrolls

editor out of view when textarea.focus is called
This commit is contained in:
nightwing 2013-01-25 18:39:18 +04:00
commit d437b63d19
3 changed files with 18 additions and 17 deletions

View file

@ -98,15 +98,17 @@
resize: none; resize: none;
outline: none; outline: none;
overflow: hidden; overflow: hidden;
font: inherit;
} }
.ace_text-input.ace_composition { .ace_text-input.ace_composition {
background: #fff; background: #f8f8f8;
color: #000; color: #111;
z-index: 1000; z-index: 1000;
opacity: 1; opacity: 1;
border: solid lightgray 1px; border: solid lightgray 1px;
margin: -1px margin: -1px;
padding: 0 1px;
} }
.ace_layer { .ace_layer {

View file

@ -51,7 +51,7 @@ var TextInput = function(parentNode, host) {
text.autocapitalize = "off"; text.autocapitalize = "off";
text.spellcheck = false; text.spellcheck = false;
text.style.top = "-2em"; text.style.bottom = "-2em";
parentNode.insertBefore(text, parentNode.firstChild); parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = "\x01\x01"; var PLACEHOLDER = "\x01\x01";
@ -350,12 +350,10 @@ var TextInput = function(parentNode, host) {
host.onCompositionEnd(); host.onCompositionEnd();
}; };
var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
event.addListener(text, "compositionstart", onCompositionStart); event.addListener(text, "compositionstart", onCompositionStart);
if (useragent.isGecko) event.addListener(text, useragent.isGecko ? "text" : "keyup", function(){syncComposition.schedule()});
event.addListener(text, "text", onCompositionUpdate);
else
event.addListener(text, "keyup", onCompositionUpdate);
event.addListener(text, "compositionend", onCompositionEnd); event.addListener(text, "compositionend", onCompositionEnd);
this.getElement = function() { this.getElement = function() {

View file

@ -566,28 +566,29 @@ var VirtualRenderer = function(container, theme) {
this.$moveTextAreaToCursor = function() { this.$moveTextAreaToCursor = function() {
if (!this.$keepTextAreaAtCursor) if (!this.$keepTextAreaAtCursor)
return; return;
var config = this.layerConfig;
var posTop = this.$cursorLayer.$pixelPos.top; var posTop = this.$cursorLayer.$pixelPos.top;
var posLeft = this.$cursorLayer.$pixelPos.left; var posLeft = this.$cursorLayer.$pixelPos.left;
posTop -= this.layerConfig.offset; posTop -= config.offset;
if (posTop < 0 || posTop > this.layerConfig.height - this.lineHeight) if (posTop < 0 || posTop > config.height - this.lineHeight)
return; return;
var w = this.characterWidth; var w = this.characterWidth;
if (this.$composition) if (this.$composition) {
w += this.textarea.scrollWidth; var val = this.textarea.value.replace(/^\x01+/, "");
w *= this.session.$getStringScreenWidth(val)[0];
}
posLeft -= this.scrollLeft; posLeft -= this.scrollLeft;
if (posLeft > this.$size.scrollerWidth - w) if (posLeft > this.$size.scrollerWidth - w)
posLeft = this.$size.scrollerWidth - w; posLeft = this.$size.scrollerWidth - w;
if (this.showGutter) posLeft -= this.scrollBar.width;
posLeft += this.$gutterLayer.gutterWidth;
this.textarea.style.height = this.lineHeight + "px"; this.textarea.style.height = this.lineHeight + "px";
this.textarea.style.width = w + "px"; this.textarea.style.width = w + "px";
this.textarea.style.left = posLeft + "px"; this.textarea.style.right = this.$size.scrollerWidth - posLeft - w + "px";
this.textarea.style.top = posTop - 1 + "px"; this.textarea.style.bottom = this.$size.height - posTop - this.lineHeight + "px";
}; };
/** /**