Skip to content
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

Introduce tests for CSS-only zooming #18105

Closed
timvandermeij opened this issue May 16, 2024 · 2 comments · Fixed by #18218 or #18129
Closed

Introduce tests for CSS-only zooming #18105

timvandermeij opened this issue May 16, 2024 · 2 comments · Fixed by #18218 or #18129
Labels

Comments

@timvandermeij
Copy link
Contributor

timvandermeij commented May 16, 2024

In PR #18077 we found that we currently don't have any tests for the CSS-only zooming functionality in the viewer. We should ideally implement two (most likely integration) tests:

/cc @nicolo-ribaudo

@nicolo-ribaudo
Copy link
Contributor

nicolo-ribaudo commented May 21, 2024

I opened #18129 for the second point. Regarding the first point, I tried but I cannot figure out how to get hasRestrictedScaling to be true (in the integration tests browser window) at

if (this.#hasRestrictedScaling) {

I could check how big is exactly the window on my machine and which display density it reports, but it feels very brittle and specific to my setup.

@timvandermeij
Copy link
Contributor Author

I'm not 100% sure, but looking at

pdf.js/web/pdf_page_view.js

Lines 1014 to 1023 in 9ee7c07

} else if (this.maxCanvasPixels > 0) {
const pixelsInViewport = width * height;
const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
outputScale.sx = maxScale;
outputScale.sy = maxScale;
this.#hasRestrictedScaling = true;
} else {
this.#hasRestrictedScaling = false;
}
I wonder if setting maxCanvasPixels to a low value might already suffice to trigger CSS-only zooming? I think it could follow the same pattern as you already introduced in #18129. I agree that we shouldn't depend on the environment the test is run in; ideally we can simply force the viewer to use CSS-only zooming after e.g. a certain zoom percentage (the current viewer should already do that; try zooming to 900% and notice that the canvas doesn't change in terms of width/height attribute anymore in the web console).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants