Commit Graph

8265 Commits

Author SHA1 Message Date
Tim van der Meij
91ab010829 Merge pull request #6201 from Rob--W/crx-dont-force-no-download
[CRX] Respect download requests in main frame
2015-07-18 15:05:32 +02:00
Rob Wu
2d6b15d0d9 [CRX] Do not load local files in non-local frames
Ordinarily, local files cannot be embedded in a non-local website. Until
this commit, the extension allowed websites to embed local PDF files on
non-local (e.g. http(s)) websites. This unintended feature is now
disabled, to align better with Chrome's existing security policies
(=local file:-URLs cannot be loaded in a tab unless expicitly allowed).
2015-07-18 00:07:02 +02:00
Rob Wu
cc0805a996 Reduce verbosity of output in test/webbrowser.js 2015-07-17 23:21:35 +02:00
Jonas Jenwald
7065c1b8e9 Merge pull request #6215 from timvandermeij/annotation-border-fixes
More cleanup regarding annotation border styles
2015-07-17 22:42:10 +02:00
Tim van der Meij
465611a2ff More cleanup regarding annotation border styles 2015-07-17 21:51:24 +02:00
Tim van der Meij
4b6e2724ae Merge pull request #6220 from Snuffleupagus/issue-6218
Ignore double negative in `Lexer_getNumber` (issue 6218)
2015-07-17 21:29:40 +02:00
Tim van der Meij
6dfe19dcf7 Merge pull request #6226 from Snuffleupagus/fonttools
Update fonttools location and version (issue 6223)
2015-07-17 21:03:38 +02:00
Jonas Jenwald
d5772fa3ca Merge pull request #6221 from Thunderforge/{find-toolbar-checkbox-keyboard-accessibility}
Fixing find toolbar checkboxes not being accessible through keyboard
2015-07-17 13:24:08 +02:00
Jonas Jenwald
d68eb153d3 Update fonttools location and version (issue 6223) 2015-07-17 12:51:09 +02:00
Tim van der Meij
b35cbaa32c Merge pull request #6157 from Snuffleupagus/components-update-on-setScale-and-pagesRotation
Make sure that the document is rendered on zooming and rotation for `PDFViewer` instances using the `defaultRenderingQueue`
2015-07-16 23:06:32 +02:00
Rob Wu
c3c6d503ee Improve robustness of builder (esp. on Windows)
- Use rimraf instead of a custom removeDirSync implementation - rimraf
  deals with edge cases like EPERM on Windows.

- Detect when the process exits before it was requested via stop(),
  instead of running the cleanup handler.

- Add fallback for process detection when the process exits before it
  was requested. On *nix systems, this is done via pkill and pgrep, on
  Windows this is done via wmic.

- Add some asserts to check the preconditions of the methods, and output
  some status information to aid debugging in case of failure.

I have verified that these changes work on ArchLinux and Windows XP,
using Chrome and Firefox, as follows:

1. node make unittest

2. node make unittest
3. Restart the Firefox process via the task manager as soon as possible.

4. node make unittest
5. Temporary lock a file/directory within the temporary profile
   directory until the tests have finished, and then unlock the file
   within 10 seconds.

In all cases, the auxilary browser processes are killed, and the
temporary profile directory is wiped.
2015-07-16 21:40:57 +02:00
Will Herrmann
cbc715ed0f Fixing find toolbar checkboxes not being accessible through keyboard navigation 2015-07-16 13:23:14 -05:00
Jonas Jenwald
c718d1ab10 Ignore double negative in Lexer_getNumber (issue 6218)
Basic mathematics would suggest that a double negative should always become positive, but it appears that Adobe Reader simply ignores that case. Hence I think that it makes sense for us to do the same.

