From 8e5f4c06229b8761a35603f01b1eb3842891a70d Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 16 Apr 2023 21:36:26 +0200 Subject: [PATCH] [Editor] Take into account the initial rotation (issue #16278) --- src/display/editor/editor.js | 4 ++- test/integration/ink_editor_spec.js | 51 ++++++++++++++++++++++++++-- test/pdfs/.gitignore | 1 + test/pdfs/issue16278.pdf | Bin 0 -> 4871 bytes 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 test/pdfs/issue16278.pdf 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 0000000000000000000000000000000000000000..270b9826d21fd1547760e4fce77ea1c8ed9d242e GIT binary patch literal 4871 zcmeHLZD<>198YUkYuA9Hj0p~(#dXfDx#xNAE|*+Lv$lD0txcPyffh<7m%B@wEy=~p zrAhli>U^6p=NJqb?!y>vb%@vw5kbLCI?%ay=R^iW)Gr&ui3oF3#OE%rYciqW{M10g zlY9QJzyI%flK;Ow==EDM#hKfG{OQ~`=2naW0!nn7+2w-$@sup6@o8BC81@6!VaIR~ zU@2HE$c1JhU?db7)?JVnH_#PI~j_w}Z z?dNIabGThT4tZ&h$M5m+Jd3++4j<>kJ$B4`Jv{PweeN;Xo08=GC`sI=uVV_ph{P9y z{c>ttn*a>bgPGJ5Wnf5AG!l`qKSYoLn1kV|vXTkpK_(uF6$anmDBji2a16(x(1Wi&z6@~Rv&BXfJZZ_r->(Tr^s z*y`ayic*T1wUa_|7!Co3yDOMTB+_)~W*azva^|6t)s8*+UBR~Dl|LiKvqE`!AJfv; zb^F=#l}P@ii!nlQnOw4SYOAG@*=F z$bp$kHXc<;_b8+Wh^8=cf-$Ce2GDkv;xPwU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