mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Replace the AnnotationStorage.lastModified
-getter with a proper hash-method
The current `lastModified`-getter, which only contains a time-stamp, is a fairly crude way of detecting if the stored data has actually been changed. In particular, when the `getRawValue`-method is used, the `lastModified`-getter doesn't cope with data being modified from the "outside". To fix these issues[1], and to prevent any future bugs in this code, this patch introduces a new `AnnotationStorage.hash`-getter which computes a hash of the currently stored data. To simplify things this re-uses the existing `MurmurHash3_64`-implementation, which required moving that file into the `src/shared/`-folder, since its performance should be good enough here. --- [1] Given how the `AnnotationStorage.lastModified`-getter was used, this would have been limited to *printing* of forms.
This commit is contained in:
parent
8135d7ccf6
commit
8267fd8a52
5 changed files with 14 additions and 10 deletions
|
@ -2402,7 +2402,7 @@ class WorkerTransport {
|
|||
isOpList = false
|
||||
) {
|
||||
let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.
|
||||
let lastModified = "";
|
||||
let annotationHash = "";
|
||||
|
||||
switch (intent) {
|
||||
case "any":
|
||||
|
@ -2429,7 +2429,7 @@ class WorkerTransport {
|
|||
case AnnotationMode.ENABLE_STORAGE:
|
||||
renderingIntent += RenderingIntentFlag.ANNOTATIONS_STORAGE;
|
||||
|
||||
lastModified = this.annotationStorage.lastModified;
|
||||
annotationHash = this.annotationStorage.hash;
|
||||
break;
|
||||
default:
|
||||
warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
|
||||
|
@ -2441,7 +2441,7 @@ class WorkerTransport {
|
|||
|
||||
return {
|
||||
renderingIntent,
|
||||
cacheKey: `${renderingIntent}_${lastModified}`,
|
||||
cacheKey: `${renderingIntent}_${annotationHash}`,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue