@@ -15,6 +15,35 @@ _html2canvas.Parse = function ( images, options ) {
15
15
16
16
var support = {
17
17
rangeBounds : false
18
+ /*,svgRendering: (function( ){
19
+ var img = new Image(),
20
+ canvas = document.createElement("canvas"),
21
+ ctx = (canvas.getContext === undefined) ? false : canvas.getContext("2d");
22
+ if (ctx === false) {
23
+ // browser doesn't support canvas, good luck supporting SVG on canvas
24
+ return false;
25
+ }
26
+ canvas.width = canvas.height = 10;
27
+ img.src = [
28
+ "data:image/svg+xml,",
29
+ "<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'>",
30
+ "<foreignObject width='10' height='10'>",
31
+ "<div xmlns='http://www.w3.org/1999/xhtml' style='width:10;height:10;'>",
32
+ "sup",
33
+ "</div>",
34
+ "</foreignObject>",
35
+ "</svg>"
36
+ ].join("");
37
+ try {
38
+ ctx.drawImage(img, 0, 0);
39
+ canvas.toDataURL();
40
+ } catch(e) {
41
+ return false;
42
+ }
43
+ h2clog('html2canvas: Parse: SVG powered rendering available');
44
+ return true;
45
+
46
+ })()*/
18
47
} ,
19
48
element = ( ( options . elements === undefined ) ? document . body : options . elements [ 0 ] ) , // select body by default
20
49
needReorder = false ,
@@ -34,8 +63,86 @@ _html2canvas.Parse = function ( images, options ) {
34
63
children ,
35
64
childrenLen ;
36
65
37
-
38
-
66
+ /*
67
+ SVG powered HTML rendering, non-tainted canvas available from FF 11+ onwards,
68
+ but due to bug https://bugzilla.mozilla.org/show_bug.cgi?id=733345 excluding this code out for now
69
+
70
+ if (support.svgRendering || true) {
71
+ (function( body, width, height ){
72
+ var img = new Image(),
73
+ html = "";
74
+
75
+ function parseDOM( el ) {
76
+ var children = _html2canvas.Util.Children( el ),
77
+ len = children.length,
78
+ attr,
79
+ a,
80
+ alen,
81
+ elm,
82
+ i;
83
+ for ( i = 0; i < len; i+=1 ) {
84
+ elm = children[ i ];
85
+ if ( elm.nodeType === 3 ) {
86
+ // Text node
87
+
88
+ html += elm.nodeValue.replace(/\</g,"<").replace(/\>/g,">");
89
+ } else if ( elm.nodeType === 1 ) {
90
+ // Element
91
+ if ( !/^(script|meta|title)$/.test(elm.nodeName.toLowerCase()) ) {
92
+
93
+ html += "<" + elm.nodeName.toLowerCase();
94
+
95
+ // add attributes
96
+ if ( elm.hasAttributes() ) {
97
+ attr = elm.attributes;
98
+ alen = attr.length;
99
+ for ( a = 0; a < alen; a+=1 ) {
100
+ html += " " + attr[ a ].name + '="' + attr[ a ].value + '"';
101
+ }
102
+ }
103
+
104
+
105
+ html += '>';
106
+
107
+ parseDOM( elm );
108
+
109
+
110
+ html += "</" + elm.nodeName.toLowerCase() + ">";
111
+ }
112
+ }
113
+
114
+ }
115
+
116
+ }
117
+
118
+ parseDOM( body );
119
+ img.src = [
120
+ "data:image/svg+xml,",
121
+ "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='" + width + "' height='" + height + "'>",
122
+ "<foreignObject width='" + width + "' height='" + height + "'>",
123
+ "<html xmlns='http://www.w3.org/1999/xhtml' style='margin:0;'>",
124
+ html,
125
+ "</html>",
126
+ "</foreignObject>",
127
+ "</svg>"
128
+ ].join("");
129
+
130
+ console.log(img.src);
131
+ img.onerror = function(e) {
132
+ console.log(e);
133
+ };
134
+
135
+ img.onload = function() {
136
+ console.log("loaded");
137
+ };
138
+
139
+ document.body.appendChild(img);
140
+ })( document.documentElement, 1280, 1024 );
141
+
142
+ }
143
+ return;
144
+ */
145
+
39
146
images = images || { } ;
40
147
41
148
// Test whether we can use ranges to measure bounding boxes
0 commit comments