mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
build dist
This commit is contained in:
17
dist/lib/dom/__mocks__/document-cloner.js
vendored
Normal file
17
dist/lib/dom/__mocks__/document-cloner.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var DocumentCloner = /** @class */ (function () {
|
||||
function DocumentCloner() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion
|
||||
this.clonedReferenceElement = {};
|
||||
}
|
||||
DocumentCloner.prototype.toIFrame = function () {
|
||||
return Promise.resolve({});
|
||||
};
|
||||
DocumentCloner.destroy = function () {
|
||||
return true;
|
||||
};
|
||||
return DocumentCloner;
|
||||
}());
|
||||
exports.DocumentCloner = DocumentCloner;
|
||||
//# sourceMappingURL=document-cloner.js.map
|
1
dist/lib/dom/__mocks__/document-cloner.js.map
vendored
Normal file
1
dist/lib/dom/__mocks__/document-cloner.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"document-cloner.js","sourceRoot":"","sources":["../../../../src/dom/__mocks__/document-cloner.ts"],"names":[],"mappings":";;AAAA;IAGI;QACI,+EAA+E;QAC/E,IAAI,CAAC,sBAAsB,GAAG,EAAiB,CAAC;IACpD,CAAC;IAED,iCAAQ,GAAR;QACI,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAEM,sBAAO,GAAd;QACI,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,qBAAC;AAAD,CAAC,AAfD,IAeC;AAfY,wCAAc"}
|
495
dist/lib/dom/document-cloner.js
vendored
Normal file
495
dist/lib/dom/document-cloner.js
vendored
Normal file
@ -0,0 +1,495 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var node_parser_1 = require("./node-parser");
|
||||
var logger_1 = require("../core/logger");
|
||||
var parser_1 = require("../css/syntax/parser");
|
||||
var tokenizer_1 = require("../css/syntax/tokenizer");
|
||||
var counter_1 = require("../css/types/functions/counter");
|
||||
var list_style_type_1 = require("../css/property-descriptors/list-style-type");
|
||||
var index_1 = require("../css/index");
|
||||
var quotes_1 = require("../css/property-descriptors/quotes");
|
||||
var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';
|
||||
var DocumentCloner = /** @class */ (function () {
|
||||
function DocumentCloner(element, options) {
|
||||
this.options = options;
|
||||
this.scrolledElements = [];
|
||||
this.referenceElement = element;
|
||||
this.counters = new counter_1.CounterState();
|
||||
this.quoteDepth = 0;
|
||||
if (!element.ownerDocument) {
|
||||
throw new Error('Cloned element does not have an owner document');
|
||||
}
|
||||
this.documentElement = this.cloneNode(element.ownerDocument.documentElement);
|
||||
}
|
||||
DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {
|
||||
var _this = this;
|
||||
var iframe = createIFrameContainer(ownerDocument, windowSize);
|
||||
if (!iframe.contentWindow) {
|
||||
return Promise.reject("Unable to find iframe window");
|
||||
}
|
||||
var scrollX = ownerDocument.defaultView.pageXOffset;
|
||||
var scrollY = ownerDocument.defaultView.pageYOffset;
|
||||
var cloneWindow = iframe.contentWindow;
|
||||
var documentClone = cloneWindow.document;
|
||||
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
|
||||
if window url is about:blank, we can assign the url to current by writing onto the document
|
||||
*/
|
||||
var iframeLoad = iframeLoader(iframe).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var onclone;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
this.scrolledElements.forEach(restoreNodeScroll);
|
||||
if (cloneWindow) {
|
||||
cloneWindow.scrollTo(windowSize.left, windowSize.top);
|
||||
if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
|
||||
(cloneWindow.scrollY !== windowSize.top || cloneWindow.scrollX !== windowSize.left)) {
|
||||
documentClone.documentElement.style.top = -windowSize.top + 'px';
|
||||
documentClone.documentElement.style.left = -windowSize.left + 'px';
|
||||
documentClone.documentElement.style.position = 'absolute';
|
||||
}
|
||||
}
|
||||
onclone = this.options.onclone;
|
||||
if (typeof this.clonedReferenceElement === 'undefined') {
|
||||
return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
|
||||
}
|
||||
if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, documentClone.fonts.ready];
|
||||
case 1:
|
||||
_a.sent();
|
||||
_a.label = 2;
|
||||
case 2:
|
||||
if (typeof onclone === 'function') {
|
||||
return [2 /*return*/, Promise.resolve()
|
||||
.then(function () { return onclone(documentClone); })
|
||||
.then(function () { return iframe; })];
|
||||
}
|
||||
return [2 /*return*/, iframe];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
documentClone.open();
|
||||
documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
|
||||
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
||||
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
||||
documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
|
||||
documentClone.close();
|
||||
return iframeLoad;
|
||||
};
|
||||
DocumentCloner.prototype.createElementClone = function (node) {
|
||||
if (node_parser_1.isCanvasElement(node)) {
|
||||
return this.createCanvasClone(node);
|
||||
}
|
||||
/*
|
||||
if (isIFrameElement(node)) {
|
||||
return this.createIFrameClone(node);
|
||||
}
|
||||
*/
|
||||
if (node_parser_1.isStyleElement(node)) {
|
||||
return this.createStyleClone(node);
|
||||
}
|
||||
var clone = node.cloneNode(false);
|
||||
// @ts-ignore
|
||||
if (node_parser_1.isImageElement(clone) && clone.loading === 'lazy') {
|
||||
// @ts-ignore
|
||||
clone.loading = 'eager';
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
DocumentCloner.prototype.createStyleClone = function (node) {
|
||||
try {
|
||||
var sheet = node.sheet;
|
||||
if (sheet && sheet.cssRules) {
|
||||
var css = [].slice.call(sheet.cssRules, 0).reduce(function (css, rule) {
|
||||
if (rule && typeof rule.cssText === 'string') {
|
||||
return css + rule.cssText;
|
||||
}
|
||||
return css;
|
||||
}, '');
|
||||
var style = node.cloneNode(false);
|
||||
style.textContent = css;
|
||||
return style;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// accessing node.sheet.cssRules throws a DOMException
|
||||
logger_1.Logger.getInstance(this.options.id).error('Unable to access cssRules property', e);
|
||||
if (e.name !== 'SecurityError') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return node.cloneNode(false);
|
||||
};
|
||||
DocumentCloner.prototype.createCanvasClone = function (canvas) {
|
||||
if (this.options.inlineImages && canvas.ownerDocument) {
|
||||
var img = canvas.ownerDocument.createElement('img');
|
||||
try {
|
||||
img.src = canvas.toDataURL();
|
||||
return img;
|
||||
}
|
||||
catch (e) {
|
||||
logger_1.Logger.getInstance(this.options.id).info("Unable to clone canvas contents, canvas is tainted");
|
||||
}
|
||||
}
|
||||
var clonedCanvas = canvas.cloneNode(false);
|
||||
try {
|
||||
clonedCanvas.width = canvas.width;
|
||||
clonedCanvas.height = canvas.height;
|
||||
var ctx = canvas.getContext('2d');
|
||||
var clonedCtx = clonedCanvas.getContext('2d');
|
||||
if (clonedCtx) {
|
||||
if (ctx) {
|
||||
clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
|
||||
}
|
||||
else {
|
||||
clonedCtx.drawImage(canvas, 0, 0);
|
||||
}
|
||||
}
|
||||
return clonedCanvas;
|
||||
}
|
||||
catch (e) { }
|
||||
return clonedCanvas;
|
||||
};
|
||||
/*
|
||||
createIFrameClone(iframe: HTMLIFrameElement) {
|
||||
const tempIframe = <HTMLIFrameElement>iframe.cloneNode(false);
|
||||
const iframeKey = generateIframeKey();
|
||||
tempIframe.setAttribute('data-html2canvas-internal-iframe-key', iframeKey);
|
||||
|
||||
const {width, height} = parseBounds(iframe);
|
||||
|
||||
this.resourceLoader.cache[iframeKey] = getIframeDocumentElement(iframe, this.options)
|
||||
.then(documentElement => {
|
||||
return this.renderer(
|
||||
documentElement,
|
||||
{
|
||||
allowTaint: this.options.allowTaint,
|
||||
backgroundColor: '#ffffff',
|
||||
canvas: null,
|
||||
imageTimeout: this.options.imageTimeout,
|
||||
logging: this.options.logging,
|
||||
proxy: this.options.proxy,
|
||||
removeContainer: this.options.removeContainer,
|
||||
scale: this.options.scale,
|
||||
foreignObjectRendering: this.options.foreignObjectRendering,
|
||||
useCORS: this.options.useCORS,
|
||||
target: new CanvasRenderer(),
|
||||
width,
|
||||
height,
|
||||
x: 0,
|
||||
y: 0,
|
||||
windowWidth: documentElement.ownerDocument.defaultView.innerWidth,
|
||||
windowHeight: documentElement.ownerDocument.defaultView.innerHeight,
|
||||
scrollX: documentElement.ownerDocument.defaultView.pageXOffset,
|
||||
scrollY: documentElement.ownerDocument.defaultView.pageYOffset
|
||||
},
|
||||
);
|
||||
})
|
||||
.then(
|
||||
(canvas: HTMLCanvasElement) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const iframeCanvas = document.createElement('img');
|
||||
iframeCanvas.onload = () => resolve(canvas);
|
||||
iframeCanvas.onerror = (event) => {
|
||||
// Empty iframes may result in empty "data:," URLs, which are invalid from the <img>'s point of view
|
||||
// and instead of `onload` cause `onerror` and unhandled rejection warnings
|
||||
// https://github.com/niklasvh/html2canvas/issues/1502
|
||||
iframeCanvas.src == 'data:,' ? resolve(canvas) : reject(event);
|
||||
};
|
||||
iframeCanvas.src = canvas.toDataURL();
|
||||
if (tempIframe.parentNode && iframe.ownerDocument && iframe.ownerDocument.defaultView) {
|
||||
tempIframe.parentNode.replaceChild(
|
||||
copyCSSStyles(
|
||||
iframe.ownerDocument.defaultView.getComputedStyle(iframe),
|
||||
iframeCanvas
|
||||
),
|
||||
tempIframe
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
return tempIframe;
|
||||
}
|
||||
*/
|
||||
DocumentCloner.prototype.cloneNode = function (node) {
|
||||
if (node_parser_1.isTextNode(node)) {
|
||||
return document.createTextNode(node.data);
|
||||
}
|
||||
if (!node.ownerDocument) {
|
||||
return node.cloneNode(false);
|
||||
}
|
||||
var window = node.ownerDocument.defaultView;
|
||||
if (window && node_parser_1.isElementNode(node) && (node_parser_1.isHTMLElementNode(node) || node_parser_1.isSVGElementNode(node))) {
|
||||
var clone = this.createElementClone(node);
|
||||
var style = window.getComputedStyle(node);
|
||||
var styleBefore = window.getComputedStyle(node, ':before');
|
||||
var styleAfter = window.getComputedStyle(node, ':after');
|
||||
if (this.referenceElement === node && node_parser_1.isHTMLElementNode(clone)) {
|
||||
this.clonedReferenceElement = clone;
|
||||
}
|
||||
if (node_parser_1.isBodyElement(clone)) {
|
||||
createPseudoHideStyles(clone);
|
||||
}
|
||||
var counters = this.counters.parse(new index_1.CSSParsedCounterDeclaration(style));
|
||||
var before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE);
|
||||
for (var child = node.firstChild; child; child = child.nextSibling) {
|
||||
if (!node_parser_1.isElementNode(child) ||
|
||||
(!node_parser_1.isScriptElement(child) &&
|
||||
!child.hasAttribute(IGNORE_ATTRIBUTE) &&
|
||||
(typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child)))) {
|
||||
if (!this.options.copyStyles || !node_parser_1.isElementNode(child) || !node_parser_1.isStyleElement(child)) {
|
||||
clone.appendChild(this.cloneNode(child));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (before) {
|
||||
clone.insertBefore(before, clone.firstChild);
|
||||
}
|
||||
var after = this.resolvePseudoContent(node, clone, styleAfter, PseudoElementType.AFTER);
|
||||
if (after) {
|
||||
clone.appendChild(after);
|
||||
}
|
||||
this.counters.pop(counters);
|
||||
if (style && (this.options.copyStyles || node_parser_1.isSVGElementNode(node)) && !node_parser_1.isIFrameElement(node)) {
|
||||
exports.copyCSSStyles(style, clone);
|
||||
}
|
||||
//this.inlineAllImages(clone);
|
||||
if (node.scrollTop !== 0 || node.scrollLeft !== 0) {
|
||||
this.scrolledElements.push([clone, node.scrollLeft, node.scrollTop]);
|
||||
}
|
||||
if ((node_parser_1.isTextareaElement(node) || node_parser_1.isSelectElement(node)) &&
|
||||
(node_parser_1.isTextareaElement(clone) || node_parser_1.isSelectElement(clone))) {
|
||||
clone.value = node.value;
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
return node.cloneNode(false);
|
||||
};
|
||||
DocumentCloner.prototype.resolvePseudoContent = function (node, clone, style, pseudoElt) {
|
||||
var _this = this;
|
||||
if (!style) {
|
||||
return;
|
||||
}
|
||||
var value = style.content;
|
||||
var document = clone.ownerDocument;
|
||||
if (!document || !value || value === 'none' || value === '-moz-alt-content' || style.display === 'none') {
|
||||
return;
|
||||
}
|
||||
this.counters.parse(new index_1.CSSParsedCounterDeclaration(style));
|
||||
var declaration = new index_1.CSSParsedPseudoDeclaration(style);
|
||||
var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
|
||||
exports.copyCSSStyles(style, anonymousReplacedElement);
|
||||
declaration.content.forEach(function (token) {
|
||||
if (token.type === tokenizer_1.TokenType.STRING_TOKEN) {
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(token.value));
|
||||
}
|
||||
else if (token.type === tokenizer_1.TokenType.URL_TOKEN) {
|
||||
var img = document.createElement('img');
|
||||
img.src = token.value;
|
||||
img.style.opacity = '1';
|
||||
anonymousReplacedElement.appendChild(img);
|
||||
}
|
||||
else if (token.type === tokenizer_1.TokenType.FUNCTION) {
|
||||
if (token.name === 'attr') {
|
||||
var attr = token.values.filter(parser_1.isIdentToken);
|
||||
if (attr.length) {
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(node.getAttribute(attr[0].value) || ''));
|
||||
}
|
||||
}
|
||||
else if (token.name === 'counter') {
|
||||
var _a = token.values.filter(parser_1.nonFunctionArgSeparator), counter = _a[0], counterStyle = _a[1];
|
||||
if (counter && parser_1.isIdentToken(counter)) {
|
||||
var counterState = _this.counters.getCounterValue(counter.value);
|
||||
var counterType = counterStyle && parser_1.isIdentToken(counterStyle)
|
||||
? list_style_type_1.listStyleType.parse(counterStyle.value)
|
||||
: list_style_type_1.LIST_STYLE_TYPE.DECIMAL;
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(counter_1.createCounterText(counterState, counterType, false)));
|
||||
}
|
||||
}
|
||||
else if (token.name === 'counters') {
|
||||
var _b = token.values.filter(parser_1.nonFunctionArgSeparator), counter = _b[0], delim = _b[1], counterStyle = _b[2];
|
||||
if (counter && parser_1.isIdentToken(counter)) {
|
||||
var counterStates = _this.counters.getCounterValues(counter.value);
|
||||
var counterType_1 = counterStyle && parser_1.isIdentToken(counterStyle)
|
||||
? list_style_type_1.listStyleType.parse(counterStyle.value)
|
||||
: list_style_type_1.LIST_STYLE_TYPE.DECIMAL;
|
||||
var separator = delim && delim.type === tokenizer_1.TokenType.STRING_TOKEN ? delim.value : '';
|
||||
var text = counterStates
|
||||
.map(function (value) { return counter_1.createCounterText(value, counterType_1, false); })
|
||||
.join(separator);
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(text));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// console.log('FUNCTION_TOKEN', token);
|
||||
}
|
||||
}
|
||||
else if (token.type === tokenizer_1.TokenType.IDENT_TOKEN) {
|
||||
switch (token.value) {
|
||||
case 'open-quote':
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(quotes_1.getQuote(declaration.quotes, _this.quoteDepth++, true)));
|
||||
break;
|
||||
case 'close-quote':
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(quotes_1.getQuote(declaration.quotes, --_this.quoteDepth, false)));
|
||||
break;
|
||||
default:
|
||||
// safari doesn't parse string tokens correctly because of lack of quotes
|
||||
anonymousReplacedElement.appendChild(document.createTextNode(token.value));
|
||||
}
|
||||
}
|
||||
});
|
||||
anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
|
||||
var newClassName = pseudoElt === PseudoElementType.BEFORE
|
||||
? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
|
||||
: " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
|
||||
if (node_parser_1.isSVGElementNode(clone)) {
|
||||
clone.className.baseValue += newClassName;
|
||||
}
|
||||
else {
|
||||
clone.className += newClassName;
|
||||
}
|
||||
return anonymousReplacedElement;
|
||||
};
|
||||
DocumentCloner.destroy = function (container) {
|
||||
if (container.parentNode) {
|
||||
container.parentNode.removeChild(container);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return DocumentCloner;
|
||||
}());
|
||||
exports.DocumentCloner = DocumentCloner;
|
||||
var PseudoElementType;
|
||||
(function (PseudoElementType) {
|
||||
PseudoElementType[PseudoElementType["BEFORE"] = 0] = "BEFORE";
|
||||
PseudoElementType[PseudoElementType["AFTER"] = 1] = "AFTER";
|
||||
})(PseudoElementType || (PseudoElementType = {}));
|
||||
var createIFrameContainer = function (ownerDocument, bounds) {
|
||||
var cloneIframeContainer = ownerDocument.createElement('iframe');
|
||||
cloneIframeContainer.className = 'html2canvas-container';
|
||||
cloneIframeContainer.style.visibility = 'hidden';
|
||||
cloneIframeContainer.style.position = 'fixed';
|
||||
cloneIframeContainer.style.left = '-10000px';
|
||||
cloneIframeContainer.style.top = '0px';
|
||||
cloneIframeContainer.style.border = '0';
|
||||
cloneIframeContainer.width = bounds.width.toString();
|
||||
cloneIframeContainer.height = bounds.height.toString();
|
||||
cloneIframeContainer.scrolling = 'no'; // ios won't scroll without it
|
||||
cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, 'true');
|
||||
ownerDocument.body.appendChild(cloneIframeContainer);
|
||||
return cloneIframeContainer;
|
||||
};
|
||||
var iframeLoader = function (iframe) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var cloneWindow = iframe.contentWindow;
|
||||
if (!cloneWindow) {
|
||||
return reject("No window assigned for iframe");
|
||||
}
|
||||
var documentClone = cloneWindow.document;
|
||||
cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = function () {
|
||||
cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = null;
|
||||
var interval = setInterval(function () {
|
||||
if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
|
||||
clearInterval(interval);
|
||||
resolve(iframe);
|
||||
}
|
||||
}, 50);
|
||||
};
|
||||
});
|
||||
};
|
||||
exports.copyCSSStyles = function (style, target) {
|
||||
// Edge does not provide value for cssText
|
||||
for (var i = style.length - 1; i >= 0; i--) {
|
||||
var property = style.item(i);
|
||||
// Safari shows pseudoelements if content is set
|
||||
if (property !== 'content') {
|
||||
target.style.setProperty(property, style.getPropertyValue(property));
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
var serializeDoctype = function (doctype) {
|
||||
var str = '';
|
||||
if (doctype) {
|
||||
str += '<!DOCTYPE ';
|
||||
if (doctype.name) {
|
||||
str += doctype.name;
|
||||
}
|
||||
if (doctype.internalSubset) {
|
||||
str += doctype.internalSubset;
|
||||
}
|
||||
if (doctype.publicId) {
|
||||
str += "\"" + doctype.publicId + "\"";
|
||||
}
|
||||
if (doctype.systemId) {
|
||||
str += "\"" + doctype.systemId + "\"";
|
||||
}
|
||||
str += '>';
|
||||
}
|
||||
return str;
|
||||
};
|
||||
var restoreOwnerScroll = function (ownerDocument, x, y) {
|
||||
if (ownerDocument &&
|
||||
ownerDocument.defaultView &&
|
||||
(x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
|
||||
ownerDocument.defaultView.scrollTo(x, y);
|
||||
}
|
||||
};
|
||||
var restoreNodeScroll = function (_a) {
|
||||
var element = _a[0], x = _a[1], y = _a[2];
|
||||
element.scrollLeft = x;
|
||||
element.scrollTop = y;
|
||||
};
|
||||
var PSEUDO_BEFORE = ':before';
|
||||
var PSEUDO_AFTER = ':after';
|
||||
var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
|
||||
var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
|
||||
var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
|
||||
var createPseudoHideStyles = function (body) {
|
||||
createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE);
|
||||
};
|
||||
var createStyles = function (body, styles) {
|
||||
var document = body.ownerDocument;
|
||||
if (document) {
|
||||
var style = document.createElement('style');
|
||||
style.textContent = styles;
|
||||
body.appendChild(style);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=document-cloner.js.map
|
1
dist/lib/dom/document-cloner.js.map
vendored
Normal file
1
dist/lib/dom/document-cloner.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
21
dist/lib/dom/element-container.js
vendored
Normal file
21
dist/lib/dom/element-container.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var index_1 = require("../css/index");
|
||||
var bounds_1 = require("../css/layout/bounds");
|
||||
var node_parser_1 = require("./node-parser");
|
||||
var ElementContainer = /** @class */ (function () {
|
||||
function ElementContainer(element) {
|
||||
this.styles = new index_1.CSSParsedDeclaration(window.getComputedStyle(element, null));
|
||||
this.textNodes = [];
|
||||
this.elements = [];
|
||||
if (this.styles.transform !== null && node_parser_1.isHTMLElementNode(element)) {
|
||||
// getBoundingClientRect takes transforms into account
|
||||
element.style.transform = 'none';
|
||||
}
|
||||
this.bounds = bounds_1.parseBounds(element);
|
||||
this.flags = 0;
|
||||
}
|
||||
return ElementContainer;
|
||||
}());
|
||||
exports.ElementContainer = ElementContainer;
|
||||
//# sourceMappingURL=element-container.js.map
|
1
dist/lib/dom/element-container.js.map
vendored
Normal file
1
dist/lib/dom/element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"element-container.js","sourceRoot":"","sources":["../../../src/dom/element-container.ts"],"names":[],"mappings":";;AAAA,sCAAkD;AAElD,+CAAyD;AACzD,6CAAgD;AAQhD;IAOI,0BAAY,OAAgB;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,4BAAoB,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,IAAI,IAAI,+BAAiB,CAAC,OAAO,CAAC,EAAE;YAC9D,sDAAsD;YACtD,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;SACpC;QACD,IAAI,CAAC,MAAM,GAAG,oBAAW,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IACL,uBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,4CAAgB"}
|
27
dist/lib/dom/elements/li-element-container.js
vendored
Normal file
27
dist/lib/dom/elements/li-element-container.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var LIElementContainer = /** @class */ (function (_super) {
|
||||
__extends(LIElementContainer, _super);
|
||||
function LIElementContainer(element) {
|
||||
var _this = _super.call(this, element) || this;
|
||||
_this.value = element.value;
|
||||
return _this;
|
||||
}
|
||||
return LIElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.LIElementContainer = LIElementContainer;
|
||||
//# sourceMappingURL=li-element-container.js.map
|
1
dist/lib/dom/elements/li-element-container.js.map
vendored
Normal file
1
dist/lib/dom/elements/li-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"li-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/li-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD;IAAwC,sCAAgB;IAGpD,4BAAY,OAAsB;QAAlC,YACI,kBAAM,OAAO,CAAC,SAEjB;QADG,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;;IAC/B,CAAC;IACL,yBAAC;AAAD,CAAC,AAPD,CAAwC,oCAAgB,GAOvD;AAPY,gDAAkB"}
|
28
dist/lib/dom/elements/ol-element-container.js
vendored
Normal file
28
dist/lib/dom/elements/ol-element-container.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var OLElementContainer = /** @class */ (function (_super) {
|
||||
__extends(OLElementContainer, _super);
|
||||
function OLElementContainer(element) {
|
||||
var _this = _super.call(this, element) || this;
|
||||
_this.start = element.start;
|
||||
_this.reversed = typeof element.reversed === 'boolean' && element.reversed === true;
|
||||
return _this;
|
||||
}
|
||||
return OLElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.OLElementContainer = OLElementContainer;
|
||||
//# sourceMappingURL=ol-element-container.js.map
|
1
dist/lib/dom/elements/ol-element-container.js.map
vendored
Normal file
1
dist/lib/dom/elements/ol-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ol-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/ol-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD;IAAwC,sCAAgB;IAIpD,4BAAY,OAAyB;QAArC,YACI,kBAAM,OAAO,CAAC,SAGjB;QAFG,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,KAAI,CAAC,QAAQ,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;;IACvF,CAAC;IACL,yBAAC;AAAD,CAAC,AATD,CAAwC,oCAAgB,GASvD;AATY,gDAAkB"}
|
28
dist/lib/dom/elements/select-element-container.js
vendored
Normal file
28
dist/lib/dom/elements/select-element-container.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var SelectElementContainer = /** @class */ (function (_super) {
|
||||
__extends(SelectElementContainer, _super);
|
||||
function SelectElementContainer(element) {
|
||||
var _this = _super.call(this, element) || this;
|
||||
var option = element.options[element.selectedIndex || 0];
|
||||
_this.value = option ? option.text || '' : '';
|
||||
return _this;
|
||||
}
|
||||
return SelectElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.SelectElementContainer = SelectElementContainer;
|
||||
//# sourceMappingURL=select-element-container.js.map
|
1
dist/lib/dom/elements/select-element-container.js.map
vendored
Normal file
1
dist/lib/dom/elements/select-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"select-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/select-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD;IAA4C,0CAAgB;IAExD,gCAAY,OAA0B;QAAtC,YACI,kBAAM,OAAO,CAAC,SAGjB;QAFG,IAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;QAC3D,KAAI,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;;IACjD,CAAC;IACL,6BAAC;AAAD,CAAC,AAPD,CAA4C,oCAAgB,GAO3D;AAPY,wDAAsB"}
|
27
dist/lib/dom/elements/textarea-element-container.js
vendored
Normal file
27
dist/lib/dom/elements/textarea-element-container.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var TextareaElementContainer = /** @class */ (function (_super) {
|
||||
__extends(TextareaElementContainer, _super);
|
||||
function TextareaElementContainer(element) {
|
||||
var _this = _super.call(this, element) || this;
|
||||
_this.value = element.value;
|
||||
return _this;
|
||||
}
|
||||
return TextareaElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.TextareaElementContainer = TextareaElementContainer;
|
||||
//# sourceMappingURL=textarea-element-container.js.map
|
1
dist/lib/dom/elements/textarea-element-container.js.map
vendored
Normal file
1
dist/lib/dom/elements/textarea-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"textarea-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/textarea-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD;IAA8C,4CAAgB;IAE1D,kCAAY,OAA4B;QAAxC,YACI,kBAAM,OAAO,CAAC,SAEjB;QADG,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;;IAC/B,CAAC;IACL,+BAAC;AAAD,CAAC,AAND,CAA8C,oCAAgB,GAM7D;AANY,4DAAwB"}
|
105
dist/lib/dom/node-parser.js
vendored
Normal file
105
dist/lib/dom/node-parser.js
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("./element-container");
|
||||
var text_container_1 = require("./text-container");
|
||||
var image_element_container_1 = require("./replaced-elements/image-element-container");
|
||||
var canvas_element_container_1 = require("./replaced-elements/canvas-element-container");
|
||||
var svg_element_container_1 = require("./replaced-elements/svg-element-container");
|
||||
var li_element_container_1 = require("./elements/li-element-container");
|
||||
var ol_element_container_1 = require("./elements/ol-element-container");
|
||||
var input_element_container_1 = require("./replaced-elements/input-element-container");
|
||||
var select_element_container_1 = require("./elements/select-element-container");
|
||||
var textarea_element_container_1 = require("./elements/textarea-element-container");
|
||||
var iframe_element_container_1 = require("./replaced-elements/iframe-element-container");
|
||||
var LIST_OWNERS = ['OL', 'UL', 'MENU'];
|
||||
var parseNodeTree = function (node, parent, root) {
|
||||
for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
|
||||
nextNode = childNode.nextSibling;
|
||||
if (exports.isTextNode(childNode) && childNode.data.trim().length > 0) {
|
||||
parent.textNodes.push(new text_container_1.TextContainer(childNode, parent.styles));
|
||||
}
|
||||
else if (exports.isElementNode(childNode)) {
|
||||
var container = createContainer(childNode);
|
||||
if (container.styles.isVisible()) {
|
||||
if (createsRealStackingContext(childNode, container, root)) {
|
||||
container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
|
||||
}
|
||||
else if (createsStackingContext(container.styles)) {
|
||||
container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
|
||||
}
|
||||
if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
|
||||
container.flags |= 8 /* IS_LIST_OWNER */;
|
||||
}
|
||||
parent.elements.push(container);
|
||||
if (!exports.isTextareaElement(childNode) && !exports.isSVGElement(childNode) && !exports.isSelectElement(childNode)) {
|
||||
parseNodeTree(childNode, container, root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var createContainer = function (element) {
|
||||
if (exports.isImageElement(element)) {
|
||||
return new image_element_container_1.ImageElementContainer(element);
|
||||
}
|
||||
if (exports.isCanvasElement(element)) {
|
||||
return new canvas_element_container_1.CanvasElementContainer(element);
|
||||
}
|
||||
if (exports.isSVGElement(element)) {
|
||||
return new svg_element_container_1.SVGElementContainer(element);
|
||||
}
|
||||
if (exports.isLIElement(element)) {
|
||||
return new li_element_container_1.LIElementContainer(element);
|
||||
}
|
||||
if (exports.isOLElement(element)) {
|
||||
return new ol_element_container_1.OLElementContainer(element);
|
||||
}
|
||||
if (exports.isInputElement(element)) {
|
||||
return new input_element_container_1.InputElementContainer(element);
|
||||
}
|
||||
if (exports.isSelectElement(element)) {
|
||||
return new select_element_container_1.SelectElementContainer(element);
|
||||
}
|
||||
if (exports.isTextareaElement(element)) {
|
||||
return new textarea_element_container_1.TextareaElementContainer(element);
|
||||
}
|
||||
if (exports.isIFrameElement(element)) {
|
||||
return new iframe_element_container_1.IFrameElementContainer(element);
|
||||
}
|
||||
return new element_container_1.ElementContainer(element);
|
||||
};
|
||||
exports.parseTree = function (element) {
|
||||
var container = createContainer(element);
|
||||
container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
|
||||
parseNodeTree(element, container, container);
|
||||
return container;
|
||||
};
|
||||
var createsRealStackingContext = function (node, container, root) {
|
||||
return (container.styles.isPositionedWithZIndex() ||
|
||||
container.styles.opacity < 1 ||
|
||||
container.styles.isTransformed() ||
|
||||
(exports.isBodyElement(node) && root.styles.isTransparent()));
|
||||
};
|
||||
var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };
|
||||
exports.isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
|
||||
exports.isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
|
||||
exports.isHTMLElementNode = function (node) {
|
||||
return exports.isElementNode(node) && typeof node.style !== 'undefined' && !exports.isSVGElementNode(node);
|
||||
};
|
||||
exports.isSVGElementNode = function (element) {
|
||||
return typeof element.className === 'object';
|
||||
};
|
||||
exports.isLIElement = function (node) { return node.tagName === 'LI'; };
|
||||
exports.isOLElement = function (node) { return node.tagName === 'OL'; };
|
||||
exports.isInputElement = function (node) { return node.tagName === 'INPUT'; };
|
||||
exports.isHTMLElement = function (node) { return node.tagName === 'HTML'; };
|
||||
exports.isSVGElement = function (node) { return node.tagName === 'svg'; };
|
||||
exports.isBodyElement = function (node) { return node.tagName === 'BODY'; };
|
||||
exports.isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };
|
||||
exports.isImageElement = function (node) { return node.tagName === 'IMG'; };
|
||||
exports.isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };
|
||||
exports.isStyleElement = function (node) { return node.tagName === 'STYLE'; };
|
||||
exports.isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };
|
||||
exports.isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };
|
||||
exports.isSelectElement = function (node) { return node.tagName === 'SELECT'; };
|
||||
//# sourceMappingURL=node-parser.js.map
|
1
dist/lib/dom/node-parser.js.map
vendored
Normal file
1
dist/lib/dom/node-parser.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"node-parser.js","sourceRoot":"","sources":["../../../src/dom/node-parser.ts"],"names":[],"mappings":";;AACA,yDAA4D;AAC5D,mDAA+C;AAC/C,uFAAkF;AAClF,yFAAoF;AACpF,mFAA8E;AAC9E,wEAAmE;AACnE,wEAAmE;AACnE,uFAAkF;AAClF,gFAA2E;AAC3E,oFAA+E;AAC/E,yFAAoF;AAEpF,IAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEzC,IAAM,aAAa,GAAG,UAAC,IAAU,EAAE,MAAwB,EAAE,IAAsB;IAC/E,KAAK,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,SAAA,EAAE,SAAS,EAAE,SAAS,GAAG,QAAQ,EAAE;QAC7E,QAAQ,GAAG,SAAS,CAAC,WAAW,CAAC;QAEjC,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CAAC,OAAO,KAAK,KAAK,EAAtB,CAAsB,CAAC;AAChF,QAAA,aAAa,GAAG,UAAC,IAAa,IAA8B,OAAA,IAAI,CAAC,OAAO,KAAK,MAAM,EAAvB,CAAuB,CAAC;AACpF,QAAA,eAAe,GAAG,UAAC,IAAa,IAAgC,OAAA,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAzB,CAAyB,CAAC;AAC1F,QAAA,cAAc,GAAG,UAAC,IAAa,IAA+B,OAAA,IAAI,CAAC,OAAO,KAAK,KAAK,EAAtB,CAAsB,CAAC;AACrF,QAAA,eAAe,GAAG,UAAC,IAAa,IAAgC,OAAA,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAzB,CAAyB,CAAC;AAC1F,QAAA,cAAc,GAAG,UAAC,IAAa,IAA+B,OAAA,IAAI,CAAC,OAAO,KAAK,OAAO,EAAxB,CAAwB,CAAC;AACvF,QAAA,eAAe,GAAG,UAAC,IAAa,IAAgC,OAAA,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAzB,CAAyB,CAAC;AAC1F,QAAA,iBAAiB,GAAG,UAAC,IAAa,IAAkC,OAAA,IAAI,CAAC,OAAO,KAAK,UAAU,EAA3B,CAA2B,CAAC;AAChG,QAAA,eAAe,GAAG,UAAC,IAAa,IAAgC,OAAA,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAzB,CAAyB,CAAC"}
|
29
dist/lib/dom/replaced-elements/canvas-element-container.js
vendored
Normal file
29
dist/lib/dom/replaced-elements/canvas-element-container.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var CanvasElementContainer = /** @class */ (function (_super) {
|
||||
__extends(CanvasElementContainer, _super);
|
||||
function CanvasElementContainer(canvas) {
|
||||
var _this = _super.call(this, canvas) || this;
|
||||
_this.canvas = canvas;
|
||||
_this.intrinsicWidth = canvas.width;
|
||||
_this.intrinsicHeight = canvas.height;
|
||||
return _this;
|
||||
}
|
||||
return CanvasElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.CanvasElementContainer = CanvasElementContainer;
|
||||
//# sourceMappingURL=canvas-element-container.js.map
|
1
dist/lib/dom/replaced-elements/canvas-element-container.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/canvas-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"canvas-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/canvas-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AAEtD;IAA4C,0CAAgB;IAKxD,gCAAY,MAAyB;QAArC,YACI,kBAAM,MAAM,CAAC,SAIhB;QAHG,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;QACnC,KAAI,CAAC,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;;IACzC,CAAC;IACL,6BAAC;AAAD,CAAC,AAXD,CAA4C,oCAAgB,GAW3D;AAXY,wDAAsB"}
|
55
dist/lib/dom/replaced-elements/iframe-element-container.js
vendored
Normal file
55
dist/lib/dom/replaced-elements/iframe-element-container.js
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var node_parser_1 = require("../node-parser");
|
||||
var color_1 = require("../../css/types/color");
|
||||
var parser_1 = require("../../css/syntax/parser");
|
||||
var parseColor = function (value) { return color_1.color.parse(parser_1.Parser.create(value).parseComponentValue()); };
|
||||
var IFrameElementContainer = /** @class */ (function (_super) {
|
||||
__extends(IFrameElementContainer, _super);
|
||||
function IFrameElementContainer(iframe) {
|
||||
var _this = _super.call(this, iframe) || this;
|
||||
_this.src = iframe.src;
|
||||
_this.width = parseInt(iframe.width, 10) || 0;
|
||||
_this.height = parseInt(iframe.height, 10) || 0;
|
||||
_this.backgroundColor = _this.styles.backgroundColor;
|
||||
try {
|
||||
if (iframe.contentWindow &&
|
||||
iframe.contentWindow.document &&
|
||||
iframe.contentWindow.document.documentElement) {
|
||||
_this.tree = node_parser_1.parseTree(iframe.contentWindow.document.documentElement);
|
||||
// http://www.w3.org/TR/css3-background/#special-backgrounds
|
||||
var documentBackgroundColor = iframe.contentWindow.document.documentElement
|
||||
? parseColor(getComputedStyle(iframe.contentWindow.document.documentElement)
|
||||
.backgroundColor)
|
||||
: color_1.COLORS.TRANSPARENT;
|
||||
var bodyBackgroundColor = iframe.contentWindow.document.body
|
||||
? parseColor(getComputedStyle(iframe.contentWindow.document.body).backgroundColor)
|
||||
: color_1.COLORS.TRANSPARENT;
|
||||
_this.backgroundColor = color_1.isTransparent(documentBackgroundColor)
|
||||
? color_1.isTransparent(bodyBackgroundColor)
|
||||
? _this.styles.backgroundColor
|
||||
: bodyBackgroundColor
|
||||
: documentBackgroundColor;
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
return _this;
|
||||
}
|
||||
return IFrameElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.IFrameElementContainer = IFrameElementContainer;
|
||||
//# sourceMappingURL=iframe-element-container.js.map
|
1
dist/lib/dom/replaced-elements/iframe-element-container.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/iframe-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"iframe-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/iframe-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD,8CAAyC;AACzC,+CAA0E;AAC1E,kDAA+C;AAE/C,IAAM,UAAU,GAAG,UAAC,KAAa,IAAY,OAAA,aAAK,CAAC,KAAK,CAAC,eAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC,EAAvD,CAAuD,CAAC;AAErG;IAA4C,0CAAgB;IAOxD,gCAAY,MAAyB;QAArC,YACI,kBAAM,MAAM,CAAC,SA6BhB;QA5BG,KAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,KAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7C,KAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAI,CAAC,eAAe,GAAG,KAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QACnD,IAAI;YACA,IACI,MAAM,CAAC,aAAa;gBACpB,MAAM,CAAC,aAAa,CAAC,QAAQ;gBAC7B,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,EAC/C;gBACE,KAAI,CAAC,IAAI,GAAG,uBAAS,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;gBAErE,4DAA4D;gBAC5D,IAAM,uBAAuB,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe;oBACzE,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC;yBACrE,eAAyB,CAAC;oBACjC,CAAC,CAAC,cAAM,CAAC,WAAW,CAAC;gBACzB,IAAM,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI;oBAC1D,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,eAAyB,CAAC;oBAC5F,CAAC,CAAC,cAAM,CAAC,WAAW,CAAC;gBAEzB,KAAI,CAAC,eAAe,GAAG,qBAAa,CAAC,uBAAuB,CAAC;oBACzD,CAAC,CAAC,qBAAa,CAAC,mBAAmB,CAAC;wBAChC,CAAC,CAAC,KAAI,CAAC,MAAM,CAAC,eAAe;wBAC7B,CAAC,CAAC,mBAAmB;oBACzB,CAAC,CAAC,uBAAuB,CAAC;aACjC;SACJ;QAAC,OAAO,CAAC,EAAE,GAAE;;IAClB,CAAC;IACL,6BAAC;AAAD,CAAC,AAtCD,CAA4C,oCAAgB,GAsC3D;AAtCY,wDAAsB"}
|
31
dist/lib/dom/replaced-elements/image-element-container.js
vendored
Normal file
31
dist/lib/dom/replaced-elements/image-element-container.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var cache_storage_1 = require("../../core/cache-storage");
|
||||
var ImageElementContainer = /** @class */ (function (_super) {
|
||||
__extends(ImageElementContainer, _super);
|
||||
function ImageElementContainer(img) {
|
||||
var _this = _super.call(this, img) || this;
|
||||
_this.src = img.currentSrc || img.src;
|
||||
_this.intrinsicWidth = img.naturalWidth;
|
||||
_this.intrinsicHeight = img.naturalHeight;
|
||||
cache_storage_1.CacheStorage.getInstance().addImage(_this.src);
|
||||
return _this;
|
||||
}
|
||||
return ImageElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.ImageElementContainer = ImageElementContainer;
|
||||
//# sourceMappingURL=image-element-container.js.map
|
1
dist/lib/dom/replaced-elements/image-element-container.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/image-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"image-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/image-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD,0DAAsD;AAEtD;IAA2C,yCAAgB;IAKvD,+BAAY,GAAqB;QAAjC,YACI,kBAAM,GAAG,CAAC,SAKb;QAJG,KAAI,CAAC,GAAG,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,GAAG,CAAC;QACrC,KAAI,CAAC,cAAc,GAAG,GAAG,CAAC,YAAY,CAAC;QACvC,KAAI,CAAC,eAAe,GAAG,GAAG,CAAC,aAAa,CAAC;QACzC,4BAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAI,CAAC,GAAG,CAAC,CAAC;;IAClD,CAAC;IACL,4BAAC;AAAD,CAAC,AAZD,CAA2C,oCAAgB,GAY1D;AAZY,sDAAqB"}
|
3
dist/lib/dom/replaced-elements/index.js
vendored
Normal file
3
dist/lib/dom/replaced-elements/index.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=index.js.map
|
1
dist/lib/dom/replaced-elements/index.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/index.ts"],"names":[],"mappings":""}
|
83
dist/lib/dom/replaced-elements/input-element-container.js
vendored
Normal file
83
dist/lib/dom/replaced-elements/input-element-container.js
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var border_style_1 = require("../../css/property-descriptors/border-style");
|
||||
var background_clip_1 = require("../../css/property-descriptors/background-clip");
|
||||
var tokenizer_1 = require("../../css/syntax/tokenizer");
|
||||
var bounds_1 = require("../../css/layout/bounds");
|
||||
var CHECKBOX_BORDER_RADIUS = [
|
||||
{
|
||||
type: tokenizer_1.TokenType.DIMENSION_TOKEN,
|
||||
flags: 0,
|
||||
unit: 'px',
|
||||
number: 3
|
||||
}
|
||||
];
|
||||
var RADIO_BORDER_RADIUS = [
|
||||
{
|
||||
type: tokenizer_1.TokenType.PERCENTAGE_TOKEN,
|
||||
flags: 0,
|
||||
number: 50
|
||||
}
|
||||
];
|
||||
var reformatInputBounds = function (bounds) {
|
||||
if (bounds.width > bounds.height) {
|
||||
return new bounds_1.Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height);
|
||||
}
|
||||
else if (bounds.width < bounds.height) {
|
||||
return new bounds_1.Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width);
|
||||
}
|
||||
return bounds;
|
||||
};
|
||||
var getInputValue = function (node) {
|
||||
var value = node.type === exports.PASSWORD ? new Array(node.value.length + 1).join('\u2022') : node.value;
|
||||
return value.length === 0 ? node.placeholder || '' : value;
|
||||
};
|
||||
exports.CHECKBOX = 'checkbox';
|
||||
exports.RADIO = 'radio';
|
||||
exports.PASSWORD = 'password';
|
||||
exports.INPUT_COLOR = 0x2a2a2aff;
|
||||
var InputElementContainer = /** @class */ (function (_super) {
|
||||
__extends(InputElementContainer, _super);
|
||||
function InputElementContainer(input) {
|
||||
var _this = _super.call(this, input) || this;
|
||||
_this.type = input.type.toLowerCase();
|
||||
_this.checked = input.checked;
|
||||
_this.value = getInputValue(input);
|
||||
if (_this.type === exports.CHECKBOX || _this.type === exports.RADIO) {
|
||||
_this.styles.backgroundColor = 0xdededeff;
|
||||
_this.styles.borderTopColor = _this.styles.borderRightColor = _this.styles.borderBottomColor = _this.styles.borderLeftColor = 0xa5a5a5ff;
|
||||
_this.styles.borderTopWidth = _this.styles.borderRightWidth = _this.styles.borderBottomWidth = _this.styles.borderLeftWidth = 1;
|
||||
_this.styles.borderTopStyle = _this.styles.borderRightStyle = _this.styles.borderBottomStyle = _this.styles.borderLeftStyle =
|
||||
border_style_1.BORDER_STYLE.SOLID;
|
||||
_this.styles.backgroundClip = [background_clip_1.BACKGROUND_CLIP.BORDER_BOX];
|
||||
_this.styles.backgroundOrigin = [0 /* BORDER_BOX */];
|
||||
_this.bounds = reformatInputBounds(_this.bounds);
|
||||
}
|
||||
switch (_this.type) {
|
||||
case exports.CHECKBOX:
|
||||
_this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = CHECKBOX_BORDER_RADIUS;
|
||||
break;
|
||||
case exports.RADIO:
|
||||
_this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = RADIO_BORDER_RADIUS;
|
||||
break;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
return InputElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.InputElementContainer = InputElementContainer;
|
||||
//# sourceMappingURL=input-element-container.js.map
|
1
dist/lib/dom/replaced-elements/input-element-container.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/input-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"input-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/input-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD,4EAAyE;AACzE,kFAA+E;AAE/E,wDAAqD;AAErD,kDAA+C;AAE/C,IAAM,sBAAsB,GAA0B;IAClD;QACI,IAAI,EAAE,qBAAS,CAAC,eAAe;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,CAAC;KACZ;CACJ,CAAC;AAEF,IAAM,mBAAmB,GAA0B;IAC/C;QACI,IAAI,EAAE,qBAAS,CAAC,gBAAgB;QAChC,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,EAAE;KACb;CACJ,CAAC;AAEF,IAAM,mBAAmB,GAAG,UAAC,MAAc;IACvC,IAAI,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;QAC9B,OAAO,IAAI,eAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,MA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,GAAG,KAAI,CAAC,MAAM,CAAC,uBAAuB,GAAG,KAAI,CAAC,MAAM,CAAC,sBAAsB,GAAG,mBAAmB,CAAC;gBACpK,MAAM;SACb;;IACL,CAAC;IACL,4BAAC;AAAD,CAAC,AA/BD,CAA2C,oCAAgB,GA+B1D;AA/BY,sDAAqB"}
|
1
dist/lib/dom/replaced-elements/pseudo-elements.js
vendored
Normal file
1
dist/lib/dom/replaced-elements/pseudo-elements.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
//# sourceMappingURL=pseudo-elements.js.map
|
1
dist/lib/dom/replaced-elements/pseudo-elements.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/pseudo-elements.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"pseudo-elements.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/pseudo-elements.ts"],"names":[],"mappings":""}
|
32
dist/lib/dom/replaced-elements/svg-element-container.js
vendored
Normal file
32
dist/lib/dom/replaced-elements/svg-element-container.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var element_container_1 = require("../element-container");
|
||||
var cache_storage_1 = require("../../core/cache-storage");
|
||||
var SVGElementContainer = /** @class */ (function (_super) {
|
||||
__extends(SVGElementContainer, _super);
|
||||
function SVGElementContainer(img) {
|
||||
var _this = _super.call(this, img) || this;
|
||||
var s = new XMLSerializer();
|
||||
_this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img));
|
||||
_this.intrinsicWidth = img.width.baseVal.value;
|
||||
_this.intrinsicHeight = img.height.baseVal.value;
|
||||
cache_storage_1.CacheStorage.getInstance().addImage(_this.svg);
|
||||
return _this;
|
||||
}
|
||||
return SVGElementContainer;
|
||||
}(element_container_1.ElementContainer));
|
||||
exports.SVGElementContainer = SVGElementContainer;
|
||||
//# sourceMappingURL=svg-element-container.js.map
|
1
dist/lib/dom/replaced-elements/svg-element-container.js.map
vendored
Normal file
1
dist/lib/dom/replaced-elements/svg-element-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"svg-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/svg-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD,0DAAsD;AAEtD;IAAyC,uCAAgB;IAKrD,6BAAY,GAAkB;QAA9B,YACI,kBAAM,GAAG,CAAC,SAOb;QANG,IAAM,CAAC,GAAG,IAAI,aAAa,EAAE,CAAC;QAC9B,KAAI,CAAC,GAAG,GAAG,wBAAsB,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAG,CAAC;QAChF,KAAI,CAAC,cAAc,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAC9C,KAAI,CAAC,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAEhD,4BAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAI,CAAC,GAAG,CAAC,CAAC;;IAClD,CAAC;IACL,0BAAC;AAAD,CAAC,AAdD,CAAyC,oCAAgB,GAcxD;AAdY,kDAAmB"}
|
32
dist/lib/dom/text-container.js
vendored
Normal file
32
dist/lib/dom/text-container.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var text_transform_1 = require("../css/property-descriptors/text-transform");
|
||||
var text_1 = require("../css/layout/text");
|
||||
var TextContainer = /** @class */ (function () {
|
||||
function TextContainer(node, styles) {
|
||||
this.text = transform(node.data, styles.textTransform);
|
||||
this.textBounds = text_1.parseTextBounds(this.text, styles, node);
|
||||
}
|
||||
return TextContainer;
|
||||
}());
|
||||
exports.TextContainer = TextContainer;
|
||||
var transform = function (text, transform) {
|
||||
switch (transform) {
|
||||
case text_transform_1.TEXT_TRANSFORM.LOWERCASE:
|
||||
return text.toLowerCase();
|
||||
case text_transform_1.TEXT_TRANSFORM.CAPITALIZE:
|
||||
return text.replace(CAPITALIZE, capitalize);
|
||||
case text_transform_1.TEXT_TRANSFORM.UPPERCASE:
|
||||
return text.toUpperCase();
|
||||
default:
|
||||
return text;
|
||||
}
|
||||
};
|
||||
var CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g;
|
||||
var capitalize = function (m, p1, p2) {
|
||||
if (m.length > 0) {
|
||||
return p1 + p2.toUpperCase();
|
||||
}
|
||||
return m;
|
||||
};
|
||||
//# sourceMappingURL=text-container.js.map
|
1
dist/lib/dom/text-container.js.map
vendored
Normal file
1
dist/lib/dom/text-container.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"text-container.js","sourceRoot":"","sources":["../../../src/dom/text-container.ts"],"names":[],"mappings":";;AACA,6EAA0E;AAC1E,2CAA+D;AAE/D;IAII,uBAAY,IAAU,EAAE,MAA4B;QAChD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,sBAAe,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IACL,oBAAC;AAAD,CAAC,AARD,IAQC;AARY,sCAAa;AAU1B,IAAM,SAAS,GAAG,UAAC,IAAY,EAAE,SAAyB;IACtD,QAAQ,SAAS,EAAE;QACf,KAAK,+BAAc,CAAC,SAAS;YACzB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B,KAAK,+BAAc,CAAC,UAAU;YAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAChD,KAAK,+BAAc,CAAC,SAAS;YACzB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B;YACI,OAAO,IAAI,CAAC;KACnB;AACL,CAAC,CAAC;AAEF,IAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,IAAM,UAAU,GAAG,UAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IACjD,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACd,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;KAChC;IAED,OAAO,CAAC,CAAC;AACb,CAAC,CAAC"}
|
Reference in New Issue
Block a user