diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/components/pdfjs/content/web | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/pdfjs/content/web')
-rw-r--r-- | toolkit/components/pdfjs/content/web/viewer-geckoview.mjs | 114 | ||||
-rw-r--r-- | toolkit/components/pdfjs/content/web/viewer.css | 4 | ||||
-rw-r--r-- | toolkit/components/pdfjs/content/web/viewer.mjs | 169 |
3 files changed, 147 insertions, 140 deletions
diff --git a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs index 866c4a405a..c309f8cf12 100644 --- a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs +++ b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs @@ -529,7 +529,6 @@ function toggleExpandedBtn(button, toggle, view = null) { } ;// CONCATENATED MODULE: ./web/app_options.js -const compatibilityParams = Object.create(null); const OptionKind = { BROWSER: 0x01, VIEWER: 0x02, @@ -772,11 +771,8 @@ class AppOptions { constructor() { throw new Error("Cannot initialize AppOptions."); } - static getCompat(name) { - return compatibilityParams[name] ?? undefined; - } static get(name) { - return userOptions[name] ?? compatibilityParams[name] ?? defaultOptions[name]?.value ?? undefined; + return userOptions[name] ?? defaultOptions[name]?.value ?? undefined; } static getAll(kind = null, defaultOnly = false) { const options = Object.create(null); @@ -785,7 +781,7 @@ class AppOptions { if (kind && !(kind & defaultOption.kind)) { continue; } - options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? compatibilityParams[name] ?? defaultOption.value; + options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value; } return options; } @@ -1252,7 +1248,6 @@ const { PDFWorker, PermissionFlag, PixelsPerInch, - PromiseCapability, RenderingCancelledException, renderTextLayer, setLayerDimensions, @@ -1270,35 +1265,38 @@ const WaitOnType = { EVENT: "event", TIMEOUT: "timeout" }; -function waitOnEventOrTimeout({ +async function waitOnEventOrTimeout({ target, name, delay = 0 }) { - return new Promise(function (resolve, reject) { - if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) { - throw new Error("waitOnEventOrTimeout - invalid parameters."); - } - function handler(type) { - if (target instanceof EventBus) { - target._off(name, eventHandler); - } else { - target.removeEventListener(name, eventHandler); - } - if (timeout) { - clearTimeout(timeout); - } - resolve(type); - } - const eventHandler = handler.bind(null, WaitOnType.EVENT); + if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) { + throw new Error("waitOnEventOrTimeout - invalid parameters."); + } + const { + promise, + resolve + } = Promise.withResolvers(); + function handler(type) { if (target instanceof EventBus) { - target._on(name, eventHandler); + target._off(name, eventHandler); } else { - target.addEventListener(name, eventHandler); + target.removeEventListener(name, eventHandler); } - const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT); - const timeout = setTimeout(timeoutHandler, delay); - }); + if (timeout) { + clearTimeout(timeout); + } + resolve(type); + } + const eventHandler = handler.bind(null, WaitOnType.EVENT); + if (target instanceof EventBus) { + target._on(name, eventHandler); + } else { + target.addEventListener(name, eventHandler); + } + const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT); + const timeout = setTimeout(timeoutHandler, delay); + return promise; } class EventBus { #listeners = Object.create(null); @@ -2200,10 +2198,8 @@ class PasswordPrompt { this.dialog.addEventListener("close", this.#cancel.bind(this)); } async open() { - if (this.#activeCapability) { - await this.#activeCapability.promise; - } - this.#activeCapability = new PromiseCapability(); + await this.#activeCapability?.promise; + this.#activeCapability = Promise.withResolvers(); try { await this.overlayManager.open(this.dialog); } catch (ex) { @@ -2326,7 +2322,6 @@ function getNormalizeWithNFKC() { ;// CONCATENATED MODULE: ./web/pdf_find_controller.js - const FindState = { FOUND: 0, NOT_FOUND: 1, @@ -2664,7 +2659,7 @@ class PDFFindController { this._dirtyMatch = false; clearTimeout(this._findTimeout); this._findTimeout = null; - this._firstPageCapability = new PromiseCapability(); + this._firstPageCapability = Promise.withResolvers(); } get #query() { const { @@ -2827,14 +2822,17 @@ class PDFFindController { if (this._extractTextPromises.length > 0) { return; } - let promise = Promise.resolve(); + let deferred = Promise.resolve(); const textOptions = { disableNormalization: true }; for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) { - const extractTextCapability = new PromiseCapability(); - this._extractTextPromises[i] = extractTextCapability.promise; - promise = promise.then(() => { + const { + promise, + resolve + } = Promise.withResolvers(); + this._extractTextPromises[i] = promise; + deferred = deferred.then(() => { return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => { const strBuf = []; for (const textItem of textContent.items) { @@ -2844,13 +2842,13 @@ class PDFFindController { } } [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); - extractTextCapability.resolve(); + resolve(); }, reason => { console.error(`Unable to get text content for page ${i + 1}`, reason); this._pageContents[i] = ""; this._pageDiffs[i] = null; this._hasDiacritics[i] = false; - extractTextCapability.resolve(); + resolve(); }); }); } @@ -3982,7 +3980,7 @@ class PDFScriptingManager { return; } await this.#willPrintCapability?.promise; - this.#willPrintCapability = new PromiseCapability(); + this.#willPrintCapability = Promise.withResolvers(); try { await this.#scripting.dispatchEventInSandbox({ id: "doc", @@ -4111,7 +4109,7 @@ class PDFScriptingManager { const pdfDocument = this.#pdfDocument, visitedPages = this._visitedPages; if (initialize) { - this.#closeCapability = new PromiseCapability(); + this.#closeCapability = Promise.withResolvers(); } if (!this.#closeCapability) { return; @@ -4161,7 +4159,7 @@ class PDFScriptingManager { }); } #initScripting() { - this.#destroyCapability = new PromiseCapability(); + this.#destroyCapability = Promise.withResolvers(); if (this.#scripting) { throw new Error("#initScripting: Scripting already exists."); } @@ -5116,7 +5114,7 @@ class PDFPageView { this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE; this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS; this.imageResourcesPath = options.imageResourcesPath || ""; - this.maxCanvasPixels = options.maxCanvasPixels ?? (AppOptions.getCompat("maxCanvasPixels") || 2 ** 25); + this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels"); this.pageColors = options.pageColors || null; this.eventBus = options.eventBus; this.renderingQueue = options.renderingQueue; @@ -5922,7 +5920,7 @@ class PDFViewer { #scaleTimeoutId = null; #textLayerMode = TextLayerMode.ENABLE; constructor(options) { - const viewerVersion = "4.1.342"; + const viewerVersion = "4.1.379"; if (version !== viewerVersion) { throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); } @@ -5977,7 +5975,7 @@ class PDFViewer { return new Set(this.#buffer); } get pageViewsReady() { - return this._pagesCapability.settled && this._pages.every(pageView => pageView?.pdfPage); + return this._pages.every(pageView => pageView?.pdfPage); } get renderForms() { return this.#annotationMode === AnnotationMode.ENABLE_FORMS; @@ -6280,7 +6278,7 @@ class PDFViewer { }; this.eventBus._on("pagerender", this._onBeforeDraw); this._onAfterDraw = evt => { - if (evt.cssTransform || this._onePageRenderedCapability.settled) { + if (evt.cssTransform) { return; } this._onePageRenderedCapability.resolve({ @@ -6452,9 +6450,9 @@ class PDFViewer { this._location = null; this._pagesRotation = 0; this._optionalContentConfigPromise = null; - this._firstPageCapability = new PromiseCapability(); - this._onePageRenderedCapability = new PromiseCapability(); - this._pagesCapability = new PromiseCapability(); + this._firstPageCapability = Promise.withResolvers(); + this._onePageRenderedCapability = Promise.withResolvers(); + this._pagesCapability = Promise.withResolvers(); this._scrollMode = ScrollMode.VERTICAL; this._previousScrollMode = ScrollMode.UNKNOWN; this._spreadMode = SpreadMode.NONE; @@ -7475,7 +7473,10 @@ const ViewOnLoad = { }; const PDFViewerApplication = { initialBookmark: document.location.hash.substring(1), - _initializedCapability: new PromiseCapability(), + _initializedCapability: { + ...Promise.withResolvers(), + settled: false + }, appConfig: null, pdfDocument: null, pdfLoadingTask: null, @@ -7550,6 +7551,7 @@ const PDFViewerApplication = { await this._initializeViewerComponents(); this.bindEvents(); this.bindWindowEvents(); + this._initializedCapability.settled = true; this._initializedCapability.resolve(); }, async _parseHashParams() { @@ -8608,6 +8610,10 @@ const PDFViewerApplication = { mediaQueryList.addEventListener("change", addWindowResolutionChange, { once: true }); + _boundEvents.removeWindowResolutionChange ||= function () { + mediaQueryList.removeEventListener("change", addWindowResolutionChange); + _boundEvents.removeWindowResolutionChange = null; + }; } addWindowResolutionChange(); _boundEvents.windowResize = () => { @@ -9531,8 +9537,8 @@ function webViewerReportTelemetry({ -const pdfjsVersion = "4.1.342"; -const pdfjsBuild = "e384df6f1"; +const pdfjsVersion = "4.1.379"; +const pdfjsBuild = "017e49244"; const AppConstants = null; window.PDFViewerApplication = PDFViewerApplication; window.PDFViewerApplicationConstants = AppConstants; diff --git a/toolkit/components/pdfjs/content/web/viewer.css b/toolkit/components/pdfjs/content/web/viewer.css index 2999c89f3a..063fa1632b 100644 --- a/toolkit/components/pdfjs/content/web/viewer.css +++ b/toolkit/components/pdfjs/content/web/viewer.css @@ -3513,7 +3513,7 @@ a:is(.toolbarButton, .secondaryToolbarButton)[href="#"]{ transition-property:none; .loadingInput:has(> &.loading)::after{ - display: block; + display:block; visibility:visible; transition-property:visibility; @@ -3525,7 +3525,7 @@ a:is(.toolbarButton, .secondaryToolbarButton)[href="#"]{ &::after{ position:absolute; visibility:hidden; - display: none; + display:none; top:calc(50% - 8px); width:16px; height:16px; diff --git a/toolkit/components/pdfjs/content/web/viewer.mjs b/toolkit/components/pdfjs/content/web/viewer.mjs index 778ce57e1a..864140b624 100644 --- a/toolkit/components/pdfjs/content/web/viewer.mjs +++ b/toolkit/components/pdfjs/content/web/viewer.mjs @@ -529,7 +529,6 @@ function toggleExpandedBtn(button, toggle, view = null) { } ;// CONCATENATED MODULE: ./web/app_options.js -const compatibilityParams = Object.create(null); const OptionKind = { BROWSER: 0x01, VIEWER: 0x02, @@ -772,11 +771,8 @@ class AppOptions { constructor() { throw new Error("Cannot initialize AppOptions."); } - static getCompat(name) { - return compatibilityParams[name] ?? undefined; - } static get(name) { - return userOptions[name] ?? compatibilityParams[name] ?? defaultOptions[name]?.value ?? undefined; + return userOptions[name] ?? defaultOptions[name]?.value ?? undefined; } static getAll(kind = null, defaultOnly = false) { const options = Object.create(null); @@ -785,7 +781,7 @@ class AppOptions { if (kind && !(kind & defaultOption.kind)) { continue; } - options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? compatibilityParams[name] ?? defaultOption.value; + options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value; } return options; } @@ -1252,7 +1248,6 @@ const { PDFWorker, PermissionFlag, PixelsPerInch, - PromiseCapability, RenderingCancelledException, renderTextLayer, setLayerDimensions, @@ -1270,35 +1265,38 @@ const WaitOnType = { EVENT: "event", TIMEOUT: "timeout" }; -function waitOnEventOrTimeout({ +async function waitOnEventOrTimeout({ target, name, delay = 0 }) { - return new Promise(function (resolve, reject) { - if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) { - throw new Error("waitOnEventOrTimeout - invalid parameters."); - } - function handler(type) { - if (target instanceof EventBus) { - target._off(name, eventHandler); - } else { - target.removeEventListener(name, eventHandler); - } - if (timeout) { - clearTimeout(timeout); - } - resolve(type); - } - const eventHandler = handler.bind(null, WaitOnType.EVENT); + if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) { + throw new Error("waitOnEventOrTimeout - invalid parameters."); + } + const { + promise, + resolve + } = Promise.withResolvers(); + function handler(type) { if (target instanceof EventBus) { - target._on(name, eventHandler); + target._off(name, eventHandler); } else { - target.addEventListener(name, eventHandler); + target.removeEventListener(name, eventHandler); } - const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT); - const timeout = setTimeout(timeoutHandler, delay); - }); + if (timeout) { + clearTimeout(timeout); + } + resolve(type); + } + const eventHandler = handler.bind(null, WaitOnType.EVENT); + if (target instanceof EventBus) { + target._on(name, eventHandler); + } else { + target.addEventListener(name, eventHandler); + } + const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT); + const timeout = setTimeout(timeoutHandler, delay); + return promise; } class EventBus { #listeners = Object.create(null); @@ -2480,10 +2478,8 @@ class PasswordPrompt { this.dialog.addEventListener("close", this.#cancel.bind(this)); } async open() { - if (this.#activeCapability) { - await this.#activeCapability.promise; - } - this.#activeCapability = new PromiseCapability(); + await this.#activeCapability?.promise; + this.#activeCapability = Promise.withResolvers(); try { await this.overlayManager.open(this.dialog); } catch (ex) { @@ -2642,7 +2638,7 @@ class PDFAttachmentViewer extends BaseTreeViewer { super.reset(); this._attachments = null; if (!keepRenderedCapability) { - this._renderedCapability = new PromiseCapability(); + this._renderedCapability = Promise.withResolvers(); } this._pendingDispatchEvent = false; } @@ -3039,7 +3035,7 @@ class PDFDocumentProperties { #reset() { this.pdfDocument = null; this.#fieldData = null; - this._dataAvailableCapability = new PromiseCapability(); + this._dataAvailableCapability = Promise.withResolvers(); this._currentPageNumber = 1; this._pagesRotation = 0; } @@ -3214,7 +3210,6 @@ function getNormalizeWithNFKC() { ;// CONCATENATED MODULE: ./web/pdf_find_controller.js - const FindState = { FOUND: 0, NOT_FOUND: 1, @@ -3552,7 +3547,7 @@ class PDFFindController { this._dirtyMatch = false; clearTimeout(this._findTimeout); this._findTimeout = null; - this._firstPageCapability = new PromiseCapability(); + this._firstPageCapability = Promise.withResolvers(); } get #query() { const { @@ -3715,14 +3710,17 @@ class PDFFindController { if (this._extractTextPromises.length > 0) { return; } - let promise = Promise.resolve(); + let deferred = Promise.resolve(); const textOptions = { disableNormalization: true }; for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) { - const extractTextCapability = new PromiseCapability(); - this._extractTextPromises[i] = extractTextCapability.promise; - promise = promise.then(() => { + const { + promise, + resolve + } = Promise.withResolvers(); + this._extractTextPromises[i] = promise; + deferred = deferred.then(() => { return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => { const strBuf = []; for (const textItem of textContent.items) { @@ -3732,13 +3730,13 @@ class PDFFindController { } } [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); - extractTextCapability.resolve(); + resolve(); }, reason => { console.error(`Unable to get text content for page ${i + 1}`, reason); this._pageContents[i] = ""; this._pageDiffs[i] = null; this._hasDiacritics[i] = false; - extractTextCapability.resolve(); + resolve(); }); }); } @@ -4722,7 +4720,6 @@ class PDFLayerViewer extends BaseTreeViewer { ;// CONCATENATED MODULE: ./web/pdf_outline_viewer.js - class PDFOutlineViewer extends BaseTreeViewer { constructor(options) { super(options); @@ -4735,9 +4732,7 @@ class PDFOutlineViewer extends BaseTreeViewer { }); this.eventBus._on("pagesloaded", evt => { this._isPagesLoaded = !!evt.pagesCount; - if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) { - this._currentOutlineItemCapability.resolve(this._isPagesLoaded); - } + this._currentOutlineItemCapability?.resolve(this._isPagesLoaded); }); this.eventBus._on("sidebarviewchanged", evt => { this._sidebarView = evt.view; @@ -4749,13 +4744,11 @@ class PDFOutlineViewer extends BaseTreeViewer { this._pageNumberToDestHashCapability = null; this._currentPageNumber = 1; this._isPagesLoaded = null; - if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) { - this._currentOutlineItemCapability.resolve(false); - } + this._currentOutlineItemCapability?.resolve(false); this._currentOutlineItemCapability = null; } _dispatchEvent(outlineCount) { - this._currentOutlineItemCapability = new PromiseCapability(); + this._currentOutlineItemCapability = Promise.withResolvers(); if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) { this._currentOutlineItemCapability.resolve(false); } else if (this._isPagesLoaded !== null) { @@ -4937,7 +4930,7 @@ class PDFOutlineViewer extends BaseTreeViewer { if (this._pageNumberToDestHashCapability) { return this._pageNumberToDestHashCapability.promise; } - this._pageNumberToDestHashCapability = new PromiseCapability(); + this._pageNumberToDestHashCapability = Promise.withResolvers(); const pageNumberToDestHash = new Map(), pageNumberNesting = new Map(); const queue = [{ @@ -5752,7 +5745,7 @@ class PDFScriptingManager { return; } await this.#willPrintCapability?.promise; - this.#willPrintCapability = new PromiseCapability(); + this.#willPrintCapability = Promise.withResolvers(); try { await this.#scripting.dispatchEventInSandbox({ id: "doc", @@ -5881,7 +5874,7 @@ class PDFScriptingManager { const pdfDocument = this.#pdfDocument, visitedPages = this._visitedPages; if (initialize) { - this.#closeCapability = new PromiseCapability(); + this.#closeCapability = Promise.withResolvers(); } if (!this.#closeCapability) { return; @@ -5931,7 +5924,7 @@ class PDFScriptingManager { }); } #initScripting() { - this.#destroyCapability = new PromiseCapability(); + this.#destroyCapability = Promise.withResolvers(); if (this.#scripting) { throw new Error("#initScripting: Scripting already exists."); } @@ -6409,7 +6402,7 @@ class PDFThumbnailView { } this.resume = null; } - _getPageDrawContext(upscaleFactor = 1) { + #getPageDrawContext(upscaleFactor = 1) { const canvas = document.createElement("canvas"); const ctx = canvas.getContext("2d", { alpha: false @@ -6424,11 +6417,11 @@ class PDFThumbnailView { transform }; } - _convertCanvasToImage(canvas) { + #convertCanvasToImage(canvas) { if (this.renderingState !== RenderingStates.FINISHED) { - throw new Error("_convertCanvasToImage: Rendering has not finished."); + throw new Error("#convertCanvasToImage: Rendering has not finished."); } - const reducedCanvas = this._reduceImage(canvas); + const reducedCanvas = this.#reduceImage(canvas); const image = document.createElement("img"); image.className = "thumbnailImage"; image.setAttribute("data-l10n-id", "pdfjs-thumb-page-canvas"); @@ -6448,7 +6441,7 @@ class PDFThumbnailView { return; } this.renderingState = RenderingStates.FINISHED; - this._convertCanvasToImage(canvas); + this.#convertCanvasToImage(canvas); if (error) { throw error; } @@ -6470,7 +6463,7 @@ class PDFThumbnailView { ctx, canvas, transform - } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR); + } = this.#getPageDrawContext(DRAW_UPSCALE_FACTOR); const drawViewport = this.viewport.clone({ scale: DRAW_UPSCALE_FACTOR * this.scale }); @@ -6525,13 +6518,13 @@ class PDFThumbnailView { return; } this.renderingState = RenderingStates.FINISHED; - this._convertCanvasToImage(canvas); + this.#convertCanvasToImage(canvas); } - _reduceImage(img) { + #reduceImage(img) { const { ctx, canvas - } = this._getPageDrawContext(); + } = this.#getPageDrawContext(); if (img.width <= 2 * canvas.width) { ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); return canvas; @@ -6585,16 +6578,16 @@ class PDFThumbnailViewer { this.linkService = linkService; this.renderingQueue = renderingQueue; this.pageColors = pageColors || null; - this.scroll = watchScroll(this.container, this._scrollUpdated.bind(this)); - this._resetView(); + this.scroll = watchScroll(this.container, this.#scrollUpdated.bind(this)); + this.#resetView(); } - _scrollUpdated() { + #scrollUpdated() { this.renderingQueue.renderHighestPriority(); } getThumbnail(index) { return this._thumbnails[index]; } - _getVisibleThumbs() { + #getVisibleThumbs() { return getVisibleElements({ scrollEl: this.container, views: this._thumbnails @@ -6618,7 +6611,7 @@ class PDFThumbnailViewer { first, last, views - } = this._getVisibleThumbs(); + } = this.#getVisibleThumbs(); if (views.length > 0) { let shouldScroll = false; if (pageNumber <= first.id || pageNumber >= last.id) { @@ -6672,7 +6665,7 @@ class PDFThumbnailViewer { } TempImageFactory.destroyCanvas(); } - _resetView() { + #resetView() { this._thumbnails = []; this._currentPageNumber = 1; this._pageLabels = null; @@ -6681,8 +6674,8 @@ class PDFThumbnailViewer { } setDocument(pdfDocument) { if (this.pdfDocument) { - this._cancelRendering(); - this._resetView(); + this.#cancelRendering(); + this.#resetView(); } this.pdfDocument = pdfDocument; if (!pdfDocument) { @@ -6717,7 +6710,7 @@ class PDFThumbnailViewer { console.error("Unable to initialize thumbnail viewer", reason); }); } - _cancelRendering() { + #cancelRendering() { for (const thumbnail of this._thumbnails) { thumbnail.cancelRendering(); } @@ -6762,7 +6755,7 @@ class PDFThumbnailViewer { return this.scroll.down; } forceRendering() { - const visibleThumbs = this._getVisibleThumbs(); + const visibleThumbs = this.#getVisibleThumbs(); const scrollAhead = this.#getScrollAhead(visibleThumbs); const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead); if (thumbView) { @@ -7694,7 +7687,7 @@ class PDFPageView { this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE; this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS; this.imageResourcesPath = options.imageResourcesPath || ""; - this.maxCanvasPixels = options.maxCanvasPixels ?? (AppOptions.getCompat("maxCanvasPixels") || 2 ** 25); + this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels"); this.pageColors = options.pageColors || null; this.eventBus = options.eventBus; this.renderingQueue = options.renderingQueue; @@ -8500,7 +8493,7 @@ class PDFViewer { #scaleTimeoutId = null; #textLayerMode = TextLayerMode.ENABLE; constructor(options) { - const viewerVersion = "4.1.342"; + const viewerVersion = "4.1.379"; if (version !== viewerVersion) { throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); } @@ -8555,7 +8548,7 @@ class PDFViewer { return new Set(this.#buffer); } get pageViewsReady() { - return this._pagesCapability.settled && this._pages.every(pageView => pageView?.pdfPage); + return this._pages.every(pageView => pageView?.pdfPage); } get renderForms() { return this.#annotationMode === AnnotationMode.ENABLE_FORMS; @@ -8858,7 +8851,7 @@ class PDFViewer { }; this.eventBus._on("pagerender", this._onBeforeDraw); this._onAfterDraw = evt => { - if (evt.cssTransform || this._onePageRenderedCapability.settled) { + if (evt.cssTransform) { return; } this._onePageRenderedCapability.resolve({ @@ -9030,9 +9023,9 @@ class PDFViewer { this._location = null; this._pagesRotation = 0; this._optionalContentConfigPromise = null; - this._firstPageCapability = new PromiseCapability(); - this._onePageRenderedCapability = new PromiseCapability(); - this._pagesCapability = new PromiseCapability(); + this._firstPageCapability = Promise.withResolvers(); + this._onePageRenderedCapability = Promise.withResolvers(); + this._pagesCapability = Promise.withResolvers(); this._scrollMode = ScrollMode.VERTICAL; this._previousScrollMode = ScrollMode.UNKNOWN; this._spreadMode = SpreadMode.NONE; @@ -10543,7 +10536,10 @@ const ViewOnLoad = { }; const PDFViewerApplication = { initialBookmark: document.location.hash.substring(1), - _initializedCapability: new PromiseCapability(), + _initializedCapability: { + ...Promise.withResolvers(), + settled: false + }, appConfig: null, pdfDocument: null, pdfLoadingTask: null, @@ -10617,6 +10613,7 @@ const PDFViewerApplication = { await this._initializeViewerComponents(); this.bindEvents(); this.bindWindowEvents(); + this._initializedCapability.settled = true; this._initializedCapability.resolve(); }, async _parseHashParams() { @@ -11708,6 +11705,10 @@ const PDFViewerApplication = { mediaQueryList.addEventListener("change", addWindowResolutionChange, { once: true }); + _boundEvents.removeWindowResolutionChange ||= function () { + mediaQueryList.removeEventListener("change", addWindowResolutionChange); + _boundEvents.removeWindowResolutionChange = null; + }; } addWindowResolutionChange(); _boundEvents.windowResize = () => { @@ -12631,8 +12632,8 @@ function webViewerReportTelemetry({ -const pdfjsVersion = "4.1.342"; -const pdfjsBuild = "e384df6f1"; +const pdfjsVersion = "4.1.379"; +const pdfjsBuild = "017e49244"; const AppConstants = null; window.PDFViewerApplication = PDFViewerApplication; window.PDFViewerApplicationConstants = AppConstants; |