Skip to content
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

The annotation layer dimensions must be set before adding some elements (follow-up of #15770) #15820

Merged
merged 1 commit into from
Dec 13, 2022
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
4 changes: 2 additions & 2 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,7 @@ class AnnotationLayer {
*/
static render(parameters) {
const { annotations, div, viewport, accessibilityManager } = parameters;
setLayerDimensions(div, viewport);

let zIndex = 0;

Expand Down Expand Up @@ -2652,7 +2653,6 @@ class AnnotationLayer {
}

this.#setAnnotationCanvasMap(div, parameters.annotationCanvasMap);
setLayerDimensions(div, viewport);
}

/**
Expand All @@ -2664,9 +2664,9 @@ class AnnotationLayer {
*/
static update(parameters) {
const { annotationCanvasMap, div, viewport } = parameters;
setLayerDimensions(div, { rotation: viewport.rotation });

this.#setAnnotationCanvasMap(div, annotationCanvasMap);
setLayerDimensions(div, { rotation: viewport.rotation });
div.hidden = false;
}

Expand Down
33 changes: 33 additions & 0 deletions test/integration/accessibility_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,37 @@ describe("accessibility", () => {
);
});
});

describe("Annotations order", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait("fields_order.pdf", ".annotationLayer");
});

afterAll(async () => {
await closePages(pages);
});

it("must check that the text fields are in the visual order", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const ids = await page.evaluate(() => {
const elements = document.querySelectorAll(
".annotationLayer .textWidgetAnnotation"
);
const results = [];
for (const element of elements) {
results.push(element.getAttribute("data-annotation-id"));
}
return results;
});

expect(ids)
.withContext(`In ${browserName}`)
.toEqual(["32R", "30R", "31R", "34R", "29R", "33R"]);
})
);
});
});
});
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,4 @@
!issue15759.pdf
!issue15753.pdf
!issue15789.pdf
!fields_order.pdf
Binary file added test/pdfs/fields_order.pdf
Binary file not shown.