Commit Graph

11076 Commits

Author SHA1 Message Date
Jonas Jenwald
6c4157acd9 Attempt to support plural forms in the matches counter of the findbar (issue 10067)
Based on a quick look at https://github.com/fabi1cazenave/webL10n/#pluralization, it seems that supporting plural forms shouldn't be as difficult as I first thought it might be.
2018-09-13 13:50:51 +02:00
Brendan Dahl
6adeabbb66 Add Glyph & Cog's XPDF copyright/license information. 2018-09-12 13:59:56 -07:00
Tim van der Meij
29683d40a5
Merge pull request #10063 from Snuffleupagus/JPEG-isSourcePDF-assert
Slightly improve the `isSourcePDF` parameter handling in `JpegImage` (PR 10031 follow-up)
2018-09-12 14:56:42 +02:00
Jonas Jenwald
5181172498 Slightly improve the isSourcePDF parameter handling in JpegImage (PR 10031 follow-up)
Currently there's only a single spot in the code-base where `JpegImage.getData` is called, however it nonetheless seem like a good idea to ensure during tests that the `isSourcePDF` parameter is correctly set. (Especially considering that the PDF use-cases will break without it.)

Additionally, in `JpegImage._getLinearizedBlockData`, the code can be made a tiny bit more efficient by checking the value of `isSourcePDF` *first* to avoid useless checks (for the default PDF use-cases).
2018-09-12 11:30:59 +02:00
Tim van der Meij
9c764da8af
Merge pull request #10061 from timvandermeij/unit-testing
Implement unit tests for the `isSameOrigin` and `createValidAbsoluteUrl` utility functions and use the `const` keyword for constants in `src/shared/util.js`
2018-09-11 16:31:02 +02:00
Tim van der Meij
bf13c8a50b
Use the const keyword for constants in src/shared/util.js
Moreover, move general constants to the top of the file, i.e., those
that are not closely tied to a function in the file.
2018-09-11 16:17:45 +02:00
Tim van der Meij
99de25d6cc
Implement unit tests for the isSameOrigin and createValidAbsoluteUrl utility functions
Moreover, mark the `isValidProtocol` function as private since it's only
used in the utilities file and is not (meant to be) exported.
2018-09-11 16:17:45 +02:00
Tim van der Meij
a789368b7a
Merge pull request #10060 from Snuffleupagus/matchesCount-invalid
Ensure that `PDFFindController._requestMatchesCount` won't return broken data when searching starts (PR 10052 follow-up)
2018-09-11 15:40:41 +02:00
Jonas Jenwald
0a4c326650 Ensure that PDFFindController._requestMatchesCount won't return broken data when searching starts (PR 10052 follow-up)
This is an unfortunate oversight on my part, which I stumbled upon when (locally) testing the `mozilla-central` follow-up patch necessary to enable the matches counter in the built-in PDF viewer.
2018-09-11 14:38:02 +02:00
Tim van der Meij
bf368f3a32
Merge pull request #10056 from Snuffleupagus/matchesCount-viewer-close
[Regression] Ensure that `PDFFindBar.updateResultsCount` doesn't throw when the viewer is closed, by providing proper default values
2018-09-11 00:27:55 +02:00
Jonas Jenwald
11c8e33ed1 [Regression] Ensure that PDFFindBar.updateResultsCount doesn't throw when the viewer is closed, by providing proper default values
The error can be reproduced by opening any file in the viewer, and then running `PDFViewerApplication.close()` in the console.
2018-09-10 16:02:44 +02:00
Tim van der Meij
bc5111d152
Merge pull request #10028 from Snuffleupagus/entireWord
Add initial support for "Whole words" searching in the viewer
2018-09-10 13:01:24 +02:00
Jonas Jenwald
b4edcce296 Remove unused findStatusIcon property from PDFFindBar instances
The property is intended to contain a reference to a DOM element, which not only is nowhere to be found *now* but appears to never have existed in the first place.
2018-09-10 11:59:30 +02:00
Jonas Jenwald
6d804d657f Add initial support for "Whole words" searching in the viewer
As outlined in https://bugzilla.mozilla.org/show_bug.cgi?id=1282759 the internal Firefox name for the feature is `entireWord`, hence that name is used here as well for consistency (with "Whole words" being limited to the UI).

Given existing limitations of the PDF.js search functionality, e.g. the existing problems of searching across "new lines", there's some edge-cases where "Whole words" searching will ignore (valid) results.
However, considering that this is a pre-existing issue related to the way that the find controller joins text-content together, that shouldn't have to block this new feature in my opionion.

