Skip to content

Commit 9d917b2

Browse files
authored
Merge pull request #20323 from calixteman/bug1991482
Increase the rendering quality of the detail view (bug 1991482)
2 parents 7fa5071 + 91e2f6c commit 9d917b2

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

test/integration/viewer_spec.mjs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,12 @@ describe("PDF viewer", () => {
364364
.toBeLessThan(originalCanvasSize * factor ** 2);
365365

366366
expect(canvasSize)
367-
.withContext(`In ${browserName}, <= MAX_CANVAS_PIXELS / 100`)
368-
.toBeLessThanOrEqual(MAX_CANVAS_PIXELS.get(browserName) / 100);
367+
.withContext(`In ${browserName}, <= MAX_CANVAS_PIXELS / 4`)
368+
.toBeLessThanOrEqual(MAX_CANVAS_PIXELS.get(browserName) / 4);
369369

370370
expect(canvasSize)
371-
.withContext(
372-
`In ${browserName}, > MAX_CANVAS_PIXELS / 100 * 0.95`
373-
)
374-
.toBeGreaterThan(
375-
(MAX_CANVAS_PIXELS.get(browserName) / 100) * 0.95
376-
);
371+
.withContext(`In ${browserName}, > MAX_CANVAS_PIXELS / 4 * 0.95`)
372+
.toBeGreaterThan((MAX_CANVAS_PIXELS.get(browserName) / 4) * 0.95);
377373
})
378374
);
379375
});
@@ -570,10 +566,10 @@ describe("PDF viewer", () => {
570566
.toBe(2);
571567
expect(after[0].width)
572568
.withContext(`In ${browserName}`)
573-
.toBe(Math.floor(58.2 * pixelRatio));
569+
.toBe(Math.floor(291 * pixelRatio));
574570
expect(after[0].height)
575571
.withContext(`In ${browserName}`)
576-
.toBe(Math.floor(82.3 * pixelRatio));
572+
.toBe(Math.floor(411.5 * pixelRatio));
577573

578574
// The dimensions of the detail canvas are capped to 800x600 but
579575
// it depends on the visible area which depends itself of the

web/pdf_page_detail_view.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ class PDFPageDetailView extends BasePDFPageView {
267267
canvasWrapper.prepend(newCanvas);
268268
}
269269
}, hideUntilComplete);
270-
canvas.setAttribute("aria-hidden", "true");
270+
canvas.ariaHidden = true;
271+
if (this.enableOptimizedPartialRendering) {
272+
canvas.className = "detailView";
273+
}
271274

272275
const { width, height } = viewport;
273276

web/pdf_page_view.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,12 @@ class PDFPageView extends BasePDFPageView {
804804
if (this.#needsRestrictedScaling && this.enableDetailCanvas) {
805805
// If we are going to have a high-res detail view, further reduce
806806
// the canvas resolution to improve rendering performance.
807-
outputScale.sx /= 10;
808-
outputScale.sy /= 10;
807+
// When enableOptimizedPartialRendering is enabled the factor can be
808+
// higher since less data will be rendered and it's more acceptable to
809+
// have a lower quality (the canvas is exposed less time to the user).
810+
const factor = this.enableOptimizedPartialRendering ? 4 : 2;
811+
outputScale.sx /= factor;
812+
outputScale.sy /= factor;
809813
}
810814
}
811815
}

web/pdf_viewer.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@
9999
.structTree {
100100
contain: strict;
101101
}
102+
103+
&.detailView {
104+
image-rendering: pixelated;
105+
}
102106
}
103107
}
104108
}

0 commit comments

Comments
 (0)