mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16: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:
parent
3c78ff5fb0
commit
70b6ddc5d9
2 changed files with 36 additions and 27 deletions
|
@ -230,11 +230,44 @@ class OptionalContentConfig {
|
|||
}
|
||||
|
||||
setVisibility(id, visible = true) {
|
||||
if (!this.#groups.has(id)) {
|
||||
const group = this.#groups.get(id);
|
||||
if (!group) {
|
||||
warn(`Optional content group not found: ${id}`);
|
||||
return;
|
||||
}
|
||||
this.#groups.get(id)._setVisible(INTERNAL, !!visible, /* userSet = */ true);
|
||||
group._setVisible(INTERNAL, !!visible, /* userSet = */ true);
|
||||
|
||||
this.#cachedGetHash = null;
|
||||
}
|
||||
|
||||
setOCGState({ state, preserveRB }) {
|
||||
let operator;
|
||||
|
||||
for (const elem of state) {
|
||||
switch (elem) {
|
||||
case "ON":
|
||||
case "OFF":
|
||||
case "Toggle":
|
||||
operator = elem;
|
||||
continue;
|
||||
}
|
||||
|
||||
const group = this.#groups.get(elem);
|
||||
if (!group) {
|
||||
continue;
|
||||
}
|
||||
switch (operator) {
|
||||
case "ON":
|
||||
group._setVisible(INTERNAL, true);
|
||||
break;
|
||||
case "OFF":
|
||||
group._setVisible(INTERNAL, false);
|
||||
break;
|
||||
case "Toggle":
|
||||
group._setVisible(INTERNAL, !group.visible);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.#cachedGetHash = null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue