Skip to content

Commit 7cb92a6

Browse files
committed
XFA - Add support for access property
- it's a partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716816.
1 parent 2e6d3d6 commit 7cb92a6

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

src/core/xfa/html_utils.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@ function fixTextIndent(styles) {
448448
}
449449
}
450450

451+
function setAccess(node, classNames) {
452+
switch (node.access) {
453+
case "nonInteractive":
454+
case "readOnly":
455+
classNames.push("xfaReadOnly");
456+
break;
457+
case "protected":
458+
classNames.push("xfaDisabled");
459+
break;
460+
}
461+
}
462+
451463
function getFonts(family, fontFinder) {
452464
if (family.startsWith("'") || family.startsWith('"')) {
453465
family = family.slice(1, family.length - 1);
@@ -473,6 +485,7 @@ export {
473485
layoutClass,
474486
layoutText,
475487
measureToString,
488+
setAccess,
476489
setMinMaxDimensions,
477490
toStyle,
478491
};

src/core/xfa/template.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
layoutClass,
7373
layoutText,
7474
measureToString,
75+
setAccess,
7576
setMinMaxDimensions,
7677
toStyle,
7778
} from "./html_utils.js";
@@ -2023,8 +2024,11 @@ class ExclGroup extends XFAObject {
20232024
const children = [];
20242025
const attributes = {
20252026
id: this[$uid],
2027+
class: [],
20262028
};
20272029

2030+
setAccess(this, attributes.class);
2031+
20282032
if (!this[$extra]) {
20292033
this[$extra] = Object.create(null);
20302034
}
@@ -2329,6 +2333,8 @@ class Field extends XFAObject {
23292333
class: classNames,
23302334
};
23312335

2336+
setAccess(this, classNames);
2337+
23322338
if (this.name) {
23332339
attributes.xfaName = this.name;
23342340
}
@@ -4171,8 +4177,11 @@ class Subform extends XFAObject {
41714177
const children = [];
41724178
const attributes = {
41734179
id: this[$uid],
4180+
class: [],
41744181
};
41754182

4183+
setAccess(this, attributes.class);
4184+
41764185
if (!this[$extra]) {
41774186
this[$extra] = Object.create(null);
41784187
}

src/display/xfa_layer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ class XfaLayer {
181181
childHtml.appendChild(document.createTextNode(child.value));
182182
}
183183
}
184+
185+
for (const el of rootDiv.querySelectorAll(
186+
".xfaDisabled input, .xfaDisabled textarea"
187+
)) {
188+
el.setAttribute("disabled", true);
189+
}
190+
for (const el of rootDiv.querySelectorAll(
191+
".xfaReadOnly input, .xfaReadOnly textarea"
192+
)) {
193+
el.setAttribute("readOnly", true);
194+
}
184195
}
185196

186197
/**

test/pdfs/xfa_bug1716816.pdf.link

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://bugzilla.mozilla.org/attachment.cgi?id=9227455

test/test_manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,14 @@
946946
"enableXfa": true,
947947
"type": "eq"
948948
},
949+
{ "id": "xfa_bug1716816",
950+
"file": "pdfs/xfa_bug1716816.pdf",
951+
"md5": "3051cd18db7839bc4953df35b52cf3e0",
952+
"link": true,
953+
"rounds": 1,
954+
"enableXfa": true,
955+
"type": "eq"
956+
},
949957
{ "id": "xfa_bug1716809",
950958
"file": "pdfs/xfa_bug1716809.pdf",
951959
"md5": "7192f9e27e8b84776d107f57cbe353d5",

web/xfa_layer_builder.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@
277277
flex: 1;
278278
}
279279

280+
.xfaDisabled input,
281+
.xfaDisabled textarea,
282+
.xfaReadOnly input,
283+
.xfaReadOnly textarea {
284+
background: initial;
285+
}
286+
280287
@media print {
281288
.xfaTextfield,
282289
.xfaSelect {

0 commit comments

Comments
 (0)