From 7c25b1b455e262baa79b38c6563117d91d646aa3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 29 Nov 2022 19:57:38 +0100 Subject: [PATCH] [api-minor] Remove the TextLayer `timeout` parameter (PR 15742 follow-up) The deprecation is included in the current release, i.e. version `3.1.81`, and given the edge-case nature of this option I really don't think that we need to keep it deprecated for multiple releases. --- src/display/text_layer.js | 30 +++--------------------------- web/text_layer_builder.js | 6 +----- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/display/text_layer.js b/src/display/text_layer.js index 253177379..b4e84b8df 100644 --- a/src/display/text_layer.js +++ b/src/display/text_layer.js @@ -18,7 +18,6 @@ import { createPromiseCapability, Util, } from "../shared/util.js"; -import { deprecated } from "./display_utils.js"; /** * Text layer render parameters. @@ -38,8 +37,6 @@ import { deprecated } from "./display_utils.js"; * @property {Array} [textContentItemsStr] - Strings that correspond to * the `str` property of the text items of the textContent input. * This is output and shall initially be set to an empty array. - * @property {number} [timeout] - Delay in milliseconds before rendering of the - * text runs occurs. */ const MAX_TEXT_DIVS_TO_RENDER = 100000; @@ -250,7 +247,6 @@ class TextLayerRenderTask { this._renderingDone = false; this._canceled = false; this._capability = createPromiseCapability(); - this._renderTimer = null; this._devicePixelRatio = globalThis.devicePixelRatio || 1; // Always clean-up the temporary canvas once rendering is no longer pending. @@ -293,10 +289,6 @@ class TextLayerRenderTask { }); this._reader = null; } - if (this._renderTimer !== null) { - clearTimeout(this._renderTimer); - this._renderTimer = null; - } this._capability.reject(new Error("TextLayer task cancelled.")); } @@ -378,7 +370,7 @@ class TextLayerRenderTask { /** * @private */ - _render(timeout = 0) { + _render() { const capability = createPromiseCapability(); let styleCache = Object.create(null); @@ -417,23 +409,7 @@ class TextLayerRenderTask { capability.promise.then(() => { styleCache = null; - if (!timeout) { - // Render right away - render(this); - } else { - if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) { - throw new Error("The `timeout` parameter was removed."); - } - deprecated( - "The TextLayerRender `timeout` parameter will be removed in the " + - "future, since streaming of textContent has made it obsolete." - ); - // Schedule - this._renderTimer = setTimeout(() => { - render(this); - this._renderTimer = null; - }, timeout); - } + render(this); }, this._capability.reject); } } @@ -451,7 +427,7 @@ function renderTextLayer(renderParameters) { textDivs: renderParameters.textDivs, textContentItemsStr: renderParameters.textContentItemsStr, }); - task._render(renderParameters.timeout); + task._render(); return task; } diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js index 070cd1b17..f79371924 100644 --- a/web/text_layer_builder.js +++ b/web/text_layer_builder.js @@ -79,11 +79,8 @@ class TextLayerBuilder { /** * Renders the text layer. - * - * @param {number} [timeout] - Wait for a specified amount of milliseconds - * before rendering. */ - render(timeout = 0) { + render() { if (!(this.textContent || this.textContentStream) || this.renderingDone) { return; } @@ -101,7 +98,6 @@ class TextLayerBuilder { viewport: this.viewport, textDivs: this.textDivs, textContentItemsStr: this.textContentItemsStr, - timeout, }); this.textLayerRenderTask.promise.then( () => {