fix: inline styles for hidden helper elements

Set layout-neutral styles at the creation sites for the hidden TextLayer
canvas and PDFViewer copy element rather than relying on the shared
web/pdf_viewer.css rule.

This keeps the helper elements invisible and out of layout when viewer CSS
selectors are scoped or omitted, and removes the obsolete hiddenCanvasElement
class and shared CSS rule.
This commit is contained in:
Roland Arnold 2026-05-03 18:30:40 +01:00
parent 7ade637449
commit 16d82e094f
3 changed files with 4 additions and 11 deletions

View File

@ -472,7 +472,8 @@ class TextLayer {
// their replacements when they aren't embedded) and then we can use an
// OffscreenCanvas.
const canvas = document.createElement("canvas");
canvas.className = "hiddenCanvasElement";
canvas.style.cssText =
"position:absolute;top:0;left:0;width:0;height:0;display:none";
canvas.lang = lang;
document.body.append(canvas);
ctx = canvas.getContext("2d", {

View File

@ -78,16 +78,6 @@
transform: rotate(270deg) translateX(-100%);
}
#hiddenCopyElement,
.hiddenCanvasElement {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
display: none;
}
.pdfViewer {
/* Define this variable here and not in :root to avoid to reflow all the UI
when scaling (see #15929). */

View File

@ -967,6 +967,8 @@ class PDFViewer {
const element = (this.#hiddenCopyElement =
document.createElement("div"));
element.id = "hiddenCopyElement";
element.style.cssText =
"position:absolute;top:0;left:0;width:0;height:0;display:none";
viewer.before(element);
}