Permalink
Commits on Sep 28, 2016
Commits on Sep 26, 2016
  1. Respect the 'ColorTransform' entry in the image dictionary when decod…

    …ing JPEG images (bug 956965, issue 6574)
    
    Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=956965.
    Fixes 6574.
    Snuffleupagus committed Sep 22, 2016
Commits on Sep 22, 2016
  1. Merge pull request #7649 from timvandermeij/interactive-forms-tx-comb

    Text widget annotations: implement comb support
    Snuffleupagus committed on GitHub Sep 22, 2016
Commits on Sep 21, 2016
  1. Prevent errors if the 'resize' event is fired before the `eventBus` h…

    …as been initialized
    
    When opening a PDF file that triggers the browser fallback bar in the Firefox addon/built-in version, e.g. http://web.archive.org/web/20110918100215/http://www.irs.gov/pub/irs-pdf/f1040.pdf (with forms *disabled*), and then reloading the document an error can be thrown.
    The reason is that displaying the fallback bar triggers 'resize' events, and they can arrive *before* the viewer has had a chance to run all the necessary initialization code.
    Snuffleupagus committed Sep 21, 2016
  2. When rendering forms, don't use `element.value` since it prevents the…

    … AnnotationLayer rasterizer (in `test/driver.js`) from parsing the elements correctly
    
    Without this, the reference test images will have empty fields despite the viewer working as intended.
    Snuffleupagus committed Sep 21, 2016
  3. Ensure that `test/driver.js` actually takes the same `Annotation` cod…

    …e-path as the viewer when running `forms` tests (PR 7633 follow-up)
    
    Unfortunately PR 7633 missed, and I didn't catch it during review, to update `test/driver.js` such that the `forms` tests takes the correct code-path.
    This resultet in the `forms` reference test images looking better than they should, and more problematicly differing from the rendering in the viewer.
    
    With this patch, the tests now correctly skip over any `Appearance` streams.
    The `forms` tests now highlights quite clearly (e.g. look at `annotation-tx2.pdf`/`annotation-tx3.pdf`) that we cannot just skip the `Appearance` streams when rendering forms. Hence we're going to have to find a way to fix that *before* enabling forms by default, since both display *and* print would look completely wrong otherwise.
    Finally, this patch also uncovers one more existing bug that still needs to be fixed, since the current `rasterizeAnnotationLayer` in `test/driver.js` isn't able to handle the contents of e.g. `<input>` and `<textarea>`.
    Snuffleupagus committed Sep 18, 2016
  4. Pass in the `renderInteractiveForms` parameter to `Annotation_appendT…

    …oOperatorList`, in `Page_getOperatorList`, instead of to the `Annotation` constructor (PR 7633 follow-up)
    
    When debugging issue 7643, I noticed that the `forms` tests currently doesn't look like the rendering in the viewer (with `renderInteractiveForms = true` set).
    After scratching my head for a little while, I realized that PR 7633 make the implicit assumption that `Page_getOperatorList` (in `core/document.js`) is called *before* fetching the annotation with `PDFPageProxy_getAnnotations` (in `display/api.js`).
    
    Hence this patch, that changes it so that we instead pass in the `renderInteractiveForms` parameter to `Annotation_appendToOperatorList` to ensure that it's always correctly set.
    Snuffleupagus committed Sep 18, 2016
Commits on Sep 20, 2016
  1. Update l10n files

    Snuffleupagus committed Sep 20, 2016
Commits on Sep 18, 2016
Commits on Sep 17, 2016
Commits on Sep 16, 2016
  1. Merge pull request #7550 from Snuffleupagus/Type1-toUnicode-builtInEn…

    …coding-fallback
    
    For embedded Type1 fonts without included `ToUnicode`/`Encoding` data, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
    Snuffleupagus committed on GitHub Sep 16, 2016
