Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the unused "GetIsPureXfa" message handler; and avoid unnecessary parsing when no structTree is available (PR 13069 follow-up, PR 13221 follow-up) #13223

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/core/document.js
Expand Up @@ -454,7 +454,13 @@ class Page {
const structTreeRoot = await this.pdfManager.ensureCatalog(
"structTreeRoot"
);
return this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
if (!structTreeRoot) {
return null;
}
const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [
structTreeRoot,
]);
return structTree.serializable;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/core/struct_tree.js
Expand Up @@ -328,10 +328,6 @@ class StructTreePage {
}
nodeToSerializable(child, root);
}

if (root.children.length === 0) {
return null;
}
return root;
}
}
Expand Down
18 changes: 4 additions & 14 deletions src/core/worker.js
Expand Up @@ -487,7 +487,7 @@ class WorkerMessageHandler {

handler.on("GetPageJSActions", function ({ pageIndex }) {
return pdfManager.getPage(pageIndex).then(function (page) {
return page.jsActions;
return pdfManager.ensure(page, "jsActions");
});
});

Expand All @@ -497,10 +497,6 @@ class WorkerMessageHandler {
});
});

handler.on("GetIsPureXfa", function wphSetupGetIsPureXfa(data) {
return pdfManager.ensureDoc("isPureXfa");
});

handler.on("GetOutline", function wphSetupGetOutline(data) {
return pdfManager.ensureCatalog("documentOutline");
});
Expand Down Expand Up @@ -747,15 +743,9 @@ class WorkerMessageHandler {
});

handler.on("GetStructTree", function wphGetStructTree(data) {
const pageIndex = data.pageIndex;
return pdfManager
.getPage(pageIndex)
.then(function (page) {
return pdfManager.ensure(page, "getStructTree");
})
.then(function (structTree) {
return structTree.serializable;
});
return pdfManager.getPage(data.pageIndex).then(function (page) {
return pdfManager.ensure(page, "getStructTree");
});
});

handler.on("FontFallback", function (data) {
Expand Down