Commit Graph

13421 Commits

Author SHA1 Message Date
Tim van der Meij
25d84e4c40
Merge pull request #12887 from Snuffleupagus/keep-logical-assignment-operators
Keep logical assignment operators in `MOZCENTRAL`/`TESTING`-builds
2021-01-22 20:21:40 +01:00
Tim van der Meij
5b675c7bf7
Merge pull request #12886 from Snuffleupagus/_getSaveFieldResources-fontName
Use `_defaultAppearanceData` directly in `WidgetAnnotation._getSaveFieldResources` (PR 12831 follow-up)
2021-01-22 20:08:59 +01:00
Tim van der Meij
5533148496
Merge pull request #12890 from Snuffleupagus/cleanup-eslint-off-rules
Enable ESLint rules that no longer need to be disabled on a directory/file-basis
2021-01-22 20:06:17 +01:00
Tim van der Meij
73da906102
Merge pull request #12888 from Snuffleupagus/stylelint-shorthand-property-no-redundant-values
Enable the Stylelint `shorthand-property-no-redundant-values` rule
2021-01-22 20:01:45 +01:00
Jonas Jenwald
4db7330677 Enable ESLint rules that no longer need to be disabled on a directory/file-basis
Given that browsers/environments without native support for both arrow functions and object shorthand properties are no longer supported in PDF.js, please refer to the compatibility information below, we can now enable a fair number of ESLint rules and also simplify/remove some `.eslintrc` files.

With the exception of the `no-alert` cases, all code changes were made automatically by using `gulp lint --fix`.

 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#browser_compatibility
2021-01-22 17:47:03 +01:00
Jonas Jenwald
38c9f1a37a Enable the Stylelint shorthand-property-no-redundant-values rule
Note that these changes were done automatically, using `gulp lint --fix`; this rule will help avoid unnecessary repetition in the CSS.

