1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 00:28:06 +02:00
Commit graph

6645 commits

Author SHA1 Message Date
Jonas Jenwald
c88d3a31cf
Merge pull request #18888 from Snuffleupagus/MessageHandler-AbortSignal
Re-factor the `MessageHandler`-class event handler function
2024-10-18 17:27:14 +02:00
Calixte Denizet
86d1272d1b When changing a property on a radio button then change it for the siblings (bug 1922766) 2024-10-17 18:27:12 +02:00
Jonas Jenwald
788eabc76a Re-factor the MessageHandler-class event handler function
- Change the "message" event handler function to a private method.

 - Remove the "message" event listener with an `AbortSignal`.

 - Extend the `LoopbackPort`-class with `AbortSignal` support.
2024-10-16 10:16:27 +02:00
Jonas Jenwald
805f962181 Reduce duplication when collecting optional content groups
After PR 18825 we can easily "compute" the optional content groups, and can thus avoid tracking them manually.
2024-10-15 13:20:30 +02:00
Jonas Jenwald
424f81c4db
Merge pull request #18825 from agrahn/rbgroups
implementing optional content radiobutton groups
2024-10-15 13:11:19 +02:00
Alexander Grahn
441efe456e Optional Content (OC) radiobutton (RB) groups implemented. Resolves #18823.
The code parses the /RBGroups entry in the OC configuration dict and adds the property `rbGroups' to instances of the OptionalContentGroup class. rbGroups takes an array of Sets, where each Set instance represents an RB group the OptionalContentGroup instance is a member of. Such a Set instance contains all OCG ids within the corresponding RB group. RB groups an OCG is associated with are processed when its visibility is set to true, as required by the PDF spec.
2024-10-15 11:34:45 +02:00
Calixte Denizet
8b7b39f5d6 Some jpx images can have a mask
It fixes #18896.
2024-10-14 21:50:32 +02:00
calixteman
e1f9fa4ea5
Merge pull request #18895 from calixteman/issue18894
Fallback on gray colorspace when there are no colorspace and no name in the scn/SCN arguments
2024-10-13 17:56:52 +02:00
Calixte Denizet
e7ab8cd8c1 Fallback on gray colorspace when there are no colorspace and no name in the scn/SCN arguments
It fixes #18894.
2024-10-13 16:02:07 +02:00
calixteman
1c0c070847
Merge pull request #18890 from calixteman/clamp_indexedcs_hival
Clamp the hival parameter of Indexed color space to the range [0; 255]
2024-10-12 23:53:59 +02:00
calixteman
e28dd8e824
Merge pull request #18889 from calixteman/rm_useless_aria_has_popup
Don't add attribute 'aria-haspopup' when no popup is rendered for an annotation
2024-10-12 23:52:15 +02:00
Calixte Denizet
4dea773c5b Clamp the hival parameter of Indexed color space to the range [0; 255]
Since this value is used to allocate an array, it makes sense to avoid to use too much memory.
From the specs, this value must be in the range [0; 255] (see section 8.6.6.3).
This patch removes the unused property 'highVal'.
2024-10-12 23:50:58 +02:00
Calixte Denizet
7c43cb2dae Don't add attribute 'aria-haspopup' when no popup is rendered for an annotation
and for ink annotations, create the popup after the loop in order to avoid useless
elements creation.
2024-10-12 20:51:40 +02:00
Jonas Jenwald
8afc542ae2 Move the regular expression caching into the PDFDateString class
This code is old enough that it pre-dates availability of private class fields, hence why this wasn't done originally.
2024-10-11 15:34:58 +02:00
Tim van der Meij
0543e9e49c
Merge pull request #18874 from Snuffleupagus/ColorPicker-AbortSignal-any
[Editor] Remove `ColorPicker` event listeners with `AbortSignal.any()` (PR 18586 follow-up)
2024-10-10 19:55:19 +02:00
calixteman
a77bf87c50
Merge pull request #18879 from calixteman/highlight_hover
Don't add the grey outline when hovering a selected highlight
2024-10-10 15:28:59 +02:00
Calixte Denizet
fa7df01568 Don't add the grey outline when hovering a selected highlight
When playing with a pen, I noticed that sometimes a free highlight has still its
gray outline when an other one is drawn: for any reason the pointerleave event isn't
triggered.
2024-10-10 14:12:50 +02:00
Calixte Denizet
f2f56b6464 Avoid exceptions in the console with ill-formed flate streams
It fixes #18876.
2024-10-10 12:07:30 +02:00
Jonas Jenwald
14537d1412 [Editor] Remove ColorPicker event listeners with AbortSignal.any() (PR 18586 follow-up)
Also, removes another "unnecessary" bound-method.
2024-10-09 10:58:35 +02:00
Jonas Jenwald
662bd022ce Reduce duplication in the PDFDocument.calculationOrderIds getter 2024-10-08 12:24:09 +02:00
Jonas Jenwald
e3b5ed2e40 Improve the promise-caching in the PDFDocument.fieldObjects getter
After PR 18845 we're accessing this getter more, hence it seems like a good idea to ensure that the initial `formInfo` access is covered as well.
While unlikely to be a problem in practice, at least theoretically that data may not be available and the code in `fieldObjects` could thus currently be *unintentionally* invoked more than once.
2024-10-08 12:15:04 +02:00
Calixte Denizet
a45e4a391a Use Calibri and Lucida Console, when it's possible, in place of sans-serif and monospaced (bug 1922063)
A recent change in Firefox induced too much difference between the text widths computed in using a Canvas
and the ones computed by the text layout engine when rendering the text layer. Consequently, the
text selection can be bad on Windows with some fonts like Arial or Consolas.
This patch is a workaround to try to use in first place some fonts which don't have the problem.
2024-10-05 20:45:25 +02:00
Calixte Denizet
3194f3de8b Keep the empty lines in the text fields
It fixes #18036.
2024-10-05 16:19:41 +02:00
Calixte Denizet
3103deaa44 Fix missing annotation parent in using the one from the Fields entry
Fixes #15096.
2024-10-04 20:00:19 +02:00
Calixte Denizet
b6e60d033a [Editor] Avoid an exception when undoing the deletion of a pre-existing annotation
It fixes #18849.

When such an annotation is deleted, we make sure that there are some data
to restore.
The version of this patch was making undoing a svg deletion buggy, so it's fixed now and
an integration test has been added for this case.
2024-10-04 18:24:58 +02:00
Calixte Denizet
8410252eb8 [Editor] Make stamp annotations editable (bug 1921291) 2024-10-03 21:54:08 +02:00
Calixte Denizet
7bd3e5ccec [Editor] Make the editor deserialization async 2024-10-03 18:34:22 +02:00
Calixte Denizet
c9050be863 [Editor] Add the possibility to save an updated stamp annotation (bug 1921291) 2024-10-02 11:45:16 +02:00
Calixte Denizet
2481a4bab9 Write the display flags in F entry when saving an annotation (issue 18072) 2024-10-01 17:26:39 +02:00
calixteman
c46ac3f73f
Merge pull request #18800 from calixteman/popup_deletion
[Editor] When deleting an annotation with popup, then delete the popup too
2024-09-26 18:04:24 +02:00
Calixte Denizet
0382dd0e25 [Editor] When deleting an annotation with popup, then delete the popup too 2024-09-26 17:52:25 +02:00
Jonas Jenwald
7db9941e0f Add basic support for non-embedded GillSansMT fonts (issue 18801)
Given the following excerpt from the [Wikipedia article](https://en.wikipedia.org/wiki/Gill_Sans), mapping this to Helvetica should hopefully be fine:

> It has been described as "the British Helvetica" because of its lasting popularity in British design.
2024-09-26 16:42:54 +02:00
Jonas Jenwald
fa2d7fc178 Remove trackTransform arguments from CachedCanvases.getCanvas-calls (PR 15281 follow-up)
This became unused in PR 15281, however that patch clearly missed some occurrences; sorry about that!
2024-09-26 15:21:44 +02:00
Jonas Jenwald
3902a148e2
Merge pull request #18785 from Snuffleupagus/transportFactory-init
Slightly re-factor the `transportFactory` initialization in `getDocument`
2024-09-26 15:03:22 +02:00
Calixte Denizet
6d88f9f154 Fix the rendering of tiling pattern when the steps are lower than the tile dimensions (bug 1837738)
It fixes #16038.

The idea is to create a pattern having the steps for dimensions and then draw
the base tile and the different overlapping parts on it.
2024-09-26 14:20:48 +02:00
Jonas Jenwald
a989244570 Slightly re-factor the transportFactory initialization in getDocument
Given that the `WorkerTransport`-constructor will access all possible factory-instances, let's ensure that the `transportFactory`-object always has a consistent shape regardless of other options.

Also, since `useWorkerFetch` is always true in MOZCENTRAL builds we never need to create `CMapReaderFactory`/`StandardFontDataFactory`-instances there.
2024-09-26 12:16:05 +02:00
Calixte Denizet
fc1564f476 Correctly compute the font size when printing a text field with an auto font size (bug 1917734) 2024-09-25 14:05:54 +02:00
Jonas Jenwald
bb302dd993 [api-minor] Pass CanvasFactory/FilterFactory, rather than instances, to getDocument
This unifies the various factory-options, since it's consistent with `CMapReaderFactory`/`StandardFontDataFactory`, and ensures that any needed parameters will always be consistently provided when creating `CanvasFactory`/`FilterFactory`-instances.

As shown in the modified example this may simplify some custom implementations, since we now provide the ability to access the `CanvasFactory`-instance used with a particular `getDocument`-invocation.
2024-09-23 11:26:30 +02:00
Jonas Jenwald
67af371e58 Ignore non-existing /Shading resources during parsing (issue 18765) 2024-09-19 21:55:02 +02:00
Calixte Denizet
78dd35483c Read a signed integer when using PUSHW in sanitizing a font (bug 1919513) 2024-09-18 22:09:17 +02:00
Jonas Jenwald
f77a29d675 Simplify the code that picks the appropriate NetworkStream-implementation
This code is quite old and has been moved/re-factored a few times over the years, however we can simplify this even further since we don't actually need a function to determine what NetworkStream-implementation to use.
2024-09-17 12:23:43 +02:00
Calixte Denizet
46fac8b2c1 [Editor] Take into account the device pixel ratio when drawing an added image
Fixes #18626.
2024-09-16 14:48:26 +02:00
Calixte Denizet
85e8bac45d [Editor] Avoid an extra new line when serializing a FreeText annotation (bug 1897909)
The extra new line is added because of using shift+enter to add a new line
in the text editor.
2024-09-12 15:35:19 +02:00
calixteman
cb20d1b169
Merge pull request #18737 from calixteman/bug1918115
[JS] Correctly format floating numbers when they're close to an integer (bug 1918115)
2024-09-11 18:03:59 +02:00
Calixte Denizet
ca95264e8b [JS] Correctly format floating numbers when they're close to an integer (bug 1918115) 2024-09-11 17:19:34 +02:00
Jonas Jenwald
c52e8485a7
Merge pull request #18731 from Snuffleupagus/TextLayer-ensureCtxFont
Ensure that textLayers can be rendered in parallel, without interfering with each other
2024-09-11 16:29:53 +02:00
Jonas Jenwald
5b3d3c7dd9 Ensure that textLayers can be rendered in parallel, without interfering with each other
Note that the textContent is returned in "chunks" from the API, through the use of `ReadableStream`s, and on the main-thread we're (normally) using just one temporary canvas in order to measure the size of the textLayer `span`s; see the [`#layout`](5b4c2fe1a8/src/display/text_layer.js (L396-L428)) method.

