Commit Graph

12151 Commits

Author SHA1 Message Date
Tim van der Meij
a88dec197f
Merge pull request #11511 from Snuffleupagus/eslint-no-nested-ternary
Enable the `no-nested-ternary` ESLint rule (PR 11488 follow-up)
2020-01-22 22:52:59 +01:00
Tim van der Meij
be5b0096b2
Merge pull request #11502 from Snuffleupagus/prettier-followup-fixes
Fix a couple of cases where Prettier broke existing formatting (PR 11446 follow-up)
2020-01-22 22:35:46 +01:00
Tim van der Meij
0d3146d09d
Merge pull request #11529 from Snuffleupagus/examples-css-tab
Display the CSS tab in the interactive examples (issue 11506 follow-up)
2020-01-22 22:23:02 +01:00
Brendan Dahl
60f0c5ac70
Merge pull request #11510 from Snuffleupagus/skip-FBF-tests-Chrome-makeref
Skip failing FBF tests in Google Chrome when running `makeref` on the bots
2020-01-22 11:45:05 -08:00
Jonas Jenwald
3b78f4e8f8 Fix a couple of cases where Prettier broke existing formatting (PR 11446 follow-up)
These two cases should have been whitelisted prior to re-formatting respectively had the comments fixed afterwards, however I unfortunately missed them because of the massive size of the diff.
2020-01-22 09:12:12 +01:00
Jonas Jenwald
c5a932a9d6 Display the CSS tab in the interactive examples (issue 11506 follow-up)
I just happened to notice that we've apparently never displayed the "CSS" tab [in the interactive examples](https://mozilla.github.io/pdf.js/examples/index.html#interactive-examples), which probably limits the number of users who'll notice the `direction: ltr;` CSS rule on the canvas :-)
2020-01-22 00:36:39 +01:00
Tim van der Meij
ead03b513c
Merge pull request #11522 from Snuffleupagus/viewer-reportTelemetry
Ensure that the viewer telemetry reporting, and fallback code, runs in development mode and GENERIC builds
2020-01-20 23:33:49 +01:00
Jonas Jenwald
f171d99799 Ensure that the viewer telemetry reporting, and fallback code, runs in development mode and GENERIC builds
While only the `MOZCENTRAL` builds will actually do anything meaningful with the telemetry data, none of the code in question actually runs *at all* in e.g. development mode.[1]
This seems bad since it essentially means that this code is completely untested, despite being quite important for the built-in Firefox PDF viewer, and this thus ought to be fixed.

In this case, the explanation for the current state of the code should be "for historical reasons". Before the viewer was split into the current components and before the pre-processor was improved, back when all code resided in the `web/viewer.js` file, the telemetry reporting was done with *direct* `FirefoxCom` calls. However, with the dummy `DefaultExternalServices.reportTelemetry` method there's nothing actually preventing attempting to report telemetry in any type of build.

NOTE: By running this code in GENERIC builds as well, in addition to just locally, the *viewer* part of telemetry reporting becomes tested e.g. in preview builds too which should help with reviewing.

---
[1] When fixing bug 1606566, I had to edit the relevant `PDFJSDev` checks to be able to actually test the changes locally.
2020-01-20 11:46:38 +01:00
Tim van der Meij
ccf327538b
Merge pull request #11519 from tamuratak/enable_eslint_import_extensions
Enable import/extensions of ESlint plugin to enforce all `import` have a `.js` file extension.
2020-01-19 17:37:19 +01:00
Tim van der Meij
918f0ff60b
Merge pull request #11521 from Snuffleupagus/rm-supportsDocumentColors
Remove the `supportsDocumentColors` warning in MOZCENTRAL builds (bug 844349 follow-up)
2020-01-19 17:24:55 +01:00
Tim van der Meij
1097fa156c
Merge pull request #11520 from Snuffleupagus/workerSrc-docs
Update the `GlobalWorkerOptions.workerSrc` JSDoc comment
2020-01-19 17:18:40 +01:00
Jonas Jenwald
a977882f54 Remove the supportsDocumentColors warning in MOZCENTRAL builds (bug 844349 follow-up)
With https://bugzilla.mozilla.org/show_bug.cgi?id=844349 now being fixed in Firefox, the textLayer will now actually stay hidden as intended regardless of the browser settings.
Hence it should no longer be necessary to display the fallback bar, nor print a warning in the console, for documents which contains a textLayer.

Besides removing the `supportsDocumentColors` methods in the default viewer, we can also remove a now unused l10n string.
2020-01-19 14:49:26 +01:00
Jonas Jenwald
ee87e898db Update the GlobalWorkerOptions.workerSrc JSDoc comment
This particular JSDoc comment is fairly old and it also contains some now unrelated/confusing information.
The only way to *guarantee* that the PDF.js library works as expected is to correctly set the global `workerSrc`[1], hence giving the impression that the option isn't strictly necessary is thus incorrect.

---
[1] Since advertising the fallbackWorkerSrc functionality definitely seems like the *wrong* thing to do.
2020-01-19 12:44:42 +01:00
Takashi Tamura
00ce7898a2 Enable import/extensions of ESlint plugin to enforce all import have a .js file extension.
Related to #11465.

- https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
2020-01-18 10:53:01 +09:00
Jonas Jenwald
1b87b1c384 Re-factor the various ExternalServices, used in the default viewer, to classes with static methods
This seems nicer overall, since it's now a bit clearer that the various build targets *extend* the default implementation.
2020-01-15 14:26:47 +01:00
Jonas Jenwald
c591826f3b Enable the no-nested-ternary ESLint rule (PR 11488 follow-up)
This rule is already enabled in mozilla-central, and helps avoid some confusing formatting, see https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#209-210

With the recent introduction of Prettier some of the existing nested ternary statements became even more difficult to read, since any possibly helpful indentation was removed.
This particular ESLint rule wasn't entirely straightforward to enable, and I do recognize that there's a certain amount of subjectivity in the changes being made. Generally, the changes in this patch fall into three categories:
 - Cases where a value is only clamped to a certain range (the easiest ones to update).
 - Cases where the values involved are "simple", such as Numbers and Strings, which are re-factored to initialize the variable with the *default* value and only update it when necessary by using `if`/`else if` statements.
 - Cases with more complex and/or larger values, such as TypedArrays, which are re-factored to let the variable be (implicitly) undefined and where all values are then set through `if`/`else if`/`else` statements.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-nested-ternary
2020-01-14 17:49:39 +01:00
Jonas Jenwald
78917bab91 Update src/display/{annotation_layer.js, svg.js} to determine the fontWeight in the same way as with canvas (PR 6091 and 7839 follow-up) 2020-01-14 15:29:59 +01:00
Jonas Jenwald
6590cc32f2 Extract the subroutine bias computation into a helper function in src/core/font_renderer.js 2020-01-14 15:29:53 +01:00
Jonas Jenwald
6ab3ba9519 Skip failing FBF tests in Google Chrome when running makeref on the bots
Note that this will still allow the FBF tests to run locally, and also on the bots when invoked with `test`/`browsertest` (to not lose all the FBF test-coverage), but will no longer prevent `makeref` from running successfully on the bots.
2020-01-14 00:54:44 +01:00
Tim van der Meij
40f531ee87
Merge pull request #11503 from Snuffleupagus/issue-11499
Remove the unused `id` properties from page and thumbnail canvas/image DOM elements (issue 11499)
2020-01-12 19:38:17 +01:00
Tim van der Meij
611ac78341
Merge pull request #11504 from Snuffleupagus/issue-11457
Add `direction: ltr;` to the canvases used in `examples/learning`, to ensure correct text rendering (issue 11457)
2020-01-12 19:31:59 +01:00
Tim van der Meij
ba1d8d8728
Merge pull request #11505 from Snuffleupagus/eslint-no-unneeded-ternary
Enable the ESLint `no-unneeded-ternary` rule
2020-01-12 19:28:11 +01:00
Jonas Jenwald
ecd3de83f8 Enable the ESLint no-unneeded-ternary rule
This rule is already enabled in mozilla-central, see https://searchfox.org/mozilla-central/rev/b04e3a28a2ef4dbf957018dbbdc1840d62fdbc32/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#247-248

