From 0289038961231b2e95f319e8ed7ba620b1e26ce7 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 16 Dec 2022 11:59:22 +0100 Subject: [PATCH] [GeckoView] Ignore the pageLayout, from the PDF document, to prevent issues First of all, given the screen-sizes of most mobile phones using Spread modes is unlikely to be useful. Secondly, and more importantly, since there's (currently) no UI available for the user to override a PDF document-specified Spread mode this would result in a bad UX otherwise. Also, removes an outdated comment from the `apiPageLayoutToViewerModes` helper function. --- web/app.js | 3 +++ web/pdf_scripting_manager.js | 10 ++++++++-- web/ui_utils.js | 3 --- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/web/app.js b/web/app.js index 7d2cb8637..d689ab703 100644 --- a/web/app.js +++ b/web/app.js @@ -1236,7 +1236,10 @@ const PDFViewerApplication = { if (pageMode && sidebarView === SidebarView.UNKNOWN) { sidebarView = apiPageModeToSidebarView(pageMode); } + // NOTE: Always ignore the pageLayout in GeckoView since there's + // no UI available to change Scroll/Spread modes for the user. if ( + (typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW")) && pageLayout && scrollMode === ScrollMode.UNKNOWN && spreadMode === SpreadMode.UNKNOWN diff --git a/web/pdf_scripting_manager.js b/web/pdf_scripting_manager.js index a0197b614..c3a3d6e3b 100644 --- a/web/pdf_scripting_manager.js +++ b/web/pdf_scripting_manager.js @@ -265,13 +265,19 @@ class PDFScriptingManager { case "error": console.error(value); break; - case "layout": - if (isInPresentationMode) { + case "layout": { + // NOTE: Always ignore the pageLayout in GeckoView since there's + // no UI available to change Scroll/Spread modes for the user. + if ( + (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GECKOVIEW")) || + isInPresentationMode + ) { return; } const modes = apiPageLayoutToViewerModes(value); this._pdfViewer.spreadMode = modes.spreadMode; break; + } case "page-num": this._pdfViewer.currentPageNumber = value + 1; break; diff --git a/web/ui_utils.js b/web/ui_utils.js index 7bc602a99..39d6d598a 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -769,9 +769,6 @@ function getActiveOrFocusedElement() { /** * Converts API PageLayout values to the format used by `BaseViewer`. - * NOTE: This is supported to the extent that the viewer implements the - * necessary Scroll/Spread modes (since SinglePage, TwoPageLeft, - * and TwoPageRight all suggests using non-continuous scrolling). * @param {string} mode - The API PageLayout value. * @returns {Object} */