Commit Graph

17107 Commits

Author SHA1 Message Date
Jonas Jenwald
5119e7fd6a
Merge pull request #16313 from Snuffleupagus/textLayer-CSS-is
Introduce some `:is` usage in the textLayer CSS
2023-04-19 15:17:22 +02:00
Jonas Jenwald
f98358aa45
Merge pull request #16310 from Snuffleupagus/xfaLayer-CSS-is
Introduce some `:is` usage in the xfaLayer CSS
2023-04-19 15:15:38 +02:00
Jonas Jenwald
3420b2fe8a
Merge pull request #16317 from Snuffleupagus/css-before-after
Enforce double-colon notation for CSS pseudo-elements
2023-04-19 15:14:01 +02:00
Jonas Jenwald
42faecf310
Merge pull request #16320 from Snuffleupagus/enablePermissions-disable-copy-all
Disable the "copy all text" feature when `enablePermissions` is set (PR 16286 follow-up)
2023-04-18 22:13:19 +02:00
Jonas Jenwald
6bfcc96651 Disable the "copy all text" feature when enablePermissions is set (PR 16286 follow-up)
When permissions are enabled and the PDF document doesn't have the COPY-flag set, it shouldn't be possible for the user to trigger the "copy all text" feature.
2023-04-18 21:12:18 +02:00
calixteman
3e292dc222
Merge pull request #16318 from calixteman/issue16316
Correctly clip the text in the text layer (fixes #16316)
2023-04-18 17:48:51 +02:00
Calixte Denizet
19ca41896e Correctly clip the text in the text layer (fixes #16316) 2023-04-18 17:00:42 +02:00
Jonas Jenwald
529dbf9b65 Enforce double-colon notation for CSS pseudo-elements
These changes are part of https://phabricator.services.mozilla.com/D170496, and thanks to a Stylelint rule we can both enforce and fix this automatically; see also https://stylelint.io/user-guide/rules/selector-pseudo-element-colon-notation/
2023-04-18 15:50:22 +02:00
Jonas Jenwald
88e2d04b90
Merge pull request #16311 from linxianxi/fix-viewer-browser-compatibility
Compatible with ResizeObserver borderBoxSize in legacy safari
2023-04-18 13:05:13 +02:00
linxianxi
6ca702d680 Compatible with ResizeObserver borderBoxSize in legacy safari
See https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/borderBoxSize\#browser_compatibility
2023-04-18 17:40:26 +08:00
Jonas Jenwald
5cb99321d7 Introduce some :is usage in the textLayer CSS 2023-04-18 11:39:09 +02:00
Jonas Jenwald
9be2ba6170 Introduce some :is usage in the xfaLayer CSS
Hopefully these changes make sense (since this functionality is new to me), however the existing `xfa`-tests should help avoid any outright regressions.
2023-04-17 23:32:04 +02:00
calixteman
f1b005d7b8
Merge pull request #16308 from calixteman/gv_remove_button_hover
[GeckoView] Don't change style for the download button when focused/hovered
2023-04-17 16:53:33 +02:00
calixteman
dbe0c4e60c
Merge pull request #16200 from calixteman/dont_normalize
[api-minor] Don't normalize the text used in the text layer.
2023-04-17 16:50:26 +02:00
Calixte Denizet
dde79edba1 [GeckoView] Don't change style for the download button when focused/hovered 2023-04-17 16:47:05 +02:00
Calixte Denizet
117bbf7cd9 [api-minor] Don't normalize the text used in the text layer.
Some arabic chars like \ufe94 could be searched in a pdf, hence it must be normalized
when creating the search query. So to avoid to duplicate the normalization code,
everything is moved in the find controller.
The previous code to normalize text was using NFKC but with a hardcoded map, hence it
has been replaced by the use of normalize("NFKC") (it helps to reduce the bundle size
by 30kb).
In playing with this \ufe94 char, I noticed that the bidi algorithm wasn't taking into
account some RTL unicode ranges, the generated font wasn't embedding the mapping this
char and the unicode ranges in the OS/2 table weren't up-to-date.

When normalized some chars can be replaced by several ones and it induced to have
some extra chars in the text layer. To avoid any regression, when copying some text
from the text layer, a copied string is normalized (NFKC) before being put in the
clipboard (it works like this in either Acrobat or Chrome).
2023-04-17 14:31:23 +02:00
calixteman
3e08eee511
Merge pull request #16301 from calixteman/issue16278
[Editor] Take into account the initial rotation (issue #16278)
2023-04-17 09:42:07 +02:00
Calixte Denizet
8e5f4c0622 [Editor] Take into account the initial rotation (issue #16278) 2023-04-16 21:36:26 +02:00
Jonas Jenwald
1503701d9e
Merge pull request #16295 from Pascal-D/updateDeprecatedCustomEvents
Use CustomEvent when dispatching the "webviewerloaded" event
2023-04-16 16:47:20 +02:00
Pascal Drinkuth
d9bf571f5c Use CustomEvent when dispatching the "webviewerloaded" event
According to MDN, see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/initCustomEvent, using initCustomEvent() is deprecated.
2023-04-16 15:36:19 +02:00
Tim van der Meij
f46ed43b81
Merge pull request #16247 from Snuffleupagus/issue-7442
[api-minor] Add support, in `PDFFindController`, for mixing phrase/word searches (issue 7442)
2023-04-16 14:23:41 +02:00
Tim van der Meij
67ce8f18c6
Merge pull request #16299 from Snuffleupagus/TypeScript-5
Update TypeScript to version `5`
2023-04-16 14:14:22 +02:00
Tim van der Meij
6de59e6b3e
Merge pull request #16296 from Snuffleupagus/update-packages
Update packages and translations
2023-04-16 14:08:05 +02:00
Jonas Jenwald
6b4c087e9c
Merge pull request #16298 from Snuffleupagus/generate-hiddenCopyElement
Create the "hiddenCopyElement" in the `PDFViewer` constructor (PR 16286 follow-up)
2023-04-16 12:46:42 +02:00
Jonas Jenwald
5f7e43a2b1
Merge pull request #16297 from Snuffleupagus/copy-all-null-chars
Remove null chars, i.e. `\u0000`, when getting all text (PR 16286 follow-up)
2023-04-16 12:45:16 +02:00
Jonas Jenwald
de03731e92 Update TypeScript to version 5
Note that this is a major version increase, however the `gulp types` and `gulp typestest` tasks seem to work as-is; please see https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/
2023-04-16 11:34:45 +02:00
Jonas Jenwald
2fbbdd68cc Create the "hiddenCopyElement" in the PDFViewer constructor (PR 16286 follow-up)
To make this functionality work out-of-the-box in custom implementations, see e.g. the "viewer components" examples, it'd be slightly easier if we dynamically create/insert the "hiddenCopyElement" in the `PDFViewer` constructor.
Given that the "copy all text" feature still appears to work just as before with this patch, hopefully I'm not overlooking any reason why doing this would be a bad idea.
2023-04-16 09:14:05 +02:00
Jonas Jenwald
4736767b76 Remove null chars, i.e. \u0000, when getting all text (PR 16286 follow-up)
I was playing with the new "copy all text" feature, and stumbled upon one document where the copied text was truncated; see http://mirrors.ctan.org/info/lshort/english/lshort.pdf

The problem turns out to be that on [page 83](https://ftp.acc.umu.se/mirror/CTAN/info/lshort/english/lshort.pdf#page=83) the textLayer contains `\u0000` and apparently copying just stops when a null char is encountered.
To fix this we can simply use an existing helper function, and with this patch we're able to successfully copy all the text in that document.
2023-04-16 08:43:20 +02:00
Jonas Jenwald
a6409e9887 Update l10n files 2023-04-15 22:18:24 +02:00
Jonas Jenwald
877c867a92 Update npm packages 2023-04-15 22:10:02 +02:00
calixteman
92baf14531
Merge pull request #16286 from calixteman/copy_all
Add the possibility to copy all the pdf text whatever the rendered pages are (bug 1788035)
2023-04-15 19:43:13 +02:00
Calixte Denizet
ca54ea12b3 Add the possibility to copy all the pdf text whatever the rendered pages are (bug 1788035) 2023-04-15 18:59:40 +02:00
Jonas Jenwald
0e19c3a120 [api-minor] Add support, in PDFFindController, for mixing phrase/word searches (issue 7442)
*Please note:* This patch only extends the `PDFFindController` implementation itself to support this functionality, however it's *purposely* not exposed in the default viewer.

This replaces the previous `phraseSearch`-parameter, and a `query`-string will now always be interpreted as a phrase-search.
To enable searching for individual words, the `query`-parameter must instead consist of an Array of strings. This way it's now also possible to combine phrase/word searches, with a `query`-parameter looking something like `["Lorem ipsum", "foo", "bar"]` which will search for the phrase "Lorem ipsum" *and* the words "foo" respectively "bar".
2023-04-15 13:32:37 +02:00
Tim van der Meij
4d8a60b435
Merge pull request #16288 from Snuffleupagus/print-code-cleanup
Slightly modernize print-related code
2023-04-15 13:08:37 +02:00
Tim van der Meij
953c29873d
Merge pull request #16281 from Snuffleupagus/toggleCheckedBtn
Reduce some duplication when toggling buttons in the viewer toolbars
2023-04-15 13:00:23 +02:00
Jonas Jenwald
c7daa66b26
Merge pull request #16294 from Snuffleupagus/rm-compileGlobalSubrIndex
Remove `CFFCompiler.compileGlobalSubrIndex`, and simplify `CFFCompiler.compileTypedArray`
2023-04-15 12:17:02 +02:00
Jonas Jenwald
c79bdd6ae6 Simplify the CFFCompiler.compileTypedArray method
Rather than manually creating the Array, we can use the now existing `Array.from` method instead.
2023-04-15 11:13:34 +02:00
Jonas Jenwald
0ce568e789 Remove CFFCompiler.compileGlobalSubrIndex since it's completely unused
This method was originally added in PR 1320, eleven years ago, however it doesn't appear to ever have been used (not even from the start).
Furthermore, this method also tries to access a property that doesn't exist (`this.out`) and then call a method that also doesn't exist (`writeByteArray`).
2023-04-15 11:13:21 +02:00
Jonas Jenwald
ab2773416b
Merge pull request #16291 from Snuffleupagus/issue-16289
Limit the `Path2D`-checks in the worker-thread to Node.js (PR 16238 follow-up, issue 16289)
2023-04-14 21:26:12 +02:00
calixteman
a44173ea51
Merge pull request #16292 from calixteman/improve_cff_compiling
Avoid when it's possible to use Array.concat when compiling a CFF font
2023-04-14 21:17:53 +02:00
Calixte Denizet
5eab8ec610 Avoid when it's possible to use Array.concat when compiling a CFF font
In looking at https://bugs.ghostscript.com/show_bug.cgi?id=706451 I noticed that bug2.pdf was pretty
slow to load for such a basic file.
In profiling I noticed that a lot of time is spent in Array.concat, hence this patch use Array.push when
it's possible (it's now ~3 times faster).
2023-04-14 19:01:01 +02:00
Jonas Jenwald
edd13895dd Limit the Path2D-checks in the worker-thread to Node.js (PR 16238 follow-up, issue 16289)
The changes in PR 16238 were intended specifically for Node.js environments, however they accidentally applied to older browsers as well.

*Please note:* In up-to-date browsers `Path2D` is available in Workers, which should be connected to the introduction of `OffscreenCanvas`.
2023-04-14 11:51:11 +02:00
Jonas Jenwald
aeb8e36cdb Convert FirefoxPrintService and PDFPrintService into standard classes
Note that both of the affected files are old enough to predate the general availability of `class`.
2023-04-14 10:02:28 +02:00
Jonas Jenwald
ebf493f726 Slightly modernize the print layout-methods
By getting the width/height of the first page initially, we can slightly reduce the amount of code needed both in the `hasEqualPageSizes`-check and when building the print-styles.
2023-04-14 10:02:25 +02:00
calixteman
342dc760da
Merge pull request #16284 from calixteman/gv_keep_button
[GeckoView] Show the download button by default and add a pref to disable it (bug 1827963)
2023-04-13 21:17:32 +02:00
Calixte Denizet
7f0d45ce47 [GeckoView] Show the download button by default and add a pref to disable it (bug 1827963)
For the moment there is no real consensus on how we should download a pdf on Android.
Hence we keep this solution for the moment but behind a pref (which will be true on
nightly only).
2023-04-13 20:33:03 +02:00
Jonas Jenwald
2a195beb30 Reduce some duplication when toggling buttons in the viewer toolbars
Currently we repeat the same code in lots of places, to update the "toggled" class and "aria-checked" attribute, when various toolbar buttons are clicked.

For the MOZCENTRAL build-target this patch reduces the size of the *built* `web/viewer.js` file by just over `1.2` kilo-bytes.
2023-04-13 13:18:37 +02:00
Jonas Jenwald
b3932f70ed
Merge pull request #16279 from Snuffleupagus/structuredClone-transfer-legacy
Skip transfers, in `LoopbackPort.postMessage`, for PDF.js `legacy`-builds (issue 16255)
2023-04-13 10:20:11 +02:00
Jonas Jenwald
82a0bcecfa Skip transfers, in LoopbackPort.postMessage, for PDF.js legacy-builds (issue 16255)
Apparently the `structuredClone` polyfill doesn't handle transfers correctly, and `DOMException`s may thus be thrown. This is particularly problematical in Node.js environments, where that exception (obviously) isn't available.

To work-around these issues we'll simply ignore any transfers in `legacy`-builds, since those *may* use the `structuredClone` polyfill. This will obviously lead to slightly higher memory usage in those builds, however this really only affects Node.js environments. (Browsers are only affected if workers are disabled, however that's never been an officially recommended/supported configuration.)
2023-04-12 14:18:29 +02:00
calixteman
7571842d84
Merge pull request #16275 from calixteman/ifx_search_with_fractions
Fix search of numbers inside fractions
2023-04-11 21:52:56 +02:00