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

Workaround WebKit canvas rendering bug when zooming PDFs #17571

Closed
Closed
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
24 changes: 22 additions & 2 deletions web/pdf_viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@

.pdfViewer .canvasWrapper {
overflow: hidden;
width: 100%;
/* See `width: inherit` comment in `.pdfViewer .page canvas[zooming]` for the reason
* we use `inherit` and not `100%`. */
width: inherit;
height: 100%;
z-index: 1;
}
Expand Down Expand Up @@ -166,7 +168,25 @@
}

.pdfViewer .page canvas[zooming] {
width: 100%;
/* WebKit has a bug when rendering canvases that have their width defined as
* relative to their container, and their parent is resized. This causes a
* "tearing" effect when zooming in PDFs past a certain threshold, which
* is devide-dependent but tends to be between 120% and 200%.
*
* The DOM structure around the canvas is as follows:
* div.pdfViewer [ --scale-factor: ...; ]
* > div.page [ width: round(var(--scale-factor) * ..., 1px); ]
* > div.canvasWrapper
* > canvas
*
* Setting `width: inherit` on the div.canvasWrapper and on the canvas is
* equivalent to explicitly specifying the same `width` property in pixels
* as in div.page, thus making Safari properly redraw the canvas on resize.
*
* See https://bugs.webkit.org/show_bug.cgi?id=267986 for more details
* on the WebKit bug.
*/
width: inherit;
height: 100%;
}

Expand Down