Commit Graph

8673 Commits

Author SHA1 Message Date
Yury Delendik
a8e5912cb1 Moves shared/global to display/global 2016-03-23 19:24:37 -05:00
Yury Delendik
e372f3608b Makes WorkerMessageHandler non-global. 2016-03-23 19:24:37 -05:00
Yury Delendik
bda5e6235e Removes global PDFJS usage from the src/core/. 2016-03-23 19:24:37 -05:00
Yury Delendik
21ed8ff71d Merge pull request #7039 from prometheansacrifice/async-cmap-factory
Refactors CMapFactory.create to make it async
2016-03-21 13:57:36 -05:00
Manas
f6d28ca323 Refactors CMapFactory.create to make it async 2016-03-21 23:08:19 +05:30
Tim van der Meij
7ad8f3a6f0 Merge pull request #7093 from Snuffleupagus/gulp-importl10n-dir-fix
Use the correct path when checking if a `/l10n` directory exists, to avoid errors during `gulp importl10n` (PR 7063 followup)
2016-03-20 22:12:30 +01:00
Jonas Jenwald
41e5fa3c7a Use the correct path when checking if a /l10n directory exists, to avoid errors during gulp importl10n (PR 7063 followup)
This is regression from PR 7063, causing `gulp importl10n` to fail:
```
$ gulp importl10n
[19:45:02] Using gulpfile c:\Users\Jonas\Git\pdfjs\gulpfile.js
[19:45:02] Starting 'importl10n'...

Downloading ach...
[19:45:02] 'importl10n' errored after 4.42 ms
[19:45:02] Error: EEXIST, file already exists 'c:\Users\Jonas\Git\pdfjs\l10n\ach
'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:747:18)
    at downloadLanguageFiles (c:\Users\Jonas\Git\pdfjs\external\importL10n\local
es.js:59:8)
    at next (c:\Users\Jonas\Git\pdfjs\external\importL10n\locales.js:90:5)
    at Object.downloadL10n (c:\Users\Jonas\Git\pdfjs\external\importL10n\locales
.js:91:5)
    at Gulp.<anonymous> (c:\Users\Jonas\Git\pdfjs\gulpfile.js:92:11)
    at module.exports (c:\Users\Jonas\Git\pdfjs\node_modules\gulp\node_modules\o
rchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (c:\Users\Jonas\Git\pdfjs\node_modules\gulp\no
de_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (c:\Users\Jonas\Git\pdfjs\node_modules\gulp\no
de_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (c:\Users\Jonas\Git\pdfjs\node_modules\gulp\node_
modules\orchestrator\index.js:134:8)
```
2016-03-20 20:02:43 +01:00
Brendan Dahl
56f5c3a5ff Merge pull request #7088 from Snuffleupagus/issue-6957
Pass the `PDFJS.postMessageTransfer` parameter to the worker, so that the `MessageHandler` can be setup correctly in `createDocumentHandler` (issue 6957)
2016-03-18 13:08:46 -07:00
Jonas Jenwald
91756f6e86 Pass the PDFJS.postMessageTransfer parameter to the worker, so that the MessageHandler can be setup correctly in createDocumentHandler (issue 6957)
This regressed in commit acdd49f480, i.e. PR 6571.

Fixes 6957.
2016-03-16 18:34:26 +01:00
Jonas Jenwald
122d473239 Merge pull request #7084 from timvandermeij/gulp-fix
Revert renaming `node make` to `gulp` for `mozcentral`
2016-03-14 10:25:11 +01:00
Tim van der Meij
2b6d7ba3ec Gulp: allow passing parameters and revert one node make renaming 2016-03-13 21:53:17 +01:00
Yury Delendik
c6d2b7f9d9 Merge pull request #6906 from KamiHQ/fix-printing
avoid apply transform twice for composite context
2016-03-11 08:26:59 -06:00
Tim van der Meij
4784863ef7 Merge pull request #7069 from Snuffleupagus/TrueType-recover-glyphNames
Convert `uniXXXX` glyph names to proper ones when building the `charCodeToGlyphId` map for TrueType fonts (bug 1132849, issue 6893, issue 6894)
2016-03-10 20:45:59 +01:00
Jonas Jenwald
dfe9015a43 Convert uniXXXX glyph names to proper ones when building the charCodeToGlyphId map for TrueType fonts (bug 1132849, issue 6893, issue 6894)
This patch adds a `getUnicodeForGlyph` helper function, which is used to recover Unicode values for non-standard glyph names.

