1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 16:48:08 +02:00
Commit graph

4466 commits

Author SHA1 Message Date
Jonas Jenwald
4e12906061 Move the various DOM-factories into their own files
- Over time the number and size of these factories have increased, especially the `DOMFilterFactory` class, and this split should thus aid readability/maintainability of the code.

 - By introducing a couple of new import maps we can avoid bundling the `DOMCMapReaderFactory`/`DOMStandardFontDataFactory` classes in the Firefox PDF Viewer, since they are dead code there given that worker-thread fetching is always being used.

 - This patch has been successfully tested, by running `$ ./mach test toolkit/components/pdfjs/`, in a local Firefox artifact-build.

*Note:* This patch reduces the size of the `gulp mozcentral` output by `1.3` kilo-bytes, which isn't a lot but still cannot hurt.
2024-11-01 13:31:28 +01:00
Jonas Jenwald
cdd4b052f9 Don't initialize L10n.#elements eagerly since it's unused in MOZCENTRAL builds
It's not necessary to manually start translation in the Firefox PDF Viewer, and doing so would even cause problems there (see issue 17142).
2024-10-30 15:20:44 +01:00
calixteman
07a1d30fad
Merge pull request #18968 from calixteman/bug1903588
[Editor] Split the long words when showing the alt-text tooltip (bug 1903588)
2024-10-28 14:07:48 +01:00
Calixte Denizet
8fbb9e2f16 [Editor] Split the long words when showing the alt-text tooltip (bug 1903588) 2024-10-28 11:08:30 +01:00
Jonas Jenwald
b048420d21 [api-minor] Remove the CMapCompressionType enumeration
After the binary CMap format had been added there were also some ideas about *maybe* providing other formats, see [here](https://github.com/mozilla/pdf.js/pull/8064#issuecomment-279730182), however that was over seven years ago and we still only use binary CMaps.
Hence it now seems reasonable to simplify the relevant code by removing `CMapCompressionType` and instead just use a boolean to indicate the type of the built-in CMaps.
2024-10-24 11:08:16 +02:00
Jonas Jenwald
65b38f24ff Remove mask-image duplication for the print/download buttons
With the recent re-factoring of the viewer CSS rules we now have some duplication of the `mask-image` definitions for the print/download buttons in the secondaryToolbar; note 17419de157/web/viewer.css (L1204-L1210)
2024-10-20 21:15:09 +02:00
Tim van der Meij
347f155ebc
Replace eslint-plugin-sort-exports by eslint-plugin-perfectionist
The `eslint-plugin-sort-exports` plugin doesn't support ESLint 9 or has
published plans to do so. The `eslint-plugin-perfectionist` does support
ESLint 9 [1], seems more actively maintained [2, 3] and contains other
rules that could be interesting later on [4]. Note that both plugins
behave the same, except for two cases which are updated here.

[1] https://github.com/azat-io/eslint-plugin-perfectionist/issues/154
[2] https://github.com/azat-io/eslint-plugin-perfectionist/commits/main
[3] https://www.npmjs.com/package/eslint-plugin-perfectionist?activeTab=versions
[4] https://perfectionist.dev/rules
2024-10-20 18:50:35 +02:00
Jonas Jenwald
c3bbeb51e3 Remove event listeners with AbortSignal in the GrabToPan class 2024-10-19 12:01:43 +02:00
Tim van der Meij
96bced7f5b
Merge pull request #18884 from hubgit/patch-1
Handle null parentElement for selection anchor
2024-10-15 20:55:23 +02:00
Tim van der Meij
e8149b3982
Merge pull request #18898 from Snuffleupagus/PDFViewerApplication-bindEvents-opts
Create fewer Objects in `PDFViewerApplication.bindEvents`
2024-10-15 20:34:45 +02:00
Jonas Jenwald
4d7f29d736 Create fewer Objects in PDFViewerApplication.bindEvents
Given that all listeners need the same options we can create and re-use a single options-Objects for all of them.
2024-10-14 11:48:41 +02:00
Jonas Jenwald
4ae6132d07 Remove unnecessary options from removeEventListener in the web/app.js file
Only the `capture` parameter matters when removing an event listener, see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#matching_event_listeners_for_removal
2024-10-13 11:39:36 +02:00
Alf Eaton
e97e9c93d6
Handle null parentElement for selection anchor 2024-10-11 13:58:06 +01:00
Jonas Jenwald
6f307e90a3 Remove event listeners with AbortSignal in the AltTextManager class 2024-10-11 12:05:36 +02:00
Jonas Jenwald
31b0a496fd Remove the temporary "visibilitychange" listener, in PDFViewer, with AbortSignal.any()
This is similar to a lot of other code, where we've been replacing explicit `removeEventListener`-calls.
Given the somewhat limited availability of `AbortSignal.any()`, see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static#browser_compatibility), this event listener will no longer be immediately removed in older browsers (however that should be fine).
2024-10-08 15:38:31 +02:00
Jonas Jenwald
c681ff25d8 Change how we handle l10n-args for dates in the DocumentProperties dialog (bug 1922618)
Strangely enough the code works just fine as-is in the GENERIC viewer, so there must be some difference between the Firefox built-in Fluent implementation and the Fluent.js one.

It seems that we can work-around the problem by handling this l10n-arg the same way that we handle dates in the AnnotationLayer, and testing this with the Firefox Devtools it seems that it should work.
2024-10-04 19:50:05 +02:00
Calixte Denizet
8410252eb8 [Editor] Make stamp annotations editable (bug 1921291) 2024-10-03 21:54:08 +02:00
Jonas Jenwald
b7ae92c11c Remove the PDFViewer.annotationEditorMode setter event listeners with AbortSignal.any() 2024-10-03 15:57:46 +02:00
Calixte Denizet
0ce6f8b482 [GV] Increase the height (48px) of the toolbar in order to fit the a11y recommendations (bug 1838602)
and reorganize the toolbar css to use nested styles.
2024-10-02 19:17:40 +02:00
Jonas Jenwald
e25832c43f
Merge pull request #18831 from Snuffleupagus/toolbar-container
Fix `toolbarViewer`/`toolbarContainer` regressions (PR 18385, 18786 follow-up)
2024-10-02 09:37:12 +02:00
Jonas Jenwald
07e8afb247 Always set AppOptions.eventBus, regardless of build, to make local testing easier 2024-10-01 19:43:19 +02:00
Jonas Jenwald
7c9d177826 Update the CaretBrowsingMode toolbar-height if the toolbarDensity preference changes (PR 18786 follow-up)
Otherwise the isVisible-calculations may not work correctly.
2024-10-01 19:43:16 +02:00
calixteman
3cdc3258d9
Merge pull request #18830 from calixteman/menu_nvda
Make the secondary menu button usable with the keyboard when NVDA is enabled
2024-10-01 17:27:56 +02:00
Jonas Jenwald
f2a132f826 Use the "correct" toolbar container element in getViewerConfiguration (PR 18385 follow-up)
With the changes made in PR 18385 the `toolbarViewer` element is now shorter than before, since the padding is applied on its `toolbarContainer` parent-element instead.
This causes two separate regressions:
 - Clicking at the very top/bottom of the toolbar no longer closes the secondaryToolbar like previously.
 - The `CaretBrowsingMode`-constructor no longer computes the toolbar-height correctly.

Given how/where the `container`-property is being used these changes *should* thus be safe.
2024-10-01 17:17:40 +02:00
Calixte Denizet
392c17efa0 Make the secondary menu button usable with the keyboard when NVDA is enabled
It's a temporary workaround until bug 1921984 is fixed.
2024-10-01 16:57:39 +02:00
Jonas Jenwald
655ef12b14 Re-factor how PDFLayerViewer decides if the UI needs to updated on "optionalcontentconfigchanged" events
The current implementation won't work correctly in some cases, e.g. if RBGroups are present, which means that it's possible for the UI to get out-of-sync with the actual optionalContent-state.

To avoid querying the DOM unnecessarily we cache the last known UI-state and compare with the actual optionalContent-state, which thus replaces the previously used hash-comparison.
2024-10-01 13:25:22 +02:00
Jonas Jenwald
a7e1bf64c4
Merge pull request #18812 from Snuffleupagus/pr-15522-followup
Ensure that the CursorTools-buttons are disabled e.g. during editing (PR 15522 follow-up)
2024-09-28 19:20:56 +02:00
Jonas Jenwald
b1df164a26 Ensure that the CursorTools-buttons are disabled e.g. during editing (PR 15522 follow-up)
We disable any non-default CursorTool in PresentationMode and during Editing, since they don't make sense there and to prevent problems such as e.g. [bug 1792422](https://bugzilla.mozilla.org/show_bug.cgi?id=1792422).
Hence it seems like a good idea to *also* disable the relevant SecondaryToolbar-buttons, to avoid the user being surprised that the CursorTools-buttons do nothing if clicked.
2024-09-28 12:29:51 +02:00
Calixte Denizet
ec01af6b38 [Editor] Avoid to have a selected stamp annotation on top of the secondary toolbar (bug 1911980) 2024-09-26 17:48:02 +02:00
Jonas Jenwald
a1283785e5
Merge pull request #18796 from Snuffleupagus/unify-toolbarContainer
Unify separate `#toolbarContainer`-blocks in the CSS (PR 18385 follow-up)
2024-09-26 12:09:37 +02:00
Jonas Jenwald
f765b5ab35 Unify separate #toolbarContainer-blocks in the CSS (PR 18385 follow-up) 2024-09-26 11:08:55 +02:00
Jonas Jenwald
135ee03847 Remove the unused splitToolbarButton CSS class (PR 18385 follow-up) 2024-09-26 11:01:18 +02:00
Calixte Denizet
e23159c41b Increase the size of the toolbar depending on the uidensity (bug 1171799) 2024-09-25 14:27:17 +02:00
Calixte Denizet
50517b8fba Remove duplicated --toolbar-height definition in the css 2024-09-24 12:31:43 +02:00
Calixte Denizet
e9b10ae8b2 Remove useless css variable --editor-toolbar-base-offset 2024-09-24 09:58:17 +02:00
Calixte Denizet
6f40ed729b Refactor the toolbar html & css to improve its overall accessibility (bug 1171799, bug 1855695)
The first goal of this patch was to remove the tabindex because it helps
to improve overall a11y. That led to move some html elements associated
with the buttons which helped to position these elements relatively to their
buttons.
Consequently it was easy to change the toolbar height (configurable in Firefox
with the pref browser.uidensity): it's the second goal of this patch.
For a11y reasons we want to be able to change the height of the toolbar to make
the buttons larger.
2024-09-23 22:43:44 +02:00
Calixte Denizet
d35a20a8c1 [Editor] Don't show the ml toggle button when the ml is disabled (bug 1920515) 2024-09-23 19:46:32 +02:00
Calixte Denizet
b29278efb8 Fix the rendering of the different separators we've in the UI
Currently, the css for a separator is something like { height: 1px; background-color: ... }.
But its rendering depends on its position on the screen.
So instead of setting the height to 1px, we just set something like { border-top: 1px solid ...; },
this way the final rendering is exactly the same for all the separators.
2024-09-19 15:24:01 +02:00
Calixte Denizet
ee89bd1c39 Rename the toolbar buttons in order to free their current names
which can then be used for their future parent container.
This patch aims to simplify a bit the patch in #18385.
2024-09-17 20:34:38 +02:00
Calixte Denizet
46fac8b2c1 [Editor] Take into account the device pixel ratio when drawing an added image
Fixes #18626.
2024-09-16 14:48:26 +02:00
Jonas Jenwald
d86f94a3db Use the "pageColorsBackground" option as background-color for non-loaded pages (issue 18680)
This should prevent non-loaded pages from flashing white in e.g. high contrast mode (HCM).
2024-09-12 21:15:15 +02:00
Calixte Denizet
06f9d8002d Consider foo-\nBar as a compound word
Fixes #18693.
2024-09-11 15:01:54 +02:00
Calixte Denizet
6e4b7ee3f8 [Editor] Avoid to have the ML disclaimer when the ML engine isn't ready (bug 1917543) 2024-09-09 21:47:18 +02:00
Tim van der Meij
a1b45d6e69
Merge pull request #18681 from Rob--W/crx-mv3-migration
[CRX] Migrate Chrome extension to Manifest Version 3
2024-09-08 18:10:43 +02:00
Rob Wu
3fe256cd0d [CRX] Set manifest_version to 3
- Replace DOM-based pdfHandler.html (background page) with background.js
  (extension service worker).

- Adjust logic of background scripts to account for the fact that the
  scripts can execute repeatedly during a browser session. Primarily,
  register relevant extension event handlers at the top level and use
  in-memory storage.session API to keep track of initialization state.

- Extension URL router: replace blocking webRequest with the service
  worker-specific "fetch" event.

- PDF detection: replace blocking webRequest with declarativeNetRequest.
  This requires Chrome 128+. The next commit will add a fallback for
  earlier Chrome versions.
2024-09-08 16:35:13 +02:00
Rob Wu
bc4890d4d4 [CRX] Remove restoretab.js logic
restoretab.js was added in https://github.com/mozilla/pdf.js/pull/6233
with the purpose of restoring lost tabs when Chrome closes all extension
tabs when it reloads the extension. This forced reload can happen when
the user toggles the "Allow access to file URLs" option.

This logic does not work any more, and since the use of localStorage is
a blocker in migrating to MV3, this patch just drops the logic.
2024-09-08 16:35:13 +02:00
Rob Wu
bd3d993180 [CRX] Use DNR instead of webRequest in preserve-referer
webRequestBlocking is unavailable in MV3. Non-blocking webRequest can
still be used to detect the Referer, but we have to use
declarativeNetRequest to change the Referer header as needed.
2024-09-08 16:35:13 +02:00
Jonas Jenwald
b681ea6fd9 Prevent .visibleMediumView from overriding already hidden elements (issue 18704, PR 18596 follow-up)
*Please note:* As a general rule we probably don't need to fix things affecting *custom* implementations of the default viewer, but in this case a "targeted" fix seem possible that shouldn't (famous last words) break anything else.

Ensure that the `.visibleMediumView` class, which is used when the viewer becomes narrow, cannot override the `display`-value for DOM elements that are being *explicitly* hidden either through the associated attribute or class.
2024-09-08 10:47:18 +02:00
Calixte Denizet
68332ec236 Avoid to have a white line around the canvas
The canvas must have the same dims as the page in order to avoid to see the page
background.
2024-09-07 20:12:29 +02:00
Calixte Denizet
ddba096191 Make tagged images visible for screen readers (bug 1708040)
The idea is to insert a span in the text layer with an aria-role set to img
and use the bounding box provided by the attribute field in the tag dict in
order to have non-null dimensions for the image to make it "visible".
2024-09-05 17:59:42 +02:00