Commit Graph

16980 Commits

Author SHA1 Message Date
Jonas Jenwald
1fc09f0235 Enable the unicorn/prefer-string-replace-all ESLint plugin rule
Note that the `replaceAll` method still requires that a *global* regular expression is used, however by using this method it's immediately obvious when looking at the code that all occurrences will be replaced; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#parameters

Please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
2023-03-23 12:57:10 +01:00
Jonas Jenwald
5f64621d46 Use String.prototype.replaceAll() where appropriate
This fairly new method allows replacing *multiple* occurrences within a string without having to use regular expressions.

Please refer to:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#browser_compatibility
2023-03-22 15:31:10 +01:00
Jonas Jenwald
076bb30b6c
Merge pull request #16182 from Snuffleupagus/inset-block
Introduce `inset-block` usage in the viewer CSS
2023-03-22 12:59:10 +01:00
Jonas Jenwald
915bdd6576
Merge pull request #16173 from Snuffleupagus/inset
Introduce `inset` usage in the CSS files
2023-03-22 12:57:57 +01:00
Jonas Jenwald
39bbd8c94f
Merge pull request #16193 from Snuffleupagus/non-standard-ligatures
Add even more non-standard ligatures (PR 15517 follow-up)
2023-03-22 12:27:54 +01:00
Jonas Jenwald
137a2d6e30 Add even more non-standard ligatures (PR 15517 follow-up)
Given that we already create multi-byte ToUnicode entries in other cases, see e.g. the `getNormalizedUnicodes` table, this is hopefully fine.
2023-03-22 10:42:52 +01:00
Jonas Jenwald
f39ff20485
Merge pull request #16191 from Snuffleupagus/XRefStm-Set
Track previous "XRefStm"s in a `Set`, rather than an `Object`
2023-03-22 10:25:53 +01:00
Jonas Jenwald
122d5e549a Track previous "XRefStm"s in a Set, rather than an Object
Having just reviewed a patch touching this code, I couldn't help noticing that an `Object` isn't really the optimal data-structure for this and nowadays we can do better by using a `Set` instead.
2023-03-22 09:41:19 +01:00
Jonas Jenwald
9321758d91
Merge pull request #16186 from Snuffleupagus/issue-16176
Support multi-byte ToUnicode entries, when using predefined CMaps (issue 16176)
2023-03-21 22:17:18 +01:00
Jonas Jenwald
d4bcfe8c16 Support multi-byte ToUnicode entries, when using predefined CMaps (issue 16176)
Hopefully this makes sense, since we already "create" multi-byte ToUnicode entries in other cases (see e.g. the `getNormalizedUnicodes` table).
2023-03-21 21:35:57 +01:00
calixteman
8bfebf1c24
Merge pull request #16188 from calixteman/bug1823296
Use the position of the previous xref stream if any when saving a pdf (bug 1823296)
2023-03-21 21:21:49 +01:00
Calixte Denizet
2d0f30a67c Use the position of the previous xref stream if any when saving a pdf (bug 1823296) 2023-03-21 19:27:24 +01:00
Jonas Jenwald
a3ab2f6790 Introduce inset-block usage in the viewer CSS
Given that the viewer always set the `dir`-attribute, to either LTR or RTL, we should be able to use this logical CSS property to (very slightly) reduce the size of the CSS; please see https://developer.mozilla.org/en-US/docs/Web/CSS/inset-block
2023-03-20 16:42:39 +01:00
Jonas Jenwald
b1e0253f29
Merge pull request #16175 from Snuffleupagus/LoopbackPort-transfer
Fix the `transfer` parameter, for `structuredClone`, in the `LoopbackPort`
2023-03-20 14:22:09 +01:00
Jonas Jenwald
a29c131e90
Merge pull request #16181 from Snuffleupagus/pr-16162
Only warn about missing `--scale-factor` CSS-variable for visible textLayers (PR 16162 follow-up)
2023-03-20 14:21:37 +01:00
Jonas Jenwald
8bf5e96af9 Only warn about missing --scale-factor CSS-variable for visible textLayers (PR 16162 follow-up)
This is something that I completely overlooked in PR 16162, which in some cases cause the default viewer to incorrectly print warnings.
This can be reproduced with the PAGE scrolling-mode, and/or the PresentationMode, and this patch simply work-around it by checking the visibility as well (since the warning is a best-effort solution anyway).
2023-03-20 12:51:26 +01:00
Jonas Jenwald
fb2367d14f
Merge pull request #16180 from Snuffleupagus/appendFeFunc
Add a helper, in `DOMFilterFactory`, to reduce duplication when creating `<feFuncX>`s
2023-03-20 12:41:03 +01:00
Jonas Jenwald
cc9f6650a8 Stop passing in pageColors to the CanvasGraphics-constructor (PR 16075 follow-up)
The `pageColors`-option was removed from the `CanvasGraphics`-constructor in PR 16075, hence the code in the API no longer needs to pass in that option; this is something that I missed during review.
2023-03-20 11:41:57 +01:00
Jonas Jenwald
86cf62699c Add a helper, in DOMFilterFactory, to reduce duplication when creating <feFuncX>s
Currently we repeat the same code verbatim multiple times in the `DOMFilterFactory`, which seems completely unnecessary.
2023-03-20 11:27:47 +01:00
calixteman
3903391f3c
Merge pull request #16075 from calixteman/svg_filter_hcm
[api-minor] Use a SVG filter when rendering pages in HCM
2023-03-20 10:18:25 +01:00
Jonas Jenwald
c4a725fe98 Fix the transfer parameter, for structuredClone, in the LoopbackPort
The way that we handle the `transfer` parameter is unfortunately wrong, ever since PR 14392 which introduced the code, given that the MDN article originally contained incorrect information; please see https://github.com/mdn/content/pull/23164

