in lib/ace/virtual_renderer.js [822:959]
this.$renderChanges = function(changes, force) {
if (this.$changes) {
changes |= this.$changes;
this.$changes = 0;
}
if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
this.$changes |= changes;
return;
}
if (this.$size.$dirty) {
this.$changes |= changes;
return this.onResize(true);
}
if (!this.lineHeight) {
this.$textLayer.checkForSizeChanges();
}
// this.$logChanges(changes);
this._signal("beforeRender", changes);
if (this.session && this.session.$bidiHandler)
this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);
var config = this.layerConfig;
// text, scrolling and resize changes can cause the view port size to change
if (changes & this.CHANGE_FULL ||
changes & this.CHANGE_SIZE ||
changes & this.CHANGE_TEXT ||
changes & this.CHANGE_LINES ||
changes & this.CHANGE_SCROLL ||
changes & this.CHANGE_H_SCROLL
) {
changes |= this.$computeLayerConfig() | this.$loop.clear();
// If a change is made offscreen and wrapMode is on, then the onscreen
// lines may have been pushed down. If so, the first screen row will not
// have changed, but the first actual row will. In that case, adjust
// scrollTop so that the cursor and onscreen content stays in the same place.
// TODO: find a better way to handle this, that works non wrapped case and doesn't compute layerConfig twice
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
if (st > 0) {
// this check is needed as a workaround for the documentToScreenRow returning -1 if document.length == 0
this.scrollTop = st;
changes = changes | this.CHANGE_SCROLL;
changes |= this.$computeLayerConfig() | this.$loop.clear();
}
}
config = this.layerConfig;
// update scrollbar first to not lose scroll position when gutter calls resize
this.$updateScrollBarV();
if (changes & this.CHANGE_H_SCROLL)
this.$updateScrollBarH();
dom.translate(this.content, -this.scrollLeft, -config.offset);
var width = config.width + 2 * this.$padding + "px";
var height = config.minHeight + "px";
dom.setStyle(this.content.style, "width", width);
dom.setStyle(this.content.style, "height", height);
}
// horizontal scrolling
if (changes & this.CHANGE_H_SCROLL) {
dom.translate(this.content, -this.scrollLeft, -config.offset);
this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
}
// full
if (changes & this.CHANGE_FULL) {
this.$changedLines = null;
this.$textLayer.update(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
this.$markerBack.update(config);
this.$markerFront.update(config);
this.$cursorLayer.update(config);
this.$moveTextAreaToCursor();
this._signal("afterRender", changes);
return;
}
// scrolling
if (changes & this.CHANGE_SCROLL) {
this.$changedLines = null;
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
this.$textLayer.update(config);
else
this.$textLayer.scrollLines(config);
if (this.$showGutter) {
if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES)
this.$gutterLayer.update(config);
else
this.$gutterLayer.scrollLines(config);
}
this.$markerBack.update(config);
this.$markerFront.update(config);
this.$cursorLayer.update(config);
this.$moveTextAreaToCursor();
this._signal("afterRender", changes);
return;
}
if (changes & this.CHANGE_TEXT) {
this.$changedLines = null;
this.$textLayer.update(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
}
else if (changes & this.CHANGE_LINES) {
if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
this.$gutterLayer.update(config);
}
else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
if (this.$showGutter)
this.$gutterLayer.update(config);
}
else if (changes & this.CHANGE_CURSOR) {
if (this.$highlightGutterLine)
this.$gutterLayer.updateLineHighlight(config);
}
if (changes & this.CHANGE_CURSOR) {
this.$cursorLayer.update(config);
this.$moveTextAreaToCursor();
}
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
this.$markerFront.update(config);
}
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
this.$markerBack.update(config);
}
this._signal("afterRender", changes);
};