mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 20:37:21 +02:00
Compare commits
No commits in common. "2ed959d75ab04f67b3762655b82aa02a4086d62f" and "5e3d26601e95cb1da37e23729c63bc9fb40d8ecf" have entirely different histories.
2ed959d75a
...
5e3d26601e
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [20, 22, 24]
|
node-version: [20, 22, 23]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
|||||||
4
external/qcms/qcms.js
vendored
4
external/qcms/qcms.js
vendored
@ -235,7 +235,9 @@ async function __wbg_init(module_or_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof module_or_path === 'undefined') {
|
||||||
|
module_or_path = new URL('qcms_bg.wasm', import.meta.url);
|
||||||
|
}
|
||||||
const imports = __wbg_get_imports();
|
const imports = __wbg_get_imports();
|
||||||
|
|
||||||
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
||||||
|
|||||||
BIN
external/qcms/qcms_bg.wasm
vendored
BIN
external/qcms/qcms_bg.wasm
vendored
Binary file not shown.
@ -436,8 +436,14 @@ class SignatureExtractor {
|
|||||||
const isteps = Math.floor(steps);
|
const isteps = Math.floor(steps);
|
||||||
steps = steps === isteps ? isteps - 1 : isteps;
|
steps = steps === isteps ? isteps - 1 : isteps;
|
||||||
for (let i = 0; i < steps; i++) {
|
for (let i = 0; i < steps; i++) {
|
||||||
newWidth = Math.ceil(prevWidth / 2);
|
newWidth = prevWidth;
|
||||||
newHeight = Math.ceil(prevHeight / 2);
|
newHeight = prevHeight;
|
||||||
|
if (newWidth > maxDim) {
|
||||||
|
newWidth = Math.ceil(newWidth / 2);
|
||||||
|
}
|
||||||
|
if (newHeight > maxDim) {
|
||||||
|
newHeight = Math.ceil(newHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
const offscreen = new OffscreenCanvas(newWidth, newHeight);
|
const offscreen = new OffscreenCanvas(newWidth, newHeight);
|
||||||
const ctx = offscreen.getContext("2d");
|
const ctx = offscreen.getContext("2d");
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@ -27,9 +27,7 @@ import {
|
|||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
|
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
import fs from "fs";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { PNG } from "pngjs";
|
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
@ -585,90 +583,4 @@ describe("Signature Editor", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Check the aspect ratio (bug 1962819)", () => {
|
|
||||||
let pages, contentWidth, contentHeight;
|
|
||||||
|
|
||||||
function getContentAspectRatio(png) {
|
|
||||||
const { width, height } = png;
|
|
||||||
const buffer = new Uint32Array(png.data.buffer);
|
|
||||||
let x0 = width;
|
|
||||||
let y0 = height;
|
|
||||||
let x1 = 0;
|
|
||||||
let y1 = 0;
|
|
||||||
for (let i = 0; i < height; i++) {
|
|
||||||
for (let j = 0; j < width; j++) {
|
|
||||||
if (buffer[width * i + j] !== 0) {
|
|
||||||
x0 = Math.min(x0, j);
|
|
||||||
y0 = Math.min(y0, i);
|
|
||||||
x1 = Math.max(x1, j);
|
|
||||||
y1 = Math.max(y1, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
contentWidth = x1 - x0;
|
|
||||||
contentHeight = y1 - y0;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
const data = fs.readFileSync(
|
|
||||||
path.join(__dirname, "../images/samplesignature.png")
|
|
||||||
);
|
|
||||||
const png = PNG.sync.read(data);
|
|
||||||
getContentAspectRatio(png);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await closePages(pages);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("must check that the signature has the correct aspect ratio", async () => {
|
|
||||||
await Promise.all(
|
|
||||||
pages.map(async ([browserName, page]) => {
|
|
||||||
await switchToSignature(page);
|
|
||||||
await page.click("#editorSignatureAddSignature");
|
|
||||||
|
|
||||||
await page.waitForSelector("#addSignatureDialog", {
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.click("#addSignatureImageButton");
|
|
||||||
await page.waitForSelector("#addSignatureImagePlaceholder", {
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
await page.waitForSelector(`${addButtonSelector}:disabled`);
|
|
||||||
|
|
||||||
const input = await page.$("#addSignatureFilePicker");
|
|
||||||
await input.uploadFile(
|
|
||||||
`${path.join(__dirname, "../images/samplesignature.png")}`
|
|
||||||
);
|
|
||||||
await page.waitForSelector(`#addSignatureImage > path:not([d=""])`);
|
|
||||||
|
|
||||||
// The save button should be enabled now.
|
|
||||||
await page.waitForSelector(
|
|
||||||
"#addSignatureSaveContainer > input:not(:disabled)"
|
|
||||||
);
|
|
||||||
await page.click("#addSignatureAddButton");
|
|
||||||
await page.waitForSelector("#addSignatureDialog", {
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
const { width, height } = await getRect(
|
|
||||||
page,
|
|
||||||
".canvasWrapper > svg use[href='#path_p1_0']"
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(Math.abs(contentWidth / width - contentHeight / height))
|
|
||||||
.withContext(
|
|
||||||
`In ${browserName} (${contentWidth}x${contentHeight} vs ${width}x${height})`
|
|
||||||
)
|
|
||||||
.toBeLessThan(0.25);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user