Merge pull request #11503 from Snuffleupagus/issue-11499

Remove the unused `id` properties from page and thumbnail canvas/image DOM elements (issue 11499)
This commit is contained in:
Tim van der Meij 2020-01-12 19:38:17 +01:00 committed by GitHub
commit 40f531ee87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 47 deletions

View file

@ -148,6 +148,8 @@ thumbs_label=Thumbnails
findbar.title=Find in Document findbar.title=Find in Document
findbar_label=Find findbar_label=Find
# LOCALIZATION NOTE (page_canvas): "{{page}}" will be replaced by the page number.
page_canvas=Page {{page}}
# Thumbnails panel item (tooltip and alt text for images) # Thumbnails panel item (tooltip and alt text for images)
# LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page # LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page
# number. # number.

View file

@ -148,6 +148,8 @@ thumbs_label=Miniatyrer
findbar.title=Sök i dokument findbar.title=Sök i dokument
findbar_label=Sök findbar_label=Sök
# LOCALIZATION NOTE (page_canvas): "{{page}}" will be replaced by the page number.
page_canvas=Sida {{page}}
# Thumbnails panel item (tooltip and alt text for images) # Thumbnails panel item (tooltip and alt text for images)
# LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page # LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page
# number. # number.

View file

@ -559,7 +559,11 @@ class PDFPageView {
const viewport = this.viewport; const viewport = this.viewport;
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
canvas.id = this.renderingId; this.l10n
.get("page_canvas", { page: this.id }, "Page {{page}}")
.then(msg => {
canvas.setAttribute("aria-label", msg);
});
// Keep the canvas hidden until the first draw callback, or until drawing // Keep the canvas hidden until the first draw callback, or until drawing
// is complete when `!this.renderingQueue`, to prevent black flickering. // is complete when `!this.renderingQueue`, to prevent black flickering.

View file

@ -125,9 +125,7 @@ class PDFThumbnailView {
const anchor = document.createElement("a"); const anchor = document.createElement("a");
anchor.href = linkService.getAnchorUrl("#page=" + id); anchor.href = linkService.getAnchorUrl("#page=" + id);
this.l10n this._thumbPageTitle.then(msg => {
.get("thumb_page_title", { page: id }, "Page {{page}}")
.then(msg => {
anchor.title = msg; anchor.title = msg;
}); });
anchor.onclick = function() { anchor.onclick = function() {
@ -258,19 +256,11 @@ class PDFThumbnailView {
if (this.renderingState !== RenderingStates.FINISHED) { if (this.renderingState !== RenderingStates.FINISHED) {
return; return;
} }
const id = this.renderingId;
const className = "thumbnailImage"; const className = "thumbnailImage";
if (this.disableCanvasToImageConversion) { if (this.disableCanvasToImageConversion) {
this.canvas.id = id;
this.canvas.className = className; this.canvas.className = className;
this.l10n this._thumbPageCanvas.then(msg => {
.get(
"thumb_page_canvas",
{ page: this.pageId },
"Thumbnail of Page {{page}}"
)
.then(msg => {
this.canvas.setAttribute("aria-label", msg); this.canvas.setAttribute("aria-label", msg);
}); });
@ -279,15 +269,8 @@ class PDFThumbnailView {
return; return;
} }
const image = document.createElement("img"); const image = document.createElement("img");
image.id = id;
image.className = className; image.className = className;
this.l10n this._thumbPageCanvas.then(msg => {
.get(
"thumb_page_canvas",
{ page: this.pageId },
"Thumbnail of Page {{page}}"
)
.then(msg => {
image.setAttribute("aria-label", msg); image.setAttribute("aria-label", msg);
}); });
@ -455,8 +438,20 @@ class PDFThumbnailView {
this._convertCanvasToImage(); this._convertCanvasToImage();
} }
get pageId() { get _thumbPageTitle() {
return this.pageLabel !== null ? this.pageLabel : this.id; return this.l10n.get(
"thumb_page_title",
{ page: this.pageLabel !== null ? this.pageLabel : this.id },
"Page {{page}}"
);
}
get _thumbPageCanvas() {
return this.l10n.get(
"thumb_page_canvas",
{ page: this.pageLabel !== null ? this.pageLabel : this.id },
"Thumbnail of Page {{page}}"
);
} }
/** /**
@ -465,9 +460,7 @@ class PDFThumbnailView {
setPageLabel(label) { setPageLabel(label) {
this.pageLabel = typeof label === "string" ? label : null; this.pageLabel = typeof label === "string" ? label : null;
this.l10n this._thumbPageTitle.then(msg => {
.get("thumb_page_title", { page: this.pageId }, "Page {{page}}")
.then(msg => {
this.anchor.title = msg; this.anchor.title = msg;
}); });
@ -475,17 +468,11 @@ class PDFThumbnailView {
return; return;
} }
this.l10n this._thumbPageCanvas.then(msg => {
.get(
"thumb_page_canvas",
{ page: this.pageId },
"Thumbnail of Page {{page}}"
)
.then(ariaLabel => {
if (this.image) { if (this.image) {
this.image.setAttribute("aria-label", ariaLabel); this.image.setAttribute("aria-label", msg);
} else if (this.disableCanvasToImageConversion && this.canvas) { } else if (this.disableCanvasToImageConversion && this.canvas) {
this.canvas.setAttribute("aria-label", ariaLabel); this.canvas.setAttribute("aria-label", msg);
} }
}); });
} }