Merge pull request #16301 from calixteman/issue16278

[Editor] Take into account the initial rotation (issue #16278)
This commit is contained in:
calixteman 2023-04-17 09:42:07 +02:00 committed by GitHub
commit 3e08eee511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 3 deletions

View File

@ -74,6 +74,8 @@ class AnnotationEditor {
} = this.parent.viewport;
this.rotation = rotation;
this.pageRotation =
(360 + rotation - this._uiManager.viewParameters.rotation) % 360;
this.pageDimensions = [pageWidth, pageHeight];
this.pageTranslation = [pageX, pageY];
@ -250,7 +252,7 @@ class AnnotationEditor {
}
get parentRotation() {
return this._uiManager.viewParameters.rotation;
return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;
}
get parentDimensions() {

View File

@ -19,8 +19,8 @@ const {
loadAndWait,
} = require("./test_utils.js");
describe("Editor", () => {
describe("Ink", () => {
describe("Ink Editor", () => {
describe("Basic operations", () => {
let pages;
beforeAll(async () => {
@ -135,4 +135,51 @@ describe("Editor", () => {
);
});
});
describe("with a rotated pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue16278.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
await closePages(pages);
});
it("must draw something", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.click("#editorInk");
const rect = await page.$eval(".annotationEditorLayer", el => {
// With Chrome something is wrong when serializing a DomRect,
// hence we extract the values and just return them.
const { x, y } = el.getBoundingClientRect();
return { x, y };
});
const x = rect.x + 20;
const y = rect.y + 20;
await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x + 50, y + 50);
await page.mouse.up();
await page.waitForTimeout(10);
await page.keyboard.press("Escape");
await page.waitForTimeout(10);
await page.keyboard.down("Control");
await page.keyboard.press("a");
await page.keyboard.up("Control");
await page.waitForTimeout(10);
expect(await getSelectedEditors(page))
.withContext(`In ${browserName}`)
.toEqual([0]);
})
);
});
});
});

View File

@ -584,3 +584,4 @@
!bug1820909.1.pdf
!issue16221.pdf
!issue16224.pdf
!issue16278.pdf

BIN
test/pdfs/issue16278.pdf Normal file

Binary file not shown.