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

XFA - Add support for access property #13595

Merged
merged 1 commit into from
Jun 21, 2021
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
13 changes: 13 additions & 0 deletions src/core/xfa/html_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,18 @@ function fixTextIndent(styles) {
}
}

function setAccess(node, classNames) {
switch (node.access) {
case "nonInteractive":
case "readOnly":
classNames.push("xfaReadOnly");
break;
case "protected":
classNames.push("xfaDisabled");
break;
}
}

function getFonts(family, fontFinder) {
if (family.startsWith("'") || family.startsWith('"')) {
family = family.slice(1, family.length - 1);
Expand All @@ -473,6 +485,7 @@ export {
layoutClass,
layoutText,
measureToString,
setAccess,
setMinMaxDimensions,
toStyle,
};
9 changes: 9 additions & 0 deletions src/core/xfa/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
layoutClass,
layoutText,
measureToString,
setAccess,
setMinMaxDimensions,
toStyle,
} from "./html_utils.js";
Expand Down Expand Up @@ -2023,8 +2024,11 @@ class ExclGroup extends XFAObject {
const children = [];
const attributes = {
id: this[$uid],
class: [],
};

setAccess(this, attributes.class);

if (!this[$extra]) {
this[$extra] = Object.create(null);
}
Expand Down Expand Up @@ -2329,6 +2333,8 @@ class Field extends XFAObject {
class: classNames,
};

setAccess(this, classNames);

if (this.name) {
attributes.xfaName = this.name;
}
Expand Down Expand Up @@ -4171,8 +4177,11 @@ class Subform extends XFAObject {
const children = [];
const attributes = {
id: this[$uid],
class: [],
};

setAccess(this, attributes.class);

if (!this[$extra]) {
this[$extra] = Object.create(null);
}
Expand Down
11 changes: 11 additions & 0 deletions src/display/xfa_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ class XfaLayer {
childHtml.appendChild(document.createTextNode(child.value));
}
}

for (const el of rootDiv.querySelectorAll(
".xfaDisabled input, .xfaDisabled textarea"
)) {
el.setAttribute("disabled", true);
}
for (const el of rootDiv.querySelectorAll(
".xfaReadOnly input, .xfaReadOnly textarea"
)) {
el.setAttribute("readOnly", true);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/xfa_bug1716816.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://bugzilla.mozilla.org/attachment.cgi?id=9227455
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,14 @@
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_bug1716816",
"file": "pdfs/xfa_bug1716816.pdf",
"md5": "3051cd18db7839bc4953df35b52cf3e0",
"link": true,
"rounds": 1,
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_bug1716809",
"file": "pdfs/xfa_bug1716809.pdf",
"md5": "7192f9e27e8b84776d107f57cbe353d5",
Expand Down
7 changes: 7 additions & 0 deletions web/xfa_layer_builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@
flex: 1;
}

.xfaDisabled input,
.xfaDisabled textarea,
.xfaReadOnly input,
.xfaReadOnly textarea {
background: initial;
}

@media print {
.xfaTextfield,
.xfaSelect {
Expand Down