Fixes 6218.
2015-07-16 12:11:49 +02:00
Jonas Jenwald
cf6d40f348 Merge pull request #6214 from timvandermeij/annotation-color
Refactor annotation color handling and add unit tests
2015-07-16 09:38:54 +02:00
Tim van der Meij
a2e9845093 Refactor annotation color handling and add unit tests 2015-07-15 18:49:19 +02:00
Tim van der Meij
2817f008c3 Merge pull request #6208 from Snuffleupagus/issue-6204
Fetch all indirect objects (i.e. `Ref`s) in `NameTree_getAll` and `NameTree_get` (issue 6204)
2015-07-14 22:03:03 +02:00
Tim van der Meij
76d225dd3b Merge pull request #6207 from Snuffleupagus/viewer-remove-setScale
Remove `PDFViewerApplication.setScale` and further simplify the `scalechange` event handler (issue 6158)
2015-07-14 21:22:58 +02:00
Jonas Jenwald
28f40b1b58 Fetch all indirect objects (i.e. Refs) in NameTree_getAll and NameTree_get (issue 6204) 2015-07-14 10:56:56 +02:00
Jonas Jenwald
0c08113e39 Remove PDFViewerApplication.setScale and further simplify the scalechange event handler (issue 6158)
This finally fixes 6158.
2015-07-14 10:06:59 +02:00
Brendan Dahl
367794f0c7 Merge pull request #4990 from fkaelberer/refactor_chunked_stream
Minor refactoring of chunked_stream.js
2015-07-13 16:51:35 -07:00
Rob Wu
3e363ae307 scrollIntoView: Skip overflow:hidden elements 2015-07-14 00:23:29 +02:00
Rob Wu
62cf6536a2 Tests: Resolve -b to full path in webbrowser.js
This allows us to simply use "node test.js -b=firefox" instead of having
to type out the full path.
2015-07-14 00:20:07 +02:00
Tim van der Meij
1416a1b521 Merge pull request #6187 from Snuffleupagus/more-efficient-getDestination
A couple of improvements of `getDestination` (unit-test included)
2015-07-13 23:03:13 +02:00
Brendan Dahl
e498bbce90 Merge pull request #6198 from Rob--W/windows-taskkill
Use taskkill to stop the browser on Windows in tests
2015-07-13 13:30:03 -07:00
Tim van der Meij
9f5abd70d7 Merge pull request #6199 from Snuffleupagus/viewer-setInitialView-simpler-pageNumber-reset
Simplify the code that resets the value of the `pageNumber` element in `PDFViewerApplication.setInitialView`
2015-07-12 18:54:09 +02:00
Jonas Jenwald
dde3e4aaaf Merge pull request #6197 from Rob--W/issue6108
Improve robustness of stream parser (invalid length)
2015-07-12 17:26:31 +02:00
Jonas Jenwald
2608757620 Simplify the code that resets the value of the pageNumber element in PDFViewerApplication.setInitialView
After the creation of `PDFViewer`, its `_resetView` method takes care of resetting, among other things, the page number property. Hence we don't need to set `pdfViewer.currentPageNumber = 1;` here any more, and the comment is no longer accurate either.
2015-07-12 16:24:07 +02:00
Tim van der Meij
535b7c236e Merge pull request #6110 from Snuffleupagus/issue-6056
Refactor viewer code to fix issues with the "pageviewer" components example (issue 6056)
2015-07-12 16:02:37 +02:00
Rob Wu
5cce7377af Use taskkill to stop the browser on Windows 2015-07-11 20:22:53 +02:00
Rob Wu
e211c25f06 Improve robustness of stream parser (invalid length)
When the parser finds a stream, it retrieves the Length from the stream
dictionary and advances the lexer to the offset as specified in Length.
If this Length is incorrect, the lexer could end up anywhere.

When the lexer gets in an invalid state, it could throw errors. For
example, in issue 6108, the lexer ends up inside the stream data. This
stream has the ASCIIHexDecode filter, so all characters are made up from
ASCII characters, and the lexer interprets it as a command token. Tokens
cannot be longer than 127 bytes, so eventually 128 bytes are consumed
and the lexer throws "Command token too long" error.

Another possible error is "Illegal character: 41" when the lexer happens
to end up at a ')' due to the length mismatch.

