From fbbbe3a5426a0b3f846e0f75f51228a2520d7661 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 13 Oct 2020 15:52:57 +0200 Subject: [PATCH] Remove the `scope` parameter from the "GetOperatorList" handler in `src/core/worker.js` (PR 11110 follow-up) Support for the `scope` parameter, in `MessageHandler.on`, was removed in PR 11110 however this particular case was unused/unnecessary for years prior to that change. (From a quick look through the history, I'm not even sure if it was even needed in the first place.) --- src/core/worker.js | 101 +++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/src/core/worker.js b/src/core/worker.js index 673b3f45cf291e..790c3a61435623 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -599,61 +599,56 @@ class WorkerMessageHandler { }); }); - handler.on( - "GetOperatorList", - function wphSetupRenderPage(data, sink) { - var pageIndex = data.pageIndex; - pdfManager.getPage(pageIndex).then(function (page) { - var task = new WorkerTask(`GetOperatorList: page ${pageIndex}`); - startWorkerTask(task); + handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) { + var pageIndex = data.pageIndex; + pdfManager.getPage(pageIndex).then(function (page) { + var task = new WorkerTask(`GetOperatorList: page ${pageIndex}`); + startWorkerTask(task); - // NOTE: Keep this condition in sync with the `info` helper function. - const start = verbosity >= VerbosityLevel.INFOS ? Date.now() : 0; - - // Pre compile the pdf page and fetch the fonts/images. - page - .getOperatorList({ - handler, - sink, - task, - intent: data.intent, - renderInteractiveForms: data.renderInteractiveForms, - annotationStorage: data.annotationStorage, - }) - .then( - function (operatorListInfo) { - finishWorkerTask(task); - - if (start) { - info( - `page=${pageIndex + 1} - getOperatorList: time=` + - `${Date.now() - start}ms, len=${operatorListInfo.length}` - ); - } - sink.close(); - }, - function (reason) { - finishWorkerTask(task); - if (task.terminated) { - return; // ignoring errors from the terminated thread - } - // For compatibility with older behavior, generating unknown - // unsupported feature notification on errors. - handler.send("UnsupportedFeature", { - featureId: UNSUPPORTED_FEATURES.errorOperatorList, - }); - - sink.error(reason); - - // TODO: Should `reason` be re-thrown here (currently that - // casues "Uncaught exception: ..." messages in the - // console)? + // NOTE: Keep this condition in sync with the `info` helper function. + const start = verbosity >= VerbosityLevel.INFOS ? Date.now() : 0; + + // Pre compile the pdf page and fetch the fonts/images. + page + .getOperatorList({ + handler, + sink, + task, + intent: data.intent, + renderInteractiveForms: data.renderInteractiveForms, + annotationStorage: data.annotationStorage, + }) + .then( + function (operatorListInfo) { + finishWorkerTask(task); + + if (start) { + info( + `page=${pageIndex + 1} - getOperatorList: time=` + + `${Date.now() - start}ms, len=${operatorListInfo.length}` + ); } - ); - }); - }, - this - ); + sink.close(); + }, + function (reason) { + finishWorkerTask(task); + if (task.terminated) { + return; // ignoring errors from the terminated thread + } + // For compatibility with older behavior, generating unknown + // unsupported feature notification on errors. + handler.send("UnsupportedFeature", { + featureId: UNSUPPORTED_FEATURES.errorOperatorList, + }); + + sink.error(reason); + + // TODO: Should `reason` be re-thrown here (currently that casues + // "Uncaught exception: ..." messages in the console)? + } + ); + }); + }); handler.on("GetTextContent", function wphExtractText(data, sink) { var pageIndex = data.pageIndex;