1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

XFA - Add support for prototypes (#12979)

- specifications: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.364.2157&rep=rep1&type=pdf#page=225&zoom=auto,-207,784
 - add a clone method on nodes in order to be able to clone a proto;
 - support ids in template namespace;
 - prevent from cycle when applying protos.
This commit is contained in:
calixteman 2021-02-18 01:32:25 -08:00 committed by GitHub
parent 4619b1b568
commit 0fa9976268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 413 additions and 18 deletions

View file

@ -21,6 +21,7 @@ import {
$namespaceId,
$nodeName,
$onChild,
$setSetAttributes,
ContentObject,
Option01,
OptionObject,
@ -1071,9 +1072,15 @@ class ExData extends ContentObject {
child[$namespaceId] === NamespaceIds.xhtml.id
) {
this[$content] = child;
} else if (this.contentType === "text/xml") {
this[$content] = child;
return true;
}
if (this.contentType === "text/xml") {
this[$content] = child;
return true;
}
return false;
}
}
@ -2531,9 +2538,10 @@ class Text extends ContentObject {
[$onChild](child) {
if (child[$namespaceId] === NamespaceIds.xhtml.id) {
this[$content] = child;
} else {
warn(`XFA - Invalid content in Text: ${child[$nodeName]}.`);
return true;
}
warn(`XFA - Invalid content in Text: ${child[$nodeName]}.`);
return false;
}
}
@ -2757,7 +2765,9 @@ class Variables extends XFAObject {
class TemplateNamespace {
static [$buildXFAObject](name, attributes) {
if (TemplateNamespace.hasOwnProperty(name)) {
return TemplateNamespace[name](attributes);
const node = TemplateNamespace[name](attributes);
node[$setSetAttributes](attributes);
return node;
}
return undefined;
}
@ -3215,4 +3225,4 @@ class TemplateNamespace {
}
}
export { TemplateNamespace };
export { Template, TemplateNamespace };