[Editor] Take into account the initial rotation (issue #16278)
This commit is contained in:
parent
92baf14531
commit
8e5f4c0622
@ -74,6 +74,8 @@ class AnnotationEditor {
|
|||||||
} = this.parent.viewport;
|
} = this.parent.viewport;
|
||||||
|
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
this.pageRotation =
|
||||||
|
(360 + rotation - this._uiManager.viewParameters.rotation) % 360;
|
||||||
this.pageDimensions = [pageWidth, pageHeight];
|
this.pageDimensions = [pageWidth, pageHeight];
|
||||||
this.pageTranslation = [pageX, pageY];
|
this.pageTranslation = [pageX, pageY];
|
||||||
|
|
||||||
@ -250,7 +252,7 @@ class AnnotationEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get parentRotation() {
|
get parentRotation() {
|
||||||
return this._uiManager.viewParameters.rotation;
|
return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
get parentDimensions() {
|
get parentDimensions() {
|
||||||
|
@ -19,8 +19,8 @@ const {
|
|||||||
loadAndWait,
|
loadAndWait,
|
||||||
} = require("./test_utils.js");
|
} = require("./test_utils.js");
|
||||||
|
|
||||||
describe("Editor", () => {
|
describe("Ink Editor", () => {
|
||||||
describe("Ink", () => {
|
describe("Basic operations", () => {
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
beforeAll(async () => {
|
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]);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -584,3 +584,4 @@
|
|||||||
!bug1820909.1.pdf
|
!bug1820909.1.pdf
|
||||||
!issue16221.pdf
|
!issue16221.pdf
|
||||||
!issue16224.pdf
|
!issue16224.pdf
|
||||||
|
!issue16278.pdf
|
||||||
|
BIN
test/pdfs/issue16278.pdf
Normal file
BIN
test/pdfs/issue16278.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user