Skip to content

Commit ab19b38

Browse files
committed
Move the internal API/Worker isEditing-state into RenderingIntentFlag
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.
1 parent 790470c commit ab19b38

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/core/document.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ class Page {
411411
intent,
412412
cacheKey,
413413
annotationStorage = null,
414-
isEditing = false,
415414
modifiedIds = null,
416415
}) {
417416
const contentStreamPromise = this.getContentStream();
@@ -570,6 +569,7 @@ class Page {
570569
return { length: pageOpList.totalLength };
571570
}
572571
const renderForms = !!(intent & RenderingIntentFlag.ANNOTATIONS_FORMS),
572+
isEditing = !!(intent & RenderingIntentFlag.IS_EDITING),
573573
intentAny = !!(intent & RenderingIntentFlag.ANY),
574574
intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY),
575575
intentPrint = !!(intent & RenderingIntentFlag.PRINT);

src/core/worker.js

-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ class WorkerMessageHandler {
752752
intent: data.intent,
753753
cacheKey: data.cacheKey,
754754
annotationStorage: data.annotationStorage,
755-
isEditing: data.isEditing,
756755
modifiedIds: data.modifiedIds,
757756
})
758757
.then(

src/display/api.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,6 @@ class PDFPageProxy {
18181818
renderingIntent,
18191819
cacheKey,
18201820
annotationStorageSerializable,
1821-
isEditing,
18221821
modifiedIds,
18231822
}) {
18241823
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
@@ -1836,7 +1835,6 @@ class PDFPageProxy {
18361835
intent: renderingIntent,
18371836
cacheKey,
18381837
annotationStorage: map,
1839-
isEditing,
18401838
modifiedIds,
18411839
},
18421840
transfer
@@ -2473,6 +2471,9 @@ class WorkerTransport {
24732471
warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
24742472
}
24752473

2474+
if (isEditing) {
2475+
renderingIntent += RenderingIntentFlag.IS_EDITING;
2476+
}
24762477
if (isOpList) {
24772478
renderingIntent += RenderingIntentFlag.OPLIST;
24782479
}
@@ -2483,15 +2484,13 @@ class WorkerTransport {
24832484
const cacheKeyBuf = [
24842485
renderingIntent,
24852486
annotationStorageSerializable.hash,
2486-
isEditing ? 1 : 0,
24872487
modifiedIdsHash,
24882488
];
24892489

24902490
return {
24912491
renderingIntent,
24922492
cacheKey: cacheKeyBuf.join("_"),
24932493
annotationStorageSerializable,
2494-
isEditing,
24952494
modifiedIds,
24962495
};
24972496
}

src/shared/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const RenderingIntentFlag = {
5656
ANNOTATIONS_FORMS: 0x10,
5757
ANNOTATIONS_STORAGE: 0x20,
5858
ANNOTATIONS_DISABLE: 0x40,
59+
IS_EDITING: 0x80,
5960
OPLIST: 0x100,
6061
};
6162

0 commit comments

Comments
 (0)