Please find additional details about the Stylelint rule at https://stylelint.io/user-guide/rules/shorthand-property-no-redundant-values
2021-01-22 14:36:02 +01:00
Jonas Jenwald
4215534b3e Keep logical assignment operators in MOZCENTRAL/TESTING-builds
Given how recently logical assignment operators support were added to browsers, we're intentionally translating them even in `SKIP_BABEL = true` builds for the time being.
However, in either `MOZCENTRAL` or `TESTING` builds it should be OK to simply leave logical assignment operators intact.
2021-01-22 14:06:21 +01:00
Jonas Jenwald
ca1f58ea42 Use _defaultAppearanceData directly in WidgetAnnotation._getSaveFieldResources (PR 12831 follow-up)
With the changes in PR 12831, it's no longer necessary to keep track of the `fontName`-string separately since it's available through the `_defaultAppearanceData`-property as well.
2021-01-22 13:23:04 +01:00
Brendan Dahl
2cba290361
Merge pull request #12836 from calixteman/update_buttons
JS -- update radio/checkbox values even if there are no actions
2021-01-21 14:00:26 -08:00
calixteman
1039698697
Add a parser to get font data from the default appearance (#12831)
* Add a parser to get font data from the default appearance
 - pdfium & poppler use a special parser too to get these info.

* Update src/core/default_appearance.js

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>
2021-01-21 20:15:31 +01:00
Brendan Dahl
4142001fc2
Merge pull request #12869 from calixteman/lw
Fix zoom issue with too thin lines
2021-01-21 08:31:59 -08:00
Tim van der Meij
9d4bad91e2
Merge pull request #12878 from Snuffleupagus/worker-compat-checks
Remove redundant compatibility checks, for modern `generic` builds, in `src/core/worker.js`
2021-01-20 21:03:04 +01:00
Brendan Dahl
f45ba02fd3
Merge pull request #12850 from calixteman/missing_cstes
JS -- Add few missing constants in global scope
2021-01-20 11:33:02 -08:00
Jonas Jenwald
b4eb55250e Remove redundant compatibility checks, for modern generic builds, in src/core/worker.js
With the recent additions of optional chaining and nullish coalescing to the PDF.js code-base, a couple of the checks in `src/core/worker.js` are now redundant; please see this compatibility information:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator#browser_compatibility

In practice, for the non-translated/non-polyfilled PDF.js builds, browsers without support for optional chaining and nullish coalescing will simply throw immediately upon loading of the code.
Hence both the `globalThis` and `Promise.allSettled` checks are now unnecessary, given this compatibility information:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled#browser_compatibility

*Please note:* The `ReadableStream` check is however still necessary, since Node.js doesn't support that.
2021-01-20 13:09:56 +01:00
Tim van der Meij
a10dc1cb6e
Merge pull request #12871 from Snuffleupagus/simplify-pdfSidebarNotification
Only display a notification on the `sidebarToggle`-button, and not the individual view-buttons (PR 7959 follow-up)
2021-01-19 19:09:08 +01:00
Tim van der Meij
5e1e0e03a6
Merge pull request #12875 from Snuffleupagus/src-display-more-optional-chaining
Replace some ternary operators with optional chaining, and nullish coalescing, in the `src/display/`-folder
2021-01-19 18:58:01 +01:00
Tim van der Meij
2731dd4b49
Merge pull request #12874 from Snuffleupagus/docs-less-es5
Put less emphasis on "ES5"/"ES6" in the README and other documentation
2021-01-19 18:52:16 +01:00
Jonas Jenwald
5520737798 Update the main, and pdfjs-dist, README to also include recent ECMAScript features
This adds "optional chaining" and "nullish coalescing" to the list of features needed when using the *modern*, i.e. non-translated/non-polyfilled, build of the PDF.js library.
2021-01-19 17:49:12 +01:00
Jonas Jenwald
298ee5cfbb Replace some ternary operators with optional chaining, and nullish coalescing, in the src/display/-folder
This way, we can further reduce unnecessary code-repetition in some cases.
2021-01-19 17:20:02 +01:00
Jonas Jenwald
abd2346e2a Put less emphasis on "ES5"/"ES6" in the README and other documentation
- Don't explicitly mention "ES5" in https://mozilla.github.io/pdf.js/getting_started/#download, since that's no longer accurate. As-is, this will more than likely give users the wrong impression regarding our *actual* browser support.

 - Reword the "Getting the Code"-section of the README, since an ES6-compatible browser is no longer sufficient for development purposes given our usage of modern ECMAScript features.

 - Update the "Building PDF.js"-section of the README, to explicitly mention both the `gulp generic` and `gulp generic-es5` commands.

Hopefully this will help reduce *some* user confusion, but we should perhaps also consider changing the "-es5"-suffix in our build-scripts and build-folders. (That would however require coming up with a "better" suffix, which might not be trivial.)
2021-01-19 13:02:02 +01:00
Jonas Jenwald
e997f60656 Only display a notification on the sidebarToggle-button, and not the individual view-buttons (PR 7959 follow-up)
The whole purpose of showing a notification on the `sidebarToggle` button, when the sidebar is closed, was to give users *some* kind of indication that the PDF document contains outline/attachments/layers without having to manually open the sidebar to check.
However, in the implementation in PR 7959, I also added notifications for each view-buttons in the sidebar. Looking back at this, I've always questioned the value of the last part, since the view-buttons already have a `disabled`-state which shows if they're available or not. Hence we're actually, in a sense, duplicating notifications for the outline/attachments/layers-buttons without adding (in my opinion) all that much overall value.

All-in-all, I'm thus proposing that we only display the notification on the `sidebarToggle`-button itself, since that should really be sufficient here, which also allows us to simplify the relevant code a fair bit.
2021-01-18 11:36:42 +01:00
Calixte Denizet
9754216c60 Fix zoom issue with too thin lines
- aims to fix issue #12868: apply zoom factor to linewidth after setting it to 1.
 - only apply 1px-width when required
 - the sign of getSinglePixelWidth is used to know if 1px-width is required
2021-01-16 15:52:27 +01:00
Tim van der Meij
172abc02e1
Merge pull request #12864 from calixteman/6127
Enforce linewidth to 1px when at least one of scale factor is lower than 1
2021-01-15 20:54:34 +01:00
Calixte Denizet
0d1b19632d Enforce linewidth to 1px when at least one of scale factor is lower than 1 2021-01-15 13:18:24 +01:00
calixteman
d9df96d299
Merge pull request #12863 from Snuffleupagus/pr-12812-followup
Remove a duplicated reference test (PR 12812 follow-up)
2021-01-15 04:13:59 -08:00
Jonas Jenwald
cf7eb87934 Remove a duplicated reference test (PR 12812 follow-up)
- Remove a *duplicated* reference test, see "issue12810", from the manifest.

 - Improve the spelling in a couple of comments in `src/core/canvas.js`, most notable of the word "parallelogram".

 - Update a comment, also in `src/core/canvas.js`, to actually agree with the value used to reduce confusion when reading the code.
2021-01-15 10:57:15 +01:00
Brendan Dahl
6619f1f3f2
Merge pull request #12812 from calixteman/too_thin
Enforce line width to be at least 1px after applied transform
2021-01-14 15:21:44 -08:00
Tim van der Meij
db70efa3c6
Merge pull request #12861 from Snuffleupagus/bug-1671312-ArialNarrow
Always re-measure non-embedded ArialNarrow fonts (bug 1671312, PR 12725 follow-up)
2021-01-14 19:38:29 +01:00
Jonas Jenwald
2600e59acb Always re-measure non-embedded ArialNarrow fonts (bug 1671312, PR 12725 follow-up)
While PR 12725 fixed bug 1671312 as reported, i.e. the "In the upper right corner "Purposes' has bad kerning."-part, it however broke other parts of the text rendering.
Note in particular the tables, e.g. on page 2 and beyond, where the glyphs are now rendered too close together. The reason for this is that the fonts in question are non-embedded ArialNarrow, which we just replace with Helvetica which obviously is not narrow. Given that the font replacement isn't a perfect fit for non-embedded ArialNarrow, we still need to re-measure the glyph widths in this case.
2021-01-14 15:51:48 +01:00
Tim van der Meij
dcd1589b2c
Merge pull request #12855 from Snuffleupagus/find-normalization
[api-minor] Highlight search results correctly for normalized text (PR 9448)
2021-01-12 22:04:10 +01:00
Tim van der Meij
1bcbf69c96
Merge pull request #12853 from Snuffleupagus/BaseViewer-initializeScriptingEvents
Fix the initialization/resetting of scripting-related events in the `BaseViewer`
2021-01-12 20:56:19 +01:00
Jonas Jenwald
f1749f03e3 Ensure that PDFViewerApplication.close has a *consistent* return value 2021-01-12 20:28:52 +01:00
Jonas Jenwald
13742eb82d Inlude the JS actions for the page when dispatching the "pageopen"-event in the BaseViewer
Note first of all how the `PDFDocumentProxy.getJSActions` method in the API caches the result, which makes repeated lookups cheap enough to not really be an issue.
Secondly, with the previous patch, we're now only dispatching "pageopen"/"pageclose"-events when there's actually a sandbox that listens for them.

All-in-all, with these changes we can thus simplify the default-viewer "pageopen"-event handler a fair bit.
2021-01-12 20:28:50 +01:00
Ross Johnson
6dae2677d5 [api-minor] Highlight search results correctly for normalized text (PR 9448)
This patch is a rebased *and* refactored version of PR 9448, such that it applies cleanly given that `PDFFindController` has changed since that PR was opened; obviously keeping the original author information intact.

This patch will thus ensure that e.g. fractions, and other things that we normalize before searching, will still be highlighted correctly in the textLayer.

Furthermore, this patch also adds basic unit-tests for this functionality.

*Note:* The `[api-minor]` tag is added, since third-party implementations of the `PDFFindController` must now always use the `pageMatchesLength` property to get accurate length information (see the `web/text_layer_builder.js` changes).

Co-authored-by: Ross Johnson <ross@mazira.com>
Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>
2021-01-12 18:08:08 +01:00
Jonas Jenwald
a882a85446 Fix the initialization/resetting of scripting-related events in the BaseViewer
The "pageopen"/"pageclose"-events are only necessary if, and only if, there's actually a sandbox to dispatch the events in. Hence we shouldn't dispatch those events unconditionally, as soon as `enableScripting` is set, but rather initialize that functionality only when needed.

Furthermore, in `web/app.js`, there's currently a bug since we're attempting to *manually* simulate a "pageopen"-event for a page that may not actually have been rendered at the time. With the modified `BaseViewer.initializeScriptingEvents` method, we'll now dispatch a correct "pageopen"-event here.
2021-01-12 14:28:09 +01:00
calixteman
1de1ae0be6
Merge pull request #12838 from calixteman/authors
[api-minor] Change the "dc:creator" Metadata field to an Array
2021-01-12 02:44:58 -08:00
Calixte Denizet
43d5512f5c [api-minor] Change the "dc:creator" Metadata field to an Array
- add scripting support for doc.info.authors
 - doc.info.metadata is the raw string with xml code
2021-01-11 21:34:07 +01:00
Calixte Denizet
8e6bec6e2e JS -- Add few missing constants in global scope
- these constants are available in pdfium implementation too
 - fix error code in aform.js
2021-01-11 17:19:28 +01:00
Tim van der Meij
631bada0df
Merge pull request #12848 from timvandermeij/annotation-horizontal
Correctly align annotation content in horizontal/spead scrolling modes
2021-01-10 19:03:40 +01:00
Tim van der Meij
36e6ae5b2f
Correctly align annotation content in horizontal/spread scrolling modes
Not only was long text in popups no longer wrapped correctly, the
alignment was also center instead of left (or right, depending on the
locale used) for both text in popups and the other parts within the
annotation's section, such as the icon.
2021-01-10 18:58:13 +01:00
Calixte Denizet
b3dccd66ab Enforce line width to be at least 1px after applied transform
* add a comment to explain how minimal linewidth is computed.
 * when context.linewidth < 1 after transform, firefox and chrome
   don't render in the same way (issue #12810).
 * set lineWidth to 1 after transform and before stroking
   - aims fix issue #12295
   - a pixel can be transformed into a rectangle with both heights < 1.
     A single rescale leads to a rectangle with dim equals to 1 and
     the other to something greater than 1.
 * change the way to render rectangle with null dimensions:
   - right now we rely on the lineWidth set before "re" but
     it can be set after "re" and before "S" and in this case the rendering
     will be wrong.
   - render such rectangles as a single line.
2021-01-10 18:02:12 +01:00
Tim van der Meij
666ef6dac0
Merge pull request #12846 from Snuffleupagus/stylelint-length-zero-no-unit
Enable the Stylelint `length-zero-no-unit` rule
2021-01-10 16:16:41 +01:00
Jonas Jenwald
246a6f9d13 Enable the Stylelint length-zero-no-unit rule
Note that these changes were done automatically, using `gulp lint --fix`.
With this rule, we'll thus enforce a *consistent* formatting of zero-lengths in our CSS files.

Please find additional details about the Stylelint rule at https://stylelint.io/user-guide/rules/length-zero-no-unit
2021-01-10 14:09:36 +01:00
Tim van der Meij
f224a0eb9f
Merge pull request #12845 from Snuffleupagus/cleanup-more-CSS-dir
Remove unnecessary `dir`-dependent CSS rules, and simplify som findbar-button rules (PR 11077 follow-up)
2021-01-10 13:53:30 +01:00
Tim van der Meij
ddad2fe28a
Merge pull request #12844 from Snuffleupagus/update-packages
Update packages and translations
2021-01-10 13:38:16 +01:00
Jonas Jenwald
3210b91cf8 Update l10n files 2021-01-10 13:34:49 +01:00
Jonas Jenwald
0e23b8b6ce Update the eslint-plugin-unicorn package to the latest version
Please see https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v25.0.0 for additional details.
2021-01-10 13:34:49 +01:00
Jonas Jenwald
e14db97740 Update npm packages 2021-01-10 13:34:35 +01:00
Jonas Jenwald
ccbee6d2be Remove unnecessary dir-dependent CSS rules, and simplify som findbar-button rules (PR 11077 follow-up)
With the updated default viewer UI, some `dir`-dependent CSS rules are now redundant since *identical* rules are being specified for both LTR and RTL mode; after PR 12807 landed I've found even more of these cases.

Note in particular that the findbar-button rules can be simplified quite a bit, since there's a fair amount of unnecessary duplication in the CSS.
2021-01-10 13:30:36 +01:00
Tim van der Meij
f85b8721d1
Merge pull request #12842 from Snuffleupagus/issue-12841
Improve handling of JPEG images without an EOI marker (issue 12841)
2021-01-10 13:21:28 +01:00