Commit Graph

207 Commits

Author SHA1 Message Date
Calixte Denizet
de1985abbb [Editor] Set rotated free highlight at the right position after having changed its thickness (bug 1879108) 2024-02-11 21:06:56 +01:00
calixteman
f15b4b34fd
Merge pull request #17650 from calixteman/editor_highlight_keyboard
[Editor] Add a way to highlight text in using the keyboard (bug 1877426)
2024-02-11 18:52:37 +01:00
Tim van der Meij
4b7382edcb
Merge pull request #17657 from Snuffleupagus/eslint-jasmine-no-dupes
Prevent duplicate names in unit/integration tests
2024-02-11 12:18:31 +01:00
Jonas Jenwald
5732faee1e Prevent duplicate names in unit/integration tests
Having identical names for different test-cases may result in less helpful output, which we can avoid with the use of the ESLint Jasmine plugin.
This patch enables the rules at the `branch` level, to limit the amount/scope of the changes slightly. (We could thus make this rule more strict in the future, if that's deemed useful.)

Please refer to:
 - https://github.com/tlvince/eslint-plugin-jasmine/blob/master/docs/rules/no-spec-dupes.md
 - https://github.com/tlvince/eslint-plugin-jasmine/blob/master/docs/rules/no-suite-dupes.md
2024-02-11 11:45:09 +01:00
Tim van der Meij
28418598e5
Update puppeteer to version 22.0.0
This is a major version bump that requires two changes on our side:

- The new headless mode is now the default, so we can remove our
  transformation code (see https://github.com/puppeteer/puppeteer/pull/11815).
- The `page.waitForTimeout` API is removed. Sadly we still used it in
  the integration tests (but fortunately much less than before we worked
  on fixing intermittent failures), so until we remove the final
  occurrences we provide an implementation ourselves (see
  https://github.com/puppeteer/puppeteer/pull/11780).

The full changelog can be found here:
https://github.com/puppeteer/puppeteer/releases/tag/puppeteer-core-v22.0.0
2024-02-10 19:05:36 +01:00
Calixte Denizet
8fc6c5c8a6 [Editor] Add a way to highlight text in using the keyboard (bug 1877426) 2024-02-09 22:52:24 +01:00
Calixte Denizet
81466ee039 Implement caret browsing mode (bug 807730)
The users will be able to navigate within the pdf in using the arrows
and they'll be able to select some text, for example in order to
highlight it.
2024-02-07 09:35:22 +01:00
Calixte Denizet
2b8ecf5688 [Editor] Add the possibility to change the thickness of a free highlight (bug 1876096) 2024-01-24 22:04:39 +01:00
Calixte Denizet
d713df28c3 [Editor] Update the parameters in the UI of the last selected editor when undoing/redoing 2024-01-24 18:16:51 +01:00
Jonas Jenwald
f9a384d711 Enable the arrow-body-style ESLint rule
This manually ignores some cases where the resulting auto-formatting would not, as far as I'm concerned, constitute a readability improvement or where we'd just end up with more overall indentation.

Please see https://eslint.org/docs/latest/rules/arrow-body-style
2024-01-21 16:20:55 +01:00
Jonas Jenwald
9dfe9c552c Use shorter arrow functions where possible
For arrow functions that are both simple and short, we can avoid using explicit `return` to shorten them even further without hurting readability.

For the `gulp mozcentral` build-target this reduces the overall size of the output by just under 1 kilo-byte (which isn't a lot but still can't hurt).
2024-01-21 10:13:12 +01:00
Calixte Denizet
0cca9a0240 [Editor] Don't add the keyboard listener on the color-picker each time the dropdown menu is shown
and display/hide the dropdown menu when pressing arrow keys.
2024-01-20 21:57:54 +01:00
calixteman
f24246150e
Merge pull request #17541 from calixteman/issue17540
Use the original value of a field when propagating event (fixes #17540)
2024-01-20 21:51:37 +01:00
Calixte Denizet
5732c0c54a Use the original value of a field when propagating event (fixes #17540)
And avoid to not format a field when the value is 0.
2024-01-19 22:13:51 +01:00
Calixte Denizet
f3b76f5ae2 [Editor] Unselect highlights when the user click on the text layer (bug 1869767) 2024-01-19 20:16:55 +01:00
Calixte Denizet
a1bf12537c [Editor] Change the arrow direction when the dropdown is visible in the color picker (bug 1875357)
and hide the dropdown when the user click outside of the color picker.
2024-01-19 13:02:11 +01:00
Calixte Denizet
70a9d8f3bc [Editor] Avoid to move a non-draggable editor with the keyboard 2024-01-16 21:41:52 +01:00
Calixte Denizet
a76cc40ab8 [Editor] Avoid an exception when pressing space key to change the color of an highlight 2024-01-16 20:00:23 +01:00
Calixte Denizet
9765d57a26 [Editor] Extract all the lines when adding a FreeText annotation
Fixes #17079.
2024-01-14 21:11:51 +01:00
Calixte Denizet
fc7c320bd8 [Editor] Correctly serialize highlight data (regression from #17499) 2024-01-12 15:37:01 +01:00
Calixte Denizet
b4a7007397 [Editor] Don't throw when changing the color of an invisible highlight 2024-01-11 17:48:06 +01:00
Calixte Denizet
0392feaee4 Remove terminal white spaces when extracting text from annotation appearances 2024-01-09 10:42:53 +01:00
Calixte Denizet
17e1519410 [Editor] Init the default highlight color before creating the first editor instance
We want to be able to draw an highlight with the default color but without having an
instance of the HighlightEditor.
2024-01-05 17:52:54 +01:00
Calixte Denizet
7839e7b495 Preserve the whitespaces when getting text from FreeText annotations (bug 1871353)
When the text of an annotation is extracted in using getTextContent, consecutive white spaces
are just replaced by one space and. So this patch add an option to make sure that white
spaces are preserved when appearance is parsed.
For the case where there's no appearance, we can have a fast path to get the correct string
from the Content entry.
When an existing FreeText is edited, space (0x20) are replaced by non-breakable (0xa0) ones
to make to see all of them on screen.
2024-01-05 10:20:32 +01:00
Tim van der Meij
39a1fc6992
Merge pull request #17400 from calixteman/autoprint_test
Set a print listener as soon as possible in the autoprint integration test
2023-12-09 20:12:45 +01:00
Calixte Denizet
82be74d036 Set a print listener as soon as possible in the autoprint integration test
This test intermittently fails, likely because the auto-print is triggered fast enough
that we don't manage to get it.
So this patch aims to try to set a listener very early in order to be sure that
we'll be aware that a print has been triggered.
2023-12-09 16:59:43 +01:00
Calixte Denizet
e25cf1ba6f Don't run beforeunload callback when closing page in integration tests
For now, running such callbacks is disabled in Firefox but there are some
plan to reenable them: https://bugzilla.mozilla.org/show_bug.cgi?id=1824220
Having them blocks us to switch to bidi with Chrome.
2023-12-09 14:15:18 +01:00
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
Calixte Denizet
621b7af60d [Editor] Highlight must keep selected after the document has been scrolled 2023-12-05 23:22:35 +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
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
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
Henrik Skupin
9052327e07
Use "count" and not "clickCount" when calling page.mouse.click() 2023-11-30 09:40:57 +01:00
Calixte Denizet
59112a7730 [Editor] Move the alt text button in the editor toolbar 2023-11-28 15:36:29 +01:00
Calixte Denizet
1f0f51613a Make sure that only one radio button is checked in its group (bug 1864136)
When the first checked radio is met, the others in the group are set to false.
2023-11-23 17:01:49 +01:00
Calixte Denizet
09b4fe6a30 Get the field name from its parent when it doesn't have one when collecting fields (bug 1864136)
Some fields, somewhere under the Fields entry in Acroform, could have no name (in T)
but with a parent which has a name but which isn't somewhere under Fields.
As a side-effect, this patch prevents infinite loops because of potential cycles
under Fields.
2023-11-13 14:41:14 +01:00
Calixte Denizet
2d42c04543 [Editor] Avoid to click on the delete button in the freetext integration tests 2023-11-11 20:47:05 +01:00
Calixte Denizet
334f0eb060 [Editor] Add a toolbar to selected editors with a button to delete it (bug 1863763) 2023-11-10 15:19:43 +01:00
Calixte Denizet
ec396c2150 Don't avoid to execute the Blur callback when blurring a text field (bug 1863910) 2023-11-09 13:50:33 +01:00
Calixte Denizet
77475ac610 [Editor] Don't steal the keyboard events when editing mode is enabled 2023-10-30 10:03:44 +01:00
Calixte Denizet
66b1a1f34b Fix the intermittent failures with PageOpen/PageClose test 2023-10-29 20:11:51 +01:00
Calixte Denizet
d72fd9ce4f Fix intermittents failure on mac 2023-10-27 16:10:06 +02:00
Calixte Denizet
517a262fb1 Fix keyboard shortcuts on mac and for some tests make sure that all
the page is displayed in using page-fit in order to make all tested
elements visible.
2023-10-27 16:09:35 +02:00
Calixte Denizet
66982a2a11 [api-minor] Move to Fluent for the localization (bug 1858715)
- For the generic viewer we use @fluent/dom and @fluent/bundle
- For the builtin pdf viewer in Firefox, we set a localization url
  and then we rely on document.l10n which is a DOMLocalization object.
2023-10-19 11:20:41 +02:00
Tim van der Meij
2bae8af96a
Fix intermittent problems on Windows in the XFA search integration test
The current test fails intermittently only on Windows for unknown
reasons: the code is correct and on Linux it always passes. However, we
have already spent quite a lot of time on this test, so rather than
spending even more time on it I figured we should look at what behavior
the test is trying to check and find an alternative way to do it that
can't trigger this intermittent issue anymore.

This commit changes the test to use a term that only exists once in the
entire document so we cannot accidentally highlight another match
anymore. This doesn't change anything about the behavior that this test
aims to check: we still test searching in the XFA layer, we still test
that the original term is matched case-insensitively and we still test
that that match is actually highlighted. Note that the only objective of
the test is confirming that the search functionality covers the XFA
layer, so the exact phrase/match is not the interesting bit.
2023-10-15 15:02:41 +02:00
Tim van der Meij
48e41617f5
Remove Escape key press from the autoprint integration test
It's not necessary because we have configured silent printing for
Firefox and Chrome in the browser arguments we pass in `test.mjs`. This
means that the print dialog is not even shown at all or disappears
automatically once printing is done, so the Escape key press serves no
purpose. Since it has been shown to time out, likely because the page
loses focus during printing, and because the page itself doesn't know
when the printing dialog is shown and we therefore can't possibly do the
key press at the right time anyway, this commit gets rid of it to
stabilize the test.
2023-10-14 18:17:29 +02:00
Jonas Jenwald
9878d058fe Convert the integration test-files to JavaScript modules 2023-10-12 13:18:20 +02:00
Jonas Jenwald
33456d3704 Rename the integration test-files, in preparation for converting them to modules
This is done separately to ensure that Git is able to track the history correctly.
2023-10-12 13:17:56 +02:00
Tim van der Meij
2c1d95b153
Activate the selector check for the autoprint integration test as soon as possible
The Windows bot is usually slower than the Linux bot, and therefore
text layer rendering is as well. However, the `autoprint` test awaited
text layer rendering to complete before activating the selector check,
which makes it timing-sensitive and causes it to never resolve because
the page is already printed (and the printed page div removed) by then.

This commit should fix the issue by activating the selector check as
soon as possible, namely as soon as the viewer appears, which should
ensure we're always registering the selector check in time because we're
doing it even before rendering is starting.
2023-10-07 19:27:34 +02:00
Calixte Denizet
ea5eafa265 [Editor] Add the possibility to create a new editor in using the keyboard (bug 1853424)
When an editing button is disabled, focused and the user press Enter (or space), an
editor is automatically added at the center of the current page.
Next creations can be done in using the same keys within the focused page.
2023-10-05 22:49:15 +02:00