By updating the `structuredClone` call such that it works correctly, we can enable more unit-tests in Node.js environments; please refer to https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#parameters
2023-03-19 22:04:01 +01:00
Jonas Jenwald
553c2e05cd Introduce inset usage in the CSS files
The `inset` property is a nice shorthand that can be used to avoid having to specify the positions individually; please see
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline
2023-03-19 14:32:37 +01:00
Tim van der Meij
33f5d94f23
Merge pull request #16172 from Snuffleupagus/margin-inline
Use `margin-inline` in the `web/pdf_viewer.css` file (PR 14670 follow-up)
2023-03-19 12:43:44 +01:00
Tim van der Meij
6b89e66bd0
Merge pull request #16169 from Snuffleupagus/viewer-html-preprocessor-cleanup
Clean-up the pre-processor statements in `web/viewer.html`
2023-03-19 12:34:11 +01:00
Jonas Jenwald
1efe41c248 Use margin-inline in the web/pdf_viewer.css file (PR 14670 follow-up)
Given that the viewer always set the `dir`-attribute, we should be able to use logical margins in this CSS file as well; please also see https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline
2023-03-19 12:31:34 +01:00
Tim van der Meij
27fe7e9e72
Merge pull request #16171 from Snuffleupagus/PDFViewer-cleanup-scale-methods
Clean-up the `PDFViewer.{increaseScale, decreaseScale}` methods
2023-03-19 12:30:11 +01:00
Jonas Jenwald
9060757064 Clean-up the PDFViewer.{increaseScale, decreaseScale} methods
The signatures of these methods were changed in PR 15886, which has now been included in a couple of releases, hence it should hopefully be OK to remove the fallback code-paths now.
Also, the methods are updated slightly to be explicit about what options are supported and we'll no longer pass along any arbitrary options to the "private" methods.
2023-03-19 11:47:02 +01:00
Jonas Jenwald
7d688769cf Clean-up the pre-processor statements in web/viewer.html
Some of these pre-processor statements are *many* years old, and could thus do with some clean-up. Note that the pre-processor originally didn't support else-if statements, and by using those the code becomes a bit less verbose.
2023-03-18 17:17:46 +01:00
Tim van der Meij
9db4509664
Merge pull request #16166 from Snuffleupagus/pr-16151-followup
Simplify the `applyTransferMapsToCanvas` method (PR 16151 follow-up)
2023-03-18 14:06:42 +01:00
Calixte Denizet
da080cc26e [api-minor] Use a SVG filter when rendering pages in HCM
The idea is to apply an overall filter on each page: the main advantage
is to have some filtered images which could help to make them visible for
some users.
2023-03-18 12:45:10 +01:00
Jonas Jenwald
2fea9ee21b Simplify the applyTransferMapsToCanvas method (PR 16151 follow-up)
During review of PR 16151 this method was simplified, however I overlooked the fact that we now can (and really should) improve this by removing duplication.
2023-03-17 12:58:35 +01:00
Jonas Jenwald
85166c60fd
Merge pull request #16162 from Snuffleupagus/issue-16139
Warn about missing/incorrect `--scale-factor` CSS-variable in `renderTextLayer` (issue 16139)
2023-03-16 16:41:13 +01:00
Jonas Jenwald
0e54a3c37a Warn about missing/incorrect --scale-factor CSS-variable in renderTextLayer (issue 16139)
Unfortunately I don't believe that we can simply add a default `--scale-factor` CSS-variable to the `container`-element, since that might not be entirely appropriate/correct in all cases.[1]
However, we can at least print a console-error to hopefully make this situation more apparent to users. (This is purposely not using the `warn` helper-function, since those messages can be disabled.)

