554 Commits
Author SHA1 Message Date
Calixte Denizet ce31961cb1 Start loading the viewer icons earlier in Firefox
The CSS only fetches an icon once its element is rendered, so the toolbar is
first painted without icons and the menus load theirs when first opened.

Preload the toolbar icons from viewer.html (without crossorigin, since CSS
images from resource:// are fetched without CORS), and warm the image cache
up with the icons of the hidden UI once the first page is rendered.
2026-11-08 22:23:25 +01:00
calixteman ac0bdfd892 Hide Nova toolbar items at wider breakpoints (bug 2084084)
Increase Nova's breakpoints from 750/690/560px to 880/800/700px
to accommodate its larger toolbar buttons.
2026-10-27 17:57:22 +01:00
Calixte Denizet f6fa4987c7 Use Canvas for toggled controls on LinkText in forced-colors mode (bug 2083002)
and inset toggled-button hover outlines in forced-colors mode
2026-10-21 09:51:35 +02:00
Calixte Denizet 18737825a2 Let Nova Tools menu rows shrink before scrolling (bug 2076522)
Allow rows to shrink without clipping wrapped labels. Include the
notification bar's height in the menu height limits.
2026-10-16 18:26:32 +02:00
Tim van der Meij 7c8b030f8e Merge pull request #22151 from calixteman/bug2071599-nova-toggled-text
Use Nova text color for toggled controls (bug 2071599)
2026-10-12 20:19:30 +02:00
Calixte Denizet 16a1946c78 Use the interactive border color for the Nova zoom select (bug 2071594)
Match Firefox's Nova select border color (bug 2065674).
2026-10-12 10:59:13 +02:00
Calixte Denizet e85d65a8e5 Use Nova text color for toggled controls (bug 2071599)
Use --text-color for toggled menu labels and findbar toggles instead of
--toolbarbutton-icon-fill. Keep icon colors and non-Nova styling unchanged.
2026-10-12 10:41:43 +02:00
Calixte Denizet 89b3bee995 Fit the Nova zoom select in the compact toolbar (bug 2075731)
In compact density the toolbar shrinks to 32px but the select kept its 32px
min-height, so its border overflowed and was clipped. Use the small button
size there, like the 24px toolbar buttons.
2026-10-09 16:34:58 +02:00
Calixte Denizet c989d4b6e9 Defer the Firefox features notification until after first-page rendering (bug 2072145)
The notification loaded moz-message-bar and its dependencies during
viewer startup. Updating --pfn-bar-height also animated
#viewerContainer's block-start offset because its transition covered all
properties.

Load and localize the notification after the first pagerendered event,
moving this work past pdfpaint's first-page timestamp. Limit the viewer
transition to inset-inline-start, and let the viewer start if
document.l10n.ready rejects in automation.
2026-09-18 17:16:10 +02:00
calixteman c65061e336 Merge pull request #21966 from jsimplicio/fix-pdfFeaturesNotification-border-radius
Fix unexpected border-radius on the pdfFeaturesNotification bar (bug 2071593)
2026-09-17 18:16:08 +02:00
jsimplicio bd3983bc9f Set border-radius: 0 on the pdfFeaturesNotification message-bar icon container (bug 2071593)
Zero out the start-side custom properties that control the icon
container's border-radius for #pdfFeaturesNotification, and add them
to the lint-mozcentral ignoreList.
2026-09-16 12:22:41 -05:00
Calixte Denizet dd934ced3d [Firefox] Remove the about:pdf href from the PDF features notification link (bug 2071624)
Content cannot load about:pdf, and the parent process already opens the
features page when the link is activated. The href only served the context
menu and middle clicks, which asked for an illegal load and crashed the
parent process on Nightly.

Without an href the <a> is neither focusable nor activated by Enter, hence
the tabindex, the role and the keydown handler.
2026-09-15 21:35:11 +02:00
Calixte Denizet fcea525640 Use moz-message-bar for the Firefox features notification (bug 2057608)
Bug 2066198 lets the PDF viewer load the moz-message-bar module from a
chrome: URL. Add the required CSP and localization entries, and preserve viewer
focus on dismissal.
2026-09-03 09:13:36 +02:00
Calixte Denizet fd8ed8422f Nova-ify the viewer (bug 2063405) 2026-08-14 17:20:05 +02:00
Calixte Denizet b4d028132b Sync the viewer chrome with the Firefox design system
The chrome is now authored against Firefox design-token names with the shipped
value as a fallback `var(--fx-token, <literal>)` so colors, borders and radii
follow Firefox instead of having to be re-synced by hand.

In MOZCENTRAL viewer.css imports chrome://global/skin/design-system/tokens-brand.css,
gated on the new pdfjs.enableNova pref (default false, read straight from CSS via -moz-pref()).
With the pref off the sheet isn't applied, every fallback resolves, and the
viewer renders as before, as it also does in the GENERIC and components builds,
which never see the chrome sheet.

Consuming a token means never declaring its name in an unlayered rule, which
would shadow Firefox's for the whole subtree; --focus-outline, --border-color and
--text-color/--button-border-color are therefore renamed to
--editor-selection-outline, --signature-border-color and --views-*. In forced
colors each state reads a matching background/foreground/border triple so it
can't collapse to a single system color.

The dialog button styling also moves out of `.dialog .mainContainer button` into
a shared .primaryButton/.secondaryButton primitive (buttons.css, imported from
pdf_viewer.css so the components build gets it too). The password,
document-properties, print and undo-bar buttons use it in place of .dialogButton,
and the custom radio appearance gives way to native controls tinted with
accent-color.
2026-07-30 23:13:43 +02:00
Calixte Denizet f195bec9b2 Add the Firefox features notification bar to the viewer (bug 2057608)
The bar itself (`<pdf-features-notification>`) ships from mozilla-central, so
the viewer only hosts it.

Finally the maximum number of preferences is raised to 60, to match the change
made in mozilla-central in bug 2056102, since this adds a 51st one.
2026-07-25 08:43:01 +02:00
Benjamin Beurdouche 34629bd2cf Deduplicate the signature-properties warn/error toolbar icon
The warn and error state badges shipped as byte-identical files (an
X-in-circle glyph). Drop the redundant
toolbarButton-signaturePropertiesWarn.svg and point the warn state at
the error icon instead; the amber-vs-red distinction is preserved via
background-color (--sig-icon-warn vs --sig-icon-error), not the glyph.
2026-07-02 23:00:08 +02:00
Benjamin Beurdouche 07b1c625e1 Add Digital signature properties verification panel
Adds a new "Digital signature properties" doorhanger to the pdf.js
toolbar that lists every digital signature found in the opened PDF,
verifies each one (via NSS in the Firefox build through a new chrome
bridge), and shows per-signature status + certificate state.

The viewer side parses /Sig dicts in the worker
(`PDFDocument.signatures`), strict-validates the /ByteRange offsets
before slicing, and ships only signature metadata across the worker
boundary. The PKCS#7 blob and signed-data byte spans live in a
worker-side map and are fetched lazily one signature at a time via
a new `getSignatureData(id)` RPC, immediately before verification
runs, so the bytes never sit in main-thread memory for the
document's lifetime.

The panel is feature-gated by `pdfjs.enableSignatureVerification`
(true in MOZCENTRAL/TESTING, off by default in the GENERIC build).
External services expose a `createSignatureVerifier()` factory that
the Firefox build wires up to `nsIX509CertDB.asyncVerifyPKCS7Object`;
GENERIC builds return null and the toolbar button stays hidden.

UI summary:
- Toolbar button states: loading dots while in flight, then green
  check, orange `!`, or red `✕` based on the worst aggregate
  signature status.
- Doorhanger contains a banner summarising the document state, then
  one card per signature with status row + certificate row (sub-
  signatures nested under their outer revision via /ByteRange
  containment).
- Icons are mono SVGs themed via `mask-image` + `background-color`
  so they pick up light/dark/HCM via `--sig-icon-*` vars; flipped
  under RTL via `scaleX(var(--dir-factor))`. The HCM mapping reuses
  the alt-text vocabulary (ButtonFace / ButtonText / ButtonBorder /
  GrayText / AccentColor / LinkText) so this panel reads the same
  as the rest of the editor toolbar in high-contrast mode.
- All visible strings are localized via Fluent
  (`pdfjs-digital-signature-properties-*`); status row, banner, and
  certificate row use explicit lookup tables instead of generated
  ids so a grep finds them.
- Esc + outside-click close the panel through the viewer's existing
  handlers; the manager exposes `isOpen`, `close()`, and
  `shouldCloseOnClick(target)` for that.

This commit also adds a `test/pdfs/sig_corpus/` directory holding a
Python generator that produces a corpus of signed PDFs covering
every visible state of the doorhanger (verified / untrusted /
expired / invalid / unknown / multi-signature variants). The corpus
is intentionally NOT part of the automated test suite — it is a
manual-test tool. Generated `.pdf` files are gitignored; only the
generator, README, and a `user.js.example` snippet are tracked.
The generator shells out to mozilla-central's
`security/manager/tools/pycms.py` (resolved via `--mozilla-central
<path>` or the `MOZILLA_CENTRAL_SRC` env var) and the embedded test
trust anchors (`pdf-sign-ca` / `pdf-sign-ca-expired`), gated by
`security.pdf_signature_verification.enable_test_trust_anchors` so
the test certificates never validate in shipping Firefox.
2026-06-30 13:25:09 +02:00
Calixte Denizet d8ea2afe47 Add support for Screen annotations playing embedded media
Screen annotations whose rendition action resolves to an embedded audio/video
file now play through the same play-button overlay as RichMedia.
Factor the shared resolution logic into a MediaAnnotation base (used by both RichMedia and Screen).

It fixes #6078 and #2787.
2026-06-23 20:48:35 +02:00
Calixte Denizet d537f5ba4b Add support for RichMedia annotations
Render `/Subtype /RichMedia` annotations so embedded video and audio can
be played in the viewer.

The core layer parses the `RichMediaContent` dictionary to locate the
primary playable asset and its MIME type. The display layer overlays a
play button on the annotation's poster; clicking it swaps in a
`<video>`/`<audio>` element backed by a `blob:` URL. Presentation mode
lets events reach the media controls instead of advancing the page.

It fixes #2787.
2026-06-22 21:27:52 +02:00
Calixte Denizet 94de952b65 Add a Content-Security-Policy to pdf.js' viewer.html (bug 1960363) 2026-05-14 12:50:07 +02:00
Calixte Denizet b263841584 Tweak the background color of the sidebar (bug 2010822)
And tweak its position as required by UX/UI.
2026-02-26 15:39:08 +01:00
Jonas Jenwald 385c936318 [api-minor] Update the minimum supported Google Chrome version to 118
This patch updates the minimum supported browsers as follows:
 - Google Chrome 118, which was released on 2023-10-10; see https://chromereleases.googleblog.com/2023/10/stable-channel-update-for-desktop_10.html

We haven't made any changes to the supported Google Chrome version for a year, and this change allows us to remove "hacks" needed to support `float: inline-start/inline-end` in old browsers; see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/float#browser_compatibility.

Note that nowadays we usually try, where feasible and possible, to support browsers that are about two years old. By limiting support to only "recent" browsers we reduce the risk of holding back improvements of the *built-in* Firefox PDF Viewer, and also (significantly) reduce the maintenance/support burden for the PDF.js contributors.

*Please note:* As always, the minimum supported browser version assumes that a `legacy`-build of the PDF.js library is being used; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2026-02-09 12:16:46 +01:00
calixteman 2367196a00 Change the sidebar for a views manager
Update the styles and HTML to reflect the new views manager concept.
For now, nothing about split/merge functionality is implemented or visible.
The new styles for the outline, attachments, and layers will be added later.

The thumbnail view is now accessible with the keyboard.
2025-12-15 17:43:52 +01:00
Calixte Denizet 3e59e7535d Move the css for tree object in its own file 2025-12-08 20:05:43 +01:00
Calixte Denizet f9b857463b Use HTMLElement.scrollIntoView when showing a thumbnail 2025-12-03 15:51:34 +01:00
Calixte Denizet 423379e42f Slightly reduce the memory used by thumbnails
In using a blob instead of a base64 string it's possible to reduce the memory.
And simplify a bit the thumbnails themselves.
2025-11-28 21:52:40 +01:00
Calixte Denizet a372294ea3 [Editor] Make the comment sidebar resizable (bug 1990544) 2025-09-25 15:29:41 +02:00
Calixte Denizet 25990e4287 [Editor] Add a sidebar allowing the user to navigate between the comments in a pdf (bug 1985567)
This implements what has been specified but it's still not done: we have to handle editing a comment
or an annotation containing one.
2025-08-29 16:00:06 +02:00
Calixte Denizet 5ed2dfbf26 [Editor] Change the icon for inline comments 2025-08-25 20:04:56 +02:00
Calixte Denizet ca4e219b7b [Editor] Make sure that doorhangers are large enough to fit localized strings
It fixes #20091.
2025-07-15 17:14:44 +02:00
Calixte Denizet c22a425b04 [Editor] When an annotation is added, announce it if the user is using a screen reader (bug 1975264) 2025-07-03 16:53:01 +02:00
Jonas Jenwald ae1cbc6a9e Use the light-dark CSS function in the viewer (issue 17780)
This removes the need for (most) separate `@media (prefers-color-scheme: dark)` blocks when defining colors values, and also provides a simple way of forcing use of either the light or dark theme.

Please refer to https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark and https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme

*NOTE:* To support this in older browsers, we utilize a [PostCSS plugin](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-light-dark-function).
2025-04-23 15:31:39 +02:00
Jonas Jenwald 8e7060158e Remove duplicate secondaryToolbar button mask-image definitions (PR 18385 follow-up)
It appears that all secondaryToolbar buttons currently have their `mask-image` definitions duplicated, which leads to larger than necessary CSS files.
2025-04-17 10:51:51 +02:00
Calixte Denizet cd94c19f9a [Editor] Fix the color of the labels in the editing doorhangers
The fix in #19522 wasn't correct.
This one should be better.
2025-02-20 19:31:57 +01:00
Calixte Denizet b7e65b854b [Editor] Make the editing toolbar buttons text visible when hovered in HCM with Desert theme (bug 1949417) 2025-02-20 15:01:52 +01:00
Calixte Denizet 6950a312aa Fix the color of the background button when hovering it 2025-02-11 20:15:17 +01:00
Tim van der Meij d2a07dcac6 Update dependencies to the most recent versions
Moreover, fix the linting issues (using `npx gulp lint --fix`) that are
found by the new versions of the linting tools.
2025-02-09 18:58:26 +01:00
Calixte Denizet 2f828c7bf4 [Editor] (WIP) Add a new tool in order to add an handwritten signature to a pdf (bug 1942343)
This patch is adding some code in order to extract a drawing as curves from an image.
The algorithm is basically the following:
 - reduce the dimensions
 - make it gray
 - apply a bilateral filter in order to add some blurryness while keeping the edges
 - compute the histogram
 - guess what's the background color which should contain a large majority of the pixels
 - make a binary image
 - extract the contours in using the Suzuki algorithm
 - apply the Douglas-Peucker algorithm in order to reduce the number of points

The algorithm is improvable but it should work pretty well if there's a clear difference between
the background and the drawing.
In a v2 we could use a ML model in order to improve the extraction.

There's few changes related to the UI in order to make the tool usable, but they're very basic
for the moment.
2025-01-29 21:52:14 +01:00
Jonas Jenwald 61e2eceff6 Ensure that the .toggleButton, as used in the findbar, always have visible hover/focus state (issue 19165)
Similar to the regular toolbarButtons that can be toggled, this ensure that it's always possible to tell when the findbar "buttons" are hovered/focused.
2024-12-05 13:07:57 +01:00
Calixte Denizet ca3b777b89 Set the padding of the buttons in the toolbars to zero
It fixes #19008.
In Firefox on mac, the default padding is set to 4px and with Firefox for iOS, it's set to 13px.
The padding is useless for such buttons.
2024-11-09 22:30:50 +01: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 https://github.com/mozilla/pdf.js/blob/17419de15709892935ece25ffd6af105a7e6814d/web/viewer.css#L1204-L1210
2024-10-20 21:15:09 +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