24673 Commits
Author SHA1 Message Date
calixteman 857d643f46 Merge pull request #22622 from calixteman/text_layer_zoom
Zoom the text layer with CSS and only set a transform on the spans which need one
2026-11-30 14:54:29 +01:00
Jonas Jenwald cd60d8eba8 Merge pull request #22633 from Snuffleupagus/issue-22630
Validate the /BitsPerCoordinate, /BitsPerComponent, and /BitsPerFlag parameters in MeshShadings (issue 22630)
2026-11-30 14:36:22 +01:00
Calixte Denizet 34246a0b6f Zoom the text layer with CSS and only set a transform on the spans which need one
The span font sizes are in page units and the transform is only set when the
span is rotated, skewed or scaled, which makes the layout cheaper.
The free highlight box comes from the editor layer: with the pre-standard CSS
zoom (Chrome < 128, Safari 18), the zoomed text layer client rect is scaled.
2026-11-30 13:45:33 +01:00
Jonas Jenwald 1ba3c49cce Validate the /BitsPerCoordinate, /BitsPerComponent, and /BitsPerFlag parameters in MeshShadings (issue 22630)
Note https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G7.3882949
2026-11-30 13:23:30 +01:00
calixteman 9e2f31c843 Merge pull request #22620 from calixteman/bug2088921
Keep editors upright when dragging between pages (bug 2088921)
2026-11-29 20:49:48 +01:00
Jonas Jenwald de63a84665 Merge pull request #22624 from Snuffleupagus/outline-pagesedited-reset
Reset the `pageNumberToDestHash` Map, in the outline, when the pages are edited
2026-11-29 20:20:51 +01:00
Jonas Jenwald 198220539a Reset the pageNumberToDestHash Map, in the outline, when the pages are edited
Given that page-editing will change the pageNumber mapping, we cannot keep the `pageNumberToDestHash` Map since that may cause the `currentOutlineItem` functionality to highlight the wrong outline-item.

Additionally, ensure that the `#getPageNumberToDestHash` method will always resolve its capability since previously e.g. closing of a document could leave promises pending indefinitely.
2026-11-29 19:31:02 +01:00
Jonas Jenwald 98d2c6674e Merge pull request #22621 from Snuffleupagus/currentOutlineItem-lazy-page-init
Fix the `currentOutlineItem` functionality when pages are initialized lazily
2026-11-29 19:30:27 +01:00
calixteman 31fefbf113 Restore editor page geometry when undoing or redoing a drag
Restore the saved page dimensions, origin, and rotation when the page
layer is absent. Adjust positions for zoom-dependent drawing padding
and replay moves without clamping again.
2026-11-29 18:57:44 +01:00
calixteman 13488cd659 Keep editors upright when dragging between pages (bug 2088921)
Use each editor's current page rotation to convert drag deltas and
remap its position through screen coordinates when switching pages.
Update the page origin, preserve the editor's size, and compensate for
rotation changes where supported. Reject pages that are too small.
2026-11-29 18:52:54 +01:00
calixteman b952a35894 Share editor positioning and ink outline helpers
Reuse rotation and zoom helpers. Build ink SVG updates in one place
and refresh the path transform after translation.
2026-11-29 18:50:45 +01:00
calixteman 62f8448934 Merge pull request #22617 from calixteman/text_layer_kerning
Add the kerning of the PDF glyphs to the text layer fonts
2026-11-29 15:33:20 +01:00
Calixte Denizet b4390e4220 Add an test to check that the text layer font passes OTS 2026-11-29 15:16:35 +01:00
Calixte Denizet 2477bb1aed Add the kerning of the PDF glyphs to the text layer fonts
The pairs adjusted the same way are kerned in the generated font, so the
characters of a span stay at their PDF position. The highlights are painted
with a box shadow to avoid breaking the kerning.
2026-11-29 15:04:20 +01:00
Jonas Jenwald f03c33a088 Fix the currentOutlineItem functionality when pages are initialized lazily
For PDFs with more than `PagesCountLimit.FORCE_LAZY_PAGE_INIT` pages, currently set at 5000, pages are initialized lazily to improve performance.
This causes finding/highlighting of the current outline-item to not work correctly, hence we need to fallback to the `getPageIndex` API-method.

**Steps to reproduce:**
 - Open a PDF with more than 5000 pages, e.g. https://www.cs.princeton.edu/courses/archive/fall19/cos217/reading/ArmArchitectureReferenceManual.pdf#pagemode=outline
 - Goto the last page.
 - Click on the "Find Current Outline Item" button.

**Expected behaviour:**
The *last* outline-item is scrolled into view and highlighted.

