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

6789 commits

Author SHA1 Message Date
Jonas Jenwald
20d5332009 For images that include SMask/Mask entries, ignore an SMask defined in the current graphics state
From section [11.6.4.3 Mask Shape and Opacity](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G10.4848628) in the PDF specification:
 - An image XObject may contain its own *soft-mask image* in the form of a subsidiary image XObject in the `SMask` entry of the image dictionary (see "Image Dictionaries"). This mask, if present, shall override any explicit or colour key mask specified by the image dictionary's `Mask` entry. Either form of mask in the image dictionary shall override the current soft mask in the graphics state.
2024-12-30 14:25:07 +01:00
Tim van der Meij
8a50d2d302
Merge pull request #19259 from Snuffleupagus/more-wrapReason
Reduce duplication when handling "DocException" and "PasswordRequest" messages
2024-12-29 15:47:11 +01:00
Tim van der Meij
91d801728d
Merge pull request #19262 from Snuffleupagus/CompiledFont-assert-fontMatrix
Assert that the `fontMatrix` is always valid in `compileGlyph`
2024-12-29 15:41:04 +01:00
Tim van der Meij
5b94c865e7
Merge pull request #19263 from Snuffleupagus/Type2Compiled-fix-glyphNameMap
Remove the unused `glyphNameMap` parameter from `Type2Compiled`
2024-12-29 15:39:58 +01:00
Jonas Jenwald
aba6369638 Remove the unused glyphNameMap parameter from Type2Compiled
As part of the changes in PR 4259, which landed over ten years ago, the `glyphNameMap` property on `Font`-instances was removed.
The reason that this didn't cause any bugs is that we always fallback on `getGlyphsUnicode`, and when using that data we also rely on `StandardEncoding`, hence we should just remove the unused parameter from the `Type2Compiled` constructor.
2024-12-27 14:31:39 +01:00
Jonas Jenwald
2ae5aa08cc Assert that the fontMatrix is always valid in compileGlyph
While [bug 1893645](https://bugzilla.mozilla.org/show_bug.cgi?id=1893645) was fixed some time ago now, it still shouldn't hurt to also assert that the `fontMatrix` is always valid when invoking the `compileGlyph` method.
2024-12-27 11:41:49 +01:00
Jonas Jenwald
3a797317c8 Shorten some if-statements in the src/core/ folder
Thanks to modern JavaScript there's some existing code that can be shortened slightly.
2024-12-26 18:37:25 +01:00
Jonas Jenwald
6bde49a606 Reduce duplication when handling "DocException" and "PasswordRequest" messages
Rather than having to manually implement the exception-handling for the "DocException" message, we can instead re-use (and slightly extend) the existing `wrapReason` function since that one already does what we need.

Furthermore, we can also simplify handling of the "PasswordRequest" message a little bit and again re-use the `wrapReason` function.

Finally, the patch makes the following smaller changes:
 - Avoid needlessly re-creating exceptions in the `wrapReason` function.
 - Use a slightly shorter parameter name in the `wrapReason` function.
 - Remove the unused entries in the `CallbackKind`/`StreamKind` enumerations.
2024-12-26 12:55:49 +01:00
Jonas Jenwald
ec1a05c104 Add missing startWorkerTask calls in the "SaveDocument" handler
Without these calls we'll not actually wait for saving to complete when document destruction runs; compare with other `WorkerTask`-usage in this file.
While I cannot imagine that this has caused any problems for library users, the code is however not technically correct as-is.
2024-12-21 14:22:18 +01:00
calixteman
2df5d8f3ef
Merge pull request #19238 from calixteman/bug1938087
Take the absolute value of the font size when the annotation contents is in xhtml (bug 1938087)
2024-12-18 17:34:06 +01:00
Calixte Denizet
723ee9bc8c Take the absolute value of the font size when the annotation contents is in xhtml (bug 1938087) 2024-12-18 17:00:45 +01:00
Jonas Jenwald
189183aa1a Add basic support for non-embedded HelveticaLTStd-Bold fonts (issue 19234) 2024-12-18 09:39:22 +01:00
Tim van der Meij
ac81de6ab4
Merge pull request #19224 from Snuffleupagus/pr-18776-followup
[api-minor] Remove deprecated `getDocument` options (PR 18776 follow-up)
2024-12-15 15:52:34 +01:00
Tim van der Meij
322616988e
Merge pull request #19214 from Snuffleupagus/issue-19205
Don't remove trailing regular spaces from the "raw" response headers (issue 19205)
2024-12-15 15:51:20 +01:00
Jonas Jenwald
490e740365 [api-minor] Remove deprecated getDocument options (PR 18776 follow-up) 2024-12-15 14:13:44 +01:00
Calixte Denizet
4ed7f7f1ee [Editor] Add the ability to resize an editor in using a pinch gesture 2024-12-14 19:39:51 +01:00
Calixte Denizet
e0b63ecd03 Move the pinch stuff in its own file in order to use for editors 2024-12-11 23:20:01 +01:00
Calixte Denizet
d61b882888 [Editor] Avoid to focus an existing editor when enabling the layer
It fixes #18911.
2024-12-11 15:06:56 +01:00
Jonas Jenwald
08e54053ff Don't remove trailing regular spaces from the "raw" response headers (issue 19205)
This bug only seems to reproduce in Google Chrome, since browsers apparently sort response headers differently.
When the issue occurs the "raw" response headers string looks like this:
```
content-length: 525404\r\ncontent-type: \r\n
```
and since we trim *any* leading/trailing white-space characters the "content-type" header isn't detected correctly, which thus leads to `new Headers(...)` throwing.

Hence we'll keep regular spaces at the end of the "raw" response headers string, while still removing all other kinds of trailing white-space characters.

*Note:* The response headers parsing was based on https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#examples
2024-12-11 12:16:31 +01:00
Calixte Denizet
89f61b4262 [Editor] Improve drawing on a touch screen.
- it's now possible to start a drawing with a pen and use fingers to zoom
  or scroll without interacting with the current drawing;
- it's now possible to draw with a finger and them zoom with two fingers.
2024-12-10 21:54:29 +01:00
calixteman
b35999d837
Merge pull request #19198 from calixteman/fix_intermittent_itest_chrome
Fix intermittent failures when moving a freetext annotation in integration tests
2024-12-10 16:56:58 +01:00
Calixte Denizet
74a377f72f Fix intermittent failures when moving a freetext annotation in integration tests
When an editor is moved with the keyboard or in dragging it, it is moved in the DOM in order
to make screen readers happy. But this move is slightly postponed thanks to a setTimeout(..., 0).
The failures were very likely due to the fact that intermittently the DOM move was done in
the middle of the next key sequence which was making the move on screen failing.
2024-12-10 16:14:26 +01:00
calixteman
44421d36f6
Merge pull request #19201 from calixteman/fix_resize_stamp
[Editor] When resizing a stamp annotation, the opposite corner must stay fixed
2024-12-10 11:00:01 +01:00
calixteman
898be9ef5e
Merge pull request #19202 from calixteman/avoid_to_lose_focus
[Editor] Don't commit the current drawing while zooming
2024-12-09 19:00:26 +01:00
Calixte Denizet
166a529ddd [Editor] Don't commit the current drawing while zooming 2024-12-09 17:25:36 +01:00
Calixte Denizet
99f3e6b4ec [Editor] When resizing a stamp annotation, the opposite corner must stay fixed
It was due the resize observer which is removed thanks to this patch.
In order to reuse the dragAndDrop function in test, this patch slighty refactors it
in order to make it easier to use.
2024-12-09 16:07:43 +01:00
Jonas Jenwald
6153b15231 Remove the raw path-strings after creating the actual Path2D glyph-objects
The `Path2D` glyph-objects are cached on the `FontFaceObject`-instance, so we can save a little bit of memory by removing the raw path-strings once they're no longer needed.
2024-12-09 15:09:18 +01:00
calixteman
99eefb7b71
Merge pull request #19189 from calixteman/improve_font_drawer
Improve perfs of the font renderer
2024-12-09 14:15:15 +01:00
Calixte Denizet
2b05924504 Improve perfs of the font renderer
Some SVG paths are generated from the font and used in the main thread
to render the glyphs.
2024-12-08 17:12:10 +01:00
Jonas Jenwald
c6e3fc4fe6 Take the userUnit into account in the PageViewport class (issue 19176) 2024-12-08 15:51:04 +01:00
Jonas Jenwald
c60a6d1ebd Print more warnings about potential problems in Node.js environments
- Warn if the "regular" PDF.js build is used in Node.js environments, since that won't load any of the relevant polyfills.

 - Warn if the `require` function cannot be accessed, since currently we're just "swallowing" any errors.
2024-12-07 14:08:09 +01:00
Calixte Denizet
6fe6b6d6b7 Get the first codepoint instead of the first char when using the toUnicode map
It fixes #19182.
2024-12-06 18:25:13 +01:00
Jonas Jenwald
eff8ede33e Make the onError callback required in NetworkManager
This helps ensure that loading errors are always handled correctly, and note that both `PDFNetworkStreamFullRequestReader` and `PDFNetworkStreamRangeRequestReader` already provided such a callback.
2024-12-06 12:09:36 +01:00
Jonas Jenwald
2661d0623b Ensure that a missing/invalid "Content-Range" header is handled in PDFNetworkStream (issue 19075)
In the event that the "Content-Range" header is missing/invalid, loading will now be aborted rather than hanging indefinitely.
2024-12-06 12:09:34 +01:00
Calixte Denizet
d1db8d6294 Avoid to display an alert or a confirm dialog if the message is empty
It fixes #19171.
2024-12-05 21:04:07 +01:00
Calixte Denizet
dfa0e79553 [Editor] Correctly update the current drawing when zooming
We were trying to update the drawing on the current page but if the drawing is an another
page then it wasn't updated.
2024-12-05 14:22:02 +01:00
Jonas Jenwald
ef0331877d Introduce Promise.try() usage in the code-base
This simplifies the creation of Promises in some cases; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/try
2024-12-04 10:31:42 +01:00
Ujjwal Sharma
dd82d78a2d Pop open a message when user deletes an annotation
When a user deletes any number of annotations, they are notified of the action
by a popup message with an undo button. Besides that, this change reuses the
existing messageBar CSS class from the new alt-text dialog as much as possible.
2024-12-03 11:03:15 +01:00
Calixte Denizet
7e02c77250 [Editor] Make ink annotation editable 2024-12-02 17:15:33 +01:00
calixteman
97c7a8eb7a
Merge pull request #19144 from calixteman/no_focus_if_invisible
[Editor] Don't focus a newly added drawing if it isn't visible on screen
2024-12-02 14:02:01 +01:00
Calixte Denizet
673c93e832 [Editor] Don't focus a newly added drawing if it isn't visible on screen 2024-12-02 11:06:13 +01:00
Calixte Denizet
1460a8128a Fix the clickable area for rotated ink annotations 2024-12-02 09:48:22 +01:00
Tim van der Meij
2bbf9b432c
Merge pull request #19099 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-12-01 14:54:07 +01:00
Tim van der Meij
9f90bc9114
Merge pull request #19136 from Snuffleupagus/WorkerMessageHandler-this
Shorten the `WorkerMessageHandler` class a little bit
2024-12-01 14:40:38 +01:00
Jonas Jenwald
ede589dd6e Shorten the WorkerMessageHandler class a little bit
- Use `this` in all scopes where that's possible, to avoid having to spell out `WorkerMessageHandler` everywhere.

 - Inline the `isMessagePort` helper function, since there's only a single call-site.

 - Use a static initialization block to move more code into the `WorkerMessageHandler` class itself.
2024-11-30 14:07:16 +01:00
Jonas Jenwald
4b0900fdfa Use even more optional chaining in the src/display/api.js file
This slightly shortens the code, in various `destroy`-methods, which cannot hurt.
Also, use pre-processor checks to simplify `PDFDocumentLoadingTask.destroy` in the Firefox PDF Viewer since the `PDFWorker.fromPort`-method isn't used there.
2024-11-30 12:06:27 +01:00
calixteman
8f08ca2150
Merge pull request #19131 from calixteman/bug1934157
Build date consistently (in term of tz) when executing some embedded JS (bug 1934157)
2024-11-29 21:44:10 +01:00
Calixte Denizet
2a337082c0 Build date consistently (in term of tz) when executing some embedded JS (bug 1934157)
The date was create in UTC+0 and then amended in using set-Month/Date which take into account
the user timezone.
With this patch we build all the date in the user timezone.
2024-11-29 19:50:21 +01:00
calixteman
9ecc613c08
Merge pull request #19066 from jarklee/issue19056
Fix #serializeBoxes function not output correct quadPoints values for deserialize (issue19056)
2024-11-29 18:31:28 +01:00
Calixte Denizet
4acc086292 [Editor] Allow to abort the current drawing
It fixes #19126.
2024-11-29 16:22:49 +01:00