[GeckoView] Ignore Scroll/Spread-modes in the PDFViewer
setters
Rather than sprinkling pre-processor statements throughout the viewer-code, simply "disable" the relevant `PDFViewer` setters instead. Also, given that the GeckoView-specific viewer doesn't have a sidebar we don't actually need to explicitly ignore a `pageMode` during loading.
This commit is contained in:
parent
03059e1f86
commit
cca299eeb9
32
web/app.js
32
web/app.js
@ -1281,28 +1281,20 @@ const PDFViewerApplication = {
|
|||||||
spreadMode = stored.spreadMode | 0;
|
spreadMode = stored.spreadMode | 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: Ignore the pageMode/pageLayout in GeckoView since there's no
|
// Always let the user preference/view history take precedence.
|
||||||
// sidebar available, nor any UI for changing the Scroll/Spread modes.
|
if (pageMode && sidebarView === SidebarView.UNKNOWN) {
|
||||||
|
sidebarView = apiPageModeToSidebarView(pageMode);
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev === "undefined"
|
pageLayout &&
|
||||||
? !window.isGECKOVIEW
|
scrollMode === ScrollMode.UNKNOWN &&
|
||||||
: !PDFJSDev.test("GECKOVIEW")
|
spreadMode === SpreadMode.UNKNOWN
|
||||||
) {
|
) {
|
||||||
// Always let the user preference/view history take precedence.
|
const modes = apiPageLayoutToViewerModes(pageLayout);
|
||||||
if (pageMode && sidebarView === SidebarView.UNKNOWN) {
|
// TODO: Try to improve page-switching when using the mouse-wheel
|
||||||
sidebarView = apiPageModeToSidebarView(pageMode);
|
// and/or arrow-keys before allowing the document to control this.
|
||||||
}
|
// scrollMode = modes.scrollMode;
|
||||||
if (
|
spreadMode = modes.spreadMode;
|
||||||
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, {
|
||||||
|
@ -265,21 +265,13 @@ class PDFScriptingManager {
|
|||||||
case "error":
|
case "error":
|
||||||
console.error(value);
|
console.error(value);
|
||||||
break;
|
break;
|
||||||
case "layout": {
|
case "layout":
|
||||||
// NOTE: Always ignore the pageLayout in GeckoView since there's
|
if (isInPresentationMode) {
|
||||||
// no UI available to change Scroll/Spread modes for the user.
|
|
||||||
if (
|
|
||||||
(typeof PDFJSDev === "undefined"
|
|
||||||
? window.isGECKOVIEW
|
|
||||||
: PDFJSDev.test("GECKOVIEW")) ||
|
|
||||||
isInPresentationMode
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const modes = apiPageLayoutToViewerModes(value);
|
const modes = apiPageLayoutToViewerModes(value);
|
||||||
this._pdfViewer.spreadMode = modes.spreadMode;
|
this._pdfViewer.spreadMode = modes.spreadMode;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "page-num":
|
case "page-num":
|
||||||
this._pdfViewer.currentPageNumber = value + 1;
|
this._pdfViewer.currentPageNumber = value + 1;
|
||||||
break;
|
break;
|
||||||
|
@ -1842,6 +1842,15 @@ class PDFViewer {
|
|||||||
* The constants from {ScrollMode} should be used.
|
* The constants from {ScrollMode} should be used.
|
||||||
*/
|
*/
|
||||||
set scrollMode(mode) {
|
set scrollMode(mode) {
|
||||||
|
if (
|
||||||
|
typeof PDFJSDev === "undefined"
|
||||||
|
? window.isGECKOVIEW
|
||||||
|
: PDFJSDev.test("GECKOVIEW")
|
||||||
|
) {
|
||||||
|
// NOTE: Always ignore the pageLayout in GeckoView since there's
|
||||||
|
// no UI available to change Scroll/Spread modes for the user.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this._scrollMode === mode) {
|
if (this._scrollMode === mode) {
|
||||||
return; // The Scroll mode didn't change.
|
return; // The Scroll mode didn't change.
|
||||||
}
|
}
|
||||||
@ -1903,6 +1912,15 @@ class PDFViewer {
|
|||||||
* The constants from {SpreadMode} should be used.
|
* The constants from {SpreadMode} should be used.
|
||||||
*/
|
*/
|
||||||
set spreadMode(mode) {
|
set spreadMode(mode) {
|
||||||
|
if (
|
||||||
|
typeof PDFJSDev === "undefined"
|
||||||
|
? window.isGECKOVIEW
|
||||||
|
: PDFJSDev.test("GECKOVIEW")
|
||||||
|
) {
|
||||||
|
// NOTE: Always ignore the pageLayout in GeckoView since there's
|
||||||
|
// no UI available to change Scroll/Spread modes for the user.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this._spreadMode === mode) {
|
if (this._spreadMode === mode) {
|
||||||
return; // The Spread mode didn't change.
|
return; // The Spread mode didn't change.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user