Merge pull request #16620 from Snuffleupagus/AnnotationStorage-transfers

Move the `transfers` computation into the `AnnotationStorage` class
This commit is contained in:
Jonas Jenwald 2023-06-30 14:28:55 +02:00 committed by GitHub
commit ffa9795ca9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 75 deletions

View file

@ -41,6 +41,7 @@ import {
import {
AnnotationStorage,
PrintAnnotationStorage,
SerializableEmpty,
} from "./annotation_storage.js";
import {
deprecated,
@ -1801,22 +1802,18 @@ class PDFPageProxy {
/**
* @private
*/
_pumpOperatorList({ renderingIntent, cacheKey, annotationStorageMap }) {
_pumpOperatorList({
renderingIntent,
cacheKey,
annotationStorageSerializable,
}) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
Number.isInteger(renderingIntent) && renderingIntent > 0,
'_pumpOperatorList: Expected valid "renderingIntent" argument.'
);
}
const transfers = [];
if (annotationStorageMap) {
for (const annotation of annotationStorageMap.values()) {
if (annotation.bitmap) {
transfers.push(annotation.bitmap);
}
}
}
const { map, transfers } = annotationStorageSerializable;
const readableStream = this._transport.messageHandler.sendWithStream(
"GetOperatorList",
@ -1824,7 +1821,7 @@ class PDFPageProxy {
pageIndex: this._pageIndex,
intent: renderingIntent,
cacheKey,
annotationStorage: annotationStorageMap,
annotationStorage: map,
},
transfers
);
@ -2449,7 +2446,7 @@ class WorkerTransport {
isOpList = false
) {
let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.
let annotationMap = null;
let annotationStorageSerializable = SerializableEmpty;
switch (intent) {
case "any":
@ -2482,7 +2479,7 @@ class WorkerTransport {
? printAnnotationStorage
: this.annotationStorage;
annotationMap = annotationStorage.serializable;
annotationStorageSerializable = annotationStorage.serializable;
break;
default:
warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
@ -2494,10 +2491,8 @@ class WorkerTransport {
return {
renderingIntent,
cacheKey: `${renderingIntent}_${AnnotationStorage.getHash(
annotationMap
)}`,
annotationStorageMap: annotationMap,
cacheKey: `${renderingIntent}_${annotationStorageSerializable.hash}`,
annotationStorageSerializable,
};
}
@ -2905,22 +2900,15 @@ class WorkerTransport {
"please use the getData-method instead."
);
}
const annotationStorage = this.annotationStorage.serializable;
const transfers = [];
if (annotationStorage) {
for (const annotation of annotationStorage.values()) {
if (annotation.bitmap) {
transfers.push(annotation.bitmap);
}
}
}
const { map, transfers } = this.annotationStorage.serializable;
return this.messageHandler
.sendWithPromise(
"SaveDocument",
{
isPureXfa: !!this._htmlForXfa,
numPages: this._numPages,
annotationStorage,
annotationStorage: map,
filename: this._fullReader?.filename ?? null,
},
transfers