From 9a03d36af407c2f1736405bd0754378205dfb5ef Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 25 Sep 2022 10:41:06 +0200 Subject: [PATCH] Remove some unused code from the `_queueLoadingCallback` method (PR 3477 follow-up) The existing `loadingContext` class-property can be simplified slightly, since we've not been using the `id`-property on the requests ever since PR 3477 (which landed nine years ago). Furthermore, by default we're also not even using that code-path now since the Font Loading API will always be used when available. --- src/display/font_loader.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/display/font_loader.js b/src/display/font_loader.js index c67699053..c8998218b 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -167,10 +167,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { FontLoader = class GenericFontLoader extends BaseFontLoader { constructor(params) { super(params); - this.loadingContext = { - requests: [], - nextRequestId: 0, - }; + this.loadingRequests = []; this.loadTestFontId = 0; } @@ -201,20 +198,19 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { request.done = true; // Sending all completed requests in order of how they were queued. - while (context.requests.length > 0 && context.requests[0].done) { - const otherRequest = context.requests.shift(); + while (loadingRequests.length > 0 && loadingRequests[0].done) { + const otherRequest = loadingRequests.shift(); setTimeout(otherRequest.callback, 0); } } - const context = this.loadingContext; + const { loadingRequests } = this; const request = { - id: `pdfjs-font-loading-${context.nextRequestId++}`, done: false, complete: completeRequest, callback, }; - context.requests.push(request); + loadingRequests.push(request); return request; }