[api-minor] Add a new PageViewport-getter to access the original, un-scaled, viewport dimensions

While reviewing recent patches, I couldn't help but noticing that we now have a lot of call-sites that manually access the `PageViewport.viewBox`-property.
Rather than repeating that verbatim all over the code-base, this patch adds a lazily computed and cached getter for this data instead.
This commit is contained in:
Jonas Jenwald 2022-12-08 12:37:18 +01:00
parent 8e11cf9b1c
commit cafdc48147
5 changed files with 45 additions and 41 deletions

View file

@ -325,10 +325,10 @@ class TextLayerRenderTask {
properties: null,
ctx: getCtx(0, isOffscreenCanvasSupported),
};
const [pageLLx, pageLLy, pageURx, pageURy] = viewport.viewBox;
this._transform = [1, 0, 0, -1, -pageLLx, pageURy];
this._pageWidth = pageURx - pageLLx;
this._pageHeight = pageURy - pageLLy;
const { pageWidth, pageHeight, pageX, pageY } = viewport.rawDims;
this._transform = [1, 0, 0, -1, -pageX, pageY + pageHeight];
this._pageWidth = pageWidth;
this._pageHeight = pageHeight;
setLayerDimensions(container, viewport);