Skip to content

Commit ceb7875

Browse files
committed
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.
1 parent a55cec4 commit ceb7875

3 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/display/text_layer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ class TextLayer {
472472
// their replacements when they aren't embedded) and then we can use an
473473
// OffscreenCanvas.
474474
const canvas = document.createElement("canvas");
475-
canvas.className = "hiddenCanvasElement";
475+
canvas.style.cssText =
476+
"position:absolute;top:0;left:0;width:0;height:0;display:none";
476477
canvas.lang = lang;
477478
document.body.append(canvas);
478479
ctx = canvas.getContext("2d", {

web/pdf_viewer.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@
7878
transform: rotate(270deg) translateX(-100%);
7979
}
8080

81-
#hiddenCopyElement,
82-
.hiddenCanvasElement {
83-
position: absolute;
84-
top: 0;
85-
left: 0;
86-
width: 0;
87-
height: 0;
88-
display: none;
89-
}
90-
9181
.pdfViewer {
9282
/* Define this variable here and not in :root to avoid to reflow all the UI
9383
when scaling (see #15929). */

web/pdf_viewer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,8 @@ class PDFViewer {
967967
const element = (this.#hiddenCopyElement =
968968
document.createElement("div"));
969969
element.id = "hiddenCopyElement";
970+
element.style.cssText =
971+
"position:absolute;top:0;left:0;width:0;height:0;display:none";
970972
viewer.before(element);
971973
}
972974

0 commit comments

Comments
 (0)