Add a getDocId method to the idFactory, in Page instances, to avoid passing around PDFManager instances unnecessarily (PR 7941 follow-up)

This way we can avoid manually building a "document id" in multiple places in `evaluator.js`, and it also let's us avoid passing in an otherwise unnecessary `PDFManager` instance when creating a `PartialEvaluator`.
This commit is contained in:
Jonas Jenwald 2019-04-20 12:36:49 +02:00
parent 55d9b35d37
commit 34952b732e
7 changed files with 36 additions and 46 deletions

View file

@ -54,13 +54,15 @@ class Page {
this.evaluatorOptions = pdfManager.evaluatorOptions;
this.resourcesPromise = null;
const uniquePrefix = `p${this.pageIndex}_`;
const idCounters = {
obj: 0,
};
this.idFactory = {
createObjId() {
return uniquePrefix + (++idCounters.obj);
return `p${pageIndex}_${++idCounters.obj}`;
},
getDocId() {
return `g_${pdfManager.docId}`;
},
};
}
@ -195,7 +197,6 @@ class Page {
]);
const partialEvaluator = new PartialEvaluator({
pdfManager: this.pdfManager,
xref: this.xref,
handler,
pageIndex: this.pageIndex,
@ -270,7 +271,6 @@ class Page {
const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(([contentStream]) => {
const partialEvaluator = new PartialEvaluator({
pdfManager: this.pdfManager,
xref: this.xref,
handler,
pageIndex: this.pageIndex,