fix: zero size iframe rendering (#1863)

This commit is contained in:
Radics Laszlo 2019-06-18 06:23:45 +02:00 committed by Niklas von Hertzen
parent 61f4819e02
commit 81dcf7b6be
2 changed files with 15 additions and 13 deletions

View File

@ -15,8 +15,8 @@ export class IFrameElementContainer extends ElementContainer {
constructor(iframe: HTMLIFrameElement) { constructor(iframe: HTMLIFrameElement) {
super(iframe); super(iframe);
this.src = iframe.src; this.src = iframe.src;
this.width = parseInt(iframe.width, 10); this.width = parseInt(iframe.width, 10) || 0;
this.height = parseInt(iframe.height, 10); this.height = parseInt(iframe.height, 10) || 0;
this.backgroundColor = this.styles.backgroundColor; this.backgroundColor = this.styles.backgroundColor;
try { try {
if ( if (

View File

@ -306,18 +306,20 @@ export class CanvasRenderer {
}); });
const canvas = await iframeRenderer.render(container.tree); const canvas = await iframeRenderer.render(container.tree);
if (container.width && container.height) {
this.ctx.drawImage( this.ctx.drawImage(
canvas, canvas,
0, 0,
0, 0,
container.width, container.width,
container.width, container.height,
container.bounds.left, container.bounds.left,
container.bounds.top, container.bounds.top,
container.bounds.width, container.bounds.width,
container.bounds.height container.bounds.height
); );
} }
}
if (container instanceof InputElementContainer) { if (container instanceof InputElementContainer) {
const size = Math.min(container.bounds.width, container.bounds.height); const size = Math.min(container.bounds.width, container.bounds.height);