---
[1] One example is in our reference-tests, where we don't need to add it to the `container`-element itself.
2023-03-16 11:53:12 +01:00
Jonas Jenwald
5e4b3d13eb
Merge pull request #16151 from Snuffleupagus/DefaultFilterFactory
[api-minor] Extend general transfer function support to browsers without `OffscreenCanvas`
2023-03-14 14:03:26 +01:00
Jonas Jenwald
07a3283e53
Merge pull request #16152 from Snuffleupagus/type-fixes
Miscellaneous small TypeScript fixes
2023-03-14 13:24:51 +01:00
Jonas Jenwald
50c844c5b8 Stop including isOffscreenCanvasSupported in the "StartRenderPage" message
With the previous commit this is now completely unused in API, hence it can be removed. This is done in a separate commit to make it easier to re-instate it, would the need ever arise.
2023-03-14 13:09:20 +01:00
Jonas Jenwald
fc055dbd80 [api-minor] Extend general transfer function support to browsers without OffscreenCanvas
This patch extends PR 16115 to work in all browsers, regardless of their `OffscreenCanvas` support, such that transfer functions will be applied to general rendering (and not just image data).
In order to do this we introduce the `BaseFilterFactory` that is then extended in browsers/Node.js environments, similar to all the other factories used in the API, such that we always have the necessary factory available in `src/display/canvas.js`.

These changes help simplify the existing `putBinaryImageData` function, and the new method can easily be stubbed-out in the Firefox PDF Viewer.

*Please note:* This patch removes the old *partial* transfer function support, which only applied to image data, from Node.js environments since the `node-canvas` package currently doesn't support filters. However, this should hopefully be fine given that:
 - Transfer functions are not very commonly used in PDF documents.
 - Browsers in general, and Firefox in particular, are the *primary* development target for the PDF.js library.
 - The FAQ only lists Node.js as *mostly* supported, see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2023-03-14 13:09:08 +01:00
calixteman
945855a2b8
Merge pull request #16153 from calixteman/rm_base
Remove <base> tag from the Firefox built-in viewer (bug 1821408)
2023-03-14 10:40:15 +01:00
Calixte Denizet
ea1d090109 Remove <base> tag from the Firefox built-in viewer (bug 1821408)
The tag <base> is used to resolve relative URIs within the document.
Newly added SVG filters use a relative URI which then use the URI in base
but this one mismatches with the document URI and consequently filters are
not found in the Firefox viewer.
So this patch just removes <base> and replace few relative URLs by absolute
ones.
2023-03-14 10:12:42 +01:00
Jonas Jenwald
103fda1d91 Update the canvasContext parameter, in RenderParameters (issue 16133)
Hopefully this works correctly (since I don't know anything about TypeScript), given that `CanvasRenderingContext2D` is a standard name; please see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
2023-03-13 16:56:36 +01:00
Jonas Jenwald
e981badb94 Mark updateMatchesCountOnProgress, in the PDFFindControllerOptions, as optional (issue 15990) 2023-03-13 16:46:33 +01:00
Tim van der Meij
351d11c9bd
Merge pull request #16147 from Snuffleupagus/update-packages
Update packages and translations
2023-03-12 13:29:51 +01:00
Jonas Jenwald
c6c9eb4ccb Update l10n files 2023-03-12 10:40:53 +01:00
Jonas Jenwald
1d06523366 Update npm packages 2023-03-12 10:36:00 +01:00
Tim van der Meij
9819f1cc6b
Merge pull request #16108 from Snuffleupagus/delay-cleanup
Slightly delay cleanup, after rendering, in documents with large images
2023-03-11 15:52:12 +01:00
Tim van der Meij
05f29c8720
Merge pull request #16141 from Snuffleupagus/FilterFactory-docId
Include the document-id in the SVG-filter names (PR 16062 follow-up)
2023-03-11 15:45:42 +01:00
Tim van der Meij
1234d207e9
Merge pull request #16142 from Snuffleupagus/issue-16134
Fix the JSDoc `returns`-type for two `PageViewport`-methods (issue 16134)
2023-03-11 14:53:21 +01:00
Tim van der Meij
cc499505df
Merge pull request #16123 from Snuffleupagus/Node-16
[api-minor] Update the minimum supported Node.js version to 16
2023-03-11 14:49:59 +01:00
calixteman
b2a86350fc
Merge pull request #16096 from bungeman/fix_trig_functions
Correct PostScript trigonometric operators
2023-03-11 14:32:23 +01:00
calixteman
4a4c5d0fe2
Merge pull request #16145 from calixteman/issue16135
Move the svg definitions in its own div
2023-03-10 17:45:29 +01:00