**Actual behaviour:**
The *first* outline-item is highlighted, when testing in `master`.
2026-11-29 14:55:09 +01:00
calixteman eb8b817fde Merge pull request #22618 from calixteman/fix-issue-22616
Fix function-based shading scaled by the CTM
2026-11-28 17:09:21 +01:00
Calixte Denizet b29564d94c Fix function-based shading scaled by the CTM
A function-based shading was sampled at one step per user-space unit of
its own matrix, so a unit domain scaled up by the CTM, a form matrix or
a pattern matrix was drawn with a single cell.
The sampling grid is now computed from the transform the shading is
painted with, and the generated meshes are cached per grid size.

The setFillColorN/setStrokeColorN cases are merged so the base transform
is only passed in one place.

The software mesh rasterizer now clamps triangles to the canvas, so
pixels on the right edge no longer wrap into the next row.

It fixes #22616.
2026-11-28 16:36:15 +01:00
Jonas Jenwald 9548d30dd4 Merge pull request #22615 from Snuffleupagus/inline-loadPDFBug
Inline the `loadPDFBug` helper function (PR 22607 follow-up)
2026-11-27 22:13:32 +01:00
Jonas Jenwald e2a1f3647f Merge pull request #22613 from Snuffleupagus/rm-opt-minDurationToUpdateCanvas
[api-minor] Remove the `minDurationToUpdateCanvas` viewer option
2026-11-27 22:10:24 +01:00
Jonas Jenwald 8f53fe1989 [api-minor] Remove the minDurationToUpdateCanvas viewer option
With worker-rendering enabled this option is not needed, hence move it to a shadowed getter in `BasePDFPageView` and remove it from various viewer-components respectively the `AppOptions`.
2026-11-27 14:17:32 +01:00
Jonas Jenwald fad8fcc3ad Inline the debuggerSrc definition in the viewer
It really doesn't seem necessary for this to be an `AppOptions`, when it's never loaded by default and only used for development/debugging purposes.
2026-11-27 14:05:29 +01:00
Jonas Jenwald 0d27521427 Inline the loadPDFBug helper function (PR 22607 follow-up)
After PR 22607 this function only has a single call-site, hence it can just be inlined instead.
2026-11-27 14:00:20 +01:00
calixteman e530237a48 Merge pull request #22607 from calixteman/text_layer_glyph_runs
[api-major] Build the text layer items from the runs of glyphs drawn on the same baseline
2026-11-27 13:54:32 +01:00
Calixte Denizet 86d659b564 [api-major] Replace the getTextContent options with enableMarkedContent and enableNormalization
Both are true by default, which is what the viewer mostly uses.
2026-11-27 13:39:55 +01:00
Calixte Denizet 487aed7102 Use #textLayer=visible to draw the glyph boxes of the text layer fonts
The viewer gets debugTextLayerFonts from the page loading params, and the
"shadow" and "hover" debugging modes are removed.
2026-11-27 13:39:55 +01:00
Calixte Denizet 3c0c300a38 Use the d1 bounds of the Type3 glyphs for the ascent of the text layer fonts
The FontBBox can be a placeholder, e.g. [0 0 1000 1000] with a flipped font
matrix, which put the spans below the glyphs (bug 1245391).
2026-11-27 13:39:55 +01:00
Calixte Denizet 5a21695c4a Remove the old text content extraction
Annotation text and the highlight intersector now use the glyph runs too, so
the old item builder in the evaluator is gone.
Also make debugTextLayerFonts a getDocument option, and copy-all split the
text like the text layer.
2026-11-27 13:39:55 +01:00
Calixte Denizet 2e39fea37e Build the text layer items from the runs of glyphs drawn on the same baseline
Group glyphs with the same baseline, font and transform into runs. Infer
word spaces from the positions and tracking within each run, and split
runs into spans at wide gaps.

