diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index 187c3526c5332..300d8a9d2d589 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -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() { diff --git a/test/integration/ink_editor_spec.js b/test/integration/ink_editor_spec.js index 9b92d777372b6..7a40d250b282c 100644 --- a/test/integration/ink_editor_spec.js +++ b/test/integration/ink_editor_spec.js @@ -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]); + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 08047ff9b865a..b9e823515fc60 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -584,3 +584,4 @@ !bug1820909.1.pdf !issue16221.pdf !issue16224.pdf +!issue16278.pdf diff --git a/test/pdfs/issue16278.pdf b/test/pdfs/issue16278.pdf new file mode 100644 index 0000000000000..270b9826d21fd Binary files /dev/null and b/test/pdfs/issue16278.pdf differ