Skip to content

Don't shift FreeText clones by their font size (issue 22271) - #22378

Open
cestercian wants to merge 1 commit into
mozilla:masterfrom
cestercian:fix-freetext-clone-offset
Open

cestercian wants to merge 1 commit into
mozilla:masterfrom
cestercian:fix-freetext-clone-offset

Conversation

@cestercian

Copy link
Copy Markdown

When a FreeText editor is recreated as a clone (AnnotationEditorUIManager.findClonesForPage(), fed by clonePage(), which the viewer uses when pages are copied with enableSplitMerge), render() applies getInitialTranslation(). For FreeText that shift is the padding plus the font size, so the baseline sits where the user clicked. A pasted copy then replaces that position in _moveAfterPaste(), but a clone returns early there, so the shift stayed and the clone moved up by its font size.

The padding part of the shift still has to be applied: getPDFRect() adds it back, and dropping it moves the rect by --freetext-padding (2px). The serialized rect already includes the baseline shift, so a clone skips only the font-size part.

Tested with a regression test in test/integration/freetext_editor_spec.mjs that serializes a FreeText editor, deserializes it as a clone, and expects the same rect. It failed by exactly the font size before the fix and passes with it. FreeText creation, copy/paste, and undo/redo were checked as well. npx gulp lint and npx gulp unittestcli pass.

Fixes #22271

A cloned FreeText editor is positioned from its serialized rect, which
already includes the baseline shift. getInitialTranslation() applied
that shift again, and _moveAfterPaste() returns early for clones, so
the editor moved up by its font size. Keep the padding compensation
that getPDFRect() adds back, and skip only the font-size part.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A FreeText editor restored from a clone moves up by its font size

2 participants