Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the internal API/Worker isEditing-state into RenderingIntentFlag #18387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
}
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
3 changes: 3 additions & 0 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
* how these flags are being used:
* - ANY, DISPLAY, and PRINT are the normal rendering intents, note the
* `PDFPageProxy.{render, getOperatorList, getAnnotations}`-methods.
* - SAVE is used, on the worker-thread, when saving modified annotations.
* - ANNOTATIONS_FORMS, ANNOTATIONS_STORAGE, ANNOTATIONS_DISABLE control which
* annotations are rendered onto the canvas (i.e. by being included in the
* operatorList), note the `PDFPageProxy.{render, getOperatorList}`-methods
* and their `annotationMode`-option.
* - IS_EDITING is used when editing is active in the viewer.
* - OPLIST is used with the `PDFPageProxy.getOperatorList`-method, note the
* `OperatorList`-constructor (on the worker-thread).
*/
Expand All @@ -56,6 +58,7 @@ const RenderingIntentFlag = {
ANNOTATIONS_FORMS: 0x10,
ANNOTATIONS_STORAGE: 0x20,
ANNOTATIONS_DISABLE: 0x40,
IS_EDITING: 0x80,
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
OPLIST: 0x100,
};

Expand Down