fix setInnerHtml to work without side effects, and introduce rebuildWith to have perf gains, also fix some warnings in the code in related files

This commit is contained in:
Joe Walker 2011-04-07 16:27:09 +01:00
commit 817ff7ce5e
7 changed files with 24 additions and 23 deletions

View file

@ -213,7 +213,7 @@ StateHandler.prototype = {
return r; return r;
} }
} };
/** /**
* This is a useful matching function and therefore is defined here so that * This is a useful matching function and therefore is defined here so that

View file

@ -178,7 +178,7 @@ var TextInput = function(parentNode, host) {
clipboardData.setData("Text", copyText); clipboardData.setData("Text", copyText);
host.onCut(); host.onCut();
} }
event.preventDefault(e) event.preventDefault(e);
} }
}); });
} }
@ -224,12 +224,12 @@ var TextInput = function(parentNode, host) {
if(!tempStyle) if(!tempStyle)
tempStyle = text.style.cssText; tempStyle = text.style.cssText;
text.style.cssText = 'position:fixed; z-index:1000;' + text.style.cssText = 'position:fixed; z-index:1000;' +
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;' 'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;';
} }
if (isEmpty) if (isEmpty)
text.value=''; text.value='';
} };
this.onContextMenuClose = function(){ this.onContextMenuClose = function(){
setTimeout(function () { setTimeout(function () {
@ -239,7 +239,7 @@ var TextInput = function(parentNode, host) {
} }
sendText(); sendText();
}, 0); }, 0);
} };
}; };
exports.TextInput = TextInput; exports.TextInput = TextInput;

View file

@ -61,7 +61,7 @@ var Gutter = function(parentEl) {
if (!this.$decorations[row]) if (!this.$decorations[row])
this.$decorations[row] = ""; this.$decorations[row] = "";
this.$decorations[row] += " ace_" + className; this.$decorations[row] += " ace_" + className;
} };
this.removeGutterDecoration = function(row, className){ this.removeGutterDecoration = function(row, className){
this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, ""); this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, "");
@ -112,7 +112,8 @@ var Gutter = function(parentEl) {
"' title='", annotation.text.join("\n"), "' title='", annotation.text.join("\n"),
"' style='height:", this.session.getRowHeight(config, i), "px;'>", (i+1), "</div>"); "' style='height:", this.session.getRowHeight(config, i), "px;'>", (i+1), "</div>");
} }
this.element = dom.setInnerHtml(this.element, html.join(""));
this.element = dom.rebuildWith(this.element, html.join(""));
this.element.style.height = config.minHeight + "px"; this.element.style.height = config.minHeight + "px";
}; };

View file

@ -90,7 +90,7 @@ var Marker = function(parentEl) {
this.drawSingleLineMarker(html, range, marker.clazz, config); this.drawSingleLineMarker(html, range, marker.clazz, config);
} }
} }
this.element = dom.setInnerHtml(this.element, html.join("")); this.element = dom.rebuildWith(this.element, html.join(""));
}; };
this.$getTop = function(row, layerConfig) { this.$getTop = function(row, layerConfig) {

View file

@ -199,7 +199,7 @@ var Text = function(parentEl) {
var html = []; var html = [];
this.$renderLine(html, i, tokens[i-first].tokens); this.$renderLine(html, i, tokens[i-first].tokens);
lineElement = dom.setInnerHtml(lineElement, html.join("")); lineElement = dom.rebuildWith(lineElement, html.join(""));
lineElement.style.height = lineElement.style.height =
this.session.getRowHeight(config, i) + "px"; this.session.getRowHeight(config, i) + "px";
} }
@ -253,7 +253,7 @@ var Text = function(parentEl) {
var html = []; var html = [];
if (tokens.length > row-firstRow) if (tokens.length > row-firstRow)
this.$renderLine(html, row, tokens[row-firstRow].tokens); this.$renderLine(html, row, tokens[row-firstRow].tokens);
// don't use setInnerHtml since we are working with an empty DIV // don't use dom.rebuildWith since we are working with an empty DIV
lineEl.innerHTML = html.join(""); lineEl.innerHTML = html.join("");
fragment.appendChild(lineEl); fragment.appendChild(lineEl);
} }
@ -265,7 +265,7 @@ var Text = function(parentEl) {
this.config = config; this.config = config;
var html = []; var html = [];
var tokens = this.tokenizer.getTokens(config.firstRow, config.lastRow) var tokens = this.tokenizer.getTokens(config.firstRow, config.lastRow);
var fragment = this.$renderLinesFragment(config, config.firstRow, config.lastRow); var fragment = this.$renderLinesFragment(config, config.firstRow, config.lastRow);
// Clear the current content of the element and add the rendered fragment. // Clear the current content of the element and add the rendered fragment.
@ -303,11 +303,11 @@ var Text = function(parentEl) {
var space = new Array(c.length+1).join(self.SPACE_CHAR); var space = new Array(c.length+1).join(self.SPACE_CHAR);
return "<span class='ace_invisible'>" + space + "</span>"; return "<span class='ace_invisible'>" + space + "</span>";
} else { } else {
return "&#160;" return "&#160;";
} }
} else { } else {
screenColumn += 1; screenColumn += 1;
return "<span class='ace_cjk' style='width:" + (characterWidth * 2) + "px'>" + c + "</span>" return "<span class='ace_cjk' style='width:" + (characterWidth * 2) + "px'>" + c + "</span>";
} }
}); });
screenColumn += value.length; screenColumn += value.length;

View file

@ -77,7 +77,7 @@ var TextileHighlightRules = function()
{ {
token : "keyword", token : "keyword",
regex : "\\. ", regex : "\\. ",
next : "start", next : "start"
}, },
{ {
token : "keyword", token : "keyword",

@ -1 +1 @@
Subproject commit 7a14c62f84cf51e83a31b14d9a79f875bcabeacc Subproject commit 5ab8377de0c2b6bf31e4295e5bb9288cb943e8e8