From 2ec7fda1f146837cf0add1ad7a74f9139583b478 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Wed, 23 Nov 2011 13:49:04 +0100 Subject: [PATCH 1/6] replaced external image http://html2canvas.hertzen.com/images/8.jpg with data URI --- src/Parse.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Parse.js b/src/Parse.js index 63c6831..0ef8992 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -175,9 +175,8 @@ html2canvas.Parse = function (element, images, opts) { - - // TODO add another image - img.src = "http://html2canvas.hertzen.com/images/8.jpg"; + // http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever (handtinywhite.gif) + img.src = "data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs="; img.width = 1; img.height = 1; From 66d328d1e38996378a19f4994afd5c6a6af2dfd0 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Wed, 23 Nov 2011 13:53:15 +0100 Subject: [PATCH 2/6] make sure the image used for the detection of the underline is positioned correctly --- src/Parse.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Parse.js b/src/Parse.js index 0ef8992..799e9f2 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -182,6 +182,7 @@ html2canvas.Parse = function (element, images, opts) { img.style.margin = 0; img.style.padding = 0; + img.style.verticalAlign = "baseline"; span.style.fontFamily = font; span.style.fontSize = fontSize; From 62fa6038e784a3aef6956ed69056c456f90e27ea Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Wed, 23 Nov 2011 13:57:37 +0100 Subject: [PATCH 3/6] fix script error in html2canvas.Util.getCSS --- src/Core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core.js b/src/Core.js index 1e8478a..cf3524b 100644 --- a/src/Core.js +++ b/src/Core.js @@ -109,9 +109,9 @@ html2canvas.Util.getCSS = function (el, attribute) { if ( rsLeft ) { el.runtimeStyle.left = rsLeft; }*/ - val = $(el).css(attribute); + // val = $(el).css(attribute); // } - return val; + return $(el).css(attribute); }; From 217a75c0f6bc2fcb88fcef5c71298a63414436a1 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Wed, 23 Nov 2011 13:59:33 +0100 Subject: [PATCH 4/6] fix permission denied access on inner iFrame (crossDomain) --- src/Core.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Core.js b/src/Core.js index cf3524b..0600ac3 100644 --- a/src/Core.js +++ b/src/Core.js @@ -128,5 +128,12 @@ html2canvas.Util.Extend = function (options, defaults) { html2canvas.Util.Children = function(el) { // $(el).contents() !== el.childNodes, Opera / IE have issues with that - return $(el).contents(); + var children; + try { + children = $(el).contents(); + } catch (ex) { + html2canvas.log("html2canvas.Util.Children failed with exception: " + ex.message); + children = []; + } + return children; } From 4f49bd6e9b92bbec1b9301be4cc093f55c457a89 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Wed, 23 Nov 2011 14:06:00 +0100 Subject: [PATCH 5/6] accessing nodeType may throw an exception --- src/Preload.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Preload.js b/src/Preload.js index 878cdf1..03fab51 100644 --- a/src/Preload.js +++ b/src/Preload.js @@ -156,7 +156,8 @@ html2canvas.Preload = function(element, opts){ contentsLen = contents.length, background_image, src, - img; + img, + elNodeType = false; for (i = 0; i < contentsLen; i+=1 ){ // var ignRe = new RegExp("("+this.ignoreElements+")"); @@ -166,8 +167,14 @@ html2canvas.Preload = function(element, opts){ } // } - - if (el.nodeType === 1 || el.nodeType === undefined){ + try { + elNodeType = el.nodeType; + } catch (ex) { + elNodeType = false; + html2canvas.log("html2canvas: failed to access some element's nodeType - Exception: " + ex.message); + } + + if (elNodeType === 1 || elNodeType === undefined){ background_image = html2canvas.Util.getCSS(el, 'backgroundImage'); From 1f7314747ee7bd62c850150fbf6d219d271aae16 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Wed, 23 Nov 2011 14:07:12 +0100 Subject: [PATCH 6/6] instead of scrolling the view on every Bounds() call, do it only once --- src/Core.js | 2 -- src/Parse.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Core.js b/src/Core.js index 0600ac3..0cef04e 100644 --- a/src/Core.js +++ b/src/Core.js @@ -36,8 +36,6 @@ html2canvas.Util.backgroundImage = function (src) { }; html2canvas.Util.Bounds = function getBounds (el) { - - window.scroll(0,0); var clientRect, bounds = {}; diff --git a/src/Parse.js b/src/Parse.js index 799e9f2..8dc2f41 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -11,7 +11,7 @@ */ html2canvas.Parse = function (element, images, opts) { - + window.scroll(0,0); opts = opts || {}; // select body by default