Commit Graph

8179 Commits

Author SHA1 Message Date
Mike Skalnik
341c5e9d1f [PATCH] Add fallback for font loading when eval disabled
In some cases, such as in use with a CSP header, constructing a function with a
string of javascript is not allowed. However, compiling the various commands
that need to be done on the canvas element is faster than interpreting them.
This patch changes the font renderer to instead emit commands that are compiled
by the font loader. If, during compilation, we receive an EvalError, we instead
interpret them.
2015-08-13 14:33:18 -07:00
Jonas Jenwald
ee5ce4b4a2 Fix typo in drawFigures, in webgl.js, which causes shadingPatterns with figure.type === triangles to render incorrectly
The file `issue2948.pdf` from the test-suite can be used to (manually) test the patch.
2015-08-13 17:58:18 +02:00
Yury Delendik
20b46aaf88 Fixes supportsMozChunked for node.js 2015-08-12 18:48:59 -05:00
Jonas Jenwald
00b798dd76 Merge pull request #6329 from Rob--W/cmap-sparse
cmaps: Use cmap.forEach instead of Array.forEach
2015-08-10 12:23:57 +02:00
Jonas Jenwald
99d29487ab Adjust which TrueType (3, 1) glyphs we attempt to skip mapping of (issue 6336)
Fixes 6336.
2015-08-09 12:51:43 +02:00
Rob Wu
1e3078d6c4 Serialize errors before invoking postMessage
Serialize errors to make sure that the callback is still invoked when
an error is thrown.

Firefox:
"DataCloneError: The object could not be cloned."

Chrome:
"DataCloneError: Failed to execute 'postMessage' on 'WorkerGlobalScope': An object could not be cloned."
2015-08-08 21:44:57 +02:00
Rob Wu
b0a8c0fa40 cmaps: Use cmap.forEach instead of Array.forEach
CMaps may be sparse. Array.prototype.forEach is terribly slow in Chrome
(and also in Firefox) when the sparse array contains a key with a high
value. E.g.

    console.time('forEach sparse')
    var a = [];
    a[0xFFFFFF] = 1;
    a.forEach(function(){});
    console.timeEnd('forEach sparse');

    // Chrome: 2890ms
    // Firefox: 1345ms

