mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-28 23:28:16 +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:
parent
4619b1b568
commit
0fa9976268
5 changed files with 413 additions and 18 deletions
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { $clean, $finalize, $onChild, $onText } from "./xfa_object.js";
|
||||
import { $clean, $finalize, $onChild, $onText, $setId } from "./xfa_object.js";
|
||||
import { XMLParserBase, XMLParserErrorCode } from "../xml_parser.js";
|
||||
import { Builder } from "./builder.js";
|
||||
import { warn } from "../../shared/util.js";
|
||||
|
@ -23,7 +23,8 @@ class XFAParser extends XMLParserBase {
|
|||
super();
|
||||
this._builder = new Builder();
|
||||
this._stack = [];
|
||||
this._current = this._builder.buildRoot();
|
||||
this._ids = new Map();
|
||||
this._current = this._builder.buildRoot(this._ids);
|
||||
this._errorCode = XMLParserErrorCode.NoError;
|
||||
this._whiteRegex = /^\s+$/;
|
||||
}
|
||||
|
@ -35,6 +36,8 @@ class XFAParser extends XMLParserBase {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
this._current[$finalize]();
|
||||
|
||||
return this._current.element;
|
||||
}
|
||||
|
||||
|
@ -101,7 +104,9 @@ class XFAParser extends XMLParserBase {
|
|||
if (isEmpty) {
|
||||
// No children: just push the node into its parent.
|
||||
node[$finalize]();
|
||||
this._current[$onChild](node);
|
||||
if (this._current[$onChild](node)) {
|
||||
node[$setId](this._ids);
|
||||
}
|
||||
node[$clean](this._builder);
|
||||
return;
|
||||
}
|
||||
|
@ -114,7 +119,9 @@ class XFAParser extends XMLParserBase {
|
|||
const node = this._current;
|
||||
node[$finalize]();
|
||||
this._current = this._stack.pop();
|
||||
this._current[$onChild](node);
|
||||
if (this._current[$onChild](node)) {
|
||||
node[$setId](this._ids);
|
||||
}
|
||||
node[$clean](this._builder);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue