4171 Commits

Author SHA1 Message Date
Calixte Denizet
0b40bf1743 [Editor] Update the color and the position of the comment button in reading mode they've been modified 2025-09-24 09:45:37 +02:00
calixteman
225b07aa29
Merge pull request #20283 from calixteman/bug1989304
[Editor] Make sure the comment dialog is visible on the screen (bug 1989304)
2025-09-23 19:30:28 +02:00
calixteman
44affa76b9
Merge pull request #20197 from ryzokuken/sab-font-data
Serialize font data into an ArrayBuffer
2025-09-22 09:40:14 +02:00
Ujjwal Sharma
4bed7370f4 [WIP] Serialize font data into an ArrayBuffer
This PR serializes font data into an ArrayBuffer
that is then transfered from the worker to the
main thread. It's more efficient than the current
solution which clones the "export data" object
which includes the font data as a Uint8Array.

It prepares us to switch to a SharedArrayBuffer
in the future, which would allow us to share
the font data with multiple agents, which would be
crucial for the upcoming "renderer" worker.
2025-09-19 12:02:40 +05:30
Calixte Denizet
623d422ddb [Editor] Make sure the comment dialog is visible on the screen (bug 1989304) 2025-09-18 21:23:42 +02:00
Calixte Denizet
cbc5241b53 [Editor] Make sure to not add extra editors when showing again a destroyed page 2025-09-18 15:18:50 +02:00
calixteman
adf9233f46
Merge pull request #20270 from calixteman/issue20232
Consider a ttf font with both Symbolic and Nonsymbolic flags set with a Differences array in the encoding dict as non-symbolic
2025-09-14 21:37:58 +02:00
Calixte Denizet
b6d772d71d Consider a ttf font with both Symbolic and Nonsymbolic flags set with a Differences array in the encoding dict as non-symbolic
It fixes #20232.
2025-09-14 18:52:16 +02:00
Tim van der Meij
ffeaa9111a
Replace manual returns with pending in the integration tests
This allows Jasmine to track skipped tests and makes it easier to
discover them using e.g. `grep`.
2025-09-14 18:30:17 +02:00
Tim van der Meij
1cae8e2933
Merge pull request #20269 from calixteman/dichotomic_find_color
Use a dichotomy to find a color with a good contrast ratio
2025-09-14 18:15:52 +02:00
Calixte Denizet
634bef5fb4 Use a dichotomy to find a color with a good contrast ratio
It helps to reduce the number of iterations so it makes the algorithm
slightly faster in general.
2025-09-13 15:45:00 +02:00
calixteman
beb5f5ca85
Merge pull request #20208 from nicolo-ribaudo/bboxes-typedarray
Store ops bboxes in a linear Uint8Array
2025-09-12 14:52:42 +02:00
calixteman
d77f89026f
Merge pull request #20240 from calixteman/fix_contrast
Make sure that a good constrast ratio is respected when darkening/lightening a color
2025-09-12 09:24:40 +02:00
Calixte Denizet
7f85c00ee6 Make sure that a good constrast ratio is respected when darkening/lightening a color 2025-09-11 21:29:28 +02:00
Tim van der Meij
557eb2c7e1
Merge pull request #20253 from calixteman/scroll_and_center
Add an option in scrollIntoView and goToXY in order to be able to center vertically or horizontally the point XY in the viewer container
2025-09-11 21:20:55 +02:00
Nicolò Ribaudo
4c7bbd0fef
Reduce background canvas resolution
The size of the canvas has significant impact on the rendering
performance. If we are going to render a high-res detail
view on top of the full-page canvas, we can further
reduce the full-page canvas resolution to improve
rendering time without affecting the resolution seen by
the user.

Users will se the lower resolution when quickly scrolling around the
page, but it will then be replaced with the high-res
detail view.
2025-09-10 16:52:57 +02:00
Calixte Denizet
e1bdc34b4a Add an option in scrollIntoView and goToXY in order to be able to center vertically or horizontally the point XY in the viewer container 2025-09-09 13:10:49 +02:00
Nicolò Ribaudo
e4ea2e0c79
Store ops bboxes in a linear Uint8Array
This PR changes the way we store bounding boxes so that they use less
memory and can be more easily shared across threads in the future.

Instead of storing the bounding box and list of dependencies for each
operation that renders _something_, we now only store the bounding box
of _every_ operation and no dependencies list. The bounding box of
each operation covers the bounding box of all the operations affected
by it that render something. For example, the bounding box of a
`setFont` operation will be the bounding box of all the `showText`
operations that use that font.

This affects the debugging experience in pdfBug, since now the bounding
box of an operation may be larger than what it renders itself. To help
with this, now when hovering on an operation we also highlight (in red)
all its dependents. We highlight with white stripes operations that do
not affect any part of the page (i.e. with an empty bbox).

To save memory, we now save bounding box x/y coordinates as uint8
rather than float64. This effectively gives us a 256x256 uniform grid
that covers the page, which is high enough resolution for the usecase.
2025-09-09 10:24:48 +02:00
calixteman
b5113d9a74
Merge pull request #20239 from timvandermeij/integration-test-unskip-timezone
Unskip the `must check that date entered by the user is consistent` scripting integration test for Firefox
2025-09-08 22:35:18 +02:00
Tim van der Meij
3f0d39b024
Merge pull request #20244 from calixteman/fix_deleting_popup
[Editor] Fix saving a deleted popup
2025-09-08 21:23:47 +02:00
Tim van der Meij
512c30b1f6
Unskip the must check that date entered by the user is consistent scripting integration test for Firefox
Bug 1978027 has been fixed upstream 10 days ago, so this integration
test can be enabled for Firefox too now that it passed with recent
Nightly versions.
2025-09-08 20:48:24 +02:00
Calixte Denizet
2d5794f79d [Editor] Fix saving a deleted popup 2025-09-08 15:36:41 +02:00
Tim van der Meij
7f74fbf8fd
Fix block spacing inconsistencies in the integration test code
Most places have a newline before/after `before{Each,All}`,
`after{Each,All}` and `it` to visually separate the blocks for clarity,
but in a handful of places this wasn't done. This commit removes the
inconsistencies so that the test code is formatted consistently.
2025-09-07 14:39:52 +02:00
Tim van der Meij
cf5bffef2e
Use the getAnnotationSelector helper function more in the integration test code
The helper function was used in a number of places, but also a lot of
places contained the annotation selector string inline. This commit
makes sure that all places use `getAnnotationSelector` consistently to
make sure the annotation selector string is only defined in a single
place and to improve readability of the test code.
2025-09-07 14:39:52 +02:00
Tim van der Meij
c09ad5a2ce
Use the closePages helper function more in the integration test code
This test called `closeSinglePage` manually at the end of the test,
which is inconsistent with all other tests that call `closePages` in an
`afterEach` block. This commit fixes the difference for consistency.
2025-09-07 14:39:48 +02:00
Calixte Denizet
35c909843b Add a new function renderRichText to be used in the annotation layer
and which will be used in order to make the contents of the new popup used for comments.
2025-09-04 22:27:31 +02:00
Calixte Denizet
ca280399c2 [Editor] Use the color of the annotation for the background of the comment button 2025-09-02 21:17:08 +02:00
Calixte Denizet
0ec503e5ef Add a function changeLightness in order to change the lightness of a RGB color 2025-08-30 21:18:12 +02:00
Tim van der Meij
11d5d6d0ce
Skip the curvature ink editor integration test for Chrome on Windows
This test permafails for that particular OS/browser combination.

