Commit cd9e580b authored by rbpotter's avatar rbpotter Committed by Commit Bot

PDF Viewer Edits: Add an aria-haspopup attribute when appropriate

The download button should have aria-haspopup='menu' when the Edited/
Original menu is available.

Bug: 1078543
Change-Id: I8a070b81fe9e27f0cad5448f44ac245dbeada3bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2260780
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782262}
parent 7330530a
......@@ -187,6 +187,7 @@
<cr-icon-button id="download" iron-icon="cr:file-download"
on-click="onDownloadClick_" aria-label$="$i18n{tooltipDownload}"
aria-haspopup$="[[downloadHasPopup_]]"
title="$i18n{tooltipDownload}"></cr-icon-button>
<cr-action-menu id="downloadMenu">
<button class="dropdown-item" on-click="onDownloadEditedClick_">
......
......@@ -118,21 +118,31 @@ Polymer({
value: false,
},
/** @private */
downloadHasPopup_: {
type: String,
computed: 'computeDownloadHasPopup_(' +
'pdfFormSaveEnabled_, hasEdits, hasEnteredAnnotationMode)',
},
strings: {
type: Object,
observer: 'onStringsSet_',
},
/**
* Whether the PDF Form save feature is enabled.
* @private
*/
pdfFormSaveEnabled_: {
type: Boolean,
value: false,
},
},
/** @type {?Object} */
animation_: null,
/**
* Whether the PDF Form save feature is enabled.
* @private {boolean}
*/
pdfFormSaveEnabled_: false,
/** @private {?PromiseResolver<boolean>} */
waitForFormFocusChange_: null,
......@@ -260,8 +270,7 @@ Polymer({
* @private
*/
waitForEdits_() {
if (this.hasEnteredAnnotationMode ||
(this.hasEdits && this.pdfFormSaveEnabled_)) {
if (this.hasEditsToSave_()) {
return Promise.resolve(true);
}
if (!this.isFormFieldFocused || !this.pdfFormSaveEnabled_) {
......@@ -291,8 +300,8 @@ Polymer({
onDownloadEditedClick_() {
this.fire(
'save',
this.hasEnteredAnnotationsMode ? SaveRequestType.ANNOTATION :
SaveRequestType.EDITED);
this.hasEnteredAnnotationMode ? SaveRequestType.ANNOTATION :
SaveRequestType.EDITED);
this.$.downloadMenu.close();
},
......@@ -373,6 +382,24 @@ Polymer({
return !!this.annotationTool && this.annotationTool.tool === toolName;
},
/**
* @return {boolean}
* @private
*/
hasEditsToSave_() {
return this.hasEnteredAnnotationMode ||
(this.pdfFormSaveEnabled_ && this.hasEdits);
},
/**
* @return {string} The value for the aria-haspopup attribute for the download
* button.
* @private
*/
computeDownloadHasPopup_() {
return this.hasEditsToSave_() ? 'menu' : 'false';
},
/** @private */
onStringsSet_() {
assert(this.strings);
......
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