Commit Graph

5262 Commits

Author SHA1 Message Date
Jonas Jenwald
5a2899c57e Skip bogus d1 operators in Type3-glyphs (issue 14953)
In the `src/display/canvas.js` code the `d1` operator will be used to set the clipping region, and it obviously cannot be empty since that prevents the Type3-glyph from rendering.

Also, the patch removes an outdated comment; refer to PR 12718.
2022-05-24 12:20:31 +02:00
Calixte Denizet
9407adc416 [JS] Format all the fields if any when the document is open (bug 1766987)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1766987.
2022-05-22 15:50:42 +02:00
Calixte Denizet
60498c67e4 Display background when printing or saving a text widget (issue #14928) 2022-05-19 16:41:54 +02:00
Jonas Jenwald
5a774b7ed3 Adjust the heuristics for handling of incomplete path operators (issue 14917)
This limits the heuristics for handling of incomplete path operators, see PR 9838, to only apply to *sequences* of such operators. In practice a couple of invalid path operators are (hopefully) unlikely to completely break rendering, whereas a sequence of them will easily lead to fairly chaotic rendering artifacts.
2022-05-15 11:24:39 +02:00
Jonas Jenwald
d540df0582 Use TypedArray.prototype.fill() a bit more in the code-base
Please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill, which is implemented in all browsers that we currently support.
2022-05-13 12:42:51 +02:00
Tim van der Meij
fbc7981c98
Merge pull request #14894 from Snuffleupagus/rm-mozOpaque
Try to remove the `mozOpaque` canvas-property (PR 6551 follow-up)
2022-05-12 22:03:05 +02:00
Jonas Jenwald
6bcc5b615d [api-minor] Include line endings in Line/Polyline Annotation-data (issue 14896)
Please refer to:
 - https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2109792
 - https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2096489
 - https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2096447

Note that we still won't attempt to use the /LE-data when creating fallback appearance streams, as mentioned in PR 13448, since custom line endings aren't common enough to warrant the added complexity.
Finally, note that according to the PDF specification we should *potentially* also take the line endings into account for FreeText Annotations. However, in that case their use is conditional on other parameters that we currently don't support.
2022-05-12 11:08:30 +02:00
Jonas Jenwald
af5789125f Try to remove the mozOpaque canvas-property (PR 6551 follow-up)
According to MDN, see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/mozOpaque, the `mozOpaque` canvas-property is not only non-standard (obviously) but it's also been deprecated.
Instead it's recommended to use `alpha = false` when getting the canvas-context, see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#contextattributes, which all of our affected code is already doing.
2022-05-09 13:03:08 +02:00
Jonas Jenwald
38c82357b2
Merge pull request #14890 from calixteman/14889
[JS] Formatted value has to be a string when neither null nor undefined
2022-05-08 17:25:29 +02:00
Calixte Denizet
ab3958d6e8 [JS] Formatted value has to be a string when neither null nor undefined 2022-05-08 16:43:57 +02:00
Jonas Jenwald
472a1f9c91 Ignore pageColors when the background/foreground is identical (PR 14874 follow-up)
If the computed background/foreground colors are identical, the `canvas` would be rendered mostly blank with only images visible. Hence it seems reasonable to also ignore the `pageColors`-option in this case.

Also, the patch tries to *briefly* outline the various cases in which we ignore the `pageColors`-option in a comment.
2022-05-08 11:40:50 +02:00
Tim van der Meij
f8838eb794
Merge pull request #14882 from Snuffleupagus/issue-14881
Add support for TrueType format 12 `cmap`s (issue 14881)
2022-05-07 11:45:54 +02:00
Jonas Jenwald
7f40ef41a5 Simplify the "fileattachmentannotation"-event handling a little bit
*This patch can be tested, in the viewer, using the `annotation-fileattachment.pdf` document from the test-suite.*

Note how the `FileSpec`-implementation already uses `stringToPDFString` during the filename lookup, see cfac6fa511/src/core/file_spec.js (L70)
Hence there's no reason to repeat that again in the `FileAttachmentAnnotationElement`-constructor, and we can thus simplify the "fileattachmentannotation"-event handling a little bit.
2022-05-06 20:55:18 +02:00
Jonas Jenwald
6e7e9d83d8 Add support for TrueType format 12 cmaps (issue 14881)
This is, as far as I can tell, the first case we've seen of a format 12 `cmap`.
Please see https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html
2022-05-06 11:11:38 +02:00
calixteman
cfac6fa511
Merge pull request #14874 from calixteman/colors
[api-minor] Improve pdf reading in high contrast mode
2022-05-05 21:48:19 +02:00
Calixte Denizet
c8afd6ce8c [api-minor] Improve pdf reading in high contrast mode
- Use Canvas & CanvasText color when they don't have their default value
  as background and foreground colors.
- The colors used to draw (stroke/fill) in a pdf are replaced by the bg/fg
  ones according to their luminance.
2022-05-05 16:34:51 +02:00
Tim van der Meij
899e4d58d6
Merge pull request #14870 from Snuffleupagus/isNodeJS-cleanup
Only bundle the `src/display/node_utils.js` file in GENERIC-builds
2022-05-04 22:38:21 +02:00
Jonas Jenwald
8267fd8a52 Replace the AnnotationStorage.lastModified-getter with a proper hash-method
The current `lastModified`-getter, which only contains a time-stamp, is a fairly crude way of detecting if the stored data has actually been changed. In particular, when the `getRawValue`-method is used, the `lastModified`-getter doesn't cope with data being modified from the "outside".

To fix these issues[1], and to prevent any future bugs in this code, this patch introduces a new `AnnotationStorage.hash`-getter which computes a hash of the currently stored data. To simplify things this re-uses the existing `MurmurHash3_64`-implementation, which required moving that file into the `src/shared/`-folder, since its performance should be good enough here.

---
[1] Given how the `AnnotationStorage.lastModified`-getter was used, this would have been limited to *printing* of forms.
2022-05-04 15:21:30 +02:00
Jonas Jenwald
8135d7ccf6
Merge pull request #14869 from calixteman/14862
[JS] Fix few bugs present in the pdf for issue #14862
2022-05-03 18:31:31 +02:00
Calixte Denizet
094ff38da0 [JS] Fix few bugs present in the pdf for issue #14862
- since resetForm function reset a field value a calculateNow is consequently triggered.
  But the calculate callback can itself call resetForm, hence an infinite recursive loop.
  So basically, prevent calculeNow to be triggered by itself.
- in Firefox, the letters entered in some fields were duplicated: "AaBb" instead of "AB".
  It was mainly because beforeInput was triggering a Keystroke which was itself triggering
  an input value update and then the input event was triggered.
  So in order to avoid that, beforeInput calls preventDefault and then it's up to the JS to
  handle the event.
- fields have a property valueAsString which returns the value as a string. In the
  implementation it was wrongly used to store the formatted value of a field (2€ when the user
  entered 2). So this patch implements correctly valueAsString.
- non-rendered fields can be updated in using JS but when they're, they must take some properties
  in the annotationStorage. It was implemented for field values, but it wasn't for
  display, colors, ...
- it fixes #14862 and #14705.
2022-05-03 15:48:44 +02:00
Jonas Jenwald
d4fe4fd97b Simplify a couple of isNodeJS-dependent getDocument default values
Given that the `isNodeJS`-constant will, after PR 14858, *always* be `false` in non-GENERIC builds we can simplify a couple of `getDocument`-parameter default values slightly.
The old format, with inline `PDFJSDev`-checks, wasn't exactly a wonder of readability; which was my fault.
2022-05-03 11:36:10 +02:00
Jonas Jenwald
7df47c289f Only bundle the src/display/node_utils.js file in GENERIC-builds
This first of all simplifies the file, since we no longer need dummy-classes and can instead *directly* define the actual classes.
Furthermore, and more importantly, this means that we no longer need to bundle this code in e.g. MOZCENTRAL-builds which reduces the size of *built* `pdf.js` file slightly.
2022-05-03 11:34:35 +02:00
Jonas Jenwald
67719af9df Immediately release the temporary Uint8Arrays used during Type3-compilation
Given that the `compileType3Glyph` function *returns* a function, see `drawOutline`, we'll thus keep the surrounding scope alive. Hence it shouldn't hurt to *explicitly* mark the temporary `Uint8Array`s, used during parsing, as no longer needed. Given the current `MAX_SIZE_TO_COMPILE`-value these `Uint8Array`s may be approximately two mega-bytes large *for every* Type3-glyph.
2022-05-02 13:25:48 +02:00
Jonas Jenwald
df5a4fd0a7 Support encoded dest-strings in /GoTo destination dictionaries (issue 14864)
Interestingly enough this appears to be the very first case of *encoded* dest-strings, in /GoTo destination dictionaries, that we've actually come across. What's really fascinating is that it's less than a week after issue 14847, given that these issues are *somewhat* similar.
2022-05-02 10:14:32 +02:00
Jonas Jenwald
e658acffbc Slightly re-factor the compileType3Glyph function
This moves the `COMPILE_TYPE3_GLYPHS`/`MAX_SIZE_TO_COMPILE`-checks into the `compileType3Glyph` function itself, which allows for some simplification at the call-site.
These changes also mean that the `COMPILE_TYPE3_GLYPHS`-check is now done *once* per Type3-glyph, rather than everytime that the glyph is being rendered.
2022-05-01 13:56:35 +02:00
Jonas Jenwald
c2488c7864 Use Path2D, if available, when rendering Type3-fonts (bug 810214)
Note that in order to avoid unnecessary allocations we build the `Path2D`-object *inline* during parsing, rather than iterating through the complete `outlines`-Array at the end.

This patch was tested using the PDF file from bug 810214, i.e. https://bug810214.bmoattachments.org/attachment.cgi?id=9254990, with the following manifest file:
```
[
    {  "id": "bug810214",
       "file": "../web/pdfs/bug810214.pdf",
       "md5": "2b7243178f5dd5fd3edc7b6649e4bdf3",
       "rounds": 100,
       "lastPage": 25,
       "type": "eq"
    }
]

```

which gave the following results when comparing this patch against the `master` branch:
 - Overall
```
-- Grouped By browser, stat --
browser | stat         | Count | Baseline(ms) | Current(ms) | +/- |     %  | Result(P<.05)
------- | ------------ | ----- | ------------ | ----------- | --- | ------ | -------------
firefox | Overall      |  2500 |          123 |          78 | -44 | -36.25 |        faster
firefox | Page Request |  2500 |            2 |           2 |   0 |   9.11 |        slower
firefox | Rendering    |  2500 |          121 |          76 | -45 | -36.93 |        faster
```

 - Page-specific
```
-- Grouped By browser, page, stat --
browser | page | stat         | Count | Baseline(ms) | Current(ms) | +/- |     %  | Result(P<.05)
------- | ---- | ------------ | ----- | ------------ | ----------- | --- | ------ | -------------
firefox | 0    | Overall      |   100 |           36 |          35 |  -1 |  -2.89 |
firefox | 0    | Page Request |   100 |            2 |           2 |   0 |   7.33 |
firefox | 0    | Rendering    |   100 |           34 |          33 |  -1 |  -3.47 |
firefox | 1    | Overall      |   100 |          123 |          81 | -42 | -33.92 |        faster
firefox | 1    | Page Request |   100 |            2 |           2 |   0 |  -3.31 |
firefox | 1    | Rendering    |   100 |          121 |          79 | -42 | -34.44 |        faster
firefox | 2    | Overall      |   100 |          129 |          82 | -47 | -36.61 |        faster
firefox | 2    | Page Request |   100 |            2 |           2 |   0 |  24.84 |        slower
firefox | 2    | Rendering    |   100 |          127 |          80 | -47 | -37.33 |        faster
firefox | 3    | Overall      |   100 |          114 |          68 | -46 | -40.18 |        faster
firefox | 3    | Page Request |   100 |            2 |           2 |   0 |  15.63 |        slower
firefox | 3    | Rendering    |   100 |          112 |          66 | -46 | -41.07 |        faster
firefox | 4    | Overall      |   100 |          102 |          75 | -27 | -26.09 |        faster
firefox | 4    | Page Request |   100 |            2 |           2 |   0 |   9.62 |
firefox | 4    | Rendering    |   100 |          100 |          73 | -27 | -26.71 |        faster
firefox | 5    | Overall      |   100 |          103 |          77 | -26 | -25.15 |        faster
firefox | 5    | Page Request |   100 |            2 |           2 |   0 |  -6.86 |
firefox | 5    | Rendering    |   100 |          100 |          75 | -26 | -25.53 |        faster
firefox | 6    | Overall      |   100 |           48 |          37 | -11 | -22.56 |        faster
firefox | 6    | Page Request |   100 |            2 |           2 |   0 | -10.14 |
firefox | 6    | Rendering    |   100 |           46 |          35 | -11 | -23.16 |        faster
firefox | 7    | Overall      |   100 |          109 |          70 | -39 | -35.59 |        faster
firefox | 7    | Page Request |   100 |            2 |           2 |   0 |   5.29 |
firefox | 7    | Rendering    |   100 |          107 |          68 | -39 | -36.23 |        faster
firefox | 8    | Overall      |   100 |           39 |          31 |  -9 | -22.14 |        faster
firefox | 8    | Page Request |   100 |            2 |           2 |   0 |   1.72 |
firefox | 8    | Rendering    |   100 |           38 |          29 |  -9 | -23.38 |        faster
firefox | 9    | Overall      |   100 |          156 |          96 | -60 | -38.49 |        faster
firefox | 9    | Page Request |   100 |            1 |           2 |   0 |  13.61 |
firefox | 9    | Rendering    |   100 |          155 |          94 | -60 | -38.98 |        faster
firefox | 10   | Overall      |   100 |          173 |         105 | -68 | -39.20 |        faster
firefox | 10   | Page Request |   100 |            2 |           2 |   0 |  -8.81 |
firefox | 10   | Rendering    |   100 |          171 |         103 | -68 | -39.60 |        faster
firefox | 11   | Overall      |   100 |          152 |          89 | -64 | -41.88 |        faster
firefox | 11   | Page Request |   100 |            2 |           2 |   0 |   6.04 |
firefox | 11   | Rendering    |   100 |          150 |          87 | -64 | -42.47 |        faster
firefox | 12   | Overall      |   100 |          141 |          90 | -51 | -35.91 |        faster
firefox | 12   | Page Request |   100 |            2 |           2 |   0 |  17.37 |
firefox | 12   | Rendering    |   100 |          139 |          88 | -51 | -36.60 |        faster
firefox | 13   | Overall      |   100 |           97 |          61 | -36 | -36.79 |        faster
firefox | 13   | Page Request |   100 |            2 |           2 |   0 |  25.44 |        slower
firefox | 13   | Rendering    |   100 |           95 |          59 | -36 | -37.87 |        faster
firefox | 14   | Overall      |   100 |          118 |          82 | -36 | -30.33 |        faster
firefox | 14   | Page Request |   100 |            2 |           2 |   0 |   9.20 |
firefox | 14   | Rendering    |   100 |          117 |          80 | -36 | -30.95 |        faster
firefox | 15   | Overall      |   100 |          111 |          73 | -37 | -33.85 |        faster
firefox | 15   | Page Request |   100 |            2 |           2 |   0 |  13.25 |
firefox | 15   | Rendering    |   100 |          109 |          71 | -38 | -34.61 |        faster
firefox | 16   | Overall      |   100 |          145 |          88 | -57 | -39.19 |        faster
firefox | 16   | Page Request |   100 |            2 |           2 |   1 |  33.75 |        slower
firefox | 16   | Rendering    |   100 |          143 |          86 | -57 | -40.03 |        faster
firefox | 17   | Overall      |   100 |          171 |         126 | -45 | -26.27 |        faster
firefox | 17   | Page Request |   100 |            2 |           2 |   0 |  17.92 |        slower
firefox | 17   | Rendering    |   100 |          169 |         124 | -45 | -26.69 |        faster
firefox | 18   | Overall      |   100 |          126 |          78 | -47 | -37.71 |        faster
firefox | 18   | Page Request |   100 |            2 |           2 |   0 |   2.43 |
firefox | 18   | Rendering    |   100 |          124 |          76 | -48 | -38.43 |        faster
firefox | 19   | Overall      |   100 |           92 |          58 | -34 | -37.19 |        faster
firefox | 19   | Page Request |   100 |            2 |           2 |   0 |  12.74 |
firefox | 19   | Rendering    |   100 |           90 |          56 | -35 | -38.13 |        faster
firefox | 20   | Overall      |   100 |          178 |          96 | -82 | -46.18 |        faster
firefox | 20   | Page Request |   100 |            2 |           2 |   0 |  -2.23 |
firefox | 20   | Rendering    |   100 |          176 |          94 | -82 | -46.67 |        faster
firefox | 21   | Overall      |   100 |          181 |         102 | -79 | -43.77 |        faster
firefox | 21   | Page Request |   100 |            2 |           2 |   0 |  12.36 |        slower
firefox | 21   | Rendering    |   100 |          179 |          99 | -79 | -44.34 |        faster
firefox | 22   | Overall      |   100 |          140 |          84 | -55 | -39.59 |        faster
firefox | 22   | Page Request |   100 |            2 |           2 |   0 |  12.50 |
firefox | 22   | Rendering    |   100 |          138 |          82 | -55 | -40.25 |        faster
firefox | 23   | Overall      |   100 |          119 |          73 | -46 | -38.48 |        faster
firefox | 23   | Page Request |   100 |            2 |           2 |   1 |  35.71 |        slower
firefox | 23   | Rendering    |   100 |          117 |          71 | -46 | -39.48 |        faster
firefox | 24   | Overall      |   100 |          165 |          96 | -68 | -41.51 |        faster
firefox | 24   | Page Request |   100 |            2 |           2 |   0 |   2.81 |
firefox | 24   | Rendering    |   100 |          163 |          94 | -68 | -42.00 |        faster
```
2022-05-01 13:56:35 +02:00
calixteman
b10b8dad7d
Merge pull request #14853 from calixteman/white_lines
Use integer coordinates when drawing images (bug 1264608, issue #3351)
2022-04-29 18:15:03 +02:00
Calixte Denizet
624d8a8e3e Use integer coordinates when drawing images (bug 1264608, issue #3351)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1264608;
- it's only a partial fix for #3351;
- some tiled images have some spurious white lines between the tiles.
  When the current transform is applyed the corners of an image can have
  some non-integer coordinates leading to some extra transparency added
  to handle that. So with this patch the current transform is applied on the
  point and on the dimensions in order to have at the end only integer values.
2022-04-29 16:01:34 +02:00
Jonas Jenwald
fbf6dee8ee [api-minor] Remove the forceClamped-functionality in the Streams (issue 14849)
As it turns out, most of the code-paths in the `PDFImage`-class won't actually pass the TypedArray (containing the image-data) to the `ColorSpace`-code. Hence we *generally* don't need to force the image-data to be a `Uint8ClampedArray`, and can just as well directly use a `Uint8Array` instead.

In the following cases we're returning the data without any `ColorSpace`-parsing, and the exact TypedArray used shouldn't matter:
 - b72a448327/src/core/image.js (L714)
 - b72a448327/src/core/image.js (L751)

In the following cases the image-data is only used *internally*, and again the exact TypedArray used shouldn't matter:
 - b72a448327/src/core/image.js (L762) with the actual image-data being defined (as `Uint8ClampedArray`) further below
 - b72a448327/src/core/image.js (L837)

*Please note:* This is tagged `api-minor` because it's API-observable, given that *some* image/mask-data will now be returned as `Uint8Array` rather than using `Uint8ClampedArray` unconditionally. However, that seems like a small price to pay to (slightly) reduce memory usage during image-conversion.
2022-04-29 14:46:30 +02:00
Jonas Jenwald
71370d012b Support destinations in NameTrees with encoded keys (issue 14847)
Initially I considered updating the `NameOrNumberTree`-implementation to handle encoded keys, however that quickly became somewhat messy (especially in the `NameOrNumberTree.get`-method) since only NameTrees using string-keys.
Hence the easiest solution, as far as I'm concerned, was thus to just update the `Catalog.destinations`-getter instead. Please note that in the referenced PDF document the `Catalog.destination`-method will thus fallback to fetch all destinations, which should be fine since this is the very first case of encoded keys that we've seen.

Also changes the `NameOrNumberTree.getAll`-method to prevent a possible run-time error, although we've so far not seen such a case, for any non-Array Kids-entries found in a NameTree/NumberTree.

Finally, to improve overall consistency and to hopefully prevent future bugs, the patch also updates a couple of other `NameTree` call-sites to correctly handle encoded keys. (Note that the `Catalog.attachments`-getter was already doing this.)
2022-04-27 11:19:55 +02:00
Jonas Jenwald
e18edf38db Add a helper function for incrementing the count of cached ImageMasks
While working on PR 14825, I couldn't help noticing that the code to increment the `count` for cached ImageMasks was repeated multiple times. Hence it makes sense, as far as I'm concerned, to move this into a helper function instead.
2022-04-24 11:10:02 +02:00
Tim van der Meij
752dee5caa
Merge pull request #14825 from Snuffleupagus/issue-14824
Ensure that worker-thread image caching doesn't break optional content (issue 14824)
2022-04-23 13:19:56 +02:00
Tim van der Meij
f9e54d9226
Merge pull request #14823 from Snuffleupagus/issue-14821
Ignore invalid /Encoding-entries when parsing fonts (issue 14821)
2022-04-23 13:19:26 +02:00
Jonas Jenwald
6c229dffb1 Ensure that worker-thread image caching doesn't break optional content (issue 14824)
Currently we only insert optionalContent-data into the operatorList the first time that an image is parsed, which will (in hindsight) obviously cause problems for cached images.
Hence we also need to insert the optionalContent-data in the various worker-thread image caches, such that it can be accessed in the fast-paths that are used to skip re-parsing of images.

In order to reduce the amount of repeated code, this patch also adds a new `OperatorList`-method that takes care of inserting the necessary data in the operatorList.
2022-04-22 14:49:16 +02:00
Jonas Jenwald
e723da7261 Ignore invalid /Encoding-entries when parsing fonts (issue 14821)
In the referenced PDF document the fonts have /Encoding-entries that are Streams (containing completely bogus data), which are thus obviously not valid here.
Hence, only when `ignoreErrors` is set, we'll now ignore these corrupt /Encoding-entries and fallback to the existing code to try and infer a usable encoding.

Given that this is *clearly* a case of corrupt PDF documents, there's no guarantee that this will "fix" all such cases, however it's the best that we do here and shouldn't really be worse than ignoring an entire font.
2022-04-22 11:49:03 +02:00
Tim van der Meij
f39219cd45
Merge pull request #14815 from Snuffleupagus/issue-14814
Ignore non-Stream /SMask-entries when parsing images (issue 14814)
2022-04-22 11:39:13 +02:00
Sean Wei
6bf978404e Use correct case for JavaScript 2022-04-21 23:56:28 +08:00
Jonas Jenwald
39d1bdde09 Ignore non-Stream /SMask-entries when parsing images (issue 14814)
This is similar to the pre-existing check used in the /Mask-case below, to handle *corrupt* PDF documents that include non-Stream /SMask-entries in images; please refer to the PDF specification:
https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=216

*Please note:* Adobe Reader also fails to render the image on the second page, and displays an error message.
2022-04-21 12:14:08 +02:00
Jonas Jenwald
5bc7339c1b Add support for the /Catalog Base-URI when resolving URLs (issue 14802)
As far as I can tell, this is actually the very first time that we've seen a PDF document with a Base-URI specified in the /Catalog; please refer to the specification:
https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2097122

To simplify the overall implementation, this new parameter is accessed via the existing `BasePdfManager.docBaseUrl`-getter and will thus override any user-specified `docBaseUrl` API-parameter.
2022-04-19 17:14:52 +02:00
Calixte Denizet
c2aa03e194 Fix clipping issue with pattern (follow-up of #14797) 2022-04-18 12:41:14 +02:00
Jonas Jenwald
5bbed400f2
Merge pull request #14797 from calixteman/12306
Don't clip when the clip path is empty (issue #12306)
2022-04-18 11:18:32 +02:00
Calixte Denizet
3d74d2c6cb Don't clip when the clip path is empty (issue #12306) 2022-04-18 10:33:44 +02:00
Calixte Denizet
4b7691baf6 Simplify min/max computations in constructPath (bug 1135277)
- most of the time the current transform is a scaling one (modulo translation),
  hence it's possible to avoid to apply the transform on each bbox and then apply
  it a posteriori;
- compute the bbox when it's possible in the worker.
2022-04-17 17:25:54 +02:00
Calixte Denizet
f62d961dfe Improve performances with image masks (bug 857031)
- it's the second part of the fix for https://bugzilla.mozilla.org/show_bug.cgi?id=857031;
- some image masks can be used several times but at different positions;
- an image need to be pre-process before to be rendered:
  * rescale it;
  * use the fill color/pattern.
- the two operations above are time consuming so we can cache the generated canvas;
- the cache key is based on the current transform matrix (without the translation part)
  and the current fill color when it isn't a pattern.
- the rendering of the pdf in the above bug is really faster than without this patch.
2022-04-16 20:48:39 +02:00
Tim van der Meij
b73a6cc213
Merge pull request #14785 from Snuffleupagus/core-js-structuredClone-transfers
Update `core-js` to allow removing a `structuredClone` work-around
2022-04-16 12:36:44 +02:00
calixteman
681a9b8927
Merge pull request #14784 from calixteman/intersect
Improve performance of shared/utils.js::intersect (bug 1135277)
2022-04-15 22:38:19 +02:00
Calixte Denizet
7501fe6f30 Improve performance of shared/utils.js::intersect
- avoid to call normalizeRect which clones the rectangles: it's useless
  and time consuming;
- in profiling the pdf in bug 1135277, the time spent in intersect drops
  from ~1s to ~30ms.
2022-04-15 22:24:26 +02:00
Jonas Jenwald
b996e107c3 Update core-js to allow removing a structuredClone work-around
Because of a bug in previous `core-js` versions, which caused an Error to be thrown if its `structuredClone` polyfill was called with an *explicit* `null`/`undefined` transfer-parameter, the `LoopbackPort`-class contained a work-around.
In the latest `core-js` version this has been fixed, and we can thus simplify our code ever so slightly; please see https://github.com/zloirock/core-js/releases/tag/v3.22.0
2022-04-15 22:12:02 +02:00
Jonas Jenwald
e67cd7fae0 Replace the --viewport-scale-factor CSS variable
This CSS variable is only used together with the `annotationCanvasMap`-functionality in the canvas-code, however its value can be *trivially* computed by using the older `--zoom-factor` CSS variable together with the `PixelsPerInch`-structure.
Rather than having *two different* CSS variables that are this closely linked, it seems better to simplify things by using just one CSS variable instead.
2022-04-14 12:43:57 +02:00
Tim van der Meij
cdb3481d6c
Merge pull request #14764 from apeltop/correct-typos
Correct typos
2022-04-10 14:55:08 +02:00