Ensure TextLayer hiddenCanvasElement is layout-neutral by default#21218
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #21218 +/- ##
==========================================
+ Coverage 79.48% 79.50% +0.01%
==========================================
Files 254 254
Lines 64859 64860 +1
==========================================
+ Hits 51553 51565 +12
+ Misses 13306 13295 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Snuffleupagus
left a comment
There was a problem hiding this comment.
Given that using the textLayer requires also using the pdf_viewer.css file, since otherwise things are simply not guaranteed to work, it's not clear (at least to me) why this effectively duplicated code should be added here!?
|
Thanks for the quick review. I understand that Consumers building custom viewer chrome may include the viewer CSS but scope/rewrite its selectors to avoid leaking PDF.js viewer styles into the surrounding application. In that setup, the rest of the text-layer CSS is present, but That's why I thought applying the essential layout-neutralizing property at the creation site might be appropriate: the body-appended helper would not depend on a viewer-subtree stylesheet rule to avoid participating in host-page layout. If the project’s position is that |
fcfd0f3 to
3b05d2e
Compare
Snuffleupagus
left a comment
There was a problem hiding this comment.
Please also remember to write a good commit message, since a single line is rarely sufficient.
3b05d2e to
ceb7875
Compare
|
Updated again:
|
|
/botio browsertest |
From: Bot.io (Windows)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/5780beff9529d55/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/05f99bdd87ab526/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/05f99bdd87ab526/output.txt Total script time: 18.64 mins
Image differences available at: http://54.241.84.105:8877/05f99bdd87ab526/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/5780beff9529d55/output.txt Total script time: 24.59 mins
Image differences available at: http://54.193.163.58:8877/5780beff9529d55/reftest-analyzer.html#web=eq.log |
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.
ceb7875 to
16d82e0
Compare
|
Rebased on current master and force-pushed. I also rechecked the helper-element changes and don't see anything that would obviously explain the |
|
The |
|
Thanks for letting me know. |
TextLayercreates a helper canvas with classhiddenCanvasElementand appends it directly todocument.body, which can adversely affect the host-page layout/scrolling behavior.The stock viewer stylesheet
web/pdf_viewer.cssalready makes this element layout-neutral via.hiddenCanvasElement { ... display: none; }, but directpdfjs-dist/TextLayerconsumers are not required to loadweb/pdf_viewer.css. Consumers that scope the viewer stylesheet to avoid global CSS leakage also lose this protection, since the helper canvas is appended outside the scoped viewer subtree.This change applies the essential layout-neutralizing rule at the creation site, so the display-layer helper does not depend on viewer CSS to avoid participating in host-page layout.
Related context:
react-pdfadded the.hiddenCanvasElementCSS rule downstream in Hidden canvas element may break layout wojtekmaj/react-pdf#1815 to avoid layout side effects.