Reduce indentation when parsing new annotations in getOperatorList
This code has, over the years, become more complex and less indentation generally helps readability.
This commit is contained in:
parent
ce52ce063e
commit
27436d52b2
@ -436,15 +436,14 @@ class Page {
|
|||||||
options: this.evaluatorOptions,
|
options: this.evaluatorOptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newAnnotationsByPage = !this.xfaFactory
|
const newAnnotsByPage = !this.xfaFactory
|
||||||
? getNewAnnotationsMap(annotationStorage)
|
? getNewAnnotationsMap(annotationStorage)
|
||||||
: null;
|
: null;
|
||||||
|
const newAnnots = newAnnotsByPage?.get(this.pageIndex);
|
||||||
|
let newAnnotationsPromise = Promise.resolve(null);
|
||||||
let deletedAnnotations = null;
|
let deletedAnnotations = null;
|
||||||
|
|
||||||
let newAnnotationsPromise = Promise.resolve(null);
|
if (newAnnots) {
|
||||||
if (newAnnotationsByPage) {
|
|
||||||
const newAnnotations = newAnnotationsByPage.get(this.pageIndex);
|
|
||||||
if (newAnnotations) {
|
|
||||||
const annotationGlobalsPromise =
|
const annotationGlobalsPromise =
|
||||||
this.pdfManager.ensureDoc("annotationGlobals");
|
this.pdfManager.ensureDoc("annotationGlobals");
|
||||||
let imagePromises;
|
let imagePromises;
|
||||||
@ -453,7 +452,7 @@ class Page {
|
|||||||
// is defined in another annotation. So we need to find this annotation
|
// is defined in another annotation. So we need to find this annotation
|
||||||
// and generate the bitmap.
|
// and generate the bitmap.
|
||||||
const missingBitmaps = new Set();
|
const missingBitmaps = new Set();
|
||||||
for (const { bitmapId, bitmap } of newAnnotations) {
|
for (const { bitmapId, bitmap } of newAnnots) {
|
||||||
if (bitmapId && !bitmap && !missingBitmaps.has(bitmapId)) {
|
if (bitmapId && !bitmap && !missingBitmaps.has(bitmapId)) {
|
||||||
missingBitmaps.add(bitmapId);
|
missingBitmaps.add(bitmapId);
|
||||||
}
|
}
|
||||||
@ -461,7 +460,7 @@ class Page {
|
|||||||
|
|
||||||
const { isOffscreenCanvasSupported } = this.evaluatorOptions;
|
const { isOffscreenCanvasSupported } = this.evaluatorOptions;
|
||||||
if (missingBitmaps.size > 0) {
|
if (missingBitmaps.size > 0) {
|
||||||
const annotationWithBitmaps = newAnnotations.slice();
|
const annotationWithBitmaps = newAnnots.slice();
|
||||||
for (const [key, annotation] of annotationStorage) {
|
for (const [key, annotation] of annotationStorage) {
|
||||||
if (!key.startsWith(AnnotationEditorPrefix)) {
|
if (!key.startsWith(AnnotationEditorPrefix)) {
|
||||||
continue;
|
continue;
|
||||||
@ -479,14 +478,14 @@ class Page {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
imagePromises = AnnotationFactory.generateImages(
|
imagePromises = AnnotationFactory.generateImages(
|
||||||
newAnnotations,
|
newAnnots,
|
||||||
this.xref,
|
this.xref,
|
||||||
isOffscreenCanvasSupported
|
isOffscreenCanvasSupported
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
deletedAnnotations = new RefSet();
|
deletedAnnotations = new RefSet();
|
||||||
this.#replaceIdByRef(newAnnotations, deletedAnnotations, null);
|
this.#replaceIdByRef(newAnnots, deletedAnnotations, null);
|
||||||
|
|
||||||
newAnnotationsPromise = annotationGlobalsPromise.then(
|
newAnnotationsPromise = annotationGlobalsPromise.then(
|
||||||
annotationGlobals => {
|
annotationGlobals => {
|
||||||
@ -498,15 +497,17 @@ class Page {
|
|||||||
annotationGlobals,
|
annotationGlobals,
|
||||||
partialEvaluator,
|
partialEvaluator,
|
||||||
task,
|
task,
|
||||||
newAnnotations,
|
newAnnots,
|
||||||
imagePromises
|
imagePromises
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
const pageListPromise = Promise.all([
|
||||||
const pageListPromise = dataPromises.then(([contentStream]) => {
|
contentStreamPromise,
|
||||||
|
resourcesPromise,
|
||||||
|
]).then(([contentStream]) => {
|
||||||
const opList = new OperatorList(intent, sink);
|
const opList = new OperatorList(intent, sink);
|
||||||
|
|
||||||
handler.send("StartRenderPage", {
|
handler.send("StartRenderPage", {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user