1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 07:08:08 +02:00
Commit graph

19839 commits

Author SHA1 Message Date
Jonas Jenwald
5be66580e6
Merge pull request #18448 from Snuffleupagus/AppOptions-more-browser-params
Include additional data when fetching browser preferences in the PDF Viewer (bug 1908401)
2024-07-18 14:19:50 +02:00
Jonas Jenwald
31f247fe43
Merge pull request #18453 from Snuffleupagus/issue-18408
Allow /XYZ destinations without zoom parameter (issue 18408)
2024-07-18 13:32:51 +02:00
Jonas Jenwald
d24a61c648 Allow /XYZ destinations without zoom parameter (issue 18408)
According to the PDF specification these destinations should have a zoom parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870

Hence we try to work-around bad PDF generators by making the zoom parameter optional when validating explicit destinations in both the worker and the viewer.
2024-07-18 13:29:32 +02:00
calixteman
e1f64a5b3e
Merge pull request #18449 from calixteman/bug1908483
Add the possibility to change some pdfjs preferences from the viewer (bug 1908483)
2024-07-18 10:19:50 +02:00
Calixte Denizet
6cc32b699f Add the possibility to change some pdfjs preferences from the viewer (bug 1908483) 2024-07-18 09:52:10 +02:00
Jonas Jenwald
99f34f4c2e Include additional data when fetching browser preferences in the PDF Viewer (bug 1908401)
To avoid having to request and await various browser data early during the PDF Viewer initialization, we can include that data in the existing preference fetching instead. With other planned changes to the PDF Viewer, the current situation would only become worse over time.

*Note:* Technically this data aren't preference-values, however we're already including other non-prefs in this list (e.g. `isInAutomation`) and doing it this way simplifies the overall implementation.
2024-07-17 16:57:55 +02:00
calixteman
15b71b82ed
Merge pull request #18445 from calixteman/issue18444
Remove active smask when restoring the initial canvas state
2024-07-17 15:36:04 +02:00
Calixte Denizet
37db3a7143 Remove active smask when restoring the initial canvas state
Fixes #18444.
2024-07-17 14:20:50 +02:00
Jonas Jenwald
86eb5ba700
Merge pull request #18441 from Snuffleupagus/api-rm-Outliner
[api-minor] Remove `Outliner` from the official API
2024-07-16 14:32:07 +02:00
calixteman
e190cebf92
Merge pull request #18440 from calixteman/fix_add_highlight
[Editor] When in non-editing mode, add a new editor only once the editing mode has switched
2024-07-16 13:50:40 +02:00
Jonas Jenwald
8a979c2d0e [api-minor] Remove Outliner from the official API
As far as I can tell `Outliner` is only exposed in the API because we need to access it when running some of the reference-tests, but is otherwise not used.
Hence this seems like something that should be kept *internal* and thus only exposed in TESTING-builds.
2024-07-16 13:08:26 +02:00
Calixte Denizet
6dd75c0e62 [Editor] When in non-editing mode, add a new editor only once the editing mode has switched
Switching to an editing mode can be asynchronous (e.g. if an editable annotation exists on a
visible page), so we must add a new editor only when the page rendering is done.
2024-07-15 21:04:52 +02:00
Jonas Jenwald
f9e3b6bcc4
Merge pull request #18430 from Snuffleupagus/pr-18417-followup
Fix `DOMFilterFactory.#createUrl` in MOZCENTRAL builds (18417 PR follow-up)
2024-07-15 15:05:35 +02:00
Jonas Jenwald
4c45948bc4 Fix DOMFilterFactory.#createUrl in MOZCENTRAL builds (18417 PR follow-up)
Somehow I managed to mess up the URL creation relevant to e.g. MOZCENTRAL builds, which is breaking the pending PDF.js update in mozilla-central; sorry about that!

To avoid future issues, we'll now always check if absolute filter-URLs are necessary regardless of the build-target.
2024-07-15 14:10:59 +02:00
calixteman
87e74a753b
Merge pull request #18429 from calixteman/bug1907207
[Editor] Add an option to use the new 'add an image' flow (bug 1907207)
2024-07-15 13:58:08 +02:00
Tim van der Meij
5059187fff
Merge pull request #18434 from timvandermeij/pdfjs-dist
Remove obsolete `pdfjs-dist` code from the Gulpfile
2024-07-13 20:28:30 +02:00
Tim van der Meij
08967a5cd3
Merge pull request #18433 from timvandermeij/contile
Disable network connections to Contile for the tests
2024-07-13 20:28:07 +02:00
Tim van der Meij
1c5c5da12e
Remove obsolete pdfjs-dist code from the Gulpfile
The Git logic for pushing to the `pdfjs-dist` repository was already
removed in PR #18350, but it was forgotten to also remove the logic to
create a Git repository in the first place. This commit fixes the open
action for that from
https://github.com/mozilla/pdf.js/pull/18358#discussion_r1661367441.

Moreover, we implement the suggestion from
https://github.com/mozilla/pdf.js/pull/18358#discussion_r1661364026
about moving the Git URL to a separate variable for consistency and we
update the homepage URL to the HTTPS scheme to avoid an HTTP -> HTTPS
redirect and enforce TLS-encrypted connections.
2024-07-13 19:49:28 +02:00
Tim van der Meij
aea409d8cb
Disable network connections to Contile for the tests
In PR #18356 the new tab page logic was disabled to prevent Firefox
from logging failed network connections to Contile, the Mozilla Tiles
service that is used for the new tab page [1]. However, recently this
log reappeared locally and on the bots:

```
console.warn: TopSitesFeed: Failed to fetch data from Contile server:
NetworkError when attempting to fetch resource.
```

It looks like Contile communication is also triggered from other places
in Firefox such as the URL bar [2], so this commit fixes the issue by
disabling network connections to Contile [3] altogether regardless of
their origin within Firefox. Note that we don't revert the change from
PR #18356 because as noted in [4] it can't hurt to keep that disabled
too to avoid overhead for a feature we don't use in the tests.

[1] https://github.com/mozilla-services/contile
[2] 196ef8360e/browser/components/urlbar/UrlbarProviderTopSites.sys.mjs (L38)
[3] 196ef8360e/browser/components/newtab/lib/TopSitesFeed.sys.mjs (L111)
[4] https://github.com/mozilla/pdf.js/pull/18356#issuecomment-2200354730
2024-07-13 18:29:32 +02:00
Tim van der Meij
07c58aa23a
Merge pull request #18432 from timvandermeij/updates
Update dependencies to the most recent versions and update the JS/CSS files for the new Prettier/Stylelint versions
2024-07-13 17:35:05 +02:00
Tim van der Meij
c77b97daff
Update the JS/CSS files for the new Prettier/Stylelint versions 2024-07-13 16:29:47 +02:00
Tim van der Meij
49eba2f892
Update dependencies to the most recent versions 2024-07-13 16:06:32 +02:00
Calixte Denizet
dfccc8ffd9 [Editor] Add an option to use the new 'add an image' flow (bug 1907207)
UX team designed in a new flow we'll implement soon and we want to be able to
make an experiment to be able to compare current flow vs the new one.
2024-07-12 16:28:48 +02:00
calixteman
2d254375a8
Merge pull request #18424 from calixteman/avoid_hovering_when_selecting
[Editor] Disable existing highlights when drawing a new one (bug 1879035)
2024-07-12 09:22:18 +02:00
Calixte Denizet
4e7c30da9a [Editor] Disable existing highlights when drawing a new one (bug 1879035)
When the mouse was hovering an existing highlight, all the text in the page
was selected.
So when the user is selecting some text or drawing a free highlight, the mouse
is disabled for the existing editors.
2024-07-11 21:34:28 +02:00
calixteman
df5bc544df
Merge pull request #18425 from calixteman/bug1879104
[Editor] Make editor toolbars usable whatever their z-index (bug 1879104)
2024-07-11 19:03:03 +02:00
Calixte Denizet
9a64749dbe [Editor] Make editor toolbars usable whatever their z-index (bug 1879104)
Because of editor z-index, the toolbar belonging to an highlight created
before a second adjacent one, can be overlapped by this new one.
So when the user select an editor we just show it on front of all the other
ones to make sure that it can be used normally.
2024-07-11 18:00:42 +02:00
Jonas Jenwald
acc70ce0b7
Merge pull request #18423 from Snuffleupagus/rm-setZoomDisabledTimeout
Remove the remaining `zoomDisabledTimeout` usage (issue 17727)
2024-07-11 13:41:57 +02:00
Jonas Jenwald
8082c2daf1
Merge pull request #18417 from Snuffleupagus/DOMFilterFactory-baseUrl
Create absolute filter-URLs when needed in `DOMFilterFactory` (issue 18406)
2024-07-11 12:25:16 +02:00
Jonas Jenwald
6b47ddd4d5 Remove the remaining zoomDisabledTimeout usage (issue 17727)
With https://bugzilla.mozilla.org/show_bug.cgi?id=1882168 now marked as fixed by the landing of https://bugzilla.mozilla.org/show_bug.cgi?id=1902017 we should *hopefully* be able to remove this work-around.
2024-07-11 12:17:41 +02:00
Jonas Jenwald
50a5a15088 Create absolute filter-URLs when needed in DOMFilterFactory (issue 18406)
This functionality is purposely limited to development mode and GENERIC builds, since it's unnecessary in e.g. the *built-in* Firefox PDF Viewer, and will only be used when a `<base>`-element is actually present.

*Please note:* We also have tests in mozilla-central that will *indirectly* ensure that relative filter-URLs work as intended in the Firefox PDF Viewer, see https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/test/browser_pdfjs_filters.js

---

To test that the issue is fixed, the following code can be used:

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <base href=".">
  <title>base href (issue 18406)</title>
</head>
<body>

<ul>
  <li>Place this code in a file, named `base_href.html`, in the root of the PDF.js repository</li>
  <li>Run <pre>npx gulp dist-install</pre></li>
  <li>Run <pre>npx gulp server</pre></li>
  <li>Open <a href="http://localhost:8888/base_href.html">http://localhost:8888/base_href.html</a> in a browser</li>
  <li>Compare rendering with <a href="http://localhost:8888/web/viewer.html?file=/test/pdfs/issue16287.pdf">http://localhost:8888/web/viewer.html?file=/test/pdfs/issue16287.pdf</a></li>
</ul>

<canvas id="the-canvas" style="border: 1px solid black; direction: ltr;"></canvas>

<script src="/node_modules/pdfjs-dist/build/pdf.mjs" type="module"></script>

<script id="script" type="module">
  //
  // If absolute URL from the remote server is provided, configure the CORS
  // header on that server.
  //
  const url = '/test/pdfs/issue16287.pdf';

  //
  // The workerSrc property shall be specified.
  //
  pdfjsLib.GlobalWorkerOptions.workerSrc =
    '/node_modules/pdfjs-dist/build/pdf.worker.mjs';

  //
  // Asynchronous download PDF
  //
  const loadingTask = pdfjsLib.getDocument(url);
  const pdf = await loadingTask.promise;
  //
  // Fetch the first page
  //
  const page = await pdf.getPage(1);
  const scale = 1.5;
  const viewport = page.getViewport({ scale });
  // Support HiDPI-screens.
  const outputScale = window.devicePixelRatio || 1;

  //
  // Prepare canvas using PDF page dimensions
  //
  const canvas = document.getElementById("the-canvas");
  const context = canvas.getContext("2d");

  canvas.width = Math.floor(viewport.width * outputScale);
  canvas.height = Math.floor(viewport.height * outputScale);
  canvas.style.width = Math.floor(viewport.width) + "px";
  canvas.style.height = Math.floor(viewport.height) + "px";

  const transform = outputScale !== 1
    ? [outputScale, 0, 0, outputScale, 0, 0]
    : null;

  //
  // Render PDF page into canvas context
  //
  const renderContext = {
    canvasContext: context,
    transform,
    viewport,
  };
  page.render(renderContext);
</script>

</body>
</html>
```
2024-07-11 11:30:45 +02:00
calixteman
9b1b5ff7e7
Merge pull request #18419 from calixteman/reuse_old_dict_when_updating
[Editor] Update the freetext annotation dictionary instead of creating a new one when updating an existing freetext
2024-07-11 11:24:15 +02:00
Jonas Jenwald
e8d35c25ee
Merge pull request #18412 from Snuffleupagus/issue-18059
Also update the width/unicode data when replacing missing glyphs in non-embedded Type1 fonts (issue 18059)
2024-07-11 10:52:17 +02:00
Jonas Jenwald
b56e4209a9
Merge pull request #18421 from Snuffleupagus/bug-1907000
Allow e.g. /FitH destinations without additional parameter (bug 1907000)
2024-07-11 10:51:44 +02:00
Calixte Denizet
6711123f68 [Editor] Update the freetext annotation dictionary instead of creating a new one when updating an existing freetext 2024-07-11 10:44:21 +02:00
Jonas Jenwald
403d023617 Allow e.g. /FitH destinations without additional parameter (bug 1907000)
According to the PDF specification these destinations should have a coordinate parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870

Hence we try to work-around bad PDF generators by making the coordinate parameter optional when validating explicit destinations in both the worker and the viewer.
2024-07-11 10:36:44 +02:00
Tim van der Meij
cf58113e8c
Merge pull request #18416 from razh/ensureMinimumFontSize-body-flex
Fix `ensureMinFontSizeComputed` calculation if `<body>` is a flex container
2024-07-10 16:17:26 +02:00
razh
665fff020e Fix ensureMinFontSizeComputed calculation if <body> is a flex container
Given:

```css
html,
body {
  height: 100%;
}