Please see https://eslint.org/docs/rules/no-unneeded-ternary for additional information.
2020-01-12 14:50:52 +01:00
Jonas Jenwald
2e5faa8edc Add direction: ltr; to the canvases used in examples/learning, to ensure correct text rendering (issue 11457)
This is currently the only possible way of addressing the issue, until https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/direction becomes generally available in browsers.

*Note:* This will also require manually updating https://mozilla.github.io/pdf.js/examples/#interactive-examples
2020-01-12 12:25:23 +01:00
Jonas Jenwald
34e7d42ce6 Add helper functions to reduce unnecessary duplication when fetching l10n messages in PDFThumbnailView 2020-01-11 14:28:29 +01:00
Jonas Jenwald
16a94412e4 Remove the unused id properties from page and thumbnail canvas/image DOM elements (issue 11499)
As described in the issue, having a DOM element with `id=page2` (or any other number) will automatically cause that element to become linkable through the URL hash. That's currently leading to some confusing and outright wrong behaviour, since it obviously only works for pages that have been loaded and rendered.

For PDF documents the only officially supported way to reference a particular page through the URL hash is using the `#page=2` format, which also works for all pages regardless if they're loaded or not.

As far as I can tell there's nothing in the PDF.js default viewer that actually depends on the page/thumbnail `id` at this point in time, hence why I believe that this removal ought to be safe.
Just as a pre-caution this patch adds an `aria-label` to the page canvas, similar to the thumbnail canvas/image, to at least keep this information in the DOM.
2020-01-11 14:11:47 +01:00
Tim van der Meij
4729fdc0e9
Merge pull request #11488 from Snuffleupagus/web-no-nested-ternary
Enable the `no-nested-ternary` ESLint rule in the `web/` directory
2020-01-08 23:19:26 +01:00
Jonas Jenwald
1ceffac9c5 Enable the no-nested-ternary ESLint rule in the web/ directory
This rule is already enabled in mozilla-central, and helps avoid some confusing formatting[1], see https://searchfox.org/mozilla-central/rev/a92ed79b0bc746159fc31af1586adbfa9e45e264/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#209-210

Since some cases may not be aren't entirely straightforward to convert, and some we probably don't want to change either[2], this patch is limited to the `web/` directory as a proof-of-concept.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-nested-ternary

---
[1] One example with *three* ternary statements: 93aa613db7/src/core/fonts.js (L2623-L2630)

[2] One example that should be whitelisted: 93aa613db7/src/core/jbig2.js (L82-L92)
2020-01-08 11:56:10 +01:00
Tim van der Meij
93aa613db7
Merge pull request #11465 from Snuffleupagus/import-file-extension
Ensure that all `import` and `require` statements, in the entire code-base, have a `.js` file extension
2020-01-06 23:24:43 +01:00
Tim van der Meij
3772e30f9e
Merge pull request #11474 from Snuffleupagus/pdfjs-dist-rm-dependencies
[api-minor] Remove the Webpack-only npm dependencies from `pdfjs-dist` (PR 11418 follow-up)
2020-01-06 23:07:53 +01:00
Tim van der Meij
049a464372
Merge pull request #11466 from Snuffleupagus/telemetry-generator-parsing
[Firefox] Slightly simplify how the generator is determined, when sending telemetry data from the viewer
2020-01-06 22:55:30 +01:00
Tim van der Meij
f0999d271c
Merge pull request #11472 from Snuffleupagus/license_header_year
Update the year in the `license_header` files
2020-01-06 22:48:09 +01:00
Jonas Jenwald
a0cf67d52f [api-minor] Remove the Webpack-only npm dependencies from pdfjs-dist (PR 11418 follow-up)
Currently *all* users of `pdfjs-dist` are forced to install the `webpack` and `worker-loader` packages, despite the fact that they are *only* relevant if the `webpack.js` file is being used (with a custom Webpack build).
This really doesn't seem great, especially since those packages are the only remaining dependencies in the `pdfjs-dist` library, and it thus seem more reasonable overall that Webpack users handle those dependencies themselves.

To prevent unnecessarily cryptic runtime failures, when people update to newer `pdfjs-dist` versions, the `webpack.js` file was updated to explicitly check for the existence of the `worker-loader` package and error otherwise.
Furthermore, note that `webpack` was only listed as a dependency because of the `worker-loader` package itself (see issue 9248).

Obviously these changes may not be seen as great by Webpack users who rely on `pdfjs-dist`, since it forces them to handle the dependencies themselves, however it should improve things considerably for "general" users of `pdfjs-dist` by not burdening them with unnecessary dependencies.
These sort of changes are also in line with other recent changes, see PR 11418, which removed built-in fake worker loader code for specific JS builders/bundlers/frameworks. This work was prompted not only by a desire to simplify/clean-up old code, but also to lessen future support burden since the PDF.js contributors cannot be assumed to be experts in various JS bundlers.
2020-01-05 20:35:19 +01:00
Jonas Jenwald
94f084958a Update the year in the license_header files 2020-01-05 12:14:03 +01:00
Jonas Jenwald
36881e3770 Ensure that all import and require statements, in the entire code-base, have a .js file extension
In order to eventually get rid of SystemJS and start using native `import`s instead, we'll need to provide "complete" file identifiers since otherwise there'll be MIME type errors when attempting to use `import`.
2020-01-04 13:01:43 +01:00
Jonas Jenwald
299ba44bb9 [Firefox] Slightly simplify how the generator is determined, when sending telemetry data from the viewer
When working on PR 11463 I couldn't help thinking that the `Array.prototype.some` callback function, used when determining the generator, was somewhat difficult to read with its partly unused and strangely named parameters.
2020-01-02 23:29:00 +01:00
Rob Wu
b833f84307
Merge pull request #11463 from Snuffleupagus/bug-1606566
[Firefox] Ensure that telemetry will be correctly recorded even when the PDF header is missing (bug 1606566)
2020-01-01 23:02:42 +01:00
Jonas Jenwald
bee941b0d2 [Firefox] Ensure that telemetry will be correctly recorded even when the PDF header is missing (bug 1606566)
As suggested in the bug we'll now always fallback to "other", which should be fine considering that that value is listed in the histogram definition; see https://searchfox.org/mozilla-central/rev/331f0c3b25089c9a16be65f4dc8c601aeaac8cc4/toolkit/components/telemetry/Histograms.json#9097-9106

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1606566
2020-01-01 22:23:11 +01:00
Tim van der Meij
10716aab59
Merge pull request #11447 from timvandermeij/css-color-simplifications
Convert all non-RGBA colors to RGBA colors
2020-01-01 15:37:49 +01:00
Tim van der Meij
e3c0181357
Convert all six-digit HEX colors to RGBA colors 2020-01-01 14:52:37 +01:00
Tim van der Meij
403a994556
Convert all three-digit HEX colors to RGBA colors 2020-01-01 14:52:37 +01:00
Tim van der Meij
d002637405
Convert all named colors to RGBA colors 2020-01-01 14:48:56 +01:00
Tim van der Meij
2c2fc36c54
Normalize all RGBA colors
This is not only useful to have one format for consistency, but also to
be able to quickly search for colors for e.g., finding duplicates or
when tweaking the CSS for custom deployments.
2020-01-01 14:48:55 +01:00
Tim van der Meij
dd1c8a9149
Convert all RGB colors to RGBA colors 2020-01-01 14:48:55 +01:00
Tim van der Meij
3717dcdf57
Convert all HSLA colors to RGBA colors 2020-01-01 14:48:55 +01:00
Tim van der Meij
0bdb1ab202
Convert all HSL colors to RGBA colors 2019-12-28 20:54:57 +01:00
Tim van der Meij
3b44861197
Merge pull request #11455 from Snuffleupagus/update-packages
Update `npm` packages and l10n files
2019-12-28 20:35:44 +01:00
Jonas Jenwald
cac953f5a9 Update l10n files 2019-12-28 20:00:03 +01:00
Jonas Jenwald
05129deb00 Update npm packages 2019-12-28 19:57:25 +01:00
Tim van der Meij
a0fe7a77d6
Merge pull request #11454 from Snuffleupagus/move-SegoeUISymbol
Move the SegoeUISymbol font to the `getNonStdFontMap` (PR 8698 follow-up)
2019-12-28 13:37:36 +01:00