These problems are solved by catching lexer errors and recovering the
parser via the existing stream length detection branch.
2015-07-11 20:12:49 +02:00
Tim van der Meij
7d4303b7c4 Merge pull request #6194 from Rob--W/recover-mode-start-offset
Subtract start offset for xrefs in recovery mode
2015-07-11 17:22:08 +02:00
Tim van der Meij
d091263b3b Merge pull request #6195 from Snuffleupagus/viewer-remove-updateScaleControls
Remove `PDFViewerApplication.updateScaleControls` (issue 6158)
2015-07-11 16:35:35 +02:00
Jonas Jenwald
5cb15874fa Remove PDFViewerApplication.updateScaleControls (issue 6158)
*With this patch we're getting very close to fixing 6158.*

The only use-case for `PDFViewerApplication.updateScaleControls` is to try and avoid calling `selectScaleOption` from the `scalechange` event handler in viewer.js.
This will *only* happen when the user has manually changed the scale by using the `<select>` dropdown, which means that in reality this is just a micro optimization. Furthermore, `selectScaleOption` is only skipped for the "named" scale values (e.g. `auto`, `page-actual`, `page-fit`, `page-width`), thus further reducing the value of this code.

Also, since we're updating the scale `<select>` dropdown from an event handler, we're currently depending on the event being dispatched (and handled) completely before the next `scalechange` event. Relying on the execution order of the code in this way, even though it currently works, seems unfortunate since it *could* potentially cause the internal scale value and the UI from getting out of sync.
2015-07-11 11:25:32 +02:00
Rob Wu
fd29bb0c57 Subtract start offset for xrefs in recovery mode
Xref offsets are relative to the start of the PDF data, not to the start
of the PDF file. This is clear if you look at the other code:

- In the XRef's readXRefTable and processXRefTable methods of XRef, the
  offset of a xref entry is set to the bytes as given by a PDF file.
  These values are always relative to the start of the PDF file (%PDF-).

- The XRef's readXRef method adds the start offset of the stream to
  Xref entry's offset: "stream.pos = startXRef + stream.start".
  Clearly, this line assumes that the entry offset excludes the start
  offset.

However, when the PDF is parsed in recovery mode, the xref table is
filled with entries whose offset is relative to the start of the stream
rather than the PDF file. This is incorrect, and the fix is to subtract
the start offset of the stream from the entry's byte offset.

The manually created PDF file serves as a regression test. It is a valid
PDF, except:
- The integer to point to the start of the xref table and the %%EOF
  trailer are missing. This will activate recovery mode in PDF.js
- Some junk was added before the start of the PDF file. This exposes the
  bad offset bug.
2015-07-10 23:33:10 +02:00
Tim van der Meij
6c1906fd53 Merge pull request #6193 from Rob--W/long-name-is-warning-not-error
Issue a warning instead of an error for long Names
2015-07-10 22:58:08 +02:00
Tim van der Meij
5af49f8bbb Merge pull request #6166 from Snuffleupagus/issue-5801-2
Add a supplemental glyph map for non-embedded ArialBlack fonts (issue 5801)
2015-07-10 22:29:50 +02:00
Tim van der Meij
c9b6b690ec Merge pull request #6192 from Snuffleupagus/viewer-resize-update-scale
Refactor the 'resize' event handler in viewer.js (issue 6158)
2015-07-10 21:43:06 +02:00
Rob Wu
456ad438d8 Issue a warning instead of an error for long Names
The PDF specification (cited below) specifies a maximum length of a name
in bytes as a minimal architectural limit. This means that PDF *writers*
should not create names that exceed 127 bytes.

It does not forbid PDF *readers* to accept such names though. These
names are only used internally to link PDF objects to other objects. For
these use cases, the lengths of the names do not really matter. Hence I
have changed the implementation to not treat long names as errors, but
warnings.

> (7.3.5) The length of a name shall be subject to an implementation
> limit; see Annex C.
>
> (Annex C.2) Table C.1 describes the minimum architectural limits that
> should be accommodated by conforming readers running on 32-bit
> machines. Because conforming readers may be subject to these limits,
> conforming writers producing PDF files should remain within them.
>
> (Table C.1) name 127 "Maximum length of a name, in bytes."

