Merge pull request #19174 from calixteman/ink_update_width
[Editor] Correctly update the current drawing when zooming
This commit is contained in:
commit
f180de41f3
@ -804,7 +804,7 @@ class AnnotationEditorLayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#uiManager.unselectAll();
|
this.#uiManager.setCurrentDrawingSession(this);
|
||||||
this.#drawingAC = new AbortController();
|
this.#drawingAC = new AbortController();
|
||||||
const signal = this.#uiManager.combinedSignal(this.#drawingAC);
|
const signal = this.#uiManager.combinedSignal(this.#drawingAC);
|
||||||
this.div.addEventListener(
|
this.div.addEventListener(
|
||||||
@ -816,7 +816,6 @@ class AnnotationEditorLayer {
|
|||||||
},
|
},
|
||||||
{ signal }
|
{ signal }
|
||||||
);
|
);
|
||||||
this.#uiManager.disableUserSelect(true);
|
|
||||||
this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);
|
this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,9 +823,9 @@ class AnnotationEditorLayer {
|
|||||||
if (!this.#drawingAC) {
|
if (!this.#drawingAC) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
this.#uiManager.setCurrentDrawingSession(null);
|
||||||
this.#drawingAC.abort();
|
this.#drawingAC.abort();
|
||||||
this.#drawingAC = null;
|
this.#drawingAC = null;
|
||||||
this.#uiManager.disableUserSelect(false);
|
|
||||||
return this.#currentEditorType.endDrawing(isAborted);
|
return this.#currentEditorType.endDrawing(isAborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -610,6 +610,8 @@ class AnnotationEditorUIManager {
|
|||||||
|
|
||||||
#copyPasteAC = null;
|
#copyPasteAC = null;
|
||||||
|
|
||||||
|
#currentDrawingSession = null;
|
||||||
|
|
||||||
#currentPageIndex = 0;
|
#currentPageIndex = 0;
|
||||||
|
|
||||||
#deletedAnnotationsElementIds = new Set();
|
#deletedAnnotationsElementIds = new Set();
|
||||||
@ -972,6 +974,20 @@ class AnnotationEditorUIManager {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current drawing session.
|
||||||
|
* @param {AnnotationEditorLayer} layer
|
||||||
|
*/
|
||||||
|
setCurrentDrawingSession(layer) {
|
||||||
|
if (layer) {
|
||||||
|
this.unselectAll();
|
||||||
|
this.disableUserSelect(true);
|
||||||
|
} else {
|
||||||
|
this.disableUserSelect(false);
|
||||||
|
}
|
||||||
|
this.#currentDrawingSession = layer;
|
||||||
|
}
|
||||||
|
|
||||||
setMainHighlightColorPicker(colorPicker) {
|
setMainHighlightColorPicker(colorPicker) {
|
||||||
this.#mainHighlightColorPicker = colorPicker;
|
this.#mainHighlightColorPicker = colorPicker;
|
||||||
}
|
}
|
||||||
@ -1054,7 +1070,7 @@ class AnnotationEditorUIManager {
|
|||||||
for (const editor of this.#editorsToRescale) {
|
for (const editor of this.#editorsToRescale) {
|
||||||
editor.onScaleChanging();
|
editor.onScaleChanging();
|
||||||
}
|
}
|
||||||
this.currentLayer?.onScaleChanging();
|
this.#currentDrawingSession?.onScaleChanging();
|
||||||
}
|
}
|
||||||
|
|
||||||
onRotationChanging({ pagesRotation }) {
|
onRotationChanging({ pagesRotation }) {
|
||||||
@ -1984,7 +2000,7 @@ class AnnotationEditorUIManager {
|
|||||||
* @param {AnnotationEditor} editor
|
* @param {AnnotationEditor} editor
|
||||||
*/
|
*/
|
||||||
setSelected(editor) {
|
setSelected(editor) {
|
||||||
this.currentLayer?.commitOrRemove();
|
this.#currentDrawingSession?.commitOrRemove();
|
||||||
for (const ed of this.#selectedEditors) {
|
for (const ed of this.#selectedEditors) {
|
||||||
if (ed !== editor) {
|
if (ed !== editor) {
|
||||||
ed.unselect();
|
ed.unselect();
|
||||||
@ -2176,7 +2192,7 @@ class AnnotationEditorUIManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentLayer?.commitOrRemove()) {
|
if (this.#currentDrawingSession?.commitOrRemove()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -960,4 +960,66 @@ describe("Ink Editor", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Ink must update its stroke width when not the current active layer", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that the stroke width has been updated after zooming", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await switchToInk(page);
|
||||||
|
|
||||||
|
const rect = await getRect(page, ".annotationEditorLayer");
|
||||||
|
|
||||||
|
const x = rect.x + 20;
|
||||||
|
const y = rect.y + 20;
|
||||||
|
const clickHandle = await waitForPointerUp(page);
|
||||||
|
await page.mouse.move(x, y);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(x + 50, y + 50);
|
||||||
|
await page.mouse.up();
|
||||||
|
await awaitPromise(clickHandle);
|
||||||
|
|
||||||
|
const svgSelector = ".canvasWrapper svg.draw";
|
||||||
|
const strokeWidth = await page.$eval(svgSelector, el =>
|
||||||
|
parseFloat(el.getAttribute("stroke-width"))
|
||||||
|
);
|
||||||
|
|
||||||
|
await scrollIntoView(page, `.page[data-page-number = "2"]`);
|
||||||
|
|
||||||
|
const rectPageTwo = await getRect(
|
||||||
|
page,
|
||||||
|
`.page[data-page-number = "2"] .annotationEditorLayer`
|
||||||
|
);
|
||||||
|
const originX = rectPageTwo.x + rectPageTwo.width / 2;
|
||||||
|
const originY = rectPageTwo.y + rectPageTwo.height / 2;
|
||||||
|
await page.evaluate(
|
||||||
|
origin => {
|
||||||
|
window.PDFViewerApplication.pdfViewer.increaseScale({
|
||||||
|
scaleFactor: 1.5,
|
||||||
|
origin,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[originX, originY]
|
||||||
|
);
|
||||||
|
|
||||||
|
const newStrokeWidth = await page.$eval(svgSelector, el =>
|
||||||
|
parseFloat(el.getAttribute("stroke-width"))
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(newStrokeWidth)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.not.toEqual(strokeWidth);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user