*Please note:* In order to enable this feature in the `MOZCENTRAL` version, a small follow-up patch for [PdfjsChromeUtils.jsm](https://hg.mozilla.org/mozilla-central/file/tip/browser/extensions/pdfjs/content/PdfjsChromeUtils.jsm) will be required once this has landed in `mozilla-central`.
2018-09-10 11:59:29 +02:00
Tim van der Meij
53c37d3b45
Merge pull request #10055 from timvandermeij/translation
Translate the new find match count strings to Dutch
2018-09-09 20:29:41 +02:00
Tim van der Meij
04dfbb91fb
Translate the new find match count strings to Dutch 2018-09-09 20:23:07 +02:00
Tim van der Meij
38baaea8f4
Merge pull request #10052 from Snuffleupagus/matchesCount
Display the index of the currently active search result in the matches counter of the findbar (issue 6993, bug 1062025)
2018-09-09 19:56:03 +02:00
Tim van der Meij
3cf4866c99
Merge pull request #10054 from timvandermeij/updates
Update translations/packages and use HTTPS for links in `README.md`
2018-09-09 18:04:45 +02:00
Tim van der Meij
6d85c7e41a
Use HTTPS for links in README.md 2018-09-09 17:57:12 +02:00
Tim van der Meij
4471353b97
Update packages 2018-09-09 17:54:24 +02:00
Tim van der Meij
97aaf06fde
Update translations 2018-09-09 17:48:43 +02:00
Tim van der Meij
9a115b41de
Merge pull request #10034 from timvandermeij/canvas-workaround
Remove `getSinglePixelWidth` workaround
2018-09-09 17:36:04 +02:00
Tim van der Meij
c751757470
Merge pull request #10053 from Snuffleupagus/spaced-comment
Simplify the "spaced-comment" ESLint rule
2018-09-09 16:09:54 +02:00
Jonas Jenwald
6481fc0de5 Simplify the "spaced-comment" ESLint rule
With the Firefox addon removed from the GitHub repository, there's no longer any JavaScript code utilizing the old preprocessor.
2018-09-09 11:58:32 +02:00
Jonas Jenwald
c9a2564882 Display the index of the currently active search result in the matches counter of the findbar (issue 6993, bug 1062025)
For the `PDFFindBar` implementation, similar to the native Firefox findbar, the matches count displayed is now limited to a (hopefully) reasonable value.

*Please note:* In order to enable this feature in the `MOZCENTRAL` version, a follow-up patch will be required once this has landed in `mozilla-central`.
2018-09-08 21:50:22 +02:00
Tim van der Meij
510f1c84d2
Merge pull request #9995 from Snuffleupagus/async-web
Refactor code in the `web/` folder to use `async`/`await`
2018-09-08 21:40:20 +02:00
Tim van der Meij
66422eb83e
Merge pull request #9340 from brendandahl/private-use
Map all glyphs to the private use area and duplicate the first glyph.
2018-09-08 17:51:04 +02:00
Tim van der Meij
1fe35b9ca1
Merge pull request #10049 from morille/patch-1
Fix font-string variable name typo
2018-09-07 23:48:48 +02:00
Romain Petit
8671081001
Fix font-string variable name typo
The font-string rebuild condition is always satisfied because the concerned variables are never set.
2018-09-07 09:55:45 +02:00
Tim van der Meij
d692737670
Merge pull request #10041 from Snuffleupagus/revert-9986-issue-9984
Revert "Attempt to combine separate beginText/endText sequences in `getTextContent` (issue 9984)"
2018-09-06 00:42:10 +02:00
Brendan Dahl
b76cf665ec Map all glyphs to the private use area and duplicate the first glyph.
There have been lots of problems with trying to map glyphs to their unicode
values. It's more reliable to just use the private use areas so the browser's
font renderer doesn't mess with the glyphs.

Using the private use area for all glyphs did highlight other issues that this
patch also had to fix:

  * small private use area - Previously, only the BMP private use area was used
    which can't map many glyphs. Now, the (much bigger) PUP 16 area can also be
    used.

  * glyph zero not shown - Browsers will not use the glyph from a font if it is
    glyph id = 0. This issue was less prevalent when we mapped to unicode values
    since the fallback font would be used. However, when using the private use
    area, the glyph would not be drawn at all. This is illustrated in one of the
    current test cases (issue #8234) where there's an "ä" glyph at position
    zero. The PDF looked like it rendered correctly, but it was actually not
    using the glyph from the font. To properly show the first glyph it is always
    duplicated and appended to the glyphs and the maps are adjusted.

  * supplementary characters - The private use area PUP 16 is 4 bytes, so
    String.fromCodePoint must be used where we previously used
    String.fromCharCode. This is actually an issue that should have been fixed
    regardless of this patch.

  * charset - Freetype fails to load fonts when the charset size doesn't match
    number of glyphs in the font. We now write out a fake charset with the
    correct length. This also brought up the issue that glyphs with seac/endchar
    should only ever write a standard charset, but we now write a custom one.
    To get around this the seac analysis is permanently enabled so those glyphs
    are instead always drawn as two glyphs.
2018-09-05 14:04:54 -07:00
Jonas Jenwald
e5a6d892b4
Revert "Attempt to combine separate beginText/endText sequences in getTextContent (issue 9984)" 2018-09-05 18:01:33 +02:00
Jonas Jenwald
1bdfdd07b8 Utilize async/await in PDFViewerApplication.load to reduce the number of Promises and temporary variables necessary when setting the initial document location 2018-09-03 09:52:36 +02:00
Jonas Jenwald
3eba7ea267 Refactor a number of methods in PDFViewerApplication to be async rather than manually returning Promises
*Ignoring whitespace changes is probably necessary, in order for the diff to be readable.*
2018-09-03 09:52:36 +02:00
Jonas Jenwald
a60963f882 Refactor the ViewHistory to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
Jonas Jenwald
233b3274bf Refactor the Preferences classes to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
Jonas Jenwald
64e70fc16f Refactor the OverlayManager to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
Jonas Jenwald
b0fa02e845 Refactor the IL10n implementations to utilize async methods rather than manually returning Promises
This changes the methods signatures of `GenericL10n`, `MozL10n`, and `NullL10n`.
2018-09-03 09:52:36 +02:00
Tim van der Meij
af89ec271d
Merge pull request #10033 from timvandermeij/permissions-api
[api-minor] Implement a permissions API
2018-09-02 21:38:29 +02:00
Tim van der Meij
e812c6e7ac
Use shorter code for failing a test in test/unit/api_spec.js 2018-09-02 21:23:09 +02:00
Tim van der Meij
959ed3705b
Implement a permissions API 2018-09-02 21:23:09 +02:00
Tim van der Meij
4874e9ace0
Convert the WorkerTransport class, in src/display/api.js, to ES6 syntax 2018-09-02 21:06:57 +02:00
Tim van der Meij
9c37599fd3
Convert the PDFDocumentProxy class, in src/display/api.js, to ES6 syntax
Moreover, indicate that a member are private and improve the comments to
be more consistent.
2018-09-02 21:06:57 +02:00
Tim van der Meij
1a3e842dc4
Remove getSinglePixelWidth workaround
It's no longer necessary since https://bugzilla.mozilla.org/show_bug.cgi?id=1305963 is fixed quite some time ago.

While we're here, mark the `cachedGetSinglePixelWidth` member as being
private and use ES6 syntax in the `getSinglePixelWidth` method.
2018-09-02 20:36:06 +02:00
Tim van der Meij
d409c42068
Merge pull request #10031 from Snuffleupagus/JPEG-CMYK-invert
Add a new parameter to `JpegImage.getData` to indicate the source of the image data (issue 9513)
2018-09-02 15:15:26 +02:00
Tim van der Meij
a096e0c647
Merge pull request #10032 from timvandermeij/test-link
Replace broken link for `pr8808.pdf.link`
2018-09-02 14:52:21 +02:00
Tim van der Meij
b62f14f3f5
Replace broken link for pr8808.pdf.link
The current link had an invalid certificate and was a redirect to this
new link anyway. The MD5 hash is equal.
2018-09-02 14:48:26 +02:00
Jonas Jenwald
663922f93f Add a new parameter to JpegImage.getData to indicate the source of the image data (issue 9513)
The purpose of this patch is to provide a better default behaviour when `JpegImage` is used to parse standalone JPEG images with CMYK colour spaces.
Since the issue that the patch concerns is somewhat of a special-case, the implementation utilizes the already existing decode support in an attempt to minimize the impact w.r.t. code size.

*Please note:* It's always possible for the user of `JpegImage` to control image inversion, and thus override the new behaviour, by simply passing a custom `decodeTransform` array upon initialization.
2018-09-02 14:15:22 +02:00
Jonas Jenwald
47bf12cbac Change JpegImage._isColorConversionNeeded into a getter, rather than a regular function
Given how `_isColorConversionNeeded` is used, and that it always returns a boolean value, having it be a getter seems more appropriate.
2018-09-02 13:06:28 +02:00
Tim van der Meij
c94df0fef3
Merge pull request #9986 from Snuffleupagus/issue-9984
Attempt to combine separate beginText/endText sequences in `getTextContent` (issue 9984)
2018-09-01 21:21:29 +02:00