Skip to content

[api-minor] Render high-res partial page views when falling back to CSS zoom (bug 1492303) #19128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3232,17 +3232,27 @@ class PDFObjects {
class RenderTask {
#internalRenderTask = null;

/**
* Callback for incremental rendering -- a function that will be called
* each time the rendering is paused. To continue rendering call the
* function that is the first argument to the callback.
* @type {function}
*/
onContinue = null;

/**
* A function that will be synchronously called when the rendering tasks
* finishes with an error (either because of an actual error, or because the
* rendering is cancelled).
*
* @type {function}
* @param {Error} error
*/
onError = null;

constructor(internalRenderTask) {
this.#internalRenderTask = internalRenderTask;

/**
* Callback for incremental rendering -- a function that will be called
* each time the rendering is paused. To continue rendering call the
* function that is the first argument to the callback.
* @type {function}
*/
this.onContinue = null;

if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
// For testing purposes.
Object.defineProperty(this, "getOperatorList", {
Expand Down Expand Up @@ -3399,13 +3409,13 @@ class InternalRenderTask {
}
InternalRenderTask.#canvasInUse.delete(this._canvas);

this.callback(
error ||
new RenderingCancelledException(
`Rendering cancelled, page ${this._pageIndex + 1}`,
extraDelay
)
error ||= new RenderingCancelledException(
`Rendering cancelled, page ${this._pageIndex + 1}`,
extraDelay
);
this.callback(error);

this.task.onError?.(error);
}

operatorListChanged() {
Expand Down
14 changes: 11 additions & 3 deletions test/integration/test_utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ import os from "os";

const isMac = os.platform() === "darwin";

function loadAndWait(filename, selector, zoom, setups, options) {
function loadAndWait(filename, selector, zoom, setups, options, viewport) {
return Promise.all(
global.integrationSessions.map(async session => {
const page = await session.browser.newPage();

if (viewport) {
await page.setViewport(viewport);
}

// In order to avoid errors because of checks which depend on
// a locale.
await page.evaluateOnNewDocument(() => {
Expand Down Expand Up @@ -566,8 +570,12 @@ function waitForAnnotationModeChanged(page) {

function waitForPageRendered(page) {
return createPromise(page, resolve => {
window.PDFViewerApplication.eventBus.on("pagerendered", resolve, {
once: true,
const { eventBus } = window.PDFViewerApplication;
eventBus.on("pagerendered", function handler(e) {
if (!e.isDetailView) {
resolve();
eventBus.off("pagerendered", handler);
}
});
});
}
Expand Down
Loading