Compute span advances in the worker from the generated font metrics so
the text layer can lay out simple spans without measuring them. Find
uses the same extracted items as the text layer.
2026-11-27 13:39:55 +01:00
Calixte Denizet 5b1be07686 [api-major] Always include generated fonts in page text content 2026-11-27 13:39:55 +01:00
calixteman a2b1756760 Merge pull request #22611 from mozilla/update-locales
l10n: Update locale files
2026-11-27 08:53:00 +01:00
github-actions[bot] dbe0a2565b l10n: Update locale files 2026-11-27 00:20:53 +00:00
Tim van der Meij e473982703 Merge pull request #22609 from calixteman/issue22602
Use the default value for text fields only on reset
2026-11-26 21:19:02 +01:00
Tim van der Meij dda30e5bd8 Merge pull request #22608 from Snuffleupagus/TextLayer-#appendText-reuse-TX
Re-use a single transform TypedArray in all `TextLayer.prototype.#appendText` invocations
2026-11-26 21:13:28 +01:00
Calixte Denizet b6dea1c1a6 Use the default value for text fields only on reset
It fixes #22602
2026-11-26 18:35:31 +01:00
Jonas Jenwald 05fc1327ca Re-use a single transform TypedArray in all TextLayer.prototype.#appendText invocations
Also, change the `#transform` field to a TypedArray for consistency with the textItem-transform (since PR 22598 changed its type).
2026-11-26 14:06:58 +01:00
calixteman ac7d3717e4 Merge pull request #22601 from calixteman/fix/chrome-marked-content-selection
Allow Chrome text selection to end one character earlier
2026-11-26 10:42:11 +01:00
Calixte Denizet bf490904ba Allow Chrome text selection to end one character earlier 2026-11-26 09:44:35 +01:00
calixteman 808186117c Merge pull request #22589 from calixteman/bug2091402
Don't generate a Hellbox fallback when a system font covers the glyphs (bug 2091402)
2026-11-25 22:43:05 +01:00
calixteman 908c0ffa1a Merge pull request #22598 from calixteman/text-matrix-allocation
[api-minor] Reduce matrix allocations during text extraction
2026-11-25 22:26:36 +01:00
Calixte Denizet f87060e41b [api-minor] Reduce matrix allocations during text extraction
TextItem.transform is now a Float32Array.
2026-11-25 22:20:48 +01:00
Calixte Denizet 11d84b6f5e Don't generate a Hellbox fallback when a system font covers the glyphs (bug 2091402)
Probe the installed substitute in the worker and cache coverage for each requested glyph. Generate the fallback when a glyph is missing or coverage cannot be verified.
2026-11-25 10:26:54 +01:00
calixteman 98100629a8 Merge pull request #22593 from calixteman/bidi_hebrew_presentation_forms
Get the bidi classes and mirroring from the Unicode data
2026-11-25 08:54:49 +01:00
Calixte Denizet c0fe85c05a Mirror the RTL characters in bidi()
The text is in visual order, so e.g. a ')' at an RTL level is a '(' in the
logical text. A glyph is only mirrored when its shape, from the glyph names or
the cmap of the font or else from the encoding, is its ToUnicode character,
since a ToUnicode map can already give the logical one.
Also stop removing '<' and '>', a leftover from 2012.
2026-11-24 22:43:08 +01:00
Calixte Denizet 6dbf5a89aa Get the bidi classes from the Unicode data in bidi()
The hand-written ranges gave a wrong class to many characters (e.g. ₪, €,
punctuation, Hebrew presentation forms, U+FEFF), hence a wrong reordering in
the text layer and in find. The table is generated from DerivedBidiClass.txt,
and surrogate pairs are now kept together.
2026-11-24 22:34:12 +01:00
calixteman 3471ae1691 Merge pull request #22591 from calixteman/text_layer_type3_fonts
Improve the text layer fonts of Type 3 fonts
2026-11-24 18:52:43 +01:00
Calixte Denizet 5ec739bca3 Improve the text layer fonts of Type 3 fonts
- Encode the advances which don't fit in the font with the smallest power of
  two scale, and fit even a single glyph of such a font.
- Express the advances and space gaps of a font sized by its bbox in the em of
  the span, whose height is the bbox height.
- Keep the baseline of a drawing on an edge of the bbox, and don't flip the
  bbox twice when the span height already carries the flip.
- Measure the inferred spaces in the em of the text state which moved the
  text, and skip the gaps whose em is unknown.
2026-11-24 18:05:12 +01:00
Nicolò Ribaudo 9a55723636 Merge pull request #22321 from nicolo-ribaudo/silence-errors-destroyed-document
Suppress more errors due to closed documents
2026-11-24 17:57:05 +01:00
Nicolò Ribaudo ce052f009a Reject pagesCapability when the document is closed
This is so that those promises don't remain pending forever, and their
callers can clean up associated resources.
2026-11-24 15:57:43 +01:00
Nicolò Ribaudo b982ac42e4 Suppress more errors due to closed documents
Closing/switching the document in the viewer will cause multiple
tasks to fail. Other code paths already have
`if (pdfDocument !== this.pdfDocument) return;` checks to know if the
document has been changed after an async step, but it was missing in
some places leading to errors being logged in the console.

This commit adds the check in those places.
2026-11-24 15:57:14 +01:00
calixteman 32fb05b3b7 Merge pull request #22588 from calixteman/perf/document-scoped-image-options
Scope the image options to each document
2026-11-23 17:42:18 +01:00