Major refactoring of rendering mechanism

We now use a fake DOM implementation on the server to let us share more
rendering code between the text output vs. DOM output paths.
This commit is contained in:
Jeremy Ruston
2013-05-17 10:12:25 +01:00
parent bf4fede34e
commit 551ebdc005
18 changed files with 167 additions and 107 deletions
@@ -49,7 +49,7 @@ BitmapEditor.prototype.postRenderInDom = function() {
var ctx = canvas.getContext("2d");
ctx.drawImage(currImage,0,0);
// And also copy the current bitmap to the off-screen canvas
self.currCanvas = document.createElement("canvas");
self.currCanvas = self.editWidget.renderer.renderTree.document.createElement("canvas");
self.currCanvas.width = currImage.width;
self.currCanvas.height = currImage.height;
ctx = self.currCanvas.getContext("2d");
@@ -127,12 +127,12 @@ TextEditor.prototype.fixHeight = function() {
$tw.utils.nextTick(function() {
// Resize the textarea to fit its content
var textarea = self.editWidget.children[0].domNode,
scrollTop = document.body.scrollTop;
scrollTop = self.editWidget.renderer.renderTree.document.body.scrollTop;
textarea.style.height = "auto";
var newHeight = Math.max(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight,MIN_TEXT_AREA_HEIGHT);
if(newHeight !== textarea.offsetHeight) {
textarea.style.height = newHeight + "px";
document.body.scrollTop = scrollTop;
self.editWidget.renderer.renderTree.document.body.scrollTop = scrollTop;
}
});
}
@@ -143,7 +143,7 @@ TextEditor.prototype.postRenderInDom = function() {
};
TextEditor.prototype.refreshInDom = function() {
if(document.activeElement !== this.editWidget.children[0].domNode) {
if(this.editWidget.renderer.renderTree.document.activeElement !== this.editWidget.children[0].domNode) {
var editInfo = this.getEditInfo();
this.editWidget.children[0].domNode.value = editInfo.value;
}