Commit Graph

10685 Commits

Author SHA1 Message Date
Jonas Jenwald
513412c92e Add a new getLanguage method to the various IL10n implementations 2018-03-25 18:49:46 +02:00
Jonas Jenwald
ab74b32054 Adjust the displayed pageSize, in the document properties dialog, depending on the current *viewer* rotation (PR 9586 follow-up)
Please note that the behaviour implemented here mirrors the one used in Adobe Reader.
2018-03-25 18:49:46 +02:00
Jonas Jenwald
b7b5d93231 Reduce the duplication for the document_properties_page_size_* strings, by defining the units separately 2018-03-25 18:48:53 +02:00
Jonas Jenwald
77d025dc14 Move the isPortraitOrientation helper function from web/base_viewer.js to web/ui_utils.js
A couple of basic unit-tests are added, and a manual `isLandscape` check (in `web/base_viewer.js`) is also converted to use the helper function instead.
2018-03-25 18:48:53 +02:00
Tim van der Meij
5c1a16ba6e
Merge pull request #9586 from Snuffleupagus/pageSize-api-rotate
Ensure that `PDFPageProxy.pageSizeInches` handles non-default /Rotate entries correctly
2018-03-25 18:03:32 +02:00
Tim van der Meij
6cc0efe1cc
Merge pull request #9576 from timvandermeij/versions
Update packages
2018-03-25 17:52:26 +02:00
Tim van der Meij
95de23e6e3
Update packages
Jasmine had a major version bump and required a few minor changes in our
booting code. Most notably, using `pending` in a `describe` block is no
longer supported, so we can only return early there. On the positive
side, the unit tests now run in a random order by default, which
eliminates any dependencies between unit tests.

Note that upgrading to Webpack 4 is out of scope for this patch since
the bots cannot work well with the newly generated bundles (both
browsers on both bots do not react within 120 seconds). Webpack 4 is not
faster for us than Webpack 3, so for now there is no need to upgrade.
2018-03-25 16:59:50 +02:00
Jonas Jenwald
d547936827 Ensure that PDFPageProxy.pageSizeInches handles non-default /Rotate entries correctly
Without this patch, the pageSize will be incorrectly reported for some PDF files.

---

Move pageSizeInches to ui_utils
2018-03-25 16:48:29 +02:00
Tim van der Meij
115fbc47fe
Merge pull request #9594 from Snuffleupagus/pageLabel-validation
Add stricter validation in `Catalog.readPageLabels`
2018-03-24 19:40:49 +01:00
Brendan Dahl
24f766b14d
Merge pull request #9573 from yurydelendik/xml_parser
New XML parser
2018-03-21 17:00:00 -07:00
Jonas Jenwald
374d074f6e Add stricter validation in Catalog.readPageLabels
The current PageLabel dictionary validation code won't catch some (unlikely) forms of corruption. For example: a `Type`/`S` entry being `null`/`0`/empty string, a `P`/`St` entry being `null`/`0`.

Please note: I'm not aware of any bugs caused by the old code, but I've had this patch sitting locally for some time and figured it couldn't hurt to submit it.
2018-03-21 14:36:05 +01:00
Brendan Dahl
b67f117b56
Merge pull request #9590 from brendandahl/new-line
Add new line to default preferences.
2018-03-20 16:42:19 -07:00
Brendan Dahl
0aa31a493b Add new line to default preferences. 2018-03-20 16:36:37 -07:00
Tim van der Meij
c0b22da02a
Merge pull request #9584 from Rob--W/docs-examples-2.0
Update examples/ documentation for 2.0
2018-03-20 23:20:02 +01:00
Brendan Dahl
63c7aee112
Merge pull request #9565 from brendandahl/new-name
Rename the globals to shorter names.
2018-03-20 13:49:04 -07:00
Yury Delendik
655c8d34d0 New XML parser 2018-03-19 20:51:41 -05:00
Tim van der Meij
3bfc797bc7
Merge pull request #9587 from Snuffleupagus/cursorToolOnLoad
Move the `cursorToolOnLoad` preference handling into `AppOptions` (PR 9493 follow-up)
2018-03-19 23:51:42 +01:00
Jonas Jenwald
3131c9b54c Remove the deprecated mozL10n and localized properties from web/ui_utils.js
With PDF.js version `2.0`, these can now be removed.
2018-03-19 23:32:19 +01:00
Jonas Jenwald
c2f1523f06 Move the cursorToolOnLoad preference handling into AppOptions (PR 9493 follow-up)
Since no other viewer component is currently reading preferences itself, this patch thus unifies the behaviour across the viewer.
2018-03-19 23:24:56 +01:00
Brendan Dahl
6db9c3cb49
Merge pull request #9571 from Snuffleupagus/addon-prefs
[Firefox addon] Refactor bundling of the `default_preferences.json` file
2018-03-19 15:06:47 -07:00
Rob Wu
362da3bc05 Use pdfjsLib instead of PDFJS in examples
pdfjsLib is used in PDF.js 2.x,
PDFJS was the old namespace from 1.x.
2018-03-19 16:44:54 +01:00
Rob Wu
b0fe0f41db [docs] Link to other examples from examples page 2018-03-19 16:44:32 +01:00
Tim van der Meij
0d391daccc
Merge pull request #9577 from Snuffleupagus/pagesize-info-fixes
[api-minor] Fix various issues related to pageSize, and display the size for the active page in the document properties dialog
2018-03-18 15:01:21 +01:00
Tim van der Meij
4136d41a4c
Merge pull request #9574 from timvandermeij/l10n
Update translations
2018-03-18 14:49:30 +01:00
Jonas Jenwald
51ddcd6380 Display the pageSize of the *currently* active page in the document properties dialog 2018-03-18 09:10:21 +01:00
Jonas Jenwald
adeaefedae Don't unnecessarily update the fileSize, in the document properties dialog, when it's already been correctly set 2018-03-18 09:10:21 +01:00
Jonas Jenwald
1730447ca1 Tweak the pageSize l10n strings for the document properties dialog
The units are currently repeated after each dimension, which seems unnecessary and is also not done in other PDF viewers (such as e.g. Adobe Reader).

Furthermore, the name of the l10n arguments can be simplified slightly, since the name of the strings themselves should be enough information.

Finally, the `width`/`height` should be formatted according to the current locale, as is already done for other strings in the document properties dialog.
2018-03-18 09:10:21 +01:00
Jonas Jenwald
e0ae157582 [api-minor] Fix various issues related to the pageSize information
The `getPageSizeInches` method was implemented on `PDFDocumentProxy`, which seems conceptually wrong since the size property isn't global to the document but rather specific to each page. Hence the method is moved into `PDFPageProxy`, as `get pageSizeInches` instead to address this.

Despite the fact that new API functionality was implemented, no unit-tests were added. To prevent issues later on, we should *always* ensure that new functionality has at least some test-coverage; something that this patch also takes care of.

The new `PDFDocumentProperties._parsePageSize` method seemed unnecessary convoluted. Furthermore, in the "no data provided"-case it even returned incorrect data (an array, rather than the expected object).
Finally, the fallback strings didn't actually agree with the `en-US` locale. This inconsistency doesn't look too great, and it's thus addressed here as well.
2018-03-18 09:10:19 +01:00
Tim van der Meij
2247af7e95
Update translations
This required changing the import script in two ways:

- we should use the `default` branch and not the `tip` tag since the
  latter may refer to another branch than `default` (this is the case for
  the `vi` locale, which caused in the files to be overwritten with
  incorrect contents since `tip` referred to the
  `THUNDERBIRD600b1_2018031614_RELBRANCH` branch);
- we should check if the response code is indeed 200 because recently a
  script removed all empty localization files upstream (refer to
  https://bugzilla.mozilla.org/show_bug.cgi?id=1443175).
2018-03-17 16:31:04 +01:00
Tim van der Meij
db6e316efd
Merge pull request #9549 from Snuffleupagus/issue-9540
Attempt to handle corrupt PDF documents that inline Page dictionaries in a Kids array (issue 9540)
2018-03-17 15:29:32 +01:00
Brendan Dahl
01bff1a81d Rename the globals to shorter names.
pdfjsDistBuildPdf=pdfjsLib
pdfjsDistWebPdfViewer=pdfjsViewer
pdfjsDistBuildPdfWorker=pdfjsWorker
2018-03-16 11:08:56 -07:00
Jonas Jenwald
76250b923f [Firefox addon] Refactor bundling of the default_preferences.json file 2018-03-16 16:46:57 +01:00
Jonas Jenwald
d431ae069d Attempt to handle corrupt PDF documents that inline Page dictionaries in a Kids array (issue 9540)
According to the specification, see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.1942297, the contents of a Kids array should be indirect objects.
2018-03-12 14:13:23 +01:00
Tim van der Meij
6662985a20
Merge pull request #9541 from Rob--W/crx-fetch-chrome61plus
[CRX] Disable fetch in Chrome 60-
2018-03-10 00:15:47 +01:00
Tim van der Meij
58cda43b29
Merge pull request #9542 from Rob--W/crx-url-9493-fixup
[CRX] Fix error that broke the Chrome extension
2018-03-08 22:57:19 +01:00
Rob Wu
39e0b4b589 [CRX] Fix error that broke the Chrome extension
PR #9493 moved from `appConfig.defaultUrl` to `AppOptions.get('defaultUrl')`.
However, it forgot to replace `appConfig.defaultUrl` in chromecom.js,
and as a result the extension is not able to open any PDF file.

This patch fixes that issue.
2018-03-08 22:49:02 +01:00
Tim van der Meij
fded22c618
Merge pull request #9509 from timvandermeij/document
Implement a single `getInheritableProperty` utility function
2018-03-08 22:40:27 +01:00
Yury Delendik
e0fb18a339
Merge pull request #9508 from pal03377/file-info-page-size
Add paper size to document information/properties
2018-03-08 11:57:38 -06:00
Rob Wu
db428004f4 [CRX] Disable fetch in Chrome 60-
Chrome 60 and earlier does not include credentials (cookies) in requests
made with fetch, regardless of extension permissions. This was fixed in
61.0.3138.0 by
2e231cf052

This patch disables the fetch backend in all affected Chrome versions.
The browser detection is done by checking for a change that coincides
with the release of Chrome 61.

Test case:
1. Copy the `isChromeWithFetchCredentials` function from the patch.
2. Run it in the JS console of Chrome and verify the return value.

Verified results:
- 49.0.2623.75 - false (earliest supported version by us)
- 60.0.3112.90 - false (last major version affected by bug)
- 61.0.3163.100 - true (first major version without bug)
- 65.0.3325.146 - true (current stable)

Test case 2:
1. Build the extension (`gulp chromium`) and load it in Chrome.
2. Open the developer tools, and open any PDF file.
3. In the "Network tab" of the developer tools, look at "request type".
   In Chrome 60-: Should be "xhr"
   In Chrome 61+: Should be "fetch"
2018-03-08 18:27:30 +01:00
palsch
8558c5b1d9 Add page size to the document properties dialog 2018-03-08 18:23:47 +01:00
Tim van der Meij
f308d73d40
Implement a single getInheritableProperty utility function
This function combines the logic of two separate methods into one.
The loop limit is also a good thing to have for the calls in
`src/core/annotation.js`.

Moreover, since this is important functionality, a set of unit tests and
documentation is added.
2018-03-03 19:19:39 +01:00
Tim van der Meij
4e5eb59a33
Remove the getPageProp method in src/core/document.js
It's only used in two places in the class and those callsites can
directly get the information from the dictionary, which is more readable
and avoids an additional method call.
2018-03-03 14:57:42 +01:00
Tim van der Meij
c33bf800cc
Merge pull request #9493 from Snuffleupagus/refactor-api-options
[api-major] Move the remaining options from, and completely remove, the global `PDFJS` object
2018-03-03 14:48:54 +01:00
Jonas Jenwald
b8606abbc1 [api-major] Completely remove the global PDFJS object 2018-03-01 18:13:27 +01:00
Jonas Jenwald
4b4fcecf70 Ensure that we only pass in the necessary parameters when initializing PDFDataTransportStream/PDFNetworkStream in src/display/api.js
With options being moved from the global `PDFJS` object and into `getDocument`, a side-effect is that we're now passing in a fair number of useless parameters to the various transport/network streams.
Even though this doesn't *currently* cause any problems, it nonetheless seem like a good idea to explicitly provide the parameters that are actually necessary.
2018-03-01 18:11:17 +01:00
Jonas Jenwald
212553840f Move the pdfBug option from the global PDFJS object and into getDocument instead
Also removes the now unused `getDefaultSetting` helper function.
2018-03-01 18:11:17 +01:00
Jonas Jenwald
1d03ad0060 Move the disableCreateObjectURL option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:17 +01:00
Jonas Jenwald
05c05bdef5 Move the disableStream option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
b69abf1111 Move the disableRange option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
69d7191034 Move the disableAutoFetch option from the global PDFJS object and into getDocument instead
One additional complication with removing this option from the global `PDFJS` object, is that the viewer currently needs to check `disableAutoFetch` in a couple of places. To address this I'm thus proposing adding a getter in `PDFDocumentProxy`, to allow checking the *actually* used values for a particular `getDocument` invocation.
2018-03-01 18:11:16 +01:00