1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Move the /SetOCGState handling into the OptionalContentConfig class (PR 15377 follow-up)

This helps ensure that /SetOCGState actions always take the `Usage` dictionary into account as expected.
This commit is contained in:
Jonas Jenwald 2024-03-05 17:25:36 +01:00
parent 3c78ff5fb0
commit 70b6ddc5d9
2 changed files with 36 additions and 27 deletions

View file

@ -517,31 +517,7 @@ class PDFLinkService {
if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the optional content resolved.
}
let operator;
for (const elem of action.state) {
switch (elem) {
case "ON":
case "OFF":
case "Toggle":
operator = elem;
continue;
}
switch (operator) {
case "ON":
optionalContentConfig.setVisibility(elem, true);
break;
case "OFF":
optionalContentConfig.setVisibility(elem, false);
break;
case "Toggle":
const group = optionalContentConfig.getGroup(elem);
if (group) {
optionalContentConfig.setVisibility(elem, !group.visible);
}
break;
}
}
optionalContentConfig.setOCGState(action);
this.pdfViewer.optionalContentConfigPromise = Promise.resolve(
optionalContentConfig