From 0e2f2d5ae45cedc9a241c401a562c18cea7712ca Mon Sep 17 00:00:00 2001 From: Ramon Ornelas Date: Sun, 14 Aug 2016 16:53:35 -0300 Subject: [PATCH] - Update html2canvas 0.5.0-beta4 --- libs/html2canvas/dist/html2canvas.js | 2103 ++++++++++------- libs/html2canvas/readme.md | 56 +- libs/html2canvas/src/clone.js | 104 + libs/html2canvas/src/color.js | 272 +++ libs/html2canvas/src/core.js | 203 +- libs/html2canvas/src/dummyimagecontainer.js | 5 + libs/html2canvas/src/font.js | 4 + libs/html2canvas/src/fontmetrics.js | 4 + libs/html2canvas/src/framecontainer.js | 7 + libs/html2canvas/src/gradientcontainer.js | 8 +- libs/html2canvas/src/imagecontainer.js | 2 + libs/html2canvas/src/imageloader.js | 19 +- .../src/lineargradientcontainer.js | 91 +- libs/html2canvas/src/log.js | 11 +- libs/html2canvas/src/nodecontainer.js | 153 +- libs/html2canvas/src/nodeparser.js | 102 +- libs/html2canvas/src/proxy.js | 53 +- libs/html2canvas/src/proxyimagecontainer.js | 5 +- .../html2canvas/src/pseudoelementcontainer.js | 4 + libs/html2canvas/src/renderer.js | 56 +- libs/html2canvas/src/renderers/canvas.js | 19 +- libs/html2canvas/src/stackingcontext.js | 4 + libs/html2canvas/src/support.js | 2 + libs/html2canvas/src/svgcontainer.js | 46 +- libs/html2canvas/src/svgnodecontainer.js | 10 +- libs/html2canvas/src/textcontainer.js | 4 + libs/html2canvas/src/utils.js | 169 ++ .../src/webkitgradientcontainer.js | 6 +- libs/html2canvas/src/xhr.js | 2 + 29 files changed, 2154 insertions(+), 1370 deletions(-) create mode 100644 libs/html2canvas/src/clone.js create mode 100644 libs/html2canvas/src/color.js create mode 100644 libs/html2canvas/src/utils.js diff --git a/libs/html2canvas/dist/html2canvas.js b/libs/html2canvas/dist/html2canvas.js index 2ab01b2da..43fc7a594 100644 --- a/libs/html2canvas/dist/html2canvas.js +++ b/libs/html2canvas/dist/html2canvas.js @@ -1,56 +1,21 @@ /* - html2canvas 0.5.0-alpha - Copyright (c) 2014 Niklas von Hertzen + html2canvas 0.5.0-beta3 + Copyright (c) 2016 Niklas von Hertzen - Released under MIT License + Released under License */ -(function(window, document, module, exports, global, define, undefined){ - -/* - Copyright (c) 2013 Yehuda Katz, Tom Dale, and contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - */ -!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - var labels = string.split(regexSeparators); - var encoded = map(labels, fn).join('.'); - return result + encoded; + return map(string.split(regexSeparators), fn).join('.'); } /** @@ -154,7 +107,7 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva * UCS-2 exposes as separate characters) into a single code point, * matching UTF-16. * @see `punycode.ucs2.encode` - * @see + * @see * @memberOf punycode.ucs2 * @name decode * @param {String} string The Unicode input string (UCS-2). @@ -363,8 +316,8 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva } /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. + * Converts a string of Unicode symbols to a Punycode string of ASCII-only + * symbols. * @memberOf punycode * @param {String} input The string of Unicode symbols. * @returns {String} The resulting Punycode string of ASCII-only symbols. @@ -477,18 +430,17 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva } /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. + * Converts a Punycode string representing a domain name to Unicode. Only the + * Punycoded parts of the domain name will be converted, i.e. it doesn't + * matter if you call it on a string that has already been converted to + * Unicode. * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. + * @param {String} domain The Punycode domain name to convert to Unicode. * @returns {String} The Unicode representation of the given Punycode * string. */ - function toUnicode(input) { - return mapDomain(input, function(string) { + function toUnicode(domain) { + return mapDomain(domain, function(string) { return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string; @@ -496,18 +448,15 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva } /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. + * Converts a Unicode string representing a domain name to Punycode. Only the + * non-ASCII parts of the domain name will be converted, i.e. it doesn't + * matter if you call it with a domain that's already in ASCII. * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. + * @param {String} domain The domain name to convert, as a Unicode string. + * @returns {String} The Punycode representation of the given domain name. */ - function toASCII(input) { - return mapDomain(input, function(string) { + function toASCII(domain) { + return mapDomain(domain, function(string) { return regexNonASCII.test(string) ? 'xn--' + encode(string) : string; @@ -523,11 +472,11 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva * @memberOf punycode * @type String */ - 'version': '1.3.1', + 'version': '1.2.4', /** * An object of methods to convert from JavaScript's internal character * representation (UCS-2) to Unicode code points, and back. - * @see + * @see * @memberOf punycode * @type Object */ @@ -552,8 +501,8 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva define('punycode', function() { return punycode; }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { // in Node.js or RingoJS v0.8.0+ + } else if (freeExports && !freeExports.nodeType) { + if (freeModule) { // in Node.js or RingoJS v0.8.0+ freeModule.exports = punycode; } else { // in Narwhal or RingoJS v0.7.0- for (key in punycode) { @@ -566,15 +515,408 @@ if (typeof(Object.create) !== "function" || typeof(document.createElement("canva }(this)); +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],2:[function(_dereq_,module,exports){ +var log = _dereq_('./log'); + +function restoreOwnerScroll(ownerDocument, x, y) { + if (ownerDocument.defaultView && (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) { + ownerDocument.defaultView.scrollTo(x, y); + } +} + +function cloneCanvasContents(canvas, clonedCanvas) { + try { + if (clonedCanvas) { + clonedCanvas.width = canvas.width; + clonedCanvas.height = canvas.height; + clonedCanvas.getContext("2d").putImageData(canvas.getContext("2d").getImageData(0, 0, canvas.width, canvas.height), 0, 0); + } + } catch(e) { + log("Unable to copy canvas content from", canvas, e); + } +} + +function cloneNode(node, javascriptEnabled) { + var clone = node.nodeType === 3 ? document.createTextNode(node.nodeValue) : node.cloneNode(false); + + var child = node.firstChild; + while(child) { + if (javascriptEnabled === true || child.nodeType !== 1 || child.nodeName !== 'SCRIPT') { + clone.appendChild(cloneNode(child, javascriptEnabled)); + } + child = child.nextSibling; + } + + if (node.nodeType === 1) { + clone._scrollTop = node.scrollTop; + clone._scrollLeft = node.scrollLeft; + if (node.nodeName === "CANVAS") { + cloneCanvasContents(node, clone); + } else if (node.nodeName === "TEXTAREA" || node.nodeName === "SELECT") { + clone.value = node.value; + } + } + + return clone; +} + +function initNode(node) { + if (node.nodeType === 1) { + node.scrollTop = node._scrollTop; + node.scrollLeft = node._scrollLeft; + + var child = node.firstChild; + while(child) { + initNode(child); + child = child.nextSibling; + } + } +} + +module.exports = function(ownerDocument, containerDocument, width, height, options, x ,y) { + var documentElement = cloneNode(ownerDocument.documentElement, options.javascriptEnabled); + var container = containerDocument.createElement("iframe"); + + container.className = "html2canvas-container"; + container.style.visibility = "hidden"; + container.style.position = "fixed"; + container.style.left = "-10000px"; + container.style.top = "0px"; + container.style.border = "0"; + container.width = width; + container.height = height; + container.scrolling = "no"; // ios won't scroll without it + containerDocument.body.appendChild(container); + + return new Promise(function(resolve) { + var documentClone = container.contentWindow.document; + + /* Chrome doesn't detect relative background-images assigned in inline