Skip to content

Commit

Permalink
The annotation layer dimensions must be set before adding some elemen…
Browse files Browse the repository at this point in the history
…ts (follow-up of mozilla#15770)

In order to move the annotations in the DOM to have something which corresponds
to the visual order, we need to have their dimensions/positions which means that
the parent must have some dimensions.
  • Loading branch information
calixteman committed Dec 13, 2022
1 parent 0fdac9b commit f7cd09d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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 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"]);
})
);
});
});
});

0 comments on commit f7cd09d

Please sign in to comment.