From 3164e5bae0f37a419b8b1b886e99fcf0f8d59903 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sat, 20 Oct 2012 22:15:58 +0300 Subject: [PATCH 1/2] Don't create zero-width text node after each render This fixes rendering the same node getting slower each time when using Opera. --- src/Parse.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Parse.js b/src/Parse.js index 283e852..40d6b81 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -363,7 +363,10 @@ _html2canvas.Parse = function ( images, options ) { continue; } - newTextNode = oldTextNode.splitText(renderList[c].length); + if (i < listLen-1) + newTextNode = oldTextNode.splitText(renderList[c].length); + else + newTextNode = null; parent = oldTextNode.parentNode; wrapElement = doc.createElement('wrapper'); From 1b81f7d5174db2fe66f41c71694462eb7ef0aa43 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sat, 20 Oct 2012 22:18:46 +0300 Subject: [PATCH 2/2] Accept 0px as an acceptable letter-spacing value for per-word rendering This improves performance in Opera. --- src/Parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parse.js b/src/Parse.js index 40d6b81..3a546b8 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -285,7 +285,7 @@ _html2canvas.Parse = function ( images, options ) { text_align = text_align.replace(["-webkit-auto"],["auto"]); - if (options.letterRendering === false && /^(left|right|justify|auto)$/.test(text_align) && /^(normal|none)$/.test(letter_spacing)){ + if (options.letterRendering === false && /^(left|right|justify|auto)$/.test(text_align) && /^(normal|none|0px)$/.test(letter_spacing)){ // this.setContextVariable(ctx,"textAlign",text_align); renderList = textNode.nodeValue.split(/(\b| )/);