mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
[api-minor] Stop polyfilling structuredClone
in legacy builds
Comparing the currently supported browsers/environments, see [the FAQ](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support) and the [MDN compatibility data](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility), the `structuredClone` polyfill is *only* needed in Google Chrome versions < 98. Because of some limitations in the core-js polyfill we're currently forced to special-case the `transfer` handling to prevent bugs, and it'd be nice to avoid that. Note that `structuredClone`, with transfers, is only used in two spots: - The `LoopbackPort` class, which is only used with fake workers. Given that fake workers should *never* be used in browsers, breaking that edge-case in older Google Chrome versions seem fine. - The `AnnotationStorage` class, when Stamp-annotations have been added to the document. Given that Google Chrome isn't the main focus of development, breaking *part* of the editing-functionality in older Google Chrome versions should hopefully be acceptable.
This commit is contained in:
parent
e6c3257175
commit
8bd3cc0313
3 changed files with 19 additions and 27 deletions
|
@ -1802,7 +1802,7 @@ class PDFPageProxy {
|
|||
'_pumpOperatorList: Expected valid "renderingIntent" argument.'
|
||||
);
|
||||
}
|
||||
const { map, transfers } = annotationStorageSerializable;
|
||||
const { map, transfer } = annotationStorageSerializable;
|
||||
|
||||
const readableStream = this._transport.messageHandler.sendWithStream(
|
||||
"GetOperatorList",
|
||||
|
@ -1812,7 +1812,7 @@ class PDFPageProxy {
|
|||
cacheKey,
|
||||
annotationStorage: map,
|
||||
},
|
||||
transfers
|
||||
transfer
|
||||
);
|
||||
const reader = readableStream.getReader();
|
||||
|
||||
|
@ -1942,14 +1942,7 @@ class LoopbackPort {
|
|||
|
||||
postMessage(obj, transfer) {
|
||||
const event = {
|
||||
data: structuredClone(
|
||||
obj,
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("SKIP_BABEL || TESTING")) &&
|
||||
transfer
|
||||
? { transfer }
|
||||
: null
|
||||
),
|
||||
data: structuredClone(obj, transfer ? { transfer } : null),
|
||||
};
|
||||
|
||||
this.#deferred.then(() => {
|
||||
|
@ -2853,7 +2846,7 @@ class WorkerTransport {
|
|||
"please use the getData-method instead."
|
||||
);
|
||||
}
|
||||
const { map, transfers } = this.annotationStorage.serializable;
|
||||
const { map, transfer } = this.annotationStorage.serializable;
|
||||
|
||||
return this.messageHandler
|
||||
.sendWithPromise(
|
||||
|
@ -2864,7 +2857,7 @@ class WorkerTransport {
|
|||
annotationStorage: map,
|
||||
filename: this._fullReader?.filename ?? null,
|
||||
},
|
||||
transfers
|
||||
transfer
|
||||
)
|
||||
.finally(() => {
|
||||
this.annotationStorage.resetModified();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue