1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #18658 from calixteman/bug1912001

[Editor] Make the stamp annotations alt text readable by either VO or NVDA (bug 1912001)
This commit is contained in:
calixteman 2024-09-03 21:47:21 +02:00 committed by GitHub
commit d3698223a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 110 additions and 37 deletions

View file

@ -22,6 +22,8 @@
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
// eslint-disable-next-line max-len
/** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */
// eslint-disable-next-line max-len
/** @typedef {import("../../web/struct_tree_layer_builder.js").StructTreeLayerBuilder} StructTreeLayerBuilder */
import {
AnnotationBorderStyleType,
@ -2963,6 +2965,7 @@ class StampAnnotationElement extends AnnotationElement {
render() {
this.container.classList.add("stampAnnotation");
this.container.setAttribute("role", "img");
if (!this.data.popupRef && this.hasPopupData) {
this._createPopup();
@ -3070,6 +3073,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
* @property {TextAccessibilityManager} [accessibilityManager]
* @property {AnnotationEditorUIManager} [annotationEditorUIManager]
* @property {StructTreeLayerBuilder} [structTreeLayer]
*/
/**
@ -3082,6 +3086,8 @@ class AnnotationLayer {
#editableAnnotations = new Map();
#structTreeLayer = null;
constructor({
div,
accessibilityManager,
@ -3089,10 +3095,12 @@ class AnnotationLayer {
annotationEditorUIManager,
page,
viewport,
structTreeLayer,
}) {
this.div = div;
this.#accessibilityManager = accessibilityManager;
this.#annotationCanvasMap = annotationCanvasMap;
this.#structTreeLayer = structTreeLayer || null;
this.page = page;
this.viewport = viewport;
this.zIndex = 0;
@ -3115,9 +3123,16 @@ class AnnotationLayer {
return this.#editableAnnotations.size > 0;
}
#appendElement(element, id) {
async #appendElement(element, id) {
const contentElement = element.firstChild || element;
contentElement.id = `${AnnotationPrefix}${id}`;
const annotationId = (contentElement.id = `${AnnotationPrefix}${id}`);
const ariaAttributes =
await this.#structTreeLayer?.getAriaAttributes(annotationId);
if (ariaAttributes) {
for (const [key, value] of ariaAttributes) {
contentElement.setAttribute(key, value);
}
}
this.div.append(element);
this.#accessibilityManager?.moveElementInDOM(
@ -3194,7 +3209,7 @@ class AnnotationLayer {
if (data.hidden) {
rendered.style.visibility = "hidden";
}
this.#appendElement(rendered, data.id);
await this.#appendElement(rendered, data.id);
if (element._isEditable) {
this.#editableAnnotations.set(element.data.id, element);