Commit Graph

18302 Commits

Author SHA1 Message Date
Calixte Denizet
c63af10191 Use page.evaluateHandle when we want to await on document promises in integration tests
For reference: https://github.com/mozilla/pdf.js/pull/17378#issuecomment-1842864939
2023-12-07 17:00:12 +01:00
calixteman
f54cfe065a
Merge pull request #17388 from calixteman/no_double_color_picker
[Editor] Avoid to have a color picker for highlighting twice in the main toolbar
2023-12-06 16:29:33 +01:00
Jonas Jenwald
a692f8681b
Merge pull request #17386 from Snuffleupagus/issue-17361
Remove focus from the toggleButton when closing the sidebar with a mouse (issue 17361)
2023-12-06 16:21:18 +01:00
Calixte Denizet
cb9c855993 [Editor] Avoid to have a color picker for highlighting twice in the main toolbar
When opening a pdf from the secondary toolbar, a second color picker is added.
So in order to avoid that, we just stop listening for annotationeditoruimanager
in the toolbar.
2023-12-06 16:10:33 +01:00
Jonas Jenwald
6b6b7867af Remove focus from the toggleButton when closing the sidebar with a mouse (issue 17361) 2023-12-06 11:11:11 +01:00
calixteman
8702e1bbb2
Merge pull request #17359 from calixteman/editor_highlight_color_picker
[Editor] Add a color picker with predefined colors for highlighting text (bug 1866434)
2023-12-06 11:06:55 +01:00
calixteman
7e64f8213d
Merge pull request #17385 from calixteman/bug1868503
Set text field value as a string when it's for a date or a time (bug 1868503)
2023-12-06 10:48:32 +01:00
calixteman
c8f6b39fc1
Merge pull request #17381 from calixteman/editor_highlight_selected
[Editor] Highlight must keep selected after the document has been scrolled
2023-12-06 10:28:39 +01:00
Calixte Denizet
098cc16c46 Set text field value as a string when it's for a date or a time (bug 1868503) 2023-12-06 09:44:30 +01:00
Calixte Denizet
ff23d37fa2 [Editor] Add a color picker with predefined colors for highlighting text (bug 1866434)
The doorhanger for highlighting has a basic color picker composed of 5 predefined colors
to set the default color to use.
These colors can be changed thanks to a preference for now but it's something which could
be changed in the Firefox settings in the future.
Each highlight has in its own toolbar a color picker to just change its color.
The different color pickers are so similar (modulo few differences in their styles) that
this patch introduces a new class ColorPicker which provides a color picker component
which could be reused in future editors.
All in all, a large part of this patch is dedicated to color picker itself and its style
and the rest is almost a matter of wiring the component.
2023-12-05 23:27:22 +01:00
Calixte Denizet
621b7af60d [Editor] Highlight must keep selected after the document has been scrolled 2023-12-05 23:22:35 +01:00
calixteman
c0436013a0
Merge pull request #17380 from calixteman/issue17379
[Editor] Don't remove elements from the draw layer after it has been destroyed
2023-12-05 23:03:12 +01:00
Calixte Denizet
f7fec8c6d7 [Editor] Don't remove elements from the draw layer after it has been destroyed
Fixes issue #17379.
2023-12-05 22:41:20 +01:00
Jonas Jenwald
319e85449e
Merge pull request #17377 from Snuffleupagus/pr-17352-follow-up
Remove the unused `--editor-toolbar-active-bg-color` CSS variable (PR 17352 follow-up)
2023-12-05 15:06:13 +01:00
calixteman
7f04ce4d22
Merge pull request #17374 from calixteman/bug1865341
[Editor] Avoid conflicts between new persistent refs and the ones created when saving (bug 1865341)
2023-12-05 14:50:15 +01:00
Jonas Jenwald
c0bc5f9013 Remove the unused --editor-toolbar-active-bg-color CSS variable (PR 17352 follow-up)
This CSS variable became unused in PR 17352 but we apparently forgot to remove it there, which causes issues when trying to update PDF.js in mozilla-central; see https://treeherder.mozilla.org/push-health/push?repo=try&revision=0701bd2c189d85cd9ff050d6d3e8336d8f36e625&tab=tests&testGroup=pr&selectedTest=browserbasecontentteststaticbrowserparsablecssjs&selectedTaskId=
2023-12-05 14:01:23 +01:00
Calixte Denizet
ae5828c968 [Editor] Avoid conflicts between new persistent refs and the ones created when saving (bug 1865341)
When a pdf as a FreeText without appearance, we use a fake font in order to render it
and that leads to create few new refs for the font.
But then when we're saving, we create some new refs which start at the same number
as the previous created ones.
Consequently, when saving we're using some wrong objects (like a font) to check if
we're able to render the newly added FreeText.
In order to fix this bug, we just remove the persistent refs (which are only used
when rendering/printing) during the saving.
2023-12-05 12:33:21 +01:00
calixteman
795c63e400
Merge pull request #17375 from calixteman/bug1867588
[Editor] Always give the focus to the ink editor when starting drawing (bug 1867588)
2023-12-05 10:54:11 +01:00
Calixte Denizet
11610a9e66 [Editor] Always give the focus to the ink editor when starting drawing (bug 1867588)
This way, when the editor is blurred, it can be committed and everything works fine.
It fixes issue #17373.
2023-12-05 10:26:59 +01:00
calixteman
a3637e653f
Merge pull request #17370 from calixteman/issue17368
[Editor] Make sure that all layers are disabled when an editing session is done
2023-12-04 16:58:41 +01:00
Jonas Jenwald
476cb84d92
Merge pull request #17367 from timvandermeij/modernize-test
Modernize the `calculateMD5` and `verifyManifestFiles` test helper functions
2023-12-04 16:03:19 +01:00
Calixte Denizet
43eea0b38e [Editor] Make sure that all layers are disabled when an editing session is done
Fixes issue #17368.
2023-12-04 13:27:39 +01:00
Tim van der Meij
ac5667166e
Modernize the verifyManifestFiles test helper function
The test helper code largely predates the introduction of modern
JavaScript features and should be refactored to improve readability.
In particular callbacks and recursive function calls make the code
harder to understand and maintain.

This commit:

- replaces the callback argument with returning a promise;
- replaces the recursive function calls with a simple loop;
- uses `const`/`let` instead of `var`;
- uses template strings for shorter string formatting code;
- improves the error messages to have more details.
2023-12-03 20:42:50 +01:00
Tim van der Meij
c9a923066b
Modernize the calculateMD5 test helper function
The test helper code largely predates the introduction of modern
JavaScript features and should be refactored to improve readability.
In particular callbacks and recursive function calls make the code
harder to understand and maintain.

This commit:

- replaces the callback argument with returning a promise;
- uses `const` instead of `var`;
- uses arrow functions for shorter code;
- uses template strings for shorter string formatting code;
- improves the error messages to have more details.
2023-12-03 20:42:45 +01:00
Tim van der Meij
5111b6d371
Merge pull request #17337 from manunio/initial-fuzzing-support
fuzz: initial integration
2023-12-03 15:12:18 +01:00
manunio
8bb8070116 fuzz: initial integration
- Adds initial fuzz_target for image decoders.
  - Adds jazzer.js as dev-dependency.
  - Adds a .eslintrc rule to ignore import/no-unresolved error.
2023-12-03 18:52:48 +05:30
calixteman
6b3ae4492e
Merge pull request #17364 from calixteman/editor_disable_highlight
[Editor] Disable mouse events when leaving the highlight mode
2023-12-01 18:49:52 +01:00
Jonas Jenwald
a1d84f5ecf
Merge pull request #17363 from Snuffleupagus/issue-17353
[Firefox] Restore opening of PDF attachments (issue 17353, bug 1867764)
2023-12-01 18:12:52 +01:00
Calixte Denizet
83d0b6cb55 [Editor] Disable mouse events when leaving the highlight mode 2023-12-01 17:10:19 +01:00
Jonas Jenwald
4c92ec9008 [Firefox] Restore opening of PDF attachments (issue 17353)
This unfortunately broke in PR 17060, since I had completely forgotten about https://bugzilla.mozilla.org/show_bug.cgi?id=1632644#c5 when writing that patch.
The easiest solution, while slightly unfortunate, seems to be to add a couple of non-standard hash parameters specifically for the PDF attachment use-case in the Firefox PDF Viewer. (Note that we cannot use "nameddest" here, since we also need to support the stringified destination-Array case.)
2023-12-01 12:16:56 +01:00
Jonas Jenwald
096426f073
Merge pull request #17360 from Snuffleupagus/issue-17347
Remove the "transitionend" event listener from the default viewer (issue 17347)
2023-12-01 10:22:42 +01:00
Jonas Jenwald
fe3bc575de Disable the "should compress and save text" unit-test in additional Node.js versions (PR 17202 follow-up)
It seems this unit-test started failing in Node.js version 20.10 as well. We should probably try and understand why, but for now just disable it to get passing CI tests.
2023-11-30 20:47:15 +01:00
Jonas Jenwald
412502370d Remove the "transitionend" event listener from the default viewer (issue 17347)
Given that this event listener is only used to trigger rendering after the sidebar has been opened/closed, we can utilize the existing one in the `PDFSidebar` class for this purpose instead. That one is registered on the sidebar DOM-element, and is needed to remove a CSS-class indicating that the sidebar is moving.
2023-11-30 20:29:40 +01:00
calixteman
d65dca7811
Merge pull request #17358 from whimboo/mouse_click_count
Use "count" and not "clickCount" when calling page.mouse.click()
2023-11-30 10:12:37 +01:00
Henrik Skupin
9052327e07
Use "count" and not "clickCount" when calling page.mouse.click() 2023-11-30 09:40:57 +01:00
calixteman
9ac1ac6ed3
Merge pull request #17352 from calixteman/move_button_hcm
[Editor] Fix the colors in HCM when hovering a button in the editor toolbar
2023-11-29 20:21:16 +01:00
Calixte Denizet
91eda77f63 [Editor] Fix the colors in HCM when hovering a button in the editor toolbar
It fixes few errors in the CSS for HCM.
It now complies to the specs from UI/UX.
Only the foreground must change in HCM and not the background, similarly to what
we had for the alt-text button before moving it.
2023-11-29 19:53:03 +01:00
calixteman
6a35e4206e
Merge pull request #17351 from calixteman/fix_mc_test
[Editor] Fix subtype for telemetry data (follow-up of #17329)
2023-11-29 11:48:42 +01:00
Calixte Denizet
05ca005eeb [Editor] Fix subtype for telemetry data (follow-up of #17329)
Fix a test failure in m-c.
2023-11-29 11:09:22 +01:00
calixteman
59cf2ee5a9
Merge pull request #17338 from Snuffleupagus/rm-FirefoxCom-requestSync
[Firefox] Remove the `FirefoxCom.requestSync` method
2023-11-28 16:26:32 +01:00
Jonas Jenwald
b03ce96605 [Firefox] Remove the FirefoxCom.requestSync method, since it's unused
After the two previous commits, which removed the remaining call-sites, this method is no longer used and can thus be removed.
As mentioned in the JSDocs for the now removed method, synchronous communication between the viewer and the platform code isn't really a good idea.

Once this patch has landed in mozilla-central some additional clean-up of the platform code will also be possible.
2023-11-28 16:19:58 +01:00
Jonas Jenwald
9ca504e538 [Firefox] Don't send the "abortLoading" message synchronously
Despite the comment, I believe that changing this should be fine for two separate reasons:
 - The platform code has an "unload" event listener, see [this code](https://searchfox.org/mozilla-central/rev/edb2612db13e89f1c44ab95b1e4d4366c16eb9fb/toolkit/components/pdfjs/content/PdfStreamConverter.sys.mjs#533-538), that invokes the same method. Hence we should still be guaranteed that the relevant platform method will run.

 - The `FirefoxComDataRangeTransport.abort` method is never actually invoked in the Firefox PDF Viewer.
   Note that the [`PDFDataRangeTransport.abort` method](f4b396f6c8/src/display/api.js (L759)) is only invoked via the [`PDFDataTransportStream.cancelAllRequests` method](f4b396f6c8/src/display/transport_stream.js (L167-L175)), which in turn is only invoked via the [`WorkerTransport.destroy` method](f4b396f6c8/src/display/api.js (L2485-L2487)). That method is invoked via the [`PDFDocumentLoadingTask.destroy` method](f4b396f6c8/src/display/api.js (L630)), which in the viewer is only invoked via the [`PDFViewerApplication.close` method](f4b396f6c8/web/app.js (L919)) which is never actually called in the Firefox PDF Viewer.

All-in-all, given the existing platform code *and* the current viewer-implementation it should thus be safe to not wait for the "abortLoading" message to complete.
2023-11-28 16:19:58 +01:00
Jonas Jenwald
ddebb0f954 [Firefox] Don't send the "initPassiveLoading" message synchronously
The return value is not, nor has it ever been, used for anything and we should thus be able to just send the message.
Note that the responses are already handled by the "message" event listener registered above.
2023-11-28 16:19:58 +01:00
calixteman
f4952399a4
Merge pull request #17329 from calixteman/move_alt_text_button
[Editor] Move the alt text button in the editor toolbar
2023-11-28 15:57:35 +01:00
Calixte Denizet
59112a7730 [Editor] Move the alt text button in the editor toolbar 2023-11-28 15:36:29 +01:00
calixteman
8e2507e0e8
Merge pull request #17317 from calixteman/editor_highlight
[Editor] Add a new editor to highlight some text in a pdf (bug 1866119)
2023-11-28 15:12:43 +01:00
Calixte Denizet
1ea6293923 [Editor] Add a new editor to highlight some text in a pdf (bug 1866119)
This patch is first big step for the new highlight feature.
Few patches will follow in order to conform to the specs UX/UI gave us.
2023-11-28 14:21:53 +01:00
calixteman
4bf7ff2027
Merge pull request #17344 from calixteman/issue17342
[Editor] Avoid to add a new ink editor when we aren't editing anymore
2023-11-27 16:53:48 +01:00
Calixte Denizet
2be136ab70 [Editor] Avoid to add a new ink editor when we aren't editing anymore 2023-11-27 16:18:31 +01:00
calixteman
b7e943bc7d
Merge pull request #17340 from calixteman/issue17332
Don't throw when there isn't enough data to get block info in flate stream
2023-11-26 19:23:25 +01:00