Some PDF generators, e.g. Scribus PDF, use improper `uniXXXX` glyph names which breaks the glyph mapping. We can avoid this by converting them to "standard" glyph names instead.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1132849.
Fixes 6893.
Fixes 6894.
2016-03-09 19:37:15 +01:00
Tim van der Meij
147598417c Merge pull request #7046 from a0preetham/zero_descent_fix
fonts.js: bad metric overrides when values are zero
2016-03-09 12:14:03 +01:00
Yury Delendik
4065a21f8c Merge pull request #7029 from Snuffleupagus/PDFThumnailView-refactor-canvas-to-image
[PDFThumbnailView] Re-factor the `canvas` to `image` conversion such that we always render to a `canvas`, and then replace it with an `image` once rendering is done
2016-03-07 14:00:39 -06:00
Yury Delendik
b540d7d6dc Merge pull request #7063 from timvandermeij/gulp
Migrate `clean` and `importl10n` target to gulp
2016-03-07 13:29:29 -06:00
Tim van der Meij
96cca2b37a Migrate clean and importl10n target to gulp 2016-03-04 21:14:56 +01:00
Tim van der Meij
b8aaa24257 Convert all node make instances to gulp 2016-03-04 20:30:36 +01:00
Tim van der Meij
ec1cf28679 Merge pull request #7061 from yurydelendik/gulp
Introducing gulp
2016-03-04 19:25:52 +01:00
Yury Delendik
262d1e0863 Import L10n files. 2016-03-04 09:50:51 -06:00
Yury Delendik
9798e1007e Introducing gulp. 2016-03-04 09:36:46 -06:00
Preetham Mysore
be1e12dbcb Fix for descent calculation while reading font hhea headers 2016-03-03 08:51:41 -05:00
Tim van der Meij
51f6aba0a0 Merge pull request #7054 from timvandermeij/fix-typo
Correct a minor name issue in the outline viewer code
2016-03-02 22:58:05 +01:00
Tim van der Meij
f4bb23a66b Correct a minor name issue in the outline viewer code 2016-03-02 22:51:31 +01:00
Tim van der Meij
d302ac612e Merge pull request #6943 from Snuffleupagus/outline-styles
Add support for bold/italic styled outline items in the viewer
2016-03-02 22:42:03 +01:00
Yury Delendik
e1906035ca Merge pull request #7052 from yurydelendik/issue7048
Reverts back un-need change made at #6879.
2016-03-02 11:22:48 -06:00
Yury Delendik
a022f6f069 Reverts back un-need change made at #6879. 2016-03-02 09:57:33 -06:00
Jonas Jenwald
8402c79171 Merge pull request #7050 from brendandahl/issue4402
For CIDFontType2 use CID as glyph ID when missing CID to GID map.
2016-03-02 10:11:42 +01:00
Jonas Jenwald
9b126711cd Add support for bold/italic styled outline items in the viewer 2016-03-02 09:56:58 +01:00
Brendan Dahl
a6acf74b54 Merge pull request #7023 from brendandahl/issue6721
Only draw glyphs on canvas if they are in the font or the font file is missing.
2016-03-01 18:03:37 -08:00
Brendan Dahl
6e1d131384 For CIDFontType2 use CID as glyph ID when missing CID to GID map. 2016-03-01 17:05:33 -08:00
Brendan Dahl
6b1de4aa38 Merge pull request #7049 from Snuffleupagus/issue-7020
Avoid accidentally getting the entire font file in `readNameTable` (issue 7020)
2016-03-01 16:39:40 -08:00
Brendan Dahl
ff87f3fb86 Only draw glyphs on canvas if they are in the font or the font file is missing. 2016-03-01 13:24:58 -08:00
Jonas Jenwald
505f15f221 Avoid accidentally getting the entire font file in readNameTable (issue 7020)
In the PDF file in question, some of the 'name' table entries have `record.length === 0`. This becomes problematic in the non-unicode case, since `font.getBytes(0)` will fetch the *entire* stream.
Given that OTS rejects 'name' entries larger than `2^16`, this thus explain the sanitizer errors.

