mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Send the AnnotationStorage
-data to the worker-thread as a Map
Rather than converting the `AnnotationStorage`-data to an Object, before sending it to the worker-thread, we should be able to simply send the internal `Map` directly. The "structured clone algorithm" doesn't have a problem with `Map`s, however the `LoopbackPort` used when workers are *disabled* (e.g. in Node.js environments) didn't use to support them. With PR 12997 having lifted that restriction, we should now be able to simply send the `AnnotationStorage`-data as-is rather than having to iterate through it to first create an Object. *Please note:* The changes in `src/core/annotation.js` could have been a lot more compact if we were able to use optional chaining in the `src/core` folder. Unfortunately that's still not possible, since SystemJS is being used in the development viewer (i.g. `gulp server`) and fixing that is *still* blocked by [bug 1247687](https://bugzilla.mozilla.org/show_bug.cgi?id=1247687).
This commit is contained in:
parent
0fa9976268
commit
e9038cc3d1
4 changed files with 133 additions and 89 deletions
|
@ -1214,7 +1214,7 @@ class PDFPageProxy {
|
|||
pageIndex: this._pageIndex,
|
||||
intent: renderingIntent,
|
||||
renderInteractiveForms: renderInteractiveForms === true,
|
||||
annotationStorage: annotationStorage?.getAll() || null,
|
||||
annotationStorage: annotationStorage?.serializable || null,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2613,7 +2613,7 @@ class WorkerTransport {
|
|||
return this.messageHandler
|
||||
.sendWithPromise("SaveDocument", {
|
||||
numPages: this._numPages,
|
||||
annotationStorage: annotationStorage?.getAll() || null,
|
||||
annotationStorage: annotationStorage?.serializable || null,
|
||||
filename: this._fullReader?.filename ?? null,
|
||||
})
|
||||
.finally(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue