1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #13118 from brendandahl/page-aria

Add landmark region and aria-label for each page.
This commit is contained in:
Tim van der Meij 2021-03-19 23:17:55 +01:00 committed by GitHub
commit d775616fd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View file

@ -45,7 +45,7 @@ const DEFAULT_L10N_STRINGS = {
"Toggle Sidebar (document contains outline/attachments/layers)",
additional_layers: "Additional Layers",
page_canvas: "Page {{page}}",
page_landmark: "Page {{page}}",
thumb_page_title: "Page {{page}}",
thumb_page_canvas: "Thumbnail of Page {{page}}",
@ -70,6 +70,7 @@ const DEFAULT_L10N_STRINGS = {
page_scale_actual: "Actual Size",
page_scale_percent: "{{scale}}%",
loading: "Loading…",
loading_error: "An error occurred while loading the PDF.",
invalid_file_error: "Invalid or corrupted PDF file.",
missing_file_error: "Missing PDF file.",

View file

@ -125,6 +125,10 @@ class PDFPageView {
div.style.width = Math.floor(this.viewport.width) + "px";
div.style.height = Math.floor(this.viewport.height) + "px";
div.setAttribute("data-page-number", this.id);
div.setAttribute("role", "region");
this.l10n.get("page_landmark", { page: this.id }).then(msg => {
div.setAttribute("aria-label", msg);
});
this.div = div;
container.appendChild(div);
@ -259,6 +263,10 @@ class PDFPageView {
this.loadingIconDiv = document.createElement("div");
this.loadingIconDiv.className = "loadingIcon";
this.loadingIconDiv.setAttribute("role", "img");
this.l10n.get("loading").then(msg => {
this.loadingIconDiv?.setAttribute("aria-label", msg);
});
div.appendChild(this.loadingIconDiv);
}
@ -617,9 +625,6 @@ class PDFPageView {
const viewport = this.viewport;
const canvas = document.createElement("canvas");
this.l10n.get("page_canvas", { page: this.id }).then(msg => {
canvas.setAttribute("aria-label", msg);
});
// Keep the canvas hidden until the first draw callback, or until drawing
// is complete when `!this.renderingQueue`, to prevent black flickering.