Merge pull request #16018 from Snuffleupagus/GeckoView-skip-pageLabels

[GeckoView] Skip fetching/parsing of pageLabels
This commit is contained in:
Jonas Jenwald 2023-02-07 21:36:30 +01:00 committed by GitHub
commit 72abcedf48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 17 deletions

View File

@ -467,7 +467,9 @@ const PDFViewerApplication = {
linkService: pdfLinkService,
eventBus,
updateMatchesCountOnProgress:
typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW"),
typeof PDFJSDev === "undefined"
? !window.isGECKOVIEW
: !PDFJSDev.test("GECKOVIEW"),
});
this.findController = findController;
@ -1251,23 +1253,28 @@ const PDFViewerApplication = {
spreadMode = stored.spreadMode | 0;
}
}
// 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.
// 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" || !PDFJSDev.test("GECKOVIEW")) &&
pageLayout &&
scrollMode === ScrollMode.UNKNOWN &&
spreadMode === SpreadMode.UNKNOWN
typeof PDFJSDev === "undefined"
? !window.isGECKOVIEW
: !PDFJSDev.test("GECKOVIEW")
) {
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;
// Always let the user preference/view history take precedence.
if (pageMode && sidebarView === SidebarView.UNKNOWN) {
sidebarView = apiPageModeToSidebarView(pageMode);
}
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, {
@ -1528,6 +1535,13 @@ const PDFViewerApplication = {
* @private
*/
async _initializePageLabels(pdfDocument) {
if (
typeof PDFJSDev === "undefined"
? window.isGECKOVIEW
: PDFJSDev.test("GECKOVIEW")
) {
return;
}
const labels = await pdfDocument.getPageLabels();
if (pdfDocument !== this.pdfDocument) {

View File

@ -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;

View File

@ -68,6 +68,7 @@ function webViewerLoad() {
document.head.append(link);
}
window.isGECKOVIEW = true;
import("pdfjs-web/genericcom.js").then(function (genericCom) {
PDFViewerApplication.run(config);