body {
  display: flex;
}
```

The `<div>` appended to the `<body>` will take up the full height of the
viewport due to the implicit `align-items: stretch` of flex containers.

This results in an incorrect computed `minFontSize` value.
2024-07-10 08:41:09 -04:00
calixteman
b1bf8b4979
Merge pull request #18418 from calixteman/wait_for_rendering
[Editor] Wait for 'pagerendered' to switch to editing mode
2024-07-10 12:18:21 +02:00
Calixte Denizet
d27efb43cd [Editor] Wait for 'pagerendered' to switch to editing mode
The focus can potentially be stolen when the DOM is modified when adding
a new canvas element for the page being redrawn.
2024-07-10 11:29:42 +02:00
Tim van der Meij
7ffea2f02a
Merge pull request #18413 from Snuffleupagus/BasePreferences-AppOptions-wrapper
Re-factor `BasePreferences` to essentially be a wrapper around `AppOptions`
2024-07-09 23:09:09 +02:00
Jonas Jenwald
d9f0ec0b87 Re-factor BasePreferences to essentially be a wrapper around AppOptions
In the MOZCENTRAL build the `BasePreferences` class is almost unused, since it's only being used to initialize and update the `AppOptions` which means that theoretically we could move the relevant code there.
However for the other build targets (e.g. GENERIC and CHROME) we still need to keep the `BasePreferences` class, although we can re-factor things to move the necessary validation inside of `AppOptions` and thus simplify the code and reduce duplication.

The patch also moves the event dispatching, for changed preference values, into `AppOptions` instead.
2024-07-09 22:49:59 +02:00
Jonas Jenwald
56653e5770 Also update the width/unicode data when replacing missing glyphs in non-embedded Type1 fonts (issue 18059)
*Please note:* This causes a little bit of movement in the `issue2770` test-case, however this matches the rendering in both Adobe Reader and PDFium.
2024-07-09 09:41:01 +02:00
Jonas Jenwald
f9d63201eb Revert "Remove the unused Font.prototype.spaceWidth getter (PR 13424 follow-up)"
This reverts commit 4aee67227e.
2024-07-09 09:28:10 +02:00
Jonas Jenwald
7ffa9a283d Extend test-coverage for non-embedded Type1 fonts where .notdef glyphs are replaced with spaces 2024-07-09 09:12:09 +02:00
Tim van der Meij
1bdd6920ff
Merge pull request #17962 from calixteman/chrome_bidi
Use BiDi protocol for Chrome tests
2024-07-07 22:07:29 +02:00
Calixte Denizet
5bfe759574 Use BiDi protocol for Chrome tests 2024-07-07 17:12:00 +02:00
calixteman
2a125bd0f0
Merge pull request #18405 from timvandermeij/intermittent-waitforscripting
Introduce a `waitForScripting` helper function and use it in all scripting integration tests
2024-07-07 14:13:32 +02:00
Tim van der Meij
b540b6333f
Introduce a waitForScripting helper function and use it in all scripting integration tests
Code inspection uncovered that quite a few integration tests don't wait
for scripting to be ready before proceeding, which is a source of
intermittent failures, especially on slower machines where e.g. creating
the sandbox takes longer.

This commit fixes the issues by introducing a `waitForScripting` helper
function and calling it consistently in all scripting integration tests.
2024-07-06 19:29:45 +02:00
Jonas Jenwald
5ee61690f3
Merge pull request #18390 from alexcat3/fix-issue-18099
Handle toUnicode cMaps that omit leading zeros in hex encoded UTF-16 (issue 18099)
2024-07-06 18:57:07 +02:00