*Order of events, for parallel textLayer rendering:*
 1. Call [`render`](5b4c2fe1a8/src/display/text_layer.js (L155-L177)) of the textLayer for page A.
 2. Immediately call `render` of the textLayer for page B.
 3. The first text-chunk for pageA arrives, and it's parsed/layout which means updating the cached [fontSize/fontFamily](5b4c2fe1a8/src/display/text_layer.js (L409-L413)) for the textLayer of page A.
 4. The first text-chunk for pageB arrives, which means updating the cached fontSize/fontFamily *for the textLayer of page B* since this data is unique to each `TextLayer`-instance.
 5. The second text-chunk for pageA arrives, and we don't update the canvas-font since the cached fontSize/fontFamily still apply from step 3 above.

Where this potentially breaks down is between the last steps, since we're using just one temporary canvas for all measurements but have *individual* fontSize/fontFamily caches for each textLayer.
Hence it's possible that the canvas-font has actually changed, despite the cached values suggesting otherwise, and to address this we instead cache the fontSize/fontFamily globally through a new (static) helper method.

*Note:* Includes a basic unit-test, using dummy text-content, which fails on `master` and passes with this patch.

Finally, pun intended, ensure that temporary textLayer-data is cleared *before* the `render`-promise resolves to avoid any intermittent problems in the unit-tests.
2024-09-11 15:28:51 +02:00
calixteman
0ac7f294cd
Merge pull request #18726 from calixteman/issue18058
Consume any pending path before drawing an annotation
2024-09-10 19:00:58 +02:00
Calixte Denizet
518b776e43 Consume any pending path before drawing an annotation
Fixes #18058.
2024-09-10 16:44:30 +02:00
Jonas Jenwald
2883a9460e Remove ununsed static HighlightEditor._l10nPromise field 2024-09-10 10:00:41 +02:00