mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-22 16:05:56 +02:00
Merge pull request #18109 from Snuffleupagus/textLayer-no-cleanup-on-pending
Don't invoke `cleanupTextLayer` when there are pending textLayers
This commit is contained in:
commit
63b66b412c
@ -63,6 +63,7 @@ const DEFAULT_FONT_SIZE = 30;
|
|||||||
const DEFAULT_FONT_ASCENT = 0.8;
|
const DEFAULT_FONT_ASCENT = 0.8;
|
||||||
const ascentCache = new Map();
|
const ascentCache = new Map();
|
||||||
let _canvasContext = null;
|
let _canvasContext = null;
|
||||||
|
const pendingTextLayers = new Set();
|
||||||
|
|
||||||
function getCtx(lang = null) {
|
function getCtx(lang = null) {
|
||||||
if (!_canvasContext) {
|
if (!_canvasContext) {
|
||||||
@ -85,6 +86,9 @@ function getCtx(lang = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanupTextLayer() {
|
function cleanupTextLayer() {
|
||||||
|
if (pendingTextLayers.size > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_canvasContext?.canvas.remove();
|
_canvasContext?.canvas.remove();
|
||||||
_canvasContext = null;
|
_canvasContext = null;
|
||||||
}
|
}
|
||||||
@ -245,9 +249,11 @@ class TextLayerRenderTask {
|
|||||||
|
|
||||||
setLayerDimensions(container, viewport);
|
setLayerDimensions(container, viewport);
|
||||||
|
|
||||||
|
pendingTextLayers.add(this);
|
||||||
// Always clean-up the temporary canvas once rendering is no longer pending.
|
// Always clean-up the temporary canvas once rendering is no longer pending.
|
||||||
this._capability.promise
|
this._capability.promise
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
pendingTextLayers.delete(this);
|
||||||
this._layoutTextParams = null;
|
this._layoutTextParams = null;
|
||||||
this._styleCache = null;
|
this._styleCache = null;
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user