Commits on Sep 15, 2016
  1. Remove the deprecated `mozDash`/`mozDashOffset` canvas 2D context met…

    …hods
    
    According to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility) the standard versions of these methods have been supported since Firefox 27, which was released over two and a half years ago. (See the dates in https://wiki.mozilla.org/RapidRelease/Calendar#Past_branch_dates)
    
    Furthermore the non-standard properties are now in the process of being removed, please see https://groups.google.com/forum/#!topic/mozilla.dev.platform/UIudMABegcY.
    Hence I don't think that we need to keep the old `moz` prefixed ones as fallback any more.
    Snuffleupagus committed Sep 15, 2016
Commits on Sep 14, 2016
  1. [EnhanceTextSelection] Make `expandTextDivs` more efficient by updati…

    …ng all styles at once instead of piecewise
    
    I intended to provide proper benchmarking results here, as outlined in https://github.com/mozilla/pdf.js/wiki/Benchmarking-your-changes, but after wasting a couple of hours over the weekend getting weird results I gave up.
    It appears that there's a lot of, i.e. way too much, variance between subsequent runs of `text` tests for the results to be meaningful.
    (Previously I've only benchmarked `eq` tests, so I don't know if the `text` tests has never worked well or if it's a newer problem. For reference, please see the results of back-to-back benchmark runs on the current `master` with a *very* simple manifest file: [link here].)
    
    Instead I used `console.time/timeEnd` in `appendText` and `expandTextDivs` to be able to compare the performance with/without the patch. The entire viewer was (skip-cache) reloaded between measurements, and the result are available here: [link here].
    Given the troubles I've had with benchmarking, I've not yet computed any statistics on the results (e.g. mean, variance, confidence intervals, and so on).
    However, just by looking at the data I think it's safe to say that this patch first of all doesn't seem to regress the current performance. Secondly it certainly looks *very* likely that this patch actually improves the performance, especially for the one-glyph-per-text-div case (cf. issue 7224).
    
    Re: issue 7584.
    Snuffleupagus committed Sep 13, 2016
Commits on Sep 13, 2016
  1. Merge pull request #7629 from timvandermeij/interactive-form-unit-tests

    Text widget annotations: implement unit testing and sanitize data values
    Snuffleupagus committed on GitHub Sep 13, 2016
Commits on Sep 12, 2016
  1. Merge pull request #7624 from Snuffleupagus/yury-fake-cloning

    Adding "proper" message port for fake worker.
    Snuffleupagus committed on GitHub Sep 12, 2016
  2. Change `src/core/jpx.js` to use the `error` utility function instead …

    …of using `throw new Error`
    
    Note that in `parseCodestream` I purposly left the `throw new Error` instances inside of the `try` block, since we don't want to throw any `Errors` while in recovery mode.
    Finally somewhat unrelated to the rest of the patch, but I moved the `doNotRecover` variable declaration outside of the `try` block to avoid variable hoisting given that it's accessed inside the `catch` block.
    Snuffleupagus committed Sep 4, 2016
Commits on Sep 11, 2016
  1. For embedded Type1 fonts without included `ToUnicode`/`Encoding` data…

    …, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
    
    Note that in order to prevent any possible issues, this patch does *not* try to amend the `toUnicode` data for Type1 fonts that contain either `ToUnicode` or `Encoding` entries in the font dictionary.
    
    Fixes, or at least improves, issues/bugs such as e.g. 6658, 6901, 7182, 7217, bug 917796, bug 1242142.
    Snuffleupagus committed Aug 17, 2016
  2. Add a couple more, mostly `text`, reference tests for non-embedded sy…

    …mbolic fonts without included encoding information
    
    I've started to look into how we can fix issue 7580, but quickly became worried that fixing it could easily mean that we'd trade one fixed PDF file for a multitude of broken ones.
    
    Hence I started going through the history of the code that choose the fallback encoding, and noticed that it has been changed a number of times over the years to deal with various cases of weirdness/errors in non-embedded fonts.
    To my relief it turned out that almost all the PRs, please see a possibly incomplete [list here], that changed this code actually included `eq` test-cases.
    
    However, in one case it appears that a PR missed to add a test-case. Furthermore since the fallback encoding may also be the only source for creating a `toUnicode` map, changing the encoding could possibly regress only the text-selection despite a PDF file still rendering correctly.
    Therefore, this PR adds one new `eq` test, and also a number of additional `text` tests for PDF files already present in the test-suite.
    
    Note that it's obviously possible that there's a certain overlap between the added tests, but I'd be *a whole lot* more concerned with causing regressions.
    Snuffleupagus committed Sep 10, 2016
  3. Merge pull request #7546 from Snuffleupagus/issue-7544

    Don't duplicate the first entry in the `charCodeToGlyphId` map for CIDFontType2 fonts with a `CIDToGIDMap` that already mapped the first entry to a non-zero `glyphId` (issue 7544)
    Snuffleupagus committed on GitHub Sep 11, 2016
Commits on Sep 9, 2016
  1. Don't duplicate the first entry in the `charCodeToGlyphId` map for CI…

    …DFontType2 fonts with a `CIDToGIDMap` that already mapped the first entry to a non-zero `glyphId` (issue 7544)
    
    Fixes 7544.
    Snuffleupagus committed Aug 16, 2016
  2. Ensure that we provide the `source` parameter when dispatching the bu…

    …tton click events in `SecondaryToolbar` (PR 7313 follow-up)
    Snuffleupagus committed Sep 8, 2016
  3. Only update the `max-height` of the `SecondaryToolbar` when it's actu…

    …ally visible
    
    There's really no good reason to attempt to adjust the `max-height` of the `SecondaryToolbar` when it's not visible, so let's not do that anymore.
    Also, we can listen for the `resize` event in `SecondaryToolbar`, to avoid having to manually call the `max-height` adjust function from various event handlers in `app.js`. Please note that by always adjusting the `max-height` when the toolbar is opened we no longer need the `localized` event, since it was mainly used to set a correct inital `max-height` value.
    Snuffleupagus committed Sep 8, 2016
Commits on Sep 8, 2016
  1. Add a `enhanceTextSelection` preference

    Please note that this is a hack, but I think that it should be OK for now to atleast get the preference landed. Refer to the code comment for further information.
    
    Re: issue 7584 and PR 7586.
    Snuffleupagus committed Sep 7, 2016
  2. Merge pull request #7602 from timvandermeij/interactive-forms

    Render interactive form (AcroForm) text widget annotations
    Snuffleupagus committed on GitHub Sep 8, 2016
Commits on Sep 6, 2016
  1. Merge pull request #7596 from timvandermeij/widget-annotation-cleanup

    Improve the structure for widget annotations
    Snuffleupagus committed on GitHub Sep 6, 2016
  2. Check that Type1C fonts does not actually contain OpenType font files…

    … (issue 7598)
    
    This patch is yet another instalment in the (never ending) series of patches for PDF files that specify completely incorrect Type/Subtype for its fonts. In this case Type1/Type1C, when in fact OpenType would have been correct.
    
    Fixes 7598.
    Snuffleupagus committed Sep 6, 2016
Commits on Sep 5, 2016
  1. In `display/api.js` ensure that we always reject with an `Error` in `…

    …JpegDecode`, and adjust a couple of other rejection sites as well
    
    In the case where the document was destroyed, we were rejecting the `Promise` in `JpegDecode` with a string instead of an `Error`. The patch also brings the wording more inline with other such rejections.
    
    Use the `isInt` utility function when validating the `pageNumber` parameter in `WorkerTransport_getPage`, to make it more obvious what's actually happening. There's also a couple more unit-tests added, to ensure that we always fail in the expected way.
    
    Finally, we can simplify the rejection handling in `WorkerTransport_getPageIndexByRef` somewhat. (Note that the only reason for using `catch` here is that since the promise is rejected on the worker side, the `reason` becomes a string instead of an `Error` which is why we "re-reject" on the display side.)
    Snuffleupagus committed Sep 5, 2016
Commits on Sep 4, 2016
  1. Merge pull request #7588 from timvandermeij/text-layer-weakmap

    Use a `WeakMap` in `src/display/text_layer.js`
    Snuffleupagus committed on GitHub Sep 4, 2016
  2. Change `src/core/jpg.js` to use the `error` utility function instead …

    …of `throw`ing
    
    This allows us to remove the `try/catch` statements used in `src/core/stream.js` when parsing JPEG images.
    As far as I can tell, the only reason for the current usage of plain `throw` is that `jpg.js` originally was external code. Given that this code now lives in our repo, this patch brings the JPEG code more in line with e.g. `src/core/jpx.js` and `src/core/jbig2.js`.
    Snuffleupagus committed Sep 3, 2016
Commits on Sep 2, 2016
  1. Move the `Preferences` initialization/fetching code to the top of `PD…

    …FViewerApplication.initialize`, to enable using them when initializing the viewer components
    Snuffleupagus committed Sep 2, 2016
Commits on Sep 1, 2016
  1. Change the `GoToPage` Named Action to select the contents of the `pag…

    …eNumber` input, rather than just focusing the element
    
    When clicking on the `pageNumber` input, or when using the keyboard shortcut <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>G</kbd>, the element isn't just focused but its contents is actually *selected* so that the user doesn't need to clear the input before entering a new `pageNumber`.
    However, the `GoToPage` named action is only using `focus`, so let's change this to be consistent.
    
    The following document can be used for testing: http://www2.informatik.uni-freiburg.de/~frank/ENG/beamer/example/Beamer-class-example1.pdf#zoom=page-fit
    
    [screeenshot]
    Snuffleupagus committed Sep 1, 2016
Commits on Aug 31, 2016
  1. Add a reduced test-case for issue 7406

    The PDF file contains an image that we're allowed to use, since it's just the PDF.js logo.
    The logo image was simply inverted (so that it requires a /Decode entry in the image dictionary that triggers the use of `jpg.js` instead of the browser), converted to JPEG, and finally edited by hand to change the order of the DQT/SOF{n} markers.
    Snuffleupagus committed Jul 23, 2016
  2. Assign the `quantizationTables` after parsing the entire JPEG image, …

    …to prevent issues when the DQT (Define Quantization Tables) marker is encountered after SOF{n} (Start of Frame) markers (issue 7406)
    
    This is a tentative patch that fixes 7406.
    Snuffleupagus committed Jun 13, 2016
  3. Ensure that the zoom buttons are disabled correctly if the `scale` is…

    … smaller/larger than `MIN_SCALE/MAX_SCALE` in `PDFViewerApplication._updateUIToolbar`
    
    In the `zoom{In, Out}` functions in `PDFViewerApplication`, we prevent the zoom value from becoming smaller/larger than `MIN_SCALE/MAX_SCALE`.
    However, if the user sets the zoom level through the hash parameter the zoom buttons might not be correctly disabled; try http://mozilla.github.io/pdf.js/web/viewer.html#zoom=10.
    
    Note that this issue has been present since "forever", but given that the solution is so simple I think that we should just fix this. (I'm also fixing a stupid typo I previously made in the JSDoc comment.)
    Snuffleupagus committed Aug 31, 2016