Commit e5f46058 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

PDF Viewer Update: Add aria-label for thumbnails

Bug: 652400
Change-Id: I44b3f9561c3186f9c40d52201ad4ec30b3f9c6a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2439433Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812452}
parent d65cc733
...@@ -63,6 +63,7 @@ void AddPdfViewerStrings(base::Value* dict) { ...@@ -63,6 +63,7 @@ void AddPdfViewerStrings(base::Value* dict) {
{"passwordInvalid", IDS_PDF_PASSWORD_INVALID}, {"passwordInvalid", IDS_PDF_PASSWORD_INVALID},
{"passwordPrompt", IDS_PDF_NEED_PASSWORD}, {"passwordPrompt", IDS_PDF_NEED_PASSWORD},
{"passwordSubmit", IDS_PDF_PASSWORD_SUBMIT}, {"passwordSubmit", IDS_PDF_PASSWORD_SUBMIT},
{"thumbnailPageAriaLabel", IDS_PDF_THUMBNAIL_PAGE_ARIA_LABEL},
{"tooltipDocumentOutline", IDS_PDF_TOOLTIP_DOCUMENT_OUTLINE}, {"tooltipDocumentOutline", IDS_PDF_TOOLTIP_DOCUMENT_OUTLINE},
{"tooltipDownload", IDS_PDF_TOOLTIP_DOWNLOAD}, {"tooltipDownload", IDS_PDF_TOOLTIP_DOWNLOAD},
{"tooltipPrint", IDS_PDF_TOOLTIP_PRINT}, {"tooltipPrint", IDS_PDF_TOOLTIP_PRINT},
......
...@@ -165,6 +165,7 @@ js_library("viewer-thumbnail-bar") { ...@@ -165,6 +165,7 @@ js_library("viewer-thumbnail-bar") {
":viewer-thumbnail", ":viewer-thumbnail",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js/cr/ui:focus_outline_manager.m", "//ui/webui/resources/js/cr/ui:focus_outline_manager.m",
] ]
} }
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
<div id="thumbnails"> <div id="thumbnails">
<template is="dom-repeat" items="[[pageNumbers_]]" <template is="dom-repeat" items="[[pageNumbers_]]"
on-dom-change="onDomChange_"> on-dom-change="onDomChange_">
<viewer-thumbnail tabindex="0" clockwise-rotations="[[clockwiseRotations]]" <viewer-thumbnail tabindex="0" role="button"
aria-label$="[[getAriaLabel_(item)]]"
clockwise-rotations="[[clockwiseRotations]]"
is-active="[[isActivePage_(item, activePage)]]" page-number="[[item]]"> is-active="[[isActivePage_(item, activePage)]]" page-number="[[item]]">
</viewer-thumbnail> </viewer-thumbnail>
</template> </template>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {FocusOutlineManager} from 'chrome://resources/js/cr/ui/focus_outline_manager.m.js'; import {FocusOutlineManager} from 'chrome://resources/js/cr/ui/focus_outline_manager.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {ViewerThumbnailElement} from './viewer-thumbnail.js'; import {ViewerThumbnailElement} from './viewer-thumbnail.js';
...@@ -78,6 +79,15 @@ export class ViewerThumbnailBarElement extends PolymerElement { ...@@ -78,6 +79,15 @@ export class ViewerThumbnailBarElement extends PolymerElement {
return Array.from({length: this.docLength}, (_, i) => i + 1); return Array.from({length: this.docLength}, (_, i) => i + 1);
} }
/**
* @param {number} pageNumber
* @return {string}
* @private
*/
getAriaLabel_(pageNumber) {
return loadTimeData.getStringF('thumbnailPageAriaLabel', pageNumber);
}
/** /**
* @param {number} page * @param {number} page
* @return {boolean} Whether the page is the current page. * @return {boolean} Whether the page is the current page.
......
...@@ -92,6 +92,9 @@ ...@@ -92,6 +92,9 @@
=1 {PDF document containing {COUNT} page} =1 {PDF document containing {COUNT} page}
other {PDF document containing {COUNT} pages}} other {PDF document containing {COUNT} pages}}
</message> </message>
<message name="IDS_PDF_THUMBNAIL_PAGE_ARIA_LABEL" desc="aria-label describing a thumbnail by its corresponding PDF page number">
Thumbnail for page <ph name="THUMBNAIL_PAGE"><ex>1</ex>$1</ph>
</message>
<if expr="chromeos"> <if expr="chromeos">
<message name="IDS_PDF_DISCARD_FORM_CHANGES" desc="Title for a dialog that informs the user that the changes they have made to a form will be lost if they continue"> <message name="IDS_PDF_DISCARD_FORM_CHANGES" desc="Title for a dialog that informs the user that the changes they have made to a form will be lost if they continue">
Discard changes? Discard changes?
......
7fd29acf0738221b3fc8258d7039552bbf7102eb
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment