Refactor rendertree to simplify context handling

Get rid of the separate renderContext stack and instead have a parent
pointer on renderer nodes. This lets us walk back up the render tree to
resolve context references
This commit is contained in:
Jeremy Ruston 2013-05-15 17:32:17 +01:00
parent 32dc09d8ac
commit 8564602256
42 changed files with 175 additions and 183 deletions

View file

@ -66,16 +66,16 @@ Modal.prototype.display = function(title,options) {
titleText = title;
}
var headerParser = this.wiki.parseText("text/vnd.tiddlywiki-run",titleText,{parseAsInline: true}),
headerRenderTree = new $tw.WikiRenderTree(headerParser,{wiki: $tw.wiki});
headerRenderTree.execute({tiddlerTitle: title});
headerRenderTree = new $tw.WikiRenderTree(headerParser,{wiki: $tw.wiki, context: {tiddlerTitle: title}});
headerRenderTree.execute();
headerRenderTree.renderInDom(headerTitle);
this.wiki.addEventListener("change",function(changes) {
headerRenderTree.refreshInDom(changes);
});
// Render the body of the message
var bodyParser = this.wiki.parseTiddler(title),
bodyRenderTree = new $tw.WikiRenderTree(bodyParser,{wiki: $tw.wiki});
bodyRenderTree.execute({tiddlerTitle: title});
bodyRenderTree = new $tw.WikiRenderTree(bodyParser,{wiki: $tw.wiki, context: {tiddlerTitle: title}});
bodyRenderTree.execute();
bodyRenderTree.renderInDom(modalBody);
this.wiki.addEventListener("change",function(changes) {
bodyRenderTree.refreshInDom(changes);
@ -102,8 +102,8 @@ Modal.prototype.display = function(title,options) {
footerText = '<$button message="tw-close-tiddler" class="btn btn-primary">Close</$button>';
}
var footerParser = this.wiki.parseText("text/vnd.tiddlywiki-run",footerText,{parseAsInline: true}),
footerRenderTree = new $tw.WikiRenderTree(footerParser,{wiki: $tw.wiki});
footerRenderTree.execute({tiddlerTitle: title});
footerRenderTree = new $tw.WikiRenderTree(footerParser,{wiki: $tw.wiki, context: {tiddlerTitle: title}});
footerRenderTree.execute();
footerRenderTree.renderInDom(modalFooterButtons);
this.wiki.addEventListener("change",function(changes) {
footerRenderTree.refreshInDom(changes);

View file

@ -36,8 +36,8 @@ Notifier.prototype.display = function(title,options) {
$tw.utils.addClass(notification,"tw-notification");
// Render the body of the notification
var bodyParser = this.wiki.parseTiddler(title),
bodyRenderTree = new $tw.WikiRenderTree(bodyParser,{wiki: $tw.wiki});
bodyRenderTree.execute({tiddlerTitle: title});
bodyRenderTree = new $tw.WikiRenderTree(bodyParser,{wiki: $tw.wiki, context: {tiddlerTitle: title}});
bodyRenderTree.execute();
bodyRenderTree.renderInDom(notification);
this.wiki.addEventListener("change",function(changes) {
bodyRenderTree.refreshInDom(changes);

View file

@ -35,8 +35,8 @@ StylesheetManager.prototype.addStylesheet = function(title) {
this.stylesheets[title] = true;
// Parse the tiddler and render as plain text
var parser = this.wiki.parseTiddler(title),
renderTree = new $tw.WikiRenderTree(parser,{wiki: this.wiki});
renderTree.execute({tiddlerTitle: title});
renderTree = new $tw.WikiRenderTree(parser,{wiki: this.wiki, context: {tiddlerTitle: title}});
renderTree.execute();
var text = renderTree.render("text/plain");
// Create a style element and put it in the document
var styleNode = document.createElement("style");