XFA - Add support for access property

- it's a partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716816.
This commit is contained in:
Calixte Denizet 2021-06-20 18:56:14 +02:00
parent 2e6d3d6b00
commit 7cb92a64b1
6 changed files with 49 additions and 0 deletions

View File

@ -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);
@ -473,6 +485,7 @@ export {
layoutClass,
layoutText,
measureToString,
setAccess,
setMinMaxDimensions,
toStyle,
};

View File

@ -72,6 +72,7 @@ import {
layoutClass,
layoutText,
measureToString,
setAccess,
setMinMaxDimensions,
toStyle,
} from "./html_utils.js";
@ -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);
}
@ -2329,6 +2333,8 @@ class Field extends XFAObject {
class: classNames,
};
setAccess(this, classNames);
if (this.name) {
attributes.xfaName = this.name;
}
@ -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);
}

View File

@ -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);
}
}
/**

View File

@ -0,0 +1 @@
https://bugzilla.mozilla.org/attachment.cgi?id=9227455

View File

@ -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",

View File

@ -277,6 +277,13 @@
flex: 1;
}
.xfaDisabled input,
.xfaDisabled textarea,
.xfaReadOnly input,
.xfaReadOnly textarea {
background: initial;
}
@media print {
.xfaTextfield,
.xfaSelect {