Commit Graph

16146 Commits

Author SHA1 Message Date
Jonas Jenwald
0024165f1f Move binarySearchFirstItem back to the web/-folder (PR 15237 follow-up)
This was moved into the `src/display/`-folder in PR 15110, for the initial editor-a11y patch. However, with the changes in PR 15237 we're again only using `binarySearchFirstItem` in the `web/`-folder and it thus seem reasonable to move it back there.
The primary reason for moving it back is that `binarySearchFirstItem` is currently exposed in the public API, and we always want to avoid that unless it's either PDF-related functionality or code that simply must be shared between the `src/`- and `web/`-folders. In this case, `binarySearchFirstItem` is a general helper function that doesn't really satisfy either of those alternatives.
2022-08-14 11:38:17 +02:00
Jonas Jenwald
2b66ed5fef
Merge pull request #15311 from Snuffleupagus/text-a11y-removed-element
Don't add `aria-owns` attributes for non-existent elements (PR 15237 follow-up)
2022-08-14 09:31:29 +02:00
Jonas Jenwald
6c4561f3d8 Don't add aria-owns attributes for non-existent elements (PR 15237 follow-up)
Currently when the `TextAccessibilityManager.enabled` method is called, we'll update `aria-owns` for any pre-existing elements. This obviously makes sense when e.g. zooming/rotating in the viewer, since the annotationLayer/annotationEditorLayer is kept in those cases.
However when the page is *fully* reset, e.g. as result of going out-of-view and thus being evicted from the cache, we still keep the `#textNodes`-Map around. This causes us to set the `aria-owns` attribute (in the textLayer) for an element that doesn't actually exist any more, which as far as I'm concerned seems incorrect. In this case the element will simply, as already implemented, be re-inserted when the annotationLayer/annotationEditorLayer renders again.
2022-08-13 21:52:38 +02:00
Jonas Jenwald
e5e756c0b4 Remove the remaining closures in the src/core/cff_parser.js file
Given that the code is written with JavaScript module-syntax, none of this functionality will "leak" outside of this file with these changes.
For e.g. the `gulp mozcentral` command the *built* `pdf.worker.js` file-size decreases `~2 kB` with this patch, and most of the improvement comes from having less overall indentation in the code.
2022-08-13 19:48:17 +02:00
Tim van der Meij
b040d64a3c
Merge pull request #15300 from Snuffleupagus/viewer-export-constants
[GENERIC viewer] Export some viewer constants in the default viewer (issue 15294)
2022-08-13 15:25:29 +02:00
Tim van der Meij
f212341d01
Merge pull request #15306 from Snuffleupagus/Type3-only-Path2D
Only compile Type3 glyphs when `Path2D` is supported
2022-08-13 15:23:11 +02:00
Tim van der Meij
c81903d72d
Merge pull request #15309 from Snuffleupagus/function-rm-closure
Remove the remaining closure in the `src/core/function.js` file
2022-08-13 15:05:17 +02:00
Jonas Jenwald
9dcfdb9578 Remove the remaining closure in the src/core/function.js file
Given that the code is written with JavaScript module-syntax, none of this functionality will "leak" outside of this file with these changes.
By removing this closure the file-size is decreased, even for the *built* `pdf.worker.js` file, since there's now less overall indentation in the code.
2022-08-13 12:52:36 +02:00
calixteman
3cf31a8b17
Merge pull request #15307 from calixteman/role_comment
[Annotation] Add an aria role comment for FreeText annotations
2022-08-12 16:22:37 +02:00
Calixte Denizet
2916910ea1 [Annotation] Add an aria role comment for FreeText annotations 2022-08-12 15:59:21 +02:00
calixteman
6b4c2464ad
Merge pull request #15237 from calixteman/annotation_a11y
[Annotations] Add some aria-owns in the text layer to link to annotations (bug 1780375)
2022-08-12 15:04:56 +02:00
Calixte Denizet
f316300113 [Annotations] Add some aria-owns in the text layer to link to annotations (bug 1780375)
This patch doesn't structurally change the text layer: it just adds some aria-owns
attributes to some spans.
The aria-owns attribute expect to have an element id, hence it's why it adds back an
id on the element rendering an annotation, but this id is built in using crypto.randomUUID
to avoid any potential issues with the hash in the url.
The elements in the annotation layer are moved into the DOM in order to have them in the
same "order" as they visually are.
The overall goal is to help screen readers to present to the user the annotations as
they visually are and as they come in the text flow.
It is clearly not perfect, but it should improve readability for some people with visual
disabilities.
2022-08-12 14:35:26 +02:00
Jonas Jenwald
e9e9fee833 Only compile Type3 glyphs when Path2D is supported
According to MDN `Path2D` is available in all browsers that we currently support, see https://developer.mozilla.org/en-US/docs/Web/API/Path2D#browser_compatibility
Hence only Node.js is currently lagging behind here, and requires that we keep the old code as a fallback in the `compileType3Glyph` function. However, there's an open PR in the `node-canvas` repository for adding `Path2D` support.