Switching to CMap.prototype.forEach, which is optimized for such
scenarios fixes the problem.
2015-08-08 13:30:30 +02:00
Tim van der Meij
26b9205c7e Merge pull request #6327 from Snuffleupagus/viewer-sidebar-prevent-switching-to-disabled-views
Prevent switching to disabled views (i.e. outline or attachments) in the sidebar
2015-08-07 22:54:08 +02:00
Tim van der Meij
de979f1564 Merge pull request #6314 from Snuffleupagus/pagemode-regression
Fix regressions affecting both the 'pagemode' hash parameter and certain 'namedaction' types (PR 5971)
2015-08-07 22:48:38 +02:00
Jonas Jenwald
f063c78cbf Prevent switching to disabled views (i.e. outline or attachments) in the sidebar
Currently in `switchSidebarView` there is code that attempts to handle the `outline` or `attachments` being disabled. However, given the placement of it, that code does not actually accomplish anything. Even more strange is the fact that the way that the buttons are disabled, that code won't ever be hit.
(Looking back with `git blame`, it seems that it has never worked as you'd expect.)

Hence this patch, which correctly disables switching to the `outline` or `attachments` views when they are disabled.
Once PR 6314 restores the 'pagemode' hash parameter, this patch thus makes it impossible to switch to a disabled sidebar view by modifying the 'pagemode' hash of an already loaded document.
2015-08-07 13:45:32 +02:00
Jonas Jenwald
76cfd106d5 Fix 'namedaction' regression that breaks the 'Find' action
This regressed in 0ef6212b64.
2015-08-07 12:05:21 +02:00
Jonas Jenwald
5c26e5e2cd Move handling of the 'pagemode' hash parameter into viewer.js to restore the functionality
This regressed in 0ef6212b64.

Since the 'pagemode' hash parameter requires certain viewer functionality (e.g. thumbnails and an outline) in order to work, it seemed reasonable to move the functionality from `pdf_link_service.js` into `viewer.js`.
Similar to `namedaction`, this patch makes use of an event to forward the 'pagemode' parameter.
2015-08-07 12:05:17 +02:00
Yury Delendik
47aec956da Merge pull request #6325 from yurydelendik/version1.1.366
Version 1.1.366
2015-08-06 16:29:17 -05:00
Yury Delendik
0d16b44df2 Version 1.1.366 2015-08-06 16:16:12 -05:00
Brendan Dahl
5c1122c321 Merge pull request #6321 from yurydelendik/remove-pdfredirector
Removes PdfRedirector.js and PlayPreview support.
2015-08-06 10:31:03 -07:00
Yury Delendik
4f3f983a21 Removes PdfRedirector.js and PlayPreview support. 2015-08-06 10:38:45 -05:00
Tim van der Meij
9e9df5600f Merge pull request #6315 from timvandermeij/shading-testcase
Test case for tensor shading PR 6310
2015-08-05 00:53:39 +02:00
Tim van der Meij
14f1ea00fe Test case for tensor shading PR 6310 2015-08-04 23:55:55 +02:00
Tim van der Meij
9f9b76ab8a Merge pull request #6282 from Snuffleupagus/simpleviewer-linkService
Add a `PDFLinkService` instance to the "simpleviewer" component example
2015-08-04 23:32:52 +02:00
Yury Delendik
f1e35fc669 Merge pull request #6310 from THausherr/patch-1
fix handling of flags 1-3 in tensor shading
2015-08-04 16:16:46 -05:00
Tim van der Meij
1f94d8418e Merge pull request #6308 from dsprenkels/issue_6261
Apply hover style to .overlayButton not only when hovered, but also when focused.
2015-08-04 22:57:47 +02:00
Tilman Hausherr
6d1e0f7e8d fix handling of flags 1-3 in tensor shading
pi is an index in the stream and is explained on page 201 of the 32000-spec (however 1-based there), and ps is an index to something in PDF.js. I used the code from flag 0 (which works) to understand which is which. It is also important to understand that for flags 1,2 and 3, the stream is always assigned to the same coordinates and colors. What changes is which "old" coordinates and colors are assigned to what is "missing" in the stream. This is why for these flags, the code is identical except for the assignments in the first "row". (Same principle as in #6304). Note that this change will not improve the lamp_cairo.pdf file, only the two files mentioned in #6305.
2015-08-04 18:21:29 +02:00
Daan Sprenkels
c3b7ed4541 Apply hover style to .overlayButton not only when hovered, but also when focused (issue #6261) 2015-08-04 14:20:43 +02:00
Yury Delendik
1da7e893a6 Merge pull request #6304 from CodingFabian/fixup-6303
fix handling of flags 1-3 in coons shading
2015-08-03 17:41:46 -05:00
Tilman Hausherr
c85fa00d62 fix handling of flags 1-3 in coons shading
Short story: somebody got lost in two different indices. pi is an index in the stream and is explained on page 198 of the 32000-spec (however 1-based there), and ps is an index to something in PDF.js. I used the code from flag 0 (which works) to understand which is which. It is also important to understand that for flags 1,2 and 3, the stream is always assigned to the same coordinates and colors. What changes is which "old" coordinates and colors are assigned to what is "missing" in the stream. This is why for these flags, the code is identical except for the assignments in the first "row".
2015-08-03 21:15:26 +02:00
Brendan Dahl
a32d521555 Merge pull request #6222 from Rob--W/botio-robustness
Improve robustness of builder (esp. on Windows)
2015-08-03 10:10:35 -07:00
Brendan Dahl
977397ebfd Merge pull request #6270 from Snuffleupagus/opentype-cff-2
Adjust the heuristics used to detect OpenType font file with CFF data (bug 1186827, bug 1182130, issue 6264)
2015-08-03 09:43:33 -07:00
Tim van der Meij
72ecbec49d Merge pull request #6292 from Snuffleupagus/issue-6287
Fix various shading pattern regressions (issue 6287)
2015-07-31 22:26:01 +02:00
Jonas Jenwald
28130b949c Merge pull request #6281 from timvandermeij/data-url
Keep the Link annotation's data URL on one line
2015-07-31 22:23:56 +02:00
Tim van der Meij
31456a5b6d Merge pull request #6285 from Snuffleupagus/rename-PatternType-to-ShadingType
Rename `PatternType` to `ShadingType` to avoid confusion
2015-07-31 21:27:57 +02:00
Jonas Jenwald
1d65daf5e5 Correctly access colorSpace.numComps in MeshStreamReader (issue 6287)
This regressed in f750e35224.
2015-07-31 18:00:58 +02:00
Jonas Jenwald
7fe2442a18 Ensure that we don't use the same typed array for both coords and colors in Mesh figures (issue 6287)
This regressed in 1e8d70af98.
2015-07-31 18:00:23 +02:00
Jonas Jenwald
55bc98a8b0 Rename PatternType to ShadingType to avoid confusion
The current name is somewhat confusing, since the specification calls it `ShadingType`, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.4044105 and http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3882826.

The real problem, however, is that there is actually another property called `PatternType`, which makes the current code very confusing, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.1850929.

Since `ShadingType` is only relevant for shading patterns (i.e. `PatternType === 2`), and *not* for tiling patterns (i.e `PatternType === 1`), this patch should help reduce confusion when reading the code.
2015-07-30 20:03:45 +02:00
Jonas Jenwald
1f9466ea02 Add a couple of CSS hacks in order for scrollIntoView to work in the "simpleviewer" component example
This is intended as a temporary solution, in order to get the "simpleviewer" example to work, until we've re-factored `scrollIntoView` to work in both the standard and components-based viewers.
2015-07-30 17:19:54 +02:00
Jonas Jenwald
297f760dce Add a PDFLinkService instance to the "simpleviewer" component example 2015-07-30 17:19:54 +02:00
Tim van der Meij
a9d0e42871 Keep the Link annotation's data URL on one line
Fixes #6278.
2015-07-30 17:18:42 +02:00
Jonas Jenwald
e876dd8123 Merge pull request #6273 from timvandermeij/annotation-factory
Refactor annotation code to use a factory
2015-07-29 16:29:34 +02:00
Tim van der Meij
4f920ad100 Refactor annotation code to use a factory
Currently, `src/core/core.js` uses the `fromRef` method on an `Annotation` object to obtain the right annotation type object (such as `LinkAnnotation` or `TextAnnotation`). That method in turn uses a method `getConstructor` to find out which annotation type object must be returned.

Aside from the fact that there is currently a lot of code to achieve this, these methods should not be part of the base `Annotation` class at all. Creation of annotation object should be done by a factory (as also recommended by @yurydelendik at https://github.com/mozilla/pdf.js/pull/5218#issuecomment-52779659) that handles finding out the correct annotation type object and returning it. This patch implements this separation of concerns.

Doing this allows us to also simplify the code quite a bit and to make it more readable. Additionally, we are now able to get rid of the hardcoded array of supported annotation types. The factory takes care of checking the annotation types and falls back to returning the base annotation type (and issuing a warning, which the current code also does not do well) when an annotation type is unsupported.

I have manually tested this commit with 20 test PDFs with different annotation types, such as /Link, /Text, /Widget, /FileAttachment and /FreeText. All render identically before and after the patch, and unsupported annotation types are now properly indicated with a warning in the console.
2015-07-29 00:31:51 +02:00
Tim van der Meij
d08895d659 Merge pull request #6236 from Rob--W/print-javascript-action
Detect scripted auto-print requests
2015-07-25 19:42:31 +02:00
Tim van der Meij
0c15f8a777 Merge pull request #6268 from Rob--W/text-layer-optimize-access
Optimize text layer: Avoid unneeded .textContent access
2015-07-25 16:33:17 +02:00
Jonas Jenwald
0a024b5051 Adjust the heuristics used to detect OpenType font file with CFF data (bug 1186827, bug 1182130, issue 6264)
*This is a tentative patch.*

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1186827.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1182130.
Fixes 6264.
2015-07-25 12:26:36 +02:00
Rob Wu
47f2c14723 Optimize text layer: Avoid unneeded .textContent
Built-in DOM properties are slower than plain JS properties.
A few lines before, textContent is assigned as follows:
  textDiv.textContent = geom.str;
So replacing textDiv.textContent.length with geom.str.length slightly
improves performance without side effects.
2015-07-25 10:55:00 +02:00
Tim van der Meij
61f9052233 Merge pull request #6240 from Snuffleupagus/issue-6238
Check if the `Decode` entry is non-default when deciding if JPEG images are natively supported/decodable (issue 6238)
2015-07-23 22:52:49 +02:00
Jonas Jenwald
94d9a27a67 Update l10n files 2015-07-23 16:59:58 +02:00
Jonas Jenwald
45810e0866 Merge pull request #6257 from timvandermeij/viewer-cleanup
Remove unused globals and updateViewarea function from viewer.js
2015-07-23 16:32:11 +02:00
Tim van der Meij
9c510bd6e6 Remove unused globals and updateViewarea function from viewer.js 2015-07-23 16:02:39 +02:00
Tim van der Meij
d162dba85e Merge pull request #6256 from Snuffleupagus/bug-1186842
Ensure that the viewer always receives focus when the HOME/END keys are pressed (bug 1186842)
2015-07-23 14:46:32 +02:00
Tim van der Meij
21053460d7 Merge pull request #6254 from Snuffleupagus/issue-6253
Prevent documents from intermittently opening with the zoom level set to 1% (issue 6253)
2015-07-23 14:09:56 +02:00
Jonas Jenwald
8275dff1b1 Reduce code duplication in the 'keydown' event handler in viewer.js, by re-factoring the code which ensures that the viewerContainer is focused 2015-07-23 13:01:55 +02:00
Jonas Jenwald
d5232f5b5a Ensure that the viewer always receives focus when the HOME/END keys are pressed (bug 1186842)
It appears that I broke this with PR 4941.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1186842.
2015-07-23 12:04:49 +02:00