Fix ToCToU issue with canvas resizing

This could end up in endless resizing&repainting of the markup canvas.
This commit is contained in:
Simon Rozman 2025-02-28 09:44:51 +01:00
parent 16e85f5498
commit 0ed93fb9b2

View File

@ -885,12 +885,14 @@ class BesService {
this.canvasPanel.style.height = `${this.hostElement.scrollHeight}px`
const dpr = window.devicePixelRatio
const canvasPanelRect = this.canvasPanel.getBoundingClientRect()
const newCanvasWidth = Math.round(canvasPanelRect.width * dpr)
const newCanvasHeight = Math.round(canvasPanelRect.height * dpr)
if (
this.canvasPanel.width !== canvasPanelRect.width * dpr ||
this.canvasPanel.height !== canvasPanelRect.height * dpr
this.canvasPanel.width !== newCanvasWidth ||
this.canvasPanel.height !== newCanvasHeight
) {
this.canvasPanel.width = Math.round(canvasPanelRect.width * dpr)
this.canvasPanel.height = Math.round(canvasPanelRect.height * dpr)
this.canvasPanel.width = newCanvasWidth
this.canvasPanel.height = newCanvasHeight
this.repositionAllMarkup()
}
if (this.isHostElementInline()) {