Skip to content

Commit ac868b3

Browse files
committed
Add landmark region and aria-label for each page.
Allows screen readers to jump landmarks and announce the page. Since landmarks must have content, I also added aria labels for the loading images.
1 parent a164941 commit ac868b3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

l10n/en-US/viewer.properties

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ page_scale_actual=Actual Size
223223
page_scale_percent={{scale}}%
224224

225225
# Loading indicator messages
226+
loading=Loading…
226227
loading_error=An error occurred while loading the PDF.
227228
invalid_file_error=Invalid or corrupted PDF file.
228229
missing_file_error=Missing PDF file.

web/pdf_page_view.js

+10
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ class PDFPageView {
122122
div.style.width = Math.floor(this.viewport.width) + "px";
123123
div.style.height = Math.floor(this.viewport.height) + "px";
124124
div.setAttribute("data-page-number", this.id);
125+
div.setAttribute("role", "region");
126+
this.l10n
127+
.get("page_canvas", { page: this.id }, "Page {{page}}")
128+
.then(msg => {
129+
div.setAttribute("aria-label", msg);
130+
});
125131
this.div = div;
126132

127133
container.appendChild(div);
@@ -233,6 +239,10 @@ class PDFPageView {
233239

234240
this.loadingIconDiv = document.createElement("div");
235241
this.loadingIconDiv.className = "loadingIcon";
242+
this.loadingIconDiv.setAttribute("role", "img");
243+
this.l10n.get("loading").then(msg => {
244+
this.loadingIconDiv?.setAttribute("aria-label", msg);
245+
});
236246
div.appendChild(this.loadingIconDiv);
237247
}
238248

0 commit comments

Comments
 (0)