As far as I'm concerned, there's two possible solutions here:
 - We land this patch now, since it removes unnecessary code in e.g. the Firefox PDF Viewer, which means that compilation of Type3 glyphs will be disabled in Node.js until that PR is landed.[1]
   If users report bugs about Type3 glyphs looking "inconsistent" in Node.js and/or being slow to render, we could perhaps encourage them to upvote and otherwise help out getting that PR landed?

 - We wait for the mentioned PR to land *first*, before moving forward with this patch. Given that there's been no updates on that PR for almost two months, this alternative may possibly take a while.

---
[1] Note that Type3 fonts are first of all not very common in PDF documents, and secondly that compilation only applies specifically to Type3 glyphs that contain /ImageMask-data (i.e. not all Type3 fonts are affected).
2022-08-12 13:06:42 +02:00
Jonas Jenwald
b8bb1d67d4 [GENERIC viewer] Export some viewer constants in the default viewer (issue 15294)
This exports the same constants as the viewer components, but in the default viewer. To avoid bloating the global-scope the constants are added to a new `PDFViewerApplicationConstants` object[1], which also allows us to skip this in builds where it's not actually needed (e.g. the Firefox *built-in* PDF Viewer).

*Please note:* I'm not completely sold on this idea, and thus wouldn't mind the patch being rejected, since we probably don't want to export every single viewer constant this way. (And it may seem a bit arbitrary, to users, why some constants are exported and others are not.)

---
[1] Somewhat similar to the existing `PDFViewerApplicationOptions` structure.
2022-08-11 16:22:12 +02:00
Jonas Jenwald
69462e5e14 Export additional constants in the viewer components
In addition to the existing `LinkTarget` constant, used by the `PDFLinkService`-constructor, this patch exports the following constants in the viewer components:
 - `ScrollMode` and `SpreadMode`, since the `BaseViewer` has getters/setters which work with those constants.
 - `RenderingStates`, since that one may be helpful when using `PDFPageView` directly.
