Skip to content

Compute the transformOrigin correctly, for negative values, when rendering AnnotationElements (bug 1627030) #12409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class AnnotationElement {
]);

container.style.transform = `matrix(${viewport.transform.join(",")})`;
container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
container.style.transformOrigin = `${-rect[0]}px ${-rect[1]}px`;

if (!ignoreBorder && data.borderStyle.width > 0) {
container.style.borderWidth = `${data.borderStyle.width}px`;
Expand Down Expand Up @@ -763,12 +763,13 @@ class PopupAnnotationElement extends AnnotationElement {

// Position the popup next to the parent annotation's container.
// PDF viewers ignore a popup annotation's rectangle.
const parentLeft = parseFloat(parentElement.style.left);
const parentWidth = parseFloat(parentElement.style.width);
this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${
parentElement.style.top
}`;
this.container.style.left = `${parentLeft + parentWidth}px`;
const parentTop = parseFloat(parentElement.style.top),
parentLeft = parseFloat(parentElement.style.left),
parentWidth = parseFloat(parentElement.style.width);
const popupLeft = parentLeft + parentWidth;

this.container.style.transformOrigin = `${-popupLeft}px ${-parentTop}px`;
this.container.style.left = `${popupLeft}px`;

this.container.appendChild(popup.render());
return this.container;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/bug1627030.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://bug1627030.bmoattachments.org/attachment.cgi?id=9137808
10 changes: 10 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,16 @@
"annotations": true,
"about": "Annotation with (ridiculously) large border width."
},
{ "id": "bug1627030",
"file": "pdfs/bug1627030.pdf",
"md5": "4cde6134daa80449c43defd02c1393e2",
"rounds": 1,
"link": true,
"firstPage": 3,
"lastPage": 3,
"type": "eq",
"annotations": true
},
{ "id": "issue4934",
"file": "pdfs/issue4934.pdf",
"md5": "6099da44f677702ae65a648b51a2226d",
Expand Down