http://adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
2015-07-10 16:10:24 +02:00
Jonas Jenwald
35ee1e1b0a Refactor the 'resize' event handler in viewer.js (issue 6158)
*This is the next step towards fixing 6158.*

This patch removes the dependency on the state of the scale `<select>` dropdown from the `resize` event handler, and instead uses the (in `PDFViewer`) stored `currentScaleValue`.
I believe that the way this code is currently written is purely for historical reasons, since originally *only* the numerical scale was stored internally (hence there was no other way to access the scale value).
However, since we now store the scale value, we should use it instead of quering the DOM. This helps ensure that the internally stored scale value is always accurately displayed in the UI (which should be good since, after the creation of `PDFViewer`, the `<select>` DOM element is now updated by an event handler).
2015-07-10 11:50:54 +02:00
Tim van der Meij
ccfafea20b Merge pull request #6182 from Snuffleupagus/remove-PDFViewerApplication-get-currentScaleValue
Remove the `currentScaleValue` getter from `PDFViewerApplication` (issue 6158)
2015-07-09 15:48:08 +02:00
Tim van der Meij
ba38454865 Merge pull request #5460 from Snuffleupagus/limit-internal-scale-values-precision
Prevent re-rendering of pages because of rounding errors when computing the scale value
2015-07-09 14:19:58 +02:00
Jonas Jenwald
7df78f997e Slightly more efficient getDestination
For named destinations that are contained in a `Dict`, as opposed to a `NameTree`, we currently iterate through the *entire* dictionary just to fetch *one* destination.
This code appears to simply have been copy-pasted from the `get destinations` method, but in its current form it's quite unnecessary/inefficient since can just get the required destination directly instead.
2015-07-08 18:31:51 +02:00
Jonas Jenwald
940bedf75f Add a unit-test that attempts to fetch a non-existent named destination
Doing this helped uncover an issue with the `getDestination` implementation.
Currently if a named destination doesn't exist, the method (in `obj.js`) may return `undefined` which leads to the promise being stuck in a pending state.
*Note:* returning `null` for this case is consistent with other methods, e.g. `getOutline` and `getAttachments`.
2015-07-07 22:05:08 +02:00
Jonas Jenwald
1c0115a7e4 Remove the currentScaleValue getter from PDFViewerApplication (issue 6158)
*The next step towards fixing issue 6158.*

We can just as well access `pdfViewer.currentScaleValue` directly in `PDFViewerApplication`, instead of having a helper function which just acts as a wrapper for it.
2015-07-07 09:17:05 +02:00
Yury Delendik
eb2ad11571 Merge pull request #5918 from Snuffleupagus/remove-fallback-cpow
[Firefox] Replace the CPOW with asynchronous messages for the Fallback bar
2015-07-06 21:31:48 -05:00
Tim van der Meij
31976b9b44 Merge pull request #6181 from Rob--W/test-downloadOnly
Add --downloadOnly flag to test.js
2015-07-06 23:30:01 +02:00
Yury Delendik
8e59528e60 Merge pull request #6175 from Rob--W/font-loading-promises
fontLoadPromises -> fontsToLoad
2015-07-06 16:00:47 -05:00
Jonas Jenwald
e5b7258586 Merge pull request #6180 from timvandermeij/border-regression
Do not draw a border if neither a Border nor a BS entry is present
2015-07-06 18:04:57 +02:00
Jonas Jenwald
5aaf18db12 Merge pull request #6169 from yurydelendik/rm-playpreview
Bug 1179262 - Remove PlayPreview registration from PDF Viewer.
2015-07-06 17:32:29 +02:00
Rob Wu
f9dd7318f7 fontLoadPromises -> fontsToLoad
fontsToLoad is always an empty array, Promise.all should wait for
fontLoadPromises instead of fontsToLoad.
2015-07-06 17:31:42 +02:00