parent
a1b45d6e69
commit
3f23bcbecc
@ -659,11 +659,7 @@ class AnnotationEditor {
|
|||||||
parentScale,
|
parentScale,
|
||||||
pageDimensions: [pageWidth, pageHeight],
|
pageDimensions: [pageWidth, pageHeight],
|
||||||
} = this;
|
} = this;
|
||||||
const scaledWidth = pageWidth * parentScale;
|
return [pageWidth * parentScale, pageHeight * parentScale];
|
||||||
const scaledHeight = pageHeight * parentScale;
|
|
||||||
return FeatureTest.isCSSRoundSupported
|
|
||||||
? [Math.round(scaledWidth), Math.round(scaledHeight)]
|
|
||||||
: [scaledWidth, scaledHeight];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -553,7 +553,6 @@ class StampEditor extends AnnotationEditor {
|
|||||||
const [parentWidth, parentHeight] = this.parentDimensions;
|
const [parentWidth, parentHeight] = this.parentDimensions;
|
||||||
this.width = width / parentWidth;
|
this.width = width / parentWidth;
|
||||||
this.height = height / parentHeight;
|
this.height = height / parentHeight;
|
||||||
this.setDims(width, height);
|
|
||||||
if (this._initialOptions?.isCentered) {
|
if (this._initialOptions?.isCentered) {
|
||||||
this.center();
|
this.center();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import {
|
|||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForStorageEntries,
|
waitForStorageEntries,
|
||||||
|
waitForTimeout,
|
||||||
waitForUnselectedEditor,
|
waitForUnselectedEditor,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
@ -150,8 +151,8 @@ describe("Stamp Editor", () => {
|
|||||||
const ratio = await page.evaluate(
|
const ratio = await page.evaluate(
|
||||||
() => window.pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
|
() => window.pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
|
||||||
);
|
);
|
||||||
expect(bitmap.width).toEqual(Math.round(242 * ratio));
|
expect(Math.abs(bitmap.width - 242 * ratio) < 1).toBeTrue();
|
||||||
expect(bitmap.height).toEqual(Math.round(80 * ratio));
|
expect(Math.abs(bitmap.height - 80 * ratio) < 1).toBeTrue();
|
||||||
|
|
||||||
await clearAll(page);
|
await clearAll(page);
|
||||||
})
|
})
|
||||||
@ -1097,4 +1098,50 @@ describe("Stamp Editor", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("No auto-resize", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer", 67);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that a stamp editor isn't resizing itself", async () => {
|
||||||
|
// Run sequentially to avoid clipboard issues.
|
||||||
|
const editorSelector = getEditorSelector(0);
|
||||||
|
|
||||||
|
for (const [, page] of pages) {
|
||||||
|
await switchToStamp(page);
|
||||||
|
|
||||||
|
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||||
|
await page.waitForSelector(editorSelector);
|
||||||
|
await waitForSerialized(page, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
const getDims = () =>
|
||||||
|
page.evaluate(sel => {
|
||||||
|
const bbox = document.querySelector(sel).getBoundingClientRect();
|
||||||
|
return `${bbox.width}::${bbox.height}`;
|
||||||
|
}, editorSelector);
|
||||||
|
const initialDims = await getDims();
|
||||||
|
for (let i = 0; i < 50; i++) {
|
||||||
|
// We want to make sure that the editor doesn't resize itself, so we
|
||||||
|
// check every 10ms that the dimensions are the same.
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
await waitForTimeout(10);
|
||||||
|
|
||||||
|
const dims = await getDims();
|
||||||
|
expect(dims).withContext(`In ${browserName}`).toEqual(initialDims);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user