[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
39
web/app.js
39
web/app.js
@ -466,7 +466,9 @@ const PDFViewerApplication = {
|
|||||||
linkService: pdfLinkService,
|
linkService: pdfLinkService,
|
||||||
eventBus,
|
eventBus,
|
||||||
updateMatchesCountOnProgress:
|
updateMatchesCountOnProgress:
|
||||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW"),
|
typeof PDFJSDev === "undefined"
|
||||||
|
? !window.isGECKOVIEW
|
||||||
|
: !PDFJSDev.test("GECKOVIEW"),
|
||||||
});
|
});
|
||||||
this.findController = findController;
|
this.findController = findController;
|
||||||
|
|
||||||
@ -1247,23 +1249,28 @@ const PDFViewerApplication = {
|
|||||||
spreadMode = stored.spreadMode | 0;
|
spreadMode = stored.spreadMode | 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Always let the user preference/view history take precedence.
|
// NOTE: Ignore the pageMode/pageLayout in GeckoView since there's no
|
||||||
if (pageMode && sidebarView === SidebarView.UNKNOWN) {
|
// sidebar available, nor any UI for changing the Scroll/Spread modes.
|
||||||
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 (
|
if (
|
||||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW")) &&
|
typeof PDFJSDev === "undefined"
|
||||||
pageLayout &&
|
? !window.isGECKOVIEW
|
||||||
scrollMode === ScrollMode.UNKNOWN &&
|
: !PDFJSDev.test("GECKOVIEW")
|
||||||
spreadMode === SpreadMode.UNKNOWN
|
|
||||||
) {
|
) {
|
||||||
const modes = apiPageLayoutToViewerModes(pageLayout);
|
// Always let the user preference/view history take precedence.
|
||||||
// TODO: Try to improve page-switching when using the mouse-wheel
|
if (pageMode && sidebarView === SidebarView.UNKNOWN) {
|
||||||
// and/or arrow-keys before allowing the document to control this.
|
sidebarView = apiPageModeToSidebarView(pageMode);
|
||||||
// scrollMode = modes.scrollMode;
|
}
|
||||||
spreadMode = modes.spreadMode;
|
if (
|
||||||
|
pageLayout &&
|
||||||
|
scrollMode === ScrollMode.UNKNOWN &&
|
||||||
|
spreadMode === SpreadMode.UNKNOWN
|
||||||
|
) {
|
||||||
|
const modes = apiPageLayoutToViewerModes(pageLayout);
|
||||||
|
// TODO: Try to improve page-switching when using the mouse-wheel
|
||||||
|
// and/or arrow-keys before allowing the document to control this.
|
||||||
|
// scrollMode = modes.scrollMode;
|
||||||
|
spreadMode = modes.spreadMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setInitialView(hash, {
|
this.setInitialView(hash, {
|
||||||
|
@ -269,7 +269,9 @@ class PDFScriptingManager {
|
|||||||
// NOTE: Always ignore the pageLayout in GeckoView since there's
|
// NOTE: Always ignore the pageLayout in GeckoView since there's
|
||||||
// no UI available to change Scroll/Spread modes for the user.
|
// no UI available to change Scroll/Spread modes for the user.
|
||||||
if (
|
if (
|
||||||
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("GECKOVIEW")) ||
|
(typeof PDFJSDev === "undefined"
|
||||||
|
? window.isGECKOVIEW
|
||||||
|
: PDFJSDev.test("GECKOVIEW")) ||
|
||||||
isInPresentationMode
|
isInPresentationMode
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
|
@ -68,6 +68,7 @@ function webViewerLoad() {
|
|||||||
|
|
||||||
document.head.append(link);
|
document.head.append(link);
|
||||||
}
|
}
|
||||||
|
window.isGECKOVIEW = true;
|
||||||
|
|
||||||
import("pdfjs-web/genericcom.js").then(function (genericCom) {
|
import("pdfjs-web/genericcom.js").then(function (genericCom) {
|
||||||
PDFViewerApplication.run(config);
|
PDFViewerApplication.run(config);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user