2022-08-11 16:22:07 +02:00
Jonas Jenwald
ab1297f053
Merge pull request #15299 from Snuffleupagus/getDocument-ArrayBuffer
Add *official* support for passing `ArrayBuffer`-data to `getDocument` (issue 15269)
2022-08-11 14:12:55 +02:00
Jonas Jenwald
dd95e4f851 Add *official* support for passing ArrayBuffer-data to getDocument (issue 15269)
While this has always worked, as a consequence of the implementation, it's never been officially supported.
In addition to adding basic unit-tests, this patch also introduces a couple of new JSDoc `@typedef`s in the API to avoid overly long lines.
2022-08-10 14:13:01 +02:00
Jonas Jenwald
e1e97c6edd
Merge pull request #15279 from Snuffleupagus/firefox-rm-README
Remove the `extensions/firefox/README.mozilla` file (bug 1778567 follow-up)
2022-08-10 11:13:00 +02:00
calixteman
cef2ac99e5
Merge pull request #15298 from calixteman/ink_min_size
[Editor] Ensure an ink editor has the minimal required size after having been pasted
2022-08-10 10:27:37 +02:00
calixteman
3eb11fafca
Merge pull request #15297 from calixteman/check_pointer_down
[Editor] Avoid creation of an editor on "wrong" clicks
2022-08-10 10:27:12 +02:00
Calixte Denizet
63361dcfc7 [Editor] Ensure an ink editor has the minimal required size after having been pasted 2022-08-10 10:15:23 +02:00
Jonas Jenwald
fa48e90e3c
Merge pull request #15296 from Snuffleupagus/toolbars-reset
Move the `reset`-calls to occur last in the toolbar-constructors
2022-08-10 10:14:23 +02:00
Calixte Denizet
71ca249d2b [Editor] Avoid creation of an editor on "wrong" clicks 2022-08-10 10:05:04 +02:00
Jonas Jenwald
047522a34a Move the reset-calls to occur last in the toolbar-constructors
By invoking the `reset` methods *last* in the `Toolbar`/`SecondaryToolbar`-constructors, we ensure that the "toolbarreset"/"secondarytoolbarreset"-events are actually handle when the viewer loads. Note that previously those events were dispatched *before* the relevant event-listeners had been attached.
With this small change we can avoid inconsistent initial toolbar-state, specifically in the case when the viewer is *reloaded* (since Firefox keeps the HTML-state on "soft" reloads).
2022-08-09 22:39:38 +02:00
Jonas Jenwald
2b0b8cd665 Add more private properties/methods in web/toolbar.js 2022-08-09 22:39:07 +02:00
calixteman
0079ce4ad0
Merge pull request #15295 from calixteman/disable_editing
[Editing] Disable buttons until the first page is rendered
2022-08-09 21:47:21 +02:00
Calixte Denizet
fbce8786d0 [Editing] Disable buttons until the first page is rendered 2022-08-09 20:35:35 +02:00
Jonas Jenwald
63708a1a5b Remove the extensions/firefox/README.mozilla file (bug 1778567 follow-up)
With the changes made in [bug 1778567](https://bugzilla.mozilla.org/show_bug.cgi?id=1778567), it no longer seems correct to overwrite the mozilla-central file.
2022-08-09 13:13:39 +02:00
calixteman
589f72e325
Merge pull request #15290 from calixteman/ots_issue
Fix OTS issue with empty index (#15289)
2022-08-08 23:36:52 +02:00
Calixte Denizet
04f78c935c Fix OTS issue with empty index (#15289) 2022-08-08 22:56:26 +02:00
Jonas Jenwald
40f9f7e909
Merge pull request #15287 from calixteman/inserthtml
[Editor] Remove use of innerHtml
2022-08-07 14:37:39 +02:00
Calixte Denizet
5e0ddfb0e6 [Editor] Remove use of innerHtml 2022-08-07 13:39:41 +02:00
Tim van der Meij
2363fc0e5e
Merge pull request #15284 from Snuffleupagus/update-packages
Update packages and translations
2022-08-07 12:42:03 +02:00
Jonas Jenwald
38cf588eee Update l10n files 2022-08-07 10:22:40 +02:00
Jonas Jenwald
887e893fc8 Update npm packages 2022-08-07 10:20:21 +02:00
Tim van der Meij
2a84a3078b
Merge pull request #15283 from Snuffleupagus/sort-PopupAnnotation
[api-minor] Sort PopupAnnotations already on the worker-thread (PR 11535 follow-up)
2022-08-06 15:07:09 +02:00
Tim van der Meij
d55903764e
Merge pull request #15281 from Snuffleupagus/getTransform
Remove `mozCurrentTransform`/`mozCurrentTransformInverse` usage
2022-08-06 14:34:03 +02:00
Jonas Jenwald
358a0607fe Remove mozCurrentTransform/mozCurrentTransformInverse usage
These canvas-context properties are Mozilla-specific, and has obviously never been implemented anywhere else. Currently they are in the process of being removed, see [bug 1782651](https://bugzilla.mozilla.org/show_bug.cgi?id=1782651) and [bug 1294360](https://bugzilla.mozilla.org/show_bug.cgi?id=1294360), which in practice means that in e.g. Firefox Nightly the `addContextCurrentTransform`-function is now being used in the *built-in* PDF Viewer (which was obviously never intended).

We should thus be able to replace these Mozilla-specific properties with `CanvasRenderingContext2D.getTransform()`, which is available in all browsers that we currently support: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getTransform#browser_compatibility
2022-08-06 14:24:57 +02:00
Tim van der Meij
0ebd1daf30
Merge pull request #15261 from Snuffleupagus/issue-15260
Don't include `images/toolbarButton-editorInk.svg` in the `gulp components` build (issue 15260)
2022-08-06 14:17:55 +02:00
Tim van der Meij
70bcaf63ba
Merge pull request #15282 from Snuffleupagus/prefer-spread
Enable the ESLint `prefer-spread` rule
2022-08-06 14:12:25 +02:00
Jonas Jenwald
876a02a504 [api-minor] Sort PopupAnnotations already on the worker-thread (PR 11535 follow-up)
By doing this in the worker-thread this code will only need to run *once*, whereas currently re-rendering of a page forces this to be repeated (e.g. after it's been scrolled out-of-view and then back into view again).
2022-08-06 11:42:45 +02:00
Jonas Jenwald
f6db7975c5 Enable the ESLint prefer-spread rule
Note that in a couple of spots the argument could be `undefined` and there we simply disable the rule instead.

Please refer to https://eslint.org/docs/latest/rules/prefer-spread
2022-08-06 10:17:00 +02:00
Jonas Jenwald
d6d4653d80
Merge pull request #15275 from calixteman/textbox
[Editor] Remove some a11y properties only useful when a FreeText editor is edited
2022-08-05 09:36:56 +02:00
Calixte Denizet
fce83f8656 [Editor] Remove some a11y properties only useful when a FreeText editor is edited 2022-08-04 15:28:25 +02:00
calixteman
e88c90e898
Merge pull request #15274 from calixteman/missing_annotation
[Editor] A pasted FreeText editor was missing when printing/saving
2022-08-04 13:10:23 +02:00
Calixte Denizet
3c8d8f0d02 [Editor] A pasted FreeText editor was missing when printing/saving
When a FreeText editor is pasted then it hasn't an editorDiv yet when added
to the layer, hence it's empty.
So this patch just move the call to addToAnnotationStorage to ensure we've
what we need.
2022-08-04 13:00:45 +02:00
calixteman
b985eaa98c
Merge pull request #15267 from calixteman/freetext_a11y
[Annotation] Add a div containing the text of a FreeText annotation (bug 1780375)
2022-08-04 11:49:29 +02:00
Calixte Denizet
31155740c3 [Annotation] Add a div containing the text of a FreeText annotation (bug 1780375)
An annotation doesn't have to be in the text flow, hence it's likely a bad idea
to insert its text in the text layer. But the text must be visible from a screen
reader point of view so it must somewhere in the DOM.
So with this patch, the text from a FreeText annotation is extracted and added in
a div in its HTML counterpart, and with the patch #15237 the text should be visible
and positioned relatively to the text flow.
2022-08-04 11:14:05 +02:00
Jonas Jenwald
5ad8bbe8cb
Merge pull request #15271 from calixteman/null_field
Skip unknown fields when calculating a value in using AFSimple_Calculate
2022-08-04 10:11:46 +02:00
Calixte Denizet
6916fabd51 Skip unknown fields when calculating a value in using AFSimple_Calculate 2022-08-03 23:40:09 +02:00