Fixes 7020.
2016-03-01 21:59:49 +01:00
Yury Delendik
22341c0761 Merge pull request #6879 from yurydelendik/streams
Makes PDF data reading Streams API friendly.
2016-03-01 09:10:52 -06:00
Tim van der Meij
4d9a3d4fb9 Merge pull request #7040 from Snuffleupagus/remove-PDFThumbnailViewer_ensureThumbnailVisible
Remove `PDFThumbnailViewer_ensureThumbnailVisible`
2016-02-28 20:06:56 +01:00
Jonas Jenwald
39cba5d25d Remove PDFThumbnailViewer_ensureThumbnailVisible
Functionality wise, `ensureThumbnailVisible` is essentially just a shorthand for `scrollThumbnailIntoView`. (And note that `PDFViewer` doesn't implement a `ensurePageVisible` method.)

The only remaining usage of `PDFThumbnailViewer_ensureThumbnailVisible` is inside `PDFPresentationMode`, which introduces an otherwise unnecessary `PDFThumbnailViewer` dependency there.

We're already relying on the `presentationmodechanged` event, in various files, to track the state of Presentation Mode. Thus we can simply listen for that event in `PDFSidebar` too, and update the thumbnails if necessary.
2016-02-28 18:21:59 +01:00
Jonas Jenwald
b5582e14a9 [PDFThumbnailView] Re-factor the canvas to image conversion such that we always render to a canvas, and then replace it with an image once rendering is done
*This is a follow-up to PRs 6299 and 6441.*

The patch also adds an option to `PDFThumbnailView`, that disables the canvas-to-image conversion entirely, which might be useful in the context of issue 7026.
2016-02-28 18:18:12 +01:00
Tim van der Meij
9ff6c83bb6 Merge pull request #7038 from Snuffleupagus/refactor-sidebar
Move the sidebar related code from viewer.js into `PDFSidebar`
2016-02-28 14:58:47 +01:00
Jonas Jenwald
67a1dfcfb5 Move the sidebar related code from viewer.js into PDFSidebar
The sidebar code has, except for minor fixes/additions (such as attachments), been largely untouch for years.
To avoid having a bunch of sidebar code sprinkled throughout viewer.js, this patch moves the sidebar code into a separate file (pdf_sidebar.js), similar to how most other functionality has been moved in the last few years.

Besides simply moving code around, this patch also has the added benefit that we now keep track of the sidebar state (not just opened/closed).
This now makes it possible to handle both `Preferences` *and* `ViewHistory` settings for the sidebar state in a cleaner way, preventing strange and confusing interactions between the two.
2016-02-27 14:13:09 +01:00
Jonas Jenwald
21f048234d Refactor how PDFOutlineView/PDFAttachmentView is initialized in viewer.js, rename the classes, and refactor their render methods
Changes `PDFOutlineView`/`PDFAttachmentView` to be initialized once, since we're always creating them, and refactor their `render` methods to instead pass in the `outline`/`attachments`.

For consistency with other "classes", the `PDFOutlineView`/`PDFAttachmentView` are renamed to `PDFOutlineViewer`/`PDFAttachmentViewer`.

Also, make sure that the outline/attachments are reset when the document is closed. Currently we keep the old ones around until the `getOutline`/`getAttachments` API calls are resolved for a new document.
2016-02-27 14:13:08 +01:00
Tim van der Meij
7cb3c365ca Merge pull request #7035 from Snuffleupagus/issue-7034
Ensure that `PDFFindController_reset` actually resets *all* state (issue 7034)
2016-02-27 13:58:14 +01:00
Tim van der Meij
915eac3d20 Merge pull request #7036 from Snuffleupagus/svg-example-set-cmap-url
[SVG] Specify the `PDFJS.cMapUrl`/`PDFJS.cMapPacked` parameters in the svgviewer example
2016-02-27 13:27:37 +01:00
Jonas Jenwald
4a6575643b [SVG] Specify the PDFJS.cMapUrl/PDFJS.cMapPacked parameters in the svgviewer example
Re: issue 7017.
This should prevent the error, but does not fix the broken rendering.

The rendering issues are caused by `svg.js` not supporting the various text rendering modes, in this case specifically "invisible" (as indicated in the console `Warning: Unimplemented method setTextRenderingMode`).

Compared to the canvas case, where we just ignore invisible text, a smarter solution is probably required for the SVG case. Since just ignoring invisible text in `svg.js` would mean that text-selection isn't possible.
2016-02-26 23:07:39 +01:00
Tim van der Meij
0c19d84911 Merge pull request #7031 from Snuffleupagus/outline-default-title
Add a default title for outline items, to prevent display issues if the title is missing
2016-02-26 22:37:51 +01:00
Jonas Jenwald
c7a44391cf Add a reset method to PDFFindbar, and use it to clear parts of the find UI when the document is closed 2016-02-26 18:35:45 +01:00
Jonas Jenwald
e7d039dbce Ensure that PDFFindController_reset actually resets *all* state (issue 7034)
To reduce code duplication, the initialization code now uses the `reset` method.
Also, this patch moves `charactersToNormalize` out of `PDFFindController`, since it seemed better suited to be a "constant".
2016-02-26 18:35:17 +01:00
Jonas Jenwald
9bcbd4d872 Add a default title for outline items, to prevent display issues if the title is missing
Open http://www.puolustusvoimat.fi/wcm/61ba4180411e702ea19ee9e364705c96/luonnonmuonaohjelmalumo1985.pdf?MOD=AJPERES#pagemode=bookmarks.

Note how the outline looks entirely empty, but hovering over it you'll see that there are entries present. There's two separate issues here, first of all the fact that you cannot visually make out the outline items, and secondly that the lack of text means that the clickable area becomes too small.

In Adobe Reader this issue is somewhat mitigated, since they use an icon for every item. For PDF.js, the easist way to address this seems to be making use of a default title.
This issue should be *very* rare in practice, but given the simplicity of the solution I think that we should fix this.
2016-02-26 12:46:46 +01:00
Tim van der Meij
2b813c0ca4 Merge pull request #7030 from Snuffleupagus/PDFThumbnailView-remove-hasImage
Remove the `hasImage` property from `PDFThumbnailView`
2016-02-25 23:17:48 +01:00