[GeckoView] Introduce a development mode constant to tell the viewers apart
Currently we have a couple of pre-processor checks, specifically for the GV-viewer, spread throughout the code. This works fine when *building* the viewer, however they're obviously ignored in development mode (i.e. `gulp server`). This leads to a situation where the GV development viewer, i.e. http://localhost:8888/web/viewer-geckoview.html, behaves subtly different from its built version. This could easily lead to bugs, hence this patch introduces a development mode constant to hopefully improve things here. Finally, in a follow-up to PR 15842, also ignores the `pageMode`-state since there's no sidebar available.
This commit is contained in:
parent
c971f4a0a9
commit
8c4843f69a
15
web/app.js
15
web/app.js
@ -466,7 +466,9 @@ const PDFViewerApplication = {
|
||||
linkService: pdfLinkService,
|
||||
eventBus,
|
||||
updateMatchesCountOnProgress:
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW"),
|
||||
typeof PDFJSDev === "undefined"
|
||||
? !window.isGECKOVIEW
|
||||
: !PDFJSDev.test("GECKOVIEW"),
|
||||
});
|
||||
this.findController = findController;
|
||||
|
||||
@ -1247,14 +1249,18 @@ const PDFViewerApplication = {
|
||||
spreadMode = stored.spreadMode | 0;
|
||||
}
|
||||
}
|
||||
// NOTE: Ignore the pageMode/pageLayout in GeckoView since there's no
|
||||
// sidebar available, nor any UI for changing the Scroll/Spread modes.
|
||||
if (
|
||||
typeof PDFJSDev === "undefined"
|
||||
? !window.isGECKOVIEW
|
||||
: !PDFJSDev.test("GECKOVIEW")
|
||||
) {
|
||||
// Always let the user preference/view history take precedence.
|
||||
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
|
||||
@ -1265,6 +1271,7 @@ const PDFViewerApplication = {
|
||||
// scrollMode = modes.scrollMode;
|
||||
spreadMode = modes.spreadMode;
|
||||
}
|
||||
}
|
||||
|
||||
this.setInitialView(hash, {
|
||||
rotation,
|
||||
|
@ -269,7 +269,9 @@ class PDFScriptingManager {
|
||||
// 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")) ||
|
||||
(typeof PDFJSDev === "undefined"
|
||||
? window.isGECKOVIEW
|
||||
: PDFJSDev.test("GECKOVIEW")) ||
|
||||
isInPresentationMode
|
||||
) {
|
||||
return;
|
||||
|
@ -68,6 +68,7 @@ function webViewerLoad() {
|
||||
|
||||
document.head.append(link);
|
||||
}
|
||||
window.isGECKOVIEW = true;
|
||||
|
||||
import("pdfjs-web/genericcom.js").then(function (genericCom) {
|
||||
PDFViewerApplication.run(config);
|
||||
|
Loading…
Reference in New Issue
Block a user