mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Merge pull request #18526 from calixteman/bug1907958
[Editor] Allow Float32Array for quadpoints in annotations (bug 1907958)
This commit is contained in:
commit
63371eaed8
2 changed files with 18 additions and 4 deletions
|
@ -242,10 +242,19 @@ function isBooleanArray(arr, len) {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
function isNumberArray(arr, len) {
|
||||
if (Array.isArray(arr)) {
|
||||
return (
|
||||
(len === null || arr.length === len) &&
|
||||
arr.every(x => typeof x === "number")
|
||||
);
|
||||
}
|
||||
|
||||
// This check allows us to have typed arrays but not the
|
||||
// BigInt64Array/BigUint64Array types (their elements aren't "number").
|
||||
return (
|
||||
Array.isArray(arr) &&
|
||||
(len === null || arr.length === len) &&
|
||||
arr.every(x => typeof x === "number")
|
||||
ArrayBuffer.isView(arr) &&
|
||||
(arr.length === 0 || typeof arr[0] === "number") &&
|
||||
(len === null || arr.length === len)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -610,7 +610,7 @@ class Driver {
|
|||
|
||||
if (task.annotationStorage) {
|
||||
for (const annotation of Object.values(task.annotationStorage)) {
|
||||
const { bitmapName } = annotation;
|
||||
const { bitmapName, quadPoints } = annotation;
|
||||
if (bitmapName) {
|
||||
promise = promise.then(async doc => {
|
||||
const response = await fetch(
|
||||
|
@ -643,6 +643,11 @@ class Driver {
|
|||
return doc;
|
||||
});
|
||||
}
|
||||
if (quadPoints) {
|
||||
// Just to ensure that the quadPoints are always a Float32Array
|
||||
// like IRL (in order to avoid bugs like bug 1907958).
|
||||
annotation.quadPoints = new Float32Array(quadPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue