Commit Graph

10237 Commits

Author SHA1 Message Date
Jonas Jenwald
ac9802809c Merge pull request #8621 from Rob--W/eslint-version-update
Bump minimum eslint version to 3.19.0
2017-07-06 15:58:06 +02:00
Rob Wu
06887b6b62 Bump minimum eslint version to 3.19.0
The previously referenced eslint version is not compatible with our code base.
For example, rule "prefer-promise-reject-errors" requires 3.14.0.
2017-07-06 15:40:08 +02:00
Jonas Jenwald
c253ee9ab8 Ensure that the document is rendered on load, no matter what happens, by always calling PDFViewer.update *after* the initial position has been set 2017-07-06 13:50:02 +02:00
Jonas Jenwald
8391aacb89 Remove the scale-not-initialized hack from webViewerResize (in app.js)
Since we no longer, after PR 8555, allow changing the scale until the document is loaded, that hack is no longer necessary. Furthermore, no part of that event handling function needs to run unless a document is loaded.

The reason that this hack was initially added, is that previously the `ViewHistory` might be updated *before* `PDFViewerApplication.setInitialView` had run (in some cases leading to incorrect inital document scale). Since that is no longer possible, this is now dead code.
2017-07-06 13:13:22 +02:00
Jonas Jenwald
12f1b747b1 Merge pull request #8555 from Snuffleupagus/viewer-components-pdfDocument-checks
Don't allow setting various properties, such as `currentPageNumber`/`currentScale`/`currentScaleValue`/`pagesRotation`, before `{PDFViewer, PDFThumbnailViewer}.setDocument` has been called
2017-07-06 06:30:13 +02:00
Jonas Jenwald
1788a6b0cf Merge pull request #8615 from Snuffleupagus/issue-8613
Fix a stupid spelling error in the `ASCII85Decode` name in `Parser.makeInlineImage` (issue 8613)
2017-07-05 22:22:04 +02:00
Jonas Jenwald
ea71d23f74 Fix a stupid spelling error in the ASCII85Decode name in Parser.makeInlineImage (issue 8613)
This is a trivial follow-up to PR 5383, and it's a bit strange that this has been wrong since late 2014 without anyone noticing (maybe because inline images aren't too common).
So, apparently code works better if you actually spell correctly, who knew ;-)

Fixes 8613.
2017-07-05 19:43:09 +02:00
Yury Delendik
b3bac5100c Merge pull request #8596 from mukulmishra18/proper-read-result
Fixes wrong structure of fullReader.read() result.
2017-07-05 09:03:57 -05:00
Jonas Jenwald
9c95614bb6 Ensure that PDFFindBar._adjustWidth is called in all situations where the width of the findbar might have changed
After PR 8394, where the l10n service was converted to be asynchronous, we're no longer calling `_adjustWidth` after updating the `findMsg` label. Hence it's currently possible that the width of the findbar won't be correct. The solution is simple though, just call `_adjustWidth` after the `findMsg` label has been (asynchronously) updated.

Another existing issue, which was an oversight in PR 8132, is that `PDFFindBar.updateResultsCount` may be called directly from `PDFFindController`. In that case, we're not calling `_adjustWidth` at all, which means that the findbar may also not have the correct width.
The simple solution here is to always call `_adjustWidth` at the end of `updateResultsCount` (which is why we no longer need the `_adjustWidth` call at the end of `updateUIState`).
2017-07-05 11:34:14 +02:00
Jonas Jenwald
cb0009dab4 Actually reset the findResultsCount label, in addition to hiding it, when no matches are found
Currently we're *only* hiding the label, but not actually resetting it until a new match is found.
Obviously it's being hidden, but it seems that it really ought to be completely reset as well (since e.g. `PDFFindBar.reset` won't technically reset *all* state otherwise).
2017-07-05 11:19:29 +02:00
Jonas Jenwald
eff257b820 Merge pull request #8580 from brendandahl/missing-glyf
Fix how we detect and handle missing glyph data.
2017-07-04 12:16:07 +02:00
Jonas Jenwald
05b1ef2d23 Merge pull request #8594 from Snuffleupagus/es6-web-let
Change `var` to `let`, and use object destructuring, in a couple of previously class converted `web/*.js` files
2017-07-04 11:59:25 +02:00
Brendan Dahl
9f5c1550ed Merge pull request #8592 from brendandahl/cmap-3-0
Only mask char codes of (3, 0) cmap tables in the range of 0xF000 to 0…
2017-07-03 17:58:28 -07:00
Brendan Dahl
efbbd8533f Only mask char codes of (3, 0) cmap tables in the range of 0xF000 to 0xF0FF. 2017-07-03 13:13:46 -07:00
Brendan Dahl
6d4f748fb1 Fix how we detect and handle missing glyph data. 2017-07-03 13:06:06 -07:00
Jonas Jenwald
614e8cf295 Change var to let, and use object destructuring, in a couple of previously class converted web/*.js files
Note that these files were among the first to be converted to ES6 classes, so it probably makes sense to do another pass to bring them inline with the most recent ES6 conversions.
2017-07-03 11:22:49 +02:00
Jonas Jenwald
699f3392e4 Update l10n files 2017-07-03 11:10:21 +02:00
Mukul Mishra
308a83e5ca Fixes wrong structure of fullReader.read() result. 2017-07-01 15:52:47 +05:30
Tim van der Meij
9e4dcf156b Merge pull request #8585 from Snuffleupagus/issue-8584
Check that the `MessageHandler` isn't already terminated in the `onFailure` handler in `src/core/worker.js` (issue 8584)
2017-06-30 23:28:59 +02:00
Jonas Jenwald
82bd62ecc6 Merge pull request #8583 from Snuffleupagus/es6-app
ES6-ify the code in `web/app.js` and `web/viewer.js`
2017-06-30 10:19:09 +02:00
Jonas Jenwald
de0e7a9a68 Check that the MessageHandler isn't already terminated in the onFailure handler in src/core/worker.js (issue 8584)
All other code-paths already checks that the `MessageHandler` isn't terminated, but apparently `onFailure` was missing that check (compare e.g. with the `onSuccess` function).
From what I can tell, this is only an issue if workers are *disabled*, hence why I didn't bother adding a unit-test.

Fixes 8584.
2017-06-30 10:11:13 +02:00
Jonas Jenwald
d64ac95a91 ES6-ify the code in web/app.js and web/viewer.js
The changes consist mostly of changing `var` to `let`/`const`, and using shorthand method signatures.
2017-06-30 10:10:01 +02:00
Jonas Jenwald
80c33253ed Merge pull request #8582 from timvandermeij/es6-text-layer-builder
Convert the text layer builder to ES6 syntax
2017-06-30 10:08:28 +02:00
Tim van der Meij
19f56ec5c1
Convert the text layer builder to ES6 syntax 2017-06-29 23:41:25 +02:00
Jonas Jenwald
87a0031d77 Merge pull request #8589 from brendandahl/fix-expert-encoding
Fix missing notdef in expert encoding.
2017-06-29 22:05:44 +02:00
Brendan Dahl
a8a8909d2d Fix missing notdef in expert encoding. 2017-06-29 12:12:39 -07:00
Tim van der Meij
d6a6f390ae Merge pull request #8578 from Snuffleupagus/es6-ui_utils
ES6-ify the code in `web/ui_utils.js`
2017-06-28 22:24:37 +02:00
Jonas Jenwald
f6369fc87c ES6-ify the code in web/ui_utils.js
These changes consists mainly of replacing `var` with `let`/`const`, adding a couple of default parameters to function signatures, and finally converting `EventBus`/`ProgressBar` to proper classes.
2017-06-28 12:35:12 +02:00
Jonas Jenwald
f2fcf2a59c Merge pull request #8574 from timvandermeij/svg-stroke-properties
SVG: move setting the stroke properties to the `stroke` method
2017-06-27 10:16:30 +02:00
Tim van der Meij
f87f0d6812 Merge pull request #8576 from Snuffleupagus/toolbar-inline-selectScaleOption
Remove the `selectScaleOption` helper function, in `Toolbar._updateUIState`, and simply inline its code instead
2017-06-26 23:28:43 +02:00
Jonas Jenwald
1db290e818 Update l10n files 2017-06-26 14:30:41 +02:00
Jonas Jenwald
d4b93bec96 Remove the selectScaleOption helper function, in Toolbar._updateUIState, and simply inline its code instead
After PR 8510, we now always lookup the localized `page_scale_percent` string to prevent any possible ordering issues. Since the scaleSelect dropdown is updated asynchronous, there's really no point in having a helper function any more, hence this code can rather be placed inline in `Toolbar._updateUIState`.
2017-06-26 13:06:24 +02:00
Tim van der Meij
f1a87bab10
SVG: move setting the stroke properties to the stroke method
In general, we may not know the stroke properties when path construction
happens. Since we must know the properties when we apply the stroke, we
should set the properties at that point. Note that we already do that
for the color and opacity, but not yet for the other properties.
2017-06-25 22:28:46 +02:00
Jonas Jenwald
859e3d4dce Merge pull request #8564 from timvandermeij/svg-opacity
SVG: implement fill and stroke opacity
2017-06-24 22:42:18 +02:00
Tim van der Meij
d3a3b1db13 Merge pull request #8571 from Snuffleupagus/readme-es6
Mention in the "Getting the Code" section of README.md that an ES6 compatible browser is required when using the default viewer with `gulp server`
2017-06-24 22:14:29 +02:00
Jonas Jenwald
84d0df2b31 Mention in the "Getting the Code" section of README.md that an ES6 compatible browser is required when using the default viewer with gulp server
The https://github.com/mozilla/pdf.js/wiki/Contributing article has been updated to explicitly mention that an ES6 browser is now a minimum requirement for development.
Since we recently have seen a couple of issues filed which seemed to indicate that people tried to use PDF.js in browsers without full ES6 support, it's probably a good idea to mention this more prominently in the README as well.
2017-06-24 12:36:20 +02:00
Brendan Dahl
f1f9d98519 Merge pull request #8507 from Snuffleupagus/issue-8480
Only special-case OpenType fonts with `CFF` data if it's both a composite (i.e. Type0) font and also has a non-default CID to GID map (issue 8480)
2017-06-23 13:36:58 -07:00
Yury Delendik
e2ca894fec Merge pull request #8488 from mukulmishra18/streams-getTextContent
Streams get text content
2017-06-23 12:52:13 -05:00
Yury Delendik
d1567a947e Merge pull request #8567 from ghetolay/fix_CMapReaderFactory+worker
Fix error when using custom CMapReaderFactory
2017-06-23 12:49:55 -05:00
ghetolay
7f79e12383 Fix error when using custom CMapReaderFactory and worker 2017-06-23 15:59:43 +02:00
Tim van der Meij
f9eafefa09
SVG: implement stroke opacity 2017-06-23 00:37:27 +02:00
Tim van der Meij
440914e49b
SVG: implement fill opacity
This makes the `eoFill` method similar to the `eoStroke` method and the
ones in `src/display/canvas.js`.
2017-06-23 00:37:27 +02:00
Tim van der Meij
2f2e539bc6 Merge pull request #8561 from Snuffleupagus/zoomLayer-canvas-hidden
Don't use a hidden canvas when constructing the `zoomLayer` in `PDFPageView.update`
2017-06-22 23:51:21 +02:00
Tim van der Meij
c6ee05f7e5 Merge pull request #8542 from Rob--W/svg-clipping
Move svg:clipPath generation from clip to endPath
2017-06-22 23:48:06 +02:00
Jonas Jenwald
426e26c63b Don't use a hidden canvas when constructing the zoomLayer in PDFPageView.update
*This is an existing issue that I noticed while testing PR 8552.*

When zooming or rotation occurs, we'll try to use the current canvas as a (CSS transformed) preview until the page has been completely re-drawn.
If you manage to change the scale (or rotation) *very* quickly, it's possible that `PDFPageView.update` can be called *before* a previous `render` operation has progressed far enough to remove the `hidden` property from the canvas.

The result is thus that a page may be *entirely* black during zooming or rotation, which doesn't look very good. This effect can be a bit difficult to spot, but it does manifest even in the default viewer.
2017-06-22 10:05:41 +02:00
Rob Wu
fc6448d18c Move svg:clipPath generation from clip to endPath
In the PDF from issue 8527, the clip operator (W) shows up before a path
is defined. The current SVG backend however expects a path to exist
before generating a `<svg:clipPath>` element.
In the example, the path was defined after the clip, followed by a
endPath operator (n).
So this commit fixes the bug by moving the path generation logic from
clip to endPath.

Our canvas backend appears to use similar logic:
`CanvasGraphics_endPath` calls `consumePath`, which in turn draws the
clip and resets the `pendingClip` state. The canvas backend calls
`consumePath` from multiple other places, so we probably need to check
whether doing so is also necessary for the SVG backend.

I scanned our corpus of PDF files in test/pdfs, and found that in every
instance (except for one), the "W" PDF operator (clip) is immediately
followed by "n" (endPath). The new test from this commit (clippath.pdf)
starts with "W", followed by a path definition and then "n".

    # Commands used to find some of the clipping commands:
    grep -ra '^W$' -C7 | less -S
    grep -ra '^W ' -C7 | less -S
    grep -ra ' W$' -C7 | less -S

test/pdfs/issue6413.pdf is the only file where "W" (a tline 55) is not
followed by "n". In fact, the "W" is the last operation of a series of
XObject painting operations, and removing it does not have any effect
on the rendered PDF (confirmed by looking at the output of PDF.js's
canvas backend, and ImageMagick's convert command).
2017-06-22 01:08:17 +02:00
Tim van der Meij
36fb3686cc Merge pull request #8556 from Snuffleupagus/app-remove-pageRotation
Stop tracking the rotation in `PDFViewerApplication` and directly use `PDFViewer.pagesRotation` instead
2017-06-22 00:03:58 +02:00
Jonas Jenwald
5ff4cd8f0d Merge pull request #8552 from yurydelendik/canvas-hidden
Ensure canvas is really hidden when used with pdfjs-dist.
2017-06-21 17:28:45 +02:00
Jonas Jenwald
83673a12d7 Stop tracking the rotation in PDFViewerApplication and directly use PDFViewer.pagesRotation instead
Part of the rotation handling code, in what's now `web/app.js`, hasn't really changed since before the viewer was split into multiple files/components.

Similar to other properties, such as current page/scale, we should probably avoid tracking state in multiple places. Hence I'm suggesting that we don't store the rotation in `PDFViewerApplication`, and access the value in `PDFViewer` instead.

Since `PDFViewerApplication.pageRotation` has existed for a very long time, a getter was added to avoid outright breaking third-party code that may depend on it.
2017-06-21 11:45:36 +02:00
Jonas Jenwald
735b58c3d5 Don't allow setting various properties, such as currentPageNumber/currentScale/currentScaleValue/pagesRotation, before {PDFViewer, PDFThumbnailViewer}.setDocument has been called
Currently a number of these properties do not work correctly if set *before* calling `setDocument`; please refer to the discussion starting in https://github.com/mozilla/pdf.js/pull/8539#issuecomment-309706629.

Rather than trying to have *some* of these methods working, but not others, it seems much more consistent to simply always require that `setDocument` has been called.
2017-06-21 11:37:33 +02:00