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:
parent
45a7be6b43
commit
817ff7ce5e
7 changed files with 24 additions and 23 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ var TextInput = function(parentNode, host) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (useragent.isIE) {
|
if (useragent.isIE) {
|
||||||
event.addListener(text, "beforecopy", function(e) {
|
event.addListener(text, "beforecopy", function(e) {
|
||||||
var copyText = host.getCopyText();
|
var copyText = host.getCopyText();
|
||||||
if(copyText)
|
if(copyText)
|
||||||
clipboardData.setData("Text", copyText);
|
clipboardData.setData("Text", copyText);
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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, "");
|
||||||
|
|
@ -73,12 +73,12 @@ var Gutter = function(parentEl) {
|
||||||
|
|
||||||
this.setAnnotations = function(annotations) {
|
this.setAnnotations = function(annotations) {
|
||||||
// iterate over sparse array
|
// iterate over sparse array
|
||||||
this.$annotations = [];
|
this.$annotations = [];
|
||||||
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
||||||
var rowAnnotations = annotations[row];
|
var rowAnnotations = annotations[row];
|
||||||
if (!rowAnnotations)
|
if (!rowAnnotations)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var rowInfo = this.$annotations[row] = {
|
var rowInfo = this.$annotations[row] = {
|
||||||
text: []
|
text: []
|
||||||
};
|
};
|
||||||
|
|
@ -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";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ var Marker = function(parentEl) {
|
||||||
this.setSession = function(session) {
|
this.setSession = function(session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setMarkers = function(markers) {
|
this.setMarkers = function(markers) {
|
||||||
this.markers = markers;
|
this.markers = markers;
|
||||||
};
|
};
|
||||||
|
|
@ -65,7 +65,7 @@ var Marker = function(parentEl) {
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
var html = [];
|
var html = [];
|
||||||
for ( var key in this.markers) {
|
for ( var key in this.markers) {
|
||||||
var marker = this.markers[key];
|
var marker = this.markers[key];
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ var Marker = function(parentEl) {
|
||||||
|
|
||||||
if (marker.renderer) {
|
if (marker.renderer) {
|
||||||
var top = this.$getTop(range.start.row, config);
|
var top = this.$getTop(range.start.row, config);
|
||||||
var left = Math.round(range.start.column * config.characterWidth);
|
var left = Math.round(range.start.column * config.characterWidth);
|
||||||
marker.renderer(html, range, left, top, config);
|
marker.renderer(html, range, left, top, config);
|
||||||
}
|
}
|
||||||
else if (range.isMultiLine()) {
|
else if (range.isMultiLine()) {
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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 " "
|
return " ";
|
||||||
}
|
}
|
||||||
} 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;
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ var TextileHighlightRules = function()
|
||||||
var phraseModifiers = lang.arrayToMap(
|
var phraseModifiers = lang.arrayToMap(
|
||||||
("_|*|__|**|??|-|+|^|%|@").split("|")
|
("_|*|__|**|??|-|+|^|%|@").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var blockModifiers = lang.arrayToMap(
|
var blockModifiers = lang.arrayToMap(
|
||||||
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
|
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
|
||||||
);
|
);
|
||||||
|
|
@ -56,7 +56,7 @@ var TextileHighlightRules = function()
|
||||||
("-|--|(tm)|(r)|(c)").split("|")
|
("-|--|(tm)|(r)|(c)").split("|")
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start" : [
|
"start" : [
|
||||||
{
|
{
|
||||||
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue