Commit Graph

9692 Commits

Author SHA1 Message Date
Jonas Jenwald
cf87c9bba2 [Firefox addon] Upstream changes from: Bug 1356569 - Remove optional trailing parameters (issue 8310)
In https://bugzilla.mozilla.org/show_bug.cgi?id=1355216, the *third* parameter of `Services.obs.addObserver` was made optional.
However, omitting it in Firefox versions *without* that patch causes failures that completely prevents the addon from working (it won't even load).

As far as I can tell, there isn't *any* way to detect ahead of time if the third parameter can be safely omitted, hence we're forced to fallback to manually checking the version number :-(

*Note:* Since the `PdfJs.jsm` file is only used in the `MOZCENTRAL` build, we at least don't need to add any compatibility hacks there.
2017-04-18 20:51:17 +02:00
Vladimir Bloshchitsyn
319ea0f350 Allow use versions for pdf.js script (i.e. - pdf.js?2412313) 2017-04-18 15:07:09 +03:00
Yury Delendik
5ad3611cc4 Merge pull request #8300 from Snuffleupagus/GENERIC-DownloadManager-creation
Refactor the `DownloadManager` initialization in `GENERIC`/`CHROME` builds again (PR 8203 follow-up)
2017-04-17 07:34:13 -05:00
Yury Delendik
7812b3cfb2 Merge pull request #8299 from Snuffleupagus/domEvents-getGlobalEventBus-import
Import `getGlobalEventBus` correctly from `web/dom_events.js` in various `/web` files, to un-break e.g. the viewer components (PR 8203 follow-up)
2017-04-17 07:32:04 -05:00
Jonas Jenwald
594e8c05ef Refactor the DownloadManager initialization in GENERIC/CHROME builds again (PR 8203 follow-up)
In the first commit in PR 8203, I changed how the `DownloadManager` was included/initialized in `GENERIC`/`CHROME` builds.
The change was prompted by the fact that you cannot have conditional `import`s with ES6 modules, and I wanted to avoid bundling the general `DownloadManager` into the various Firefox specific build targets.

What I completely missed though, is that the new code meant that `download_manager.js` will now be pulling in the *entire* viewer (through `app.js`).
This is a *really* stupid mistake on my part, since it causes the `dist/build/pdf_viewer.js` used with the viewer components to now include basically the entire default viewer.

The simplest solution that I could come up with, is to add a `genericcom.js` file (similar to the `firefoxcom.js`/`chromecom.js` files) which will be responsible for importing/initializing the `DownloadManager`.
2017-04-17 13:34:30 +02:00
Jonas Jenwald
79e0745a12 Import getGlobalEventBus correctly from web/dom_events.js in various /web files, to un-break e.g. the viewer components (PR 8203 follow-up)
In PR 8203, I somehow managed to mess up the import of `getGlobalEventBus` in *all* files where it's present; my sincere apologies for this!
2017-04-17 00:54:29 +02:00
Tim van der Meij
bd0e4dc4e3 Merge pull request #8297 from timvandermeij/es6-find-bar
Convert the find bar to ES6 syntax
2017-04-16 23:46:25 +02:00
Jonas Jenwald
009d91d735 Merge pull request #8296 from timvandermeij/es6-document-properties
Convert the document properties to ES6 syntax
2017-04-16 23:17:47 +02:00
Tim van der Meij
6f6fb4dfd0
Convert the find bar to ES6 syntax 2017-04-16 23:12:11 +02:00
Tim van der Meij
6d7a0ff8f2
Convert the document properties to ES6 syntax 2017-04-16 16:42:57 +02:00
Tim van der Meij
228df572d2 Merge pull request #8294 from Snuffleupagus/es6-modules-src-display
Convert the files in the `/src/display` folder to ES6 modules
2017-04-16 16:24:34 +02:00
Tim van der Meij
3eb51f1272 Merge pull request #8295 from Snuffleupagus/web-createPromiseCapability
Use `createPromiseCapability` in `/web` files and avoid unnecessary `PDFPageView.setPdfPage` calls
2017-04-16 15:47:26 +02:00
Jonas Jenwald
10592a311a Merge pull request #8293 from timvandermeij/es6-password-prompt
Convert the password prompt to ES6 syntax
2017-04-16 15:38:24 +02:00
Tim van der Meij
dfd338a399
Remove the password prompt input type hack
The browsers have become smarter and made this hack no longer
functional. Since this is now enforced by practically all browsers,
there is nothing more we can do about this. It is up to the user to
serve the viewer over HTTPS or deal with the warning.

Note that this is in no way specific for PDF.js. Any site with password
inputs served over HTTP has this problem right now. This hack was
provided as a convenience for the users, but nothing more than that.
2017-04-16 15:17:23 +02:00
Tim van der Meij
e3796f6f41
Convert the password prompt to ES6 syntax 2017-04-16 15:17:23 +02:00
Jonas Jenwald
fce2cfddcf Check if pageView.pdfPage exists in PDFViewer._ensurePdfPageLoaded, to avoid potentially calling PDFPageView.setPdfPage multiple times for the same page
Since calling `PDFPageView.setPdfPage` will in turn call `PDFPageView.reset`, which cancels all rendering and completely resets the page, it's thus possible that we currently cause some unnecessary re-rendering during the initial loading phase of the viewer.

Depending on the order in which data arrives, it's possible (and in practice always seem to happen) that the `pdfPage` property of the *second* page has already been set during `PDFViewer.setDocument`, by the time that the request for the `pdfPage` is resolved in `PDFViewer._ensurePdfPageLoaded`.

Also, note how the `setPdfPage` call in `PDFViewer.setDocument` is already guarded by this kind of check.
2017-04-16 13:42:45 +02:00
Jonas Jenwald
b0a4f6de8f Use createPromiseCapability in /web files
In various viewer files, there's a number of cases where we basically duplicate the functionality of `createPromiseCapability` manually.
As far as I can tell, a couple of these cases have existed for a very long time, and notable even before the `createPromiseCapability` utility function existed.

Also, since we can write ES6 code now, the patch also replaces a couple of `bind` usages with arrow functions in code that's touched in the patch.
2017-04-16 12:45:24 +02:00
Jonas Jenwald
52e3de3c0a Convert the files in the /src/display folder to ES6 modules
Also disables ES2015 transpilation in development mode.
2017-04-16 12:19:10 +02:00
Tim van der Meij
c6e8ca863e Merge pull request #8291 from Snuffleupagus/pr-8157
Ensure that `PDFThumbnailView.draw` is able to handle `RenderingCancelledException` correctly (PR 8157 follow-up)
2017-04-15 20:17:03 +02:00
Jonas Jenwald
db6f2f3718 Ensure that PDFThumbnailView.draw is able to handle RenderingCancelledException correctly (PR 8157 follow-up)
In PR 8157, I embarrassingly enough forgot to change `pdf_thumbnail_view.js` to match the changes made to `pdf_page_view.js`.
2017-04-15 11:12:48 +02:00
Tim van der Meij
27c3c33eec Merge pull request #8288 from yurydelendik/mv-make-web
Moves 'web' target to the gulpfile.
2017-04-15 00:03:29 +02:00
Yury Delendik
f8b3b75e42 Merge pull request #8289 from timvandermeij/firefox-extension-cleanup
Firefox extension: remove unused preference cleanup from `bootstrap.js`
2017-04-14 17:00:59 -05:00
Yury Delendik
89df5ef033 Moves 'web' target to the gulpfile. 2017-04-14 16:57:53 -05:00
Tim van der Meij
e7a3ea29aa
Firefox extension: remove unused preference cleanup from bootstrap.js
The comment for the removal has been added three years ago, so we can
safely remove this now.
2017-04-14 23:49:01 +02:00
Jonas Jenwald
fd51a7cb8c Merge pull request #8287 from yurydelendik/babel-es2015-preset
Allow to convert (some of) ES6 code to ES5.
2017-04-14 21:47:45 +02:00
Yury Delendik
5855c0a8be Allow to convert (some of) ES6 code to ES5. 2017-04-14 14:39:25 -05:00
Jonas Jenwald
bc1f4dd9c8 Merge pull request #8285 from yurydelendik/webcjspath
Change amd to cjs path in ES6 modules
2017-04-14 18:35:39 +02:00
Yury Delendik
f6d4de9898 Merge pull request #8283 from yurydelendik/uint32arrayview
Moves Uint32ArrayView and hasCanvasTypedArrays into compatibility.js.
2017-04-14 10:39:21 -05:00
Yury Delendik
5feb2a253f Merge pull request #8286 from mozilla/package-version
Changing package.json version to 1.0.0
2017-04-14 10:37:26 -05:00
Yury Delendik
3b36a1709a Changing package.json version to 1.0.0
We are changing how we are structuring the src file -- it makes sense to create a "major" release.
2017-04-14 10:36:42 -05:00
Yury Delendik
8e681ce3e2 Change amd to cjs path in ES6 modules 2017-04-14 10:32:36 -05:00
Yury Delendik
30bee9fe0c Moves Uint32ArrayView and hasCanvasTypedArrays into compatibility.js. 2017-04-14 10:04:52 -05:00
Yury Delendik
74b31ab18f Merge pull request #8203 from Snuffleupagus/es6-modules-web
Convert the files in the `/web` folder to ES6 modules
2017-04-13 11:16:27 -05:00
Yury Delendik
c4c44c1bbe Merge pull request #8240 from Snuffleupagus/api-stopAtErrors
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
2017-04-13 10:58:49 -05:00
Yury Delendik
46646a9dd1 Merge pull request #8131 from timvandermeij/remove-umd-validation
ES6 modules: remove UMD header validation
2017-04-13 10:49:41 -05:00
Yury Delendik
b529df4547 Merge pull request #8281 from yurydelendik/v1.8.188
v1.8.188
2017-04-13 10:48:20 -05:00
Yury Delendik
b939827b4b v1.8.188 2017-04-13 10:46:19 -05:00
Yury Delendik
ad1023ff55 Merge pull request #8262 from tcorral/master
Fix worker resolution on using minified version
2017-04-13 10:41:36 -05:00
Tim van der Meij
32e01cda96 Merge pull request #8228 from timvandermeij/line-annotations
Implement support for line annotations
2017-04-13 00:18:31 +02:00
Tim van der Meij
e15a2ec523
Annotations: implement support for line annotations
This patch implements support for line annotations. Other viewers only
show the popup annotation when hovering over the line, which may have
any orientation. To make this possible, we render an invisible line (SVG
element) over the line on the canvas that acts as the trigger for the
popup annotation. This invisible line has the same starting coordinates,
ending coordinates and width of the line on the canvas.
2017-04-12 23:05:25 +02:00
Jonas Jenwald
2274465588 Merge pull request #8275 from Snuffleupagus/telemetry-stub
Rename PdfJsTelemetry-addon.jsm to PdfJsTelemetry-stub.jsm
2017-04-12 13:32:33 +02:00
Georg Fritzsche
4e8cd2b7d3 Rename PdfJsTelemetry-addon.jsm to PdfJsTelemetry-stub.jsm
And remove unused linting comments.
2017-04-12 13:11:04 +02:00
Yury Delendik
7052316f58 Merge pull request #8273 from Snuffleupagus/issue-8272
Correctly detect if `requestAnimationFrame` is supported in `compatibility.js` (issue 8272)
2017-04-11 10:14:39 -05:00
Jonas Jenwald
3a302fdb53 Correctly detect if requestAnimationFrame is supported in compatibility.js (issue 8272)
This is a regression from PR 8222.

Fixes 8272.
2017-04-11 17:01:35 +02:00
Jonas Jenwald
fbe7b2eee7 Always ignore Type3 glyphs if their OperatorLists contain errors, regardless of the value of the stopAtErrors option
Compared to the parsing of e.g. an entire page, it doesn't really make sense to only be able to render a Type3 glyph partially.
2017-04-11 08:59:22 +02:00
Jonas Jenwald
a39d636eb8 [api-minor] Always allow e.g. rendering to continue even if there are errors, and add a stopAtErrors parameter to getDocument to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.

NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.

Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-04-11 08:59:22 +02:00
Jonas Jenwald
10e5f766a2 Merge pull request #8266 from brendandahl/issue6652
Normalize blend mode names.
2017-04-11 08:54:42 +02:00
Brendan Dahl
4969b2ad97 Normalize blend mode names. 2017-04-10 16:18:08 -07:00
TCASAS
010d38a8c0 Fix worker resolution on using minified version
- When the minified version is used the resolver of the worker can not find it properly and throws 404 error.
- The problem was that:
  - It was getting the current name of the file.
  - It was replacing **.js** by **.worker.js**
- When it was loading the unminified version it was working fine because:
  - *pdf.js - .js + .worker.js*  = **pdf.worker.js**
- When it was loading the minified version it didtn't work because:
  - *pdf.min.js - .js + .worker.js* = **pdf.min.worker.js**
  - **pdf.min.worker.js** doesn't exist the real file name is **pdf.worker.min.js**
2017-04-10 13:41:50 +02:00
Tim van der Meij
30d63b0c50
Annotations: move container border removal to the display layer
The display layer is responsible for creating the HTML elements for the
annotations from the core layer. If we need to ignore border styling for
the containers of certain elements, the display layer should do so and
not the core layer. I noticed this during the implementation of line
annotations, for which we actually need the original border width in the
display layer, even though we ignore it for the container. If we set the
border style to zero in the core layer, this becomes impossible.

To prevent this, this patch moves the container border removal code from
the core layer to the display layer. This makes the core layer output
the unchanged annotation data and lets the display layer remove any
border styling if necessary.
2017-04-09 19:01:38 +02:00