Fixed support for other Renderers other than Canvas

This commit is contained in:
Paolo 2012-04-17 10:57:25 +02:00
parent 1ad7ed3e1c
commit 8d965029da
3 changed files with 16 additions and 8 deletions

View File

@ -23,6 +23,7 @@
<file name="Renderer.js"/> <file name="Renderer.js"/>
<file name="Util.js"/> <file name="Util.js"/>
<file name="renderers/Canvas.js"/> <file name="renderers/Canvas.js"/>
<file name="renderers/SVG.js"/>
<file name="html2canvas-post.txt"/> <file name="html2canvas-post.txt"/>
</filelist> </filelist>
</path> </path>
@ -76,6 +77,7 @@
<file name="Renderer.js"/> <file name="Renderer.js"/>
<file name="Util.js"/> <file name="Util.js"/>
<file name="renderers/Canvas.js"/> <file name="renderers/Canvas.js"/>
<file name="renderers/SVG.js"/>
</sources> </sources>
</jscomp> </jscomp>
<delete file="${build.dir}/${JS_NAME_MIN}.tmp"></delete> <delete file="${build.dir}/${JS_NAME_MIN}.tmp"></delete>

View File

@ -58,9 +58,9 @@ _html2canvas.Renderer = function(parseQueue, options){
sortZ(parseQueue.zIndex); sortZ(parseQueue.zIndex);
if ( typeof options.renderer._create !== "function" ) { if ( typeof options._renderer._create !== "function" ) {
throw new Error("Invalid renderer defined"); throw new Error("Invalid renderer defined");
} }
return options.renderer._create( parseQueue, options, document, queue, _html2canvas ); return options._renderer._create( parseQueue, options, document, queue, _html2canvas );
}; };

View File

@ -34,14 +34,20 @@ html2canvas = function( elements, opts ) {
flashcanvas: undefined, // path to flashcanvas flashcanvas: undefined, // path to flashcanvas
width: null, width: null,
height: null, height: null,
taintTest: true // do a taint test with all images before applying to canvas taintTest: true, // do a taint test with all images before applying to canvas
renderer: "Canvas"
}; }, renderer;
options = _html2canvas.Util.Extend(opts, options); options = _html2canvas.Util.Extend(opts, options);
options.renderer = options.renderer || _html2canvas.Renderer.Canvas( options ); if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) {
options._renderer = _html2canvas.Renderer[options.renderer]( options );
} else if (typeof options.renderer === "function") {
options._renderer = _html2canvas.Renderer.Canvas( options );
} else {
throw("Unknown renderer");
}
_html2canvas.logging = options.logging; _html2canvas.logging = options.logging;
options.complete = function( images ) { options.complete = function( images ) {