Commit Graph

8645 Commits

Author SHA1 Message Date
Yury Delendik
9798e1007e Introducing gulp. 2016-03-04 09:36:46 -06: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
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
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
Jonas Jenwald
95aa8b0415 Remove the hasImage property from PDFThumbnailView
The `hasImage` property is a left-over from older thumbnail code, and has been made obsolete by `renderingState`.
Having two different properties tracking (basically) the same state is asking for trouble, since it's very easy to forget to update one of them, with annoying bugs as the result.
2016-02-25 17:04:11 +01:00
Jonas Jenwald
05917b65d5 Merge pull request #7016 from timvandermeij/annotations-missing-popup
Group popup creation code and apply it to more annotation types
2016-02-25 10:27:49 +01:00
Tim van der Meij
ad31e52a26 Group popup creation code and apply it to more annotation types 2016-02-25 00:35:45 +01:00
Jonas Jenwald
41efb92d3a Merge pull request #6988 from timvandermeij/fileattachment-annotation
Implement support for FileAttachment annotations
2016-02-24 12:58:06 +01:00
Tim van der Meij
0351c7eff4 Move the getFileName helper function to the core
This is required to be able to use it in the annotation display code,
where we now apply it to sanitize the filename of the FileAttachment
annotation. The PDF file from https://bugzilla.mozilla.org/show_bug.cgi?id=1230933 has shown that some PDF generators include the path of the file rather than the filename, which causes filenames with weird initial characters. PDF viewers handle this differently (for example Foxit Reader just replaces forward slashes with spaces), but we think it's better to only show the filename as intended.

Additionally we add unit tests for the `getFilenameFromUrl` helper
function.
2016-02-23 22:49:53 +01:00
Tim van der Meij
10902fd882 Implement unit and reference testing for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Tim van der Meij
6a33dfd13a Implement support for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Tim van der Meij
c53581f4e5 Merge pull request #7009 from KamiHQ/annotations-fix
[api-minor] Always expose data.title and data.contents for TextAnnotation
2016-02-22 22:59:38 +01:00
Tim van der Meij
ebe6fb2560 Merge pull request #7012 from KamiHQ/fix-annotation-popup
don't render highlight/underline/squiggly/strikeout annotations that doesn't have popup
2016-02-22 21:54:08 +01:00
Xiliang Chen
6762ff2fd6 don't render highlight/underline/squiggly/strikeout annotations that doesn't have popup 2016-02-22 13:10:20 +13:00
Xiliang Chen
266cedd960 always expose data.title and data.content 2016-02-19 13:50:25 +13:00
Brendan Dahl
0629fd0afa Merge pull request #7007 from Snuffleupagus/bug-1248959
[Addon] Catch errors in `getFindBar` (in PdfStreamConverter.jsm) to fix loading of PDF files in the bookmark sidebar (bug 1248959)
2016-02-18 16:18:15 -08:00
Yury Delendik
0d591719d9 Makes PDF data reading Streams API friendly. 2016-02-18 13:17:53 -06:00
Jonas Jenwald
f64113c927 [Addon] Catch errors in getFindBar (in PdfStreamConverter.jsm) to fix loading of PDF files in the bookmark sidebar (bug 1248959)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1248959.
2016-02-18 13:59:18 +01:00
Jonas Jenwald
8cdb69634f Merge pull request #6984 from Snuffleupagus/issue-6066
Update `JpegImage.getData` to support `forceRGBoutput` for images with `numComponents === 1` (issue 6066)
2016-02-18 11:51:07 +01:00
Jonas Jenwald
a494e33776 Update JpegImage.getData to support forceRGBoutput for images with numComponents === 1 (issue 6066)
*A more robust solution for issue 6066.*

As a temporary work-around for (the upstream) [bug 1164199](https://bugzilla.mozilla.org/show_bug.cgi?id=1164199), we parsed *all* images in the Firefox addon during a short time.
Doing so uncovered an issue with our image handling (see 6066), for JPEG images with a `DeviceGray` ColorSpace *and* `bpc !== 1` (bits per component).

As long as we let the browser handle image decoding in this case, this isn't going to be an issue, but I do think that we should proactively fix this to avoid future issues if we change where the images are decoded (in `jpg.js` vs in browser).
Also, we currently don't seem to have a test-case for that kind of image data.
2016-02-18 10:12:37 +01:00
Tim van der Meij
9eedfc128c Merge pull request #6998 from Snuffleupagus/outline-styles-core
[api-minor] Change `getOutline` to actually return the RGB color of outline items
2016-02-16 23:31:55 +01:00
Jonas Jenwald
7cf9de2c17 [api-minor] Change getOutline to actually return the RGB color of outline items
Currently the `C` entry in an outline item is returned as is, which is neither particularly useful nor what the API documentation claims.

This patch also adds unit-tests for both the color handling, and the `F` entry (bold/italic flags).
2016-02-15 13:41:22 +01:00
Jonas Jenwald
45fea8808e Merge pull request #6985 from timvandermeij/xhtml-leftovers
Remove XHTML leftovers from the viewer HTML files
2016-02-14 15:32:45 +01:00
Tim van der Meij
05e080c802 Merge pull request #6987 from timvandermeij/readme
Remove Opera from the README file as they removed the extension
2016-02-14 14:09:48 +01:00
Tim van der Meij
eeeebe8061 Remove Opera from the README file as they removed the extension 2016-02-14 14:05:20 +01:00
Tim van der Meij
edb2eecdc8 Remove XHTML leftovers from the viewer HTML files 2016-02-14 13:23:34 +01:00
Jonas Jenwald
98db068079 Reduce the overall indentation level in Catalog_readDocumentOutline, by using early returns, in order to improve readability 2016-02-14 11:38:43 +01:00
Tim van der Meij
e9a1a47d28 Merge pull request #6982 from Snuffleupagus/evaluator-remove-getAll
Remove the only remaining `Dict_getAll` usage (in evaluator.js) and the method itself
2016-02-13 20:48:37 +01:00
Tim van der Meij
addc4a3ded Merge pull request #6856 from KamiHQ/remove-has-html
move hasHtml to AnnotationElement
2016-02-13 20:12:09 +01:00
Tim van der Meij
cd9d134af3 Merge pull request #6939 from LilyBin/uglifyjs
Use UglifyJS to minify files in minified target
2016-02-13 15:07:47 +01:00
Jonas Jenwald
1ee016b005 Remove Dict_getAll since it is now unused
`Dict_getAll` is problematic for a number of reasons. First of all, as issue 6961 shows, it can be really bad for performance, since it dereferences all indirect objects.
Second of all, all the derefencing can lead to data being unncessarily requested when ranged/chunked loading is used, thus unnecessarily delaying rendering.

Note: For cases where `Dict_getAll` was previously used, `Dict_getKeys` in combination with `Dict_get` can be used instead. This has the advantage that data isn't requested until it's actually needed.
2016-02-12 22:32:07 +01:00