Skip to content

Commit

Permalink
Move the internal API/Worker isEditing-state into `RenderingIntentF…
Browse files Browse the repository at this point in the history
…lag`

In *hindsight* this seems like a better idea, since it avoids the need to manually pass `isEditing` around as a boolean value.
Note that `RenderingIntentFlag` is *internal* functionality, not exposed in the official API, which means that it can be extended and modified as necessary.
  • Loading branch information
Snuffleupagus committed Jul 4, 2024
1 parent 790470c commit ab19b38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ class Page {
intent,
cacheKey,
annotationStorage = null,
isEditing = false,
modifiedIds = null,
}) {
const contentStreamPromise = this.getContentStream();
Expand Down Expand Up @@ -570,6 +569,7 @@ class Page {
return { length: pageOpList.totalLength };
}
const renderForms = !!(intent & RenderingIntentFlag.ANNOTATIONS_FORMS),
isEditing = !!(intent & RenderingIntentFlag.IS_EDITING),
intentAny = !!(intent & RenderingIntentFlag.ANY),
intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY),
intentPrint = !!(intent & RenderingIntentFlag.PRINT);
Expand Down
1 change: 0 additions & 1 deletion src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ class WorkerMessageHandler {
intent: data.intent,
cacheKey: data.cacheKey,
annotationStorage: data.annotationStorage,
isEditing: data.isEditing,
modifiedIds: data.modifiedIds,
})
.then(
Expand Down
7 changes: 3 additions & 4 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,6 @@ class PDFPageProxy {
renderingIntent,
cacheKey,
annotationStorageSerializable,
isEditing,
modifiedIds,
}) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
Expand All @@ -1836,7 +1835,6 @@ class PDFPageProxy {
intent: renderingIntent,
cacheKey,
annotationStorage: map,
isEditing,
modifiedIds,
},
transfer
Expand Down Expand Up @@ -2473,6 +2471,9 @@ class WorkerTransport {
warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
}

if (isEditing) {
renderingIntent += RenderingIntentFlag.IS_EDITING;
}
if (isOpList) {
renderingIntent += RenderingIntentFlag.OPLIST;
}
Expand All @@ -2483,15 +2484,13 @@ class WorkerTransport {
const cacheKeyBuf = [
renderingIntent,
annotationStorageSerializable.hash,
isEditing ? 1 : 0,
modifiedIdsHash,
];

return {
renderingIntent,
cacheKey: cacheKeyBuf.join("_"),
annotationStorageSerializable,
isEditing,
modifiedIds,
};
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const RenderingIntentFlag = {
ANNOTATIONS_FORMS: 0x10,
ANNOTATIONS_STORAGE: 0x20,
ANNOTATIONS_DISABLE: 0x40,
IS_EDITING: 0x80,
OPLIST: 0x100,
};

Expand Down

0 comments on commit ab19b38

Please sign in to comment.