Fixes 18d3dc18.
2025-08-25 20:09:32 +02:00
Tim van der Meij
ab41f5095c
Merge pull request #20190 from timvandermeij/text-layer-permafail
Improve the selection check in the "doesn't jump when moving selection" integration test
2025-08-25 19:40:27 +02:00
Calixte Denizet
af144be3ba Don't iterate over all empty slots in the xref entries (bug 1980958) 2025-08-25 14:02:08 +02:00
Tim van der Meij
4cc93af364
Improve the selection check in the "doesn't jump when moving selection" integration test
Locally, on Arch Linux, this integration test permafails:

```
1) Text layer Text selection using selection carets doesn't jump when moving selection
  Message:
    second selection:
        Expected '(frequently executed) bytecode sequences, records
        them, and compiles them to fast native code. We call such a s' to roughly match /frequently .* We call such a se/s.
  Stack:
        at <Jasmine>
        at UserContext.<anonymous> (file:///home/timvandermeij/Documenten/Ontwikkeling/pdf.js/Code/test/integration/text_layer_spec.mjs:521:12)
  Message:
    third selection:
        Expected '(frequently executed) bytecode sequences, records
        them, and compiles them to fast native code. We call such a s' to roughly match /frequently .* We call such a se/s.
  Stack:
        at <Jasmine>
        at UserContext.<anonymous> (file:///home/timvandermeij/Documenten/Ontwikkeling/pdf.js/Code/test/integration/text_layer_spec.mjs:529:12
```

The exact selection can differ a bit per OS/browser. In this case the
last character was consistently not selected while on other platforms it
is, so this commit fixes the issue by relaxing the regex to not consider
the final character so that the test passes if the rest matches.
2025-08-24 20:46:20 +02:00
Tim van der Meij
18d3dc18e0
Use WebDriver BiDi for Chrome 2025-08-24 15:58:52 +02:00
calixteman
592d6c070a
Merge pull request #20179 from calixteman/add_rect_popup
[Editor] Add a Rect entry to a saved popup in order to avoid to have an invalid pdf
2025-08-24 12:01:31 +02:00
calixteman
cfe08bd035
Merge pull request #20184 from calixteman/use_cached_annotations
Use the cached annotations when collecting them by types
2025-08-24 11:57:17 +02:00
Nicolò Ribaudo
6a22da9c2e
Add logic to track rendering area of various PDF ops
This commit is a first step towards #6419, and it can also help with
first compute which ops can affect what is visible in that part of
the page.

This commit adds logic to track operations with their respective
bounding boxes. Only operations that actually cause something to
be rendered have a bounding box and dependencies.

Consider the following example:
```
0. setFillRGBColor
1. beginText
2. showText "Hello"
3. endText
4. constructPath [...] -> eoFill
```
here we have three rendering operations: the showText op (2) and the
path (4). (2) depends on (0), (1) and (3), while (4) only depends on
(0). Both (2) and (4) have a bounding box.

This tracking happens when first rendering a PDF: we then use the
recorded information to optimize future partial renderings of a PDF, so
that we can skip operations that do not affected the PDF area on the
canvas.

All this logic only runs when the new `enableOptimizedPartialRendering`
preference, disabled by default, is enabled.

The bounding boxes and dependencies are also shown in the pdfBug
stepper. When hovering over a step now:
- it highlights the steps that they depend on
- it highlights on the PDF itself the bounding box
2025-08-22 18:26:59 +02:00
Calixte Denizet
ebc3411727 Use the cached annotations when collecting them by types 2025-08-21 18:04:00 +02:00
Calixte Denizet
f8466c9ff8 [Editor] Add a Rect entry to a saved popup in order to avoid to have an invalid pdf 2025-08-20 17:56:50 +02:00
Calixte Denizet
9e5ee1e5a7 [Editor] Add the ability to get all the editable annotations in a pdf document
We want to be able to show all the comments in a pdf even if the pages where they are
haven't been rendered.
And it'll help to fix the issue #18915.
2025-08-18 21:31:11 +02:00
Tim van der Meij
844681a2fa
Disable AI/ML features using Firefox preferences for testing
We don't need AI/ML features in the tests, so this should reduce CPU
usage by not having the inference process running. Moreover, it prevents
the following lines from being logged in the test output:

```
JavaScript error: resource://gre/actors/MLEngineParent.sys.mjs, line 509: Error: Unable to get the ML engine from Remote Settings.
JavaScript error: resource://gre/actors/MLEngineParent.sys.mjs, line 1279: TypeError: can't access property "postMessage", this[#port] is null
```
2025-08-17 16:05:04 +02:00
Tim van der Meij
a05dc9c1c5
Remove obsolete Firefox preferences for testing
The following preferences don't have to be set manually anymore:

- `print.show_print_progress`
  - Why: removed
  - Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1770536
  - Commit: b522664310

- `gfx.offscreencanvas.enabled`
  - Why: removed
  - Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1914083
  - Commit: 7d2c688920

- `layout.css.round.enabled`
  - Why: removed
  - Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1874633
  - Commit: 97909653e7

- `dom.events.asyncClipboard.clipboardItem`
  - Why: enabled by default
  - Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1887845
  - Commit: de56ae88bf
2025-08-17 14:53:35 +02:00
Tim van der Meij
17dc9e9917
Skip the "must check that an existing highlight is ignored on hovering" integration test on Windows
This is a temporary measure to reduce noise until #20136 is fixed. Note
that this shouldn't be an issue in terms of coverage because we still
run the test on Linux.
2025-08-14 20:54:41 +02:00
Tim van der Meij
7294377cd9
Implement a delay for Chrome protocol calls in the integration tests
In Chrome protocol calls are faster than in Firefox and thus trigger in
quicker succession. This can cause intermittent failures because new
protocol calls can run before events triggered by the previous protocol
calls had a chance to be processed (essentially causing events to get
lost).

This commit fixes the issue by configuring Chrome with a protocol call
delay value that gives it a more similar execution speed as Firefox
(which also gives us more consistency between the two browser runs).

Note that this doesn't negatively impact the overall runtime of the
integration tests because Puppeteer already waits for a test to complete
in both browsers before continuing to the next one and Chrome
consistently was, and with this patch still slightly is, faster in
completing the tests.
2025-08-14 20:54:37 +02:00
Calixte Denizet
6a00174688 [Editor] Correctly hide deleted annotations 2025-08-13 22:41:19 +02:00
Calixte Denizet
1d4ae786f4 Check the setDash arguments
It fixes #20155.
2025-08-09 22:34:44 +02:00
calixteman
fcf69d8536
Merge pull request #20093 from Aditi-1400/fix-horizontal-scroll
Make horizontal padding relative to device width
2025-08-06 11:44:55 +02:00
Aditi
9babc144a7 Make horizontal padding relative to device width
The fixed -400px horizontal offset used by
scrollIntoView led to horizontal scroll only moving
part-way right on narrow screens. The highlights near
the right-edge remained party or completely off
screen.

This centres the highlighted match on any viewport width while
clamping the left margin to 20-400px. On very narrow screens
the scrollbar now moves all the way to the right instead of
stopping midway.
2025-08-04 15:29:52 +05:30
Calixte Denizet
a81e99168a [Editor] Highlight text on a selectionchange event which hasn't been triggered by the pointer or the keyboard (bug 1976597)
It's useful for users highlighting with NVDA.
They've to enable native selection and then selection some text.
In this case only a selectionchange is triggered once the selection is done.
2025-07-31 21:03:32 +02:00
calixteman
e5922f2e72
Merge pull request #20129 from calixteman/bug1978985
Disable printing when enablePermission is true and the pdf isn't allowed to be printed (bug 1978985)
2025-07-30 20:03:44 +02:00
Calixte Denizet
806f9c1cee Disable printing when enablePermission is true and the pdf isn't allowed to be printed (bug 1978985) 2025-07-30 19:29:01 +02:00