_html2canvas.Util.Support = function (options, doc) { function supportSVGRendering() { var img = new Image(), canvas = doc.createElement("canvas"), ctx = (canvas.getContext === undefined) ? false : canvas.getContext("2d"); if (ctx === false) { return false; } canvas.width = canvas.height = 10; img.src = [ "data:image/svg+xml,", "<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'>", "<foreignObject width='10' height='10'>", "<div xmlns='http://www.w3.org/1999/xhtml' style='width:10;height:10;'>", "sup", "</div>", "</foreignObject>", "</svg>" ].join(""); try { ctx.drawImage(img, 0, 0); canvas.toDataURL(); } catch(e) { return false; } _html2canvas.Util.log('html2canvas: Parse: SVG powered rendering available'); return true; } // Test whether we can use ranges to measure bounding boxes // Opera doesn't provide valid bounds.height/bottom even though it supports the method. function supportRangeBounds() { var r, testElement, rangeBounds, rangeHeight, support = false; if (doc.createRange) { r = doc.createRange(); if (r.getBoundingClientRect) { testElement = doc.createElement('boundtest'); testElement.style.height = "123px"; testElement.style.display = "block"; doc.body.appendChild(testElement); r.selectNode(testElement); rangeBounds = r.getBoundingClientRect(); rangeHeight = rangeBounds.height; if (rangeHeight === 123) { support = true; } doc.body.removeChild(testElement); } } return support; } return { rangeBounds: supportRangeBounds(), svgRendering: options.svgRendering && supportSVGRendering() }; };