Skip to content

Commit

Permalink
Merge pull request mozilla#15835 from Snuffleupagus/viewer-safe-eleme…
Browse files Browse the repository at this point in the history
…nt-access

Protect a few additional DOM element accesses in the viewer (PR 15831 follow-up)
  • Loading branch information
Snuffleupagus authored Dec 15, 2022
2 parents 826c358 + 4bd66a2 commit b518d93
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ const PDFViewerApplication = {
pdfLinkService.setHistory(this.pdfHistory);
}

if (appConfig.findBar && !this.supportsIntegratedFind) {
if (!this.supportsIntegratedFind && appConfig.findBar) {
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
}

Expand All @@ -543,11 +543,8 @@ const PDFViewerApplication = {
eventBus
);
} else {
for (const element of [
document.getElementById("editorModeButtons"),
document.getElementById("editorModeSeparator"),
]) {
element.hidden = true;
for (const id of ["editorModeButtons", "editorModeSeparator"]) {
document.getElementById(id)?.classList.add("hidden");
}
}
}
Expand Down Expand Up @@ -792,16 +789,13 @@ const PDFViewerApplication = {
* @private
*/
_hideViewBookmark() {
const { viewBookmarkButton, presentationModeButton } =
this.appConfig.secondaryToolbar;

const { secondaryToolbar } = this.appConfig;
// URL does not reflect proper document location - hiding some buttons.
viewBookmarkButton.hidden = true;
secondaryToolbar?.viewBookmarkButton.classList.add("hidden");

// Avoid displaying multiple consecutive separators in the secondaryToolbar.
if (presentationModeButton.hidden) {
const element = document.getElementById("viewBookmarkSeparator");
element.hidden = true;
if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
}
},

Expand Down Expand Up @@ -2175,8 +2169,8 @@ function webViewerInitialized() {
appConfig.secondaryToolbar?.printButton.classList.add("hidden");
}

if (appConfig.secondaryToolbar && !PDFViewerApplication.supportsFullscreen) {
appConfig.secondaryToolbar.presentationModeButton.hidden = true;
if (!PDFViewerApplication.supportsFullscreen) {
appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
}

if (PDFViewerApplication.supportsIntegratedFind) {
Expand Down

0 comments on commit b518d93

Please sign in to comment.