Enable the import/no-cycle
ESLint plugin rule
Having cyclical imports is obviously not a good idea, and this ESLint plugin rule can help detect those; please see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
This commit is contained in:
parent
605d9f492f
commit
cf3a35e9da
@ -37,6 +37,7 @@
|
|||||||
"import/extensions": ["error", "always", { "ignorePackages": true, }],
|
"import/extensions": ["error", "always", { "ignorePackages": true, }],
|
||||||
"import/first": "error",
|
"import/first": "error",
|
||||||
"import/named": "error",
|
"import/named": "error",
|
||||||
|
"import/no-cycle": "error",
|
||||||
"import/no-empty-named-blocks": "error",
|
"import/no-empty-named-blocks": "error",
|
||||||
"import/no-mutable-exports": "error",
|
"import/no-mutable-exports": "error",
|
||||||
"import/no-self-import": "error",
|
"import/no-self-import": "error",
|
||||||
|
@ -36,12 +36,10 @@ import {
|
|||||||
$removeChild,
|
$removeChild,
|
||||||
$setValue,
|
$setValue,
|
||||||
$text,
|
$text,
|
||||||
XFAAttribute,
|
} from "./symbol_utils.js";
|
||||||
XFAObjectArray,
|
|
||||||
XmlObject,
|
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { BindItems, Field, Items, SetProperty, Text } from "./template.js";
|
import { BindItems, Field, Items, SetProperty, Text } from "./template.js";
|
||||||
import { createDataNode, searchNode } from "./som.js";
|
import { createDataNode, searchNode } from "./som.js";
|
||||||
|
import { XFAAttribute, XFAObjectArray, XmlObject } from "./xfa_object.js";
|
||||||
import { NamespaceIds } from "./namespaces.js";
|
import { NamespaceIds } from "./namespaces.js";
|
||||||
import { warn } from "../../shared/util.js";
|
import { warn } from "../../shared/util.js";
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ import {
|
|||||||
$onChild,
|
$onChild,
|
||||||
$resolvePrototypes,
|
$resolvePrototypes,
|
||||||
$root,
|
$root,
|
||||||
XFAObject,
|
} from "./symbol_utils.js";
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { NamespaceSetUp } from "./setup.js";
|
import { NamespaceSetUp } from "./setup.js";
|
||||||
import { Template } from "./template.js";
|
import { Template } from "./template.js";
|
||||||
import { UnknownNamespace } from "./unknown.js";
|
import { UnknownNamespace } from "./unknown.js";
|
||||||
import { warn } from "../../shared/util.js";
|
import { warn } from "../../shared/util.js";
|
||||||
|
import { XFAObject } from "./xfa_object.js";
|
||||||
|
|
||||||
class Root extends XFAObject {
|
class Root extends XFAObject {
|
||||||
constructor(ids) {
|
constructor(ids) {
|
||||||
|
@ -14,9 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
||||||
|
import { $content, $finalize } from "./symbol_utils.js";
|
||||||
import {
|
import {
|
||||||
$content,
|
|
||||||
$finalize,
|
|
||||||
ContentObject,
|
ContentObject,
|
||||||
IntegerObject,
|
IntegerObject,
|
||||||
Option01,
|
Option01,
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
$setValue,
|
$setValue,
|
||||||
$toString,
|
$toString,
|
||||||
$uid,
|
$uid,
|
||||||
} from "./xfa_object.js";
|
} from "./symbol_utils.js";
|
||||||
|
|
||||||
class DataHandler {
|
class DataHandler {
|
||||||
constructor(root, data) {
|
constructor(root, data) {
|
||||||
|
@ -19,10 +19,9 @@ import {
|
|||||||
$namespaceId,
|
$namespaceId,
|
||||||
$nodeName,
|
$nodeName,
|
||||||
$onChild,
|
$onChild,
|
||||||
XFAObject,
|
} from "./symbol_utils.js";
|
||||||
XmlObject,
|
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
||||||
|
import { XFAObject, XmlObject } from "./xfa_object.js";
|
||||||
|
|
||||||
const DATASETS_NS_ID = NamespaceIds.datasets.id;
|
const DATASETS_NS_ID = NamespaceIds.datasets.id;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
$text,
|
$text,
|
||||||
$toHTML,
|
$toHTML,
|
||||||
$toPages,
|
$toPages,
|
||||||
} from "./xfa_object.js";
|
} from "./symbol_utils.js";
|
||||||
import { Binder } from "./bind.js";
|
import { Binder } from "./bind.js";
|
||||||
import { DataHandler } from "./data.js";
|
import { DataHandler } from "./data.js";
|
||||||
import { FontFinder } from "./fonts.js";
|
import { FontFinder } from "./fonts.js";
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { $globalData } from "./xfa_object.js";
|
import { $globalData } from "./symbol_utils.js";
|
||||||
import { stripQuotes } from "./utils.js";
|
import { stripQuotes } from "./utils.js";
|
||||||
import { warn } from "../../shared/util.js";
|
import { warn } from "../../shared/util.js";
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ import {
|
|||||||
$pushGlyphs,
|
$pushGlyphs,
|
||||||
$text,
|
$text,
|
||||||
$toStyle,
|
$toStyle,
|
||||||
XFAObject,
|
} from "./symbol_utils.js";
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { createValidAbsoluteUrl, warn } from "../../shared/util.js";
|
import { createValidAbsoluteUrl, warn } from "../../shared/util.js";
|
||||||
import { getMeasurement, stripQuotes } from "./utils.js";
|
import { getMeasurement, stripQuotes } from "./utils.js";
|
||||||
import { selectFont } from "./fonts.js";
|
import { selectFont } from "./fonts.js";
|
||||||
import { TextMeasure } from "./text.js";
|
import { TextMeasure } from "./text.js";
|
||||||
|
import { XFAObject } from "./xfa_object.js";
|
||||||
|
|
||||||
function measureToString(m) {
|
function measureToString(m) {
|
||||||
if (typeof m === "string") {
|
if (typeof m === "string") {
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
$getTemplateRoot,
|
$getTemplateRoot,
|
||||||
$isSplittable,
|
$isSplittable,
|
||||||
$isThereMoreWidth,
|
$isThereMoreWidth,
|
||||||
} from "./xfa_object.js";
|
} from "./symbol_utils.js";
|
||||||
import { measureToString } from "./html_utils.js";
|
import { measureToString } from "./html_utils.js";
|
||||||
|
|
||||||
// Subform and ExclGroup have a layout so they share these functions.
|
// Subform and ExclGroup have a layout so they share these functions.
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
$onChild,
|
$onChild,
|
||||||
$onText,
|
$onText,
|
||||||
$setId,
|
$setId,
|
||||||
} from "./xfa_object.js";
|
} from "./symbol_utils.js";
|
||||||
import { XMLParserBase, XMLParserErrorCode } from "../xml_parser.js";
|
import { XMLParserBase, XMLParserErrorCode } from "../xml_parser.js";
|
||||||
import { Builder } from "./builder.js";
|
import { Builder } from "./builder.js";
|
||||||
import { warn } from "../../shared/util.js";
|
import { warn } from "../../shared/util.js";
|
||||||
|
@ -14,17 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
$appendChild,
|
|
||||||
$getChildren,
|
$getChildren,
|
||||||
$getChildrenByClass,
|
$getChildrenByClass,
|
||||||
$getChildrenByName,
|
$getChildrenByName,
|
||||||
$getParent,
|
$getParent,
|
||||||
$namespaceId,
|
} from "./symbol_utils.js";
|
||||||
XFAObject,
|
|
||||||
XFAObjectArray,
|
|
||||||
XmlObject,
|
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { NamespaceIds } from "./namespaces.js";
|
|
||||||
import { warn } from "../../shared/util.js";
|
import { warn } from "../../shared/util.js";
|
||||||
|
|
||||||
const namePattern = /^[^.[]+/;
|
const namePattern = /^[^.[]+/;
|
||||||
@ -58,7 +52,6 @@ const shortcuts = new Map([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const somCache = new WeakMap();
|
const somCache = new WeakMap();
|
||||||
const NS_DATASETS = NamespaceIds.datasets.id;
|
|
||||||
|
|
||||||
function parseIndex(index) {
|
function parseIndex(index) {
|
||||||
index = index.trim();
|
index = index.trim();
|
||||||
@ -193,7 +186,7 @@ function searchNode(
|
|||||||
const { name, cacheName, operator, index } = parsed[i];
|
const { name, cacheName, operator, index } = parsed[i];
|
||||||
const nodes = [];
|
const nodes = [];
|
||||||
for (const node of root) {
|
for (const node of root) {
|
||||||
if (!(node instanceof XFAObject)) {
|
if (!node.isXFAObject) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +211,7 @@ function searchNode(
|
|||||||
break;
|
break;
|
||||||
case operators.dotHash:
|
case operators.dotHash:
|
||||||
children = node[$getChildrenByClass](name);
|
children = node[$getChildrenByClass](name);
|
||||||
if (children instanceof XFAObjectArray) {
|
if (children.isXFAObjectArray) {
|
||||||
children = children.children;
|
children = children.children;
|
||||||
} else {
|
} else {
|
||||||
children = [children];
|
children = [children];
|
||||||
@ -265,20 +258,6 @@ function searchNode(
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNodes(root, path) {
|
|
||||||
let node = null;
|
|
||||||
for (const { name, index } of path) {
|
|
||||||
for (let i = 0, ii = !isFinite(index) ? 0 : index; i <= ii; i++) {
|
|
||||||
const nsId = root[$namespaceId] === NS_DATASETS ? -1 : root[$namespaceId];
|
|
||||||
node = new XmlObject(nsId, name);
|
|
||||||
root[$appendChild](node);
|
|
||||||
}
|
|
||||||
|
|
||||||
root = node;
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDataNode(root, container, expr) {
|
function createDataNode(root, container, expr) {
|
||||||
const parsed = parseExpression(expr);
|
const parsed = parseExpression(expr);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
@ -302,7 +281,7 @@ function createDataNode(root, container, expr) {
|
|||||||
const { name, operator, index } = parsed[i];
|
const { name, operator, index } = parsed[i];
|
||||||
if (!isFinite(index)) {
|
if (!isFinite(index)) {
|
||||||
parsed[i].index = 0;
|
parsed[i].index = 0;
|
||||||
return createNodes(root, parsed.slice(i));
|
return root.createNodes(parsed.slice(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
let children;
|
let children;
|
||||||
@ -315,7 +294,7 @@ function createDataNode(root, container, expr) {
|
|||||||
break;
|
break;
|
||||||
case operators.dotHash:
|
case operators.dotHash:
|
||||||
children = root[$getChildrenByClass](name);
|
children = root[$getChildrenByClass](name);
|
||||||
if (children instanceof XFAObjectArray) {
|
if (children.isXFAObjectArray) {
|
||||||
children = children.children;
|
children = children.children;
|
||||||
} else {
|
} else {
|
||||||
children = [children];
|
children = [children];
|
||||||
@ -326,19 +305,19 @@ function createDataNode(root, container, expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (children.length === 0) {
|
if (children.length === 0) {
|
||||||
return createNodes(root, parsed.slice(i));
|
return root.createNodes(parsed.slice(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < children.length) {
|
if (index < children.length) {
|
||||||
const child = children[index];
|
const child = children[index];
|
||||||
if (!(child instanceof XFAObject)) {
|
if (!child.isXFAObject) {
|
||||||
warn(`XFA - Cannot create a node.`);
|
warn(`XFA - Cannot create a node.`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
root = child;
|
root = child;
|
||||||
} else {
|
} else {
|
||||||
parsed[i].index = index - children.length;
|
parsed[i].index = index - children.length;
|
||||||
return createNodes(root, parsed.slice(i));
|
return root.createNodes(parsed.slice(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
156
src/core/xfa/symbol_utils.js
Normal file
156
src/core/xfa/symbol_utils.js
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/* Copyright 2021 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// We use these symbols to avoid name conflict between tags
|
||||||
|
// and properties/methods names.
|
||||||
|
const $acceptWhitespace = Symbol();
|
||||||
|
const $addHTML = Symbol();
|
||||||
|
const $appendChild = Symbol();
|
||||||
|
const $childrenToHTML = Symbol();
|
||||||
|
const $clean = Symbol();
|
||||||
|
const $cleanPage = Symbol();
|
||||||
|
const $cleanup = Symbol();
|
||||||
|
const $clone = Symbol();
|
||||||
|
const $consumed = Symbol();
|
||||||
|
const $content = Symbol("content");
|
||||||
|
const $data = Symbol("data");
|
||||||
|
const $dump = Symbol();
|
||||||
|
const $extra = Symbol("extra");
|
||||||
|
const $finalize = Symbol();
|
||||||
|
const $flushHTML = Symbol();
|
||||||
|
const $getAttributeIt = Symbol();
|
||||||
|
const $getAttributes = Symbol();
|
||||||
|
const $getAvailableSpace = Symbol();
|
||||||
|
const $getChildrenByClass = Symbol();
|
||||||
|
const $getChildrenByName = Symbol();
|
||||||
|
const $getChildrenByNameIt = Symbol();
|
||||||
|
const $getDataValue = Symbol();
|
||||||
|
const $getExtra = Symbol();
|
||||||
|
const $getRealChildrenByNameIt = Symbol();
|
||||||
|
const $getChildren = Symbol();
|
||||||
|
const $getContainedChildren = Symbol();
|
||||||
|
const $getNextPage = Symbol();
|
||||||
|
const $getSubformParent = Symbol();
|
||||||
|
const $getParent = Symbol();
|
||||||
|
const $getTemplateRoot = Symbol();
|
||||||
|
const $globalData = Symbol();
|
||||||
|
const $hasSettableValue = Symbol();
|
||||||
|
const $ids = Symbol();
|
||||||
|
const $indexOf = Symbol();
|
||||||
|
const $insertAt = Symbol();
|
||||||
|
const $isCDATAXml = Symbol();
|
||||||
|
const $isBindable = Symbol();
|
||||||
|
const $isDataValue = Symbol();
|
||||||
|
const $isDescendent = Symbol();
|
||||||
|
const $isNsAgnostic = Symbol();
|
||||||
|
const $isSplittable = Symbol();
|
||||||
|
const $isThereMoreWidth = Symbol();
|
||||||
|
const $isTransparent = Symbol();
|
||||||
|
const $isUsable = Symbol();
|
||||||
|
const $lastAttribute = Symbol();
|
||||||
|
const $namespaceId = Symbol("namespaceId");
|
||||||
|
const $nodeName = Symbol("nodeName");
|
||||||
|
const $nsAttributes = Symbol();
|
||||||
|
const $onChild = Symbol();
|
||||||
|
const $onChildCheck = Symbol();
|
||||||
|
const $onText = Symbol();
|
||||||
|
const $pushGlyphs = Symbol();
|
||||||
|
const $popPara = Symbol();
|
||||||
|
const $pushPara = Symbol();
|
||||||
|
const $removeChild = Symbol();
|
||||||
|
const $root = Symbol("root");
|
||||||
|
const $resolvePrototypes = Symbol();
|
||||||
|
const $searchNode = Symbol();
|
||||||
|
const $setId = Symbol();
|
||||||
|
const $setSetAttributes = Symbol();
|
||||||
|
const $setValue = Symbol();
|
||||||
|
const $tabIndex = Symbol();
|
||||||
|
const $text = Symbol();
|
||||||
|
const $toPages = Symbol();
|
||||||
|
const $toHTML = Symbol();
|
||||||
|
const $toString = Symbol();
|
||||||
|
const $toStyle = Symbol();
|
||||||
|
const $uid = Symbol("uid");
|
||||||
|
|
||||||
|
export {
|
||||||
|
$acceptWhitespace,
|
||||||
|
$addHTML,
|
||||||
|
$appendChild,
|
||||||
|
$childrenToHTML,
|
||||||
|
$clean,
|
||||||
|
$cleanPage,
|
||||||
|
$cleanup,
|
||||||
|
$clone,
|
||||||
|
$consumed,
|
||||||
|
$content,
|
||||||
|
$data,
|
||||||
|
$dump,
|
||||||
|
$extra,
|
||||||
|
$finalize,
|
||||||
|
$flushHTML,
|
||||||
|
$getAttributeIt,
|
||||||
|
$getAttributes,
|
||||||
|
$getAvailableSpace,
|
||||||
|
$getChildren,
|
||||||
|
$getChildrenByClass,
|
||||||
|
$getChildrenByName,
|
||||||
|
$getChildrenByNameIt,
|
||||||
|
$getContainedChildren,
|
||||||
|
$getDataValue,
|
||||||
|
$getExtra,
|
||||||
|
$getNextPage,
|
||||||
|
$getParent,
|
||||||
|
$getRealChildrenByNameIt,
|
||||||
|
$getSubformParent,
|
||||||
|
$getTemplateRoot,
|
||||||
|
$globalData,
|
||||||
|
$hasSettableValue,
|
||||||
|
$ids,
|
||||||
|
$indexOf,
|
||||||
|
$insertAt,
|
||||||
|
$isBindable,
|
||||||
|
$isCDATAXml,
|
||||||
|
$isDataValue,
|
||||||
|
$isDescendent,
|
||||||
|
$isNsAgnostic,
|
||||||
|
$isSplittable,
|
||||||
|
$isThereMoreWidth,
|
||||||
|
$isTransparent,
|
||||||
|
$isUsable,
|
||||||
|
$lastAttribute,
|
||||||
|
$namespaceId,
|
||||||
|
$nodeName,
|
||||||
|
$nsAttributes,
|
||||||
|
$onChild,
|
||||||
|
$onChildCheck,
|
||||||
|
$onText,
|
||||||
|
$popPara,
|
||||||
|
$pushGlyphs,
|
||||||
|
$pushPara,
|
||||||
|
$removeChild,
|
||||||
|
$resolvePrototypes,
|
||||||
|
$root,
|
||||||
|
$searchNode,
|
||||||
|
$setId,
|
||||||
|
$setSetAttributes,
|
||||||
|
$setValue,
|
||||||
|
$tabIndex,
|
||||||
|
$text,
|
||||||
|
$toHTML,
|
||||||
|
$toPages,
|
||||||
|
$toString,
|
||||||
|
$toStyle,
|
||||||
|
$uid,
|
||||||
|
};
|
@ -58,13 +58,7 @@ import {
|
|||||||
$toPages,
|
$toPages,
|
||||||
$toStyle,
|
$toStyle,
|
||||||
$uid,
|
$uid,
|
||||||
ContentObject,
|
} from "./symbol_utils.js";
|
||||||
Option01,
|
|
||||||
OptionObject,
|
|
||||||
StringObject,
|
|
||||||
XFAObject,
|
|
||||||
XFAObjectArray,
|
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
||||||
import {
|
import {
|
||||||
addHTML,
|
addHTML,
|
||||||
@ -88,6 +82,14 @@ import {
|
|||||||
setPara,
|
setPara,
|
||||||
toStyle,
|
toStyle,
|
||||||
} from "./html_utils.js";
|
} from "./html_utils.js";
|
||||||
|
import {
|
||||||
|
ContentObject,
|
||||||
|
Option01,
|
||||||
|
OptionObject,
|
||||||
|
StringObject,
|
||||||
|
XFAObject,
|
||||||
|
XFAObjectArray,
|
||||||
|
} from "./xfa_object.js";
|
||||||
import {
|
import {
|
||||||
getBBox,
|
getBBox,
|
||||||
getColor,
|
getColor,
|
||||||
|
@ -14,13 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
||||||
import {
|
import { $namespaceId, $nodeName, $onChildCheck } from "./symbol_utils.js";
|
||||||
$namespaceId,
|
import { XFAObject, XFAObjectArray } from "./xfa_object.js";
|
||||||
$nodeName,
|
|
||||||
$onChildCheck,
|
|
||||||
XFAObject,
|
|
||||||
XFAObjectArray,
|
|
||||||
} from "./xfa_object.js";
|
|
||||||
|
|
||||||
const XDP_NS_ID = NamespaceIds.xdp.id;
|
const XDP_NS_ID = NamespaceIds.xdp.id;
|
||||||
|
|
||||||
|
@ -13,83 +13,72 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
$acceptWhitespace,
|
||||||
|
$addHTML,
|
||||||
|
$appendChild,
|
||||||
|
$childrenToHTML,
|
||||||
|
$clean,
|
||||||
|
$cleanup,
|
||||||
|
$clone,
|
||||||
|
$consumed,
|
||||||
|
$content,
|
||||||
|
$dump,
|
||||||
|
$extra,
|
||||||
|
$finalize,
|
||||||
|
$flushHTML,
|
||||||
|
$getAttributeIt,
|
||||||
|
$getAttributes,
|
||||||
|
$getAvailableSpace,
|
||||||
|
$getChildren,
|
||||||
|
$getChildrenByClass,
|
||||||
|
$getChildrenByName,
|
||||||
|
$getChildrenByNameIt,
|
||||||
|
$getContainedChildren,
|
||||||
|
$getDataValue,
|
||||||
|
$getParent,
|
||||||
|
$getRealChildrenByNameIt,
|
||||||
|
$getSubformParent,
|
||||||
|
$getTemplateRoot,
|
||||||
|
$globalData,
|
||||||
|
$hasSettableValue,
|
||||||
|
$indexOf,
|
||||||
|
$insertAt,
|
||||||
|
$isBindable,
|
||||||
|
$isCDATAXml,
|
||||||
|
$isDataValue,
|
||||||
|
$isDescendent,
|
||||||
|
$isNsAgnostic,
|
||||||
|
$isSplittable,
|
||||||
|
$isThereMoreWidth,
|
||||||
|
$isTransparent,
|
||||||
|
$lastAttribute,
|
||||||
|
$namespaceId,
|
||||||
|
$nodeName,
|
||||||
|
$nsAttributes,
|
||||||
|
$onChild,
|
||||||
|
$onChildCheck,
|
||||||
|
$onText,
|
||||||
|
$popPara,
|
||||||
|
$pushPara,
|
||||||
|
$removeChild,
|
||||||
|
$resolvePrototypes,
|
||||||
|
$root,
|
||||||
|
$setId,
|
||||||
|
$setSetAttributes,
|
||||||
|
$setValue,
|
||||||
|
$text,
|
||||||
|
$toHTML,
|
||||||
|
$toString,
|
||||||
|
$toStyle,
|
||||||
|
$uid,
|
||||||
|
} from "./symbol_utils.js";
|
||||||
import { getInteger, getKeyword, HTMLResult } from "./utils.js";
|
import { getInteger, getKeyword, HTMLResult } from "./utils.js";
|
||||||
import { shadow, utf8StringToString, warn } from "../../shared/util.js";
|
import { shadow, utf8StringToString, warn } from "../../shared/util.js";
|
||||||
import { encodeToXmlString } from "../core_utils.js";
|
import { encodeToXmlString } from "../core_utils.js";
|
||||||
import { NamespaceIds } from "./namespaces.js";
|
import { NamespaceIds } from "./namespaces.js";
|
||||||
import { searchNode } from "./som.js";
|
import { searchNode } from "./som.js";
|
||||||
|
|
||||||
// We use these symbols to avoid name conflict between tags
|
|
||||||
// and properties/methods names.
|
|
||||||
const $acceptWhitespace = Symbol();
|
|
||||||
const $addHTML = Symbol();
|
|
||||||
const $appendChild = Symbol();
|
|
||||||
const $childrenToHTML = Symbol();
|
|
||||||
const $clean = Symbol();
|
|
||||||
const $cleanPage = Symbol();
|
|
||||||
const $cleanup = Symbol();
|
|
||||||
const $clone = Symbol();
|
|
||||||
const $consumed = Symbol();
|
|
||||||
const $content = Symbol("content");
|
|
||||||
const $data = Symbol("data");
|
|
||||||
const $dump = Symbol();
|
|
||||||
const $extra = Symbol("extra");
|
|
||||||
const $finalize = Symbol();
|
|
||||||
const $flushHTML = Symbol();
|
|
||||||
const $getAttributeIt = Symbol();
|
|
||||||
const $getAttributes = Symbol();
|
|
||||||
const $getAvailableSpace = Symbol();
|
|
||||||
const $getChildrenByClass = Symbol();
|
|
||||||
const $getChildrenByName = Symbol();
|
|
||||||
const $getChildrenByNameIt = Symbol();
|
|
||||||
const $getDataValue = Symbol();
|
|
||||||
const $getExtra = Symbol();
|
|
||||||
const $getRealChildrenByNameIt = Symbol();
|
|
||||||
const $getChildren = Symbol();
|
|
||||||
const $getContainedChildren = Symbol();
|
|
||||||
const $getNextPage = Symbol();
|
|
||||||
const $getSubformParent = Symbol();
|
|
||||||
const $getParent = Symbol();
|
|
||||||
const $getTemplateRoot = Symbol();
|
|
||||||
const $globalData = Symbol();
|
|
||||||
const $hasSettableValue = Symbol();
|
|
||||||
const $ids = Symbol();
|
|
||||||
const $indexOf = Symbol();
|
|
||||||
const $insertAt = Symbol();
|
|
||||||
const $isCDATAXml = Symbol();
|
|
||||||
const $isBindable = Symbol();
|
|
||||||
const $isDataValue = Symbol();
|
|
||||||
const $isDescendent = Symbol();
|
|
||||||
const $isNsAgnostic = Symbol();
|
|
||||||
const $isSplittable = Symbol();
|
|
||||||
const $isThereMoreWidth = Symbol();
|
|
||||||
const $isTransparent = Symbol();
|
|
||||||
const $isUsable = Symbol();
|
|
||||||
const $lastAttribute = Symbol();
|
|
||||||
const $namespaceId = Symbol("namespaceId");
|
|
||||||
const $nodeName = Symbol("nodeName");
|
|
||||||
const $nsAttributes = Symbol();
|
|
||||||
const $onChild = Symbol();
|
|
||||||
const $onChildCheck = Symbol();
|
|
||||||
const $onText = Symbol();
|
|
||||||
const $pushGlyphs = Symbol();
|
|
||||||
const $popPara = Symbol();
|
|
||||||
const $pushPara = Symbol();
|
|
||||||
const $removeChild = Symbol();
|
|
||||||
const $root = Symbol("root");
|
|
||||||
const $resolvePrototypes = Symbol();
|
|
||||||
const $searchNode = Symbol();
|
|
||||||
const $setId = Symbol();
|
|
||||||
const $setSetAttributes = Symbol();
|
|
||||||
const $setValue = Symbol();
|
|
||||||
const $tabIndex = Symbol();
|
|
||||||
const $text = Symbol();
|
|
||||||
const $toPages = Symbol();
|
|
||||||
const $toHTML = Symbol();
|
|
||||||
const $toString = Symbol();
|
|
||||||
const $toStyle = Symbol();
|
|
||||||
const $uid = Symbol("uid");
|
|
||||||
|
|
||||||
const _applyPrototype = Symbol();
|
const _applyPrototype = Symbol();
|
||||||
const _attributes = Symbol();
|
const _attributes = Symbol();
|
||||||
const _attributeNames = Symbol();
|
const _attributeNames = Symbol();
|
||||||
@ -123,6 +112,29 @@ class XFAObject {
|
|||||||
this[$globalData] = null;
|
this[$globalData] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isXFAObject() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
get isXFAObjectArray() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
createNodes(path) {
|
||||||
|
let root = this,
|
||||||
|
node = null;
|
||||||
|
for (const { name, index } of path) {
|
||||||
|
for (let i = 0, ii = isFinite(index) ? index : 0; i <= ii; i++) {
|
||||||
|
const nsId =
|
||||||
|
root[$namespaceId] === NS_DATASETS ? -1 : root[$namespaceId];
|
||||||
|
node = new XmlObject(nsId, name);
|
||||||
|
root[$appendChild](node);
|
||||||
|
}
|
||||||
|
root = node;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
[$onChild](child) {
|
[$onChild](child) {
|
||||||
if (!this[_hasChildren] || !this[$onChildCheck](child)) {
|
if (!this[_hasChildren] || !this[$onChildCheck](child)) {
|
||||||
return false;
|
return false;
|
||||||
@ -715,6 +727,14 @@ class XFAObjectArray {
|
|||||||
this[_children] = [];
|
this[_children] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isXFAObject() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
get isXFAObjectArray() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
push(child) {
|
push(child) {
|
||||||
const len = this[_children].length;
|
const len = this[_children].length;
|
||||||
if (len <= this[_max]) {
|
if (len <= this[_max]) {
|
||||||
@ -1077,73 +1097,6 @@ class Option10 extends IntegerObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
$acceptWhitespace,
|
|
||||||
$addHTML,
|
|
||||||
$appendChild,
|
|
||||||
$childrenToHTML,
|
|
||||||
$clean,
|
|
||||||
$cleanPage,
|
|
||||||
$cleanup,
|
|
||||||
$clone,
|
|
||||||
$consumed,
|
|
||||||
$content,
|
|
||||||
$data,
|
|
||||||
$dump,
|
|
||||||
$extra,
|
|
||||||
$finalize,
|
|
||||||
$flushHTML,
|
|
||||||
$getAttributeIt,
|
|
||||||
$getAttributes,
|
|
||||||
$getAvailableSpace,
|
|
||||||
$getChildren,
|
|
||||||
$getChildrenByClass,
|
|
||||||
$getChildrenByName,
|
|
||||||
$getChildrenByNameIt,
|
|
||||||
$getContainedChildren,
|
|
||||||
$getDataValue,
|
|
||||||
$getExtra,
|
|
||||||
$getNextPage,
|
|
||||||
$getParent,
|
|
||||||
$getRealChildrenByNameIt,
|
|
||||||
$getSubformParent,
|
|
||||||
$getTemplateRoot,
|
|
||||||
$globalData,
|
|
||||||
$hasSettableValue,
|
|
||||||
$ids,
|
|
||||||
$indexOf,
|
|
||||||
$insertAt,
|
|
||||||
$isBindable,
|
|
||||||
$isCDATAXml,
|
|
||||||
$isDataValue,
|
|
||||||
$isDescendent,
|
|
||||||
$isNsAgnostic,
|
|
||||||
$isSplittable,
|
|
||||||
$isThereMoreWidth,
|
|
||||||
$isTransparent,
|
|
||||||
$isUsable,
|
|
||||||
$namespaceId,
|
|
||||||
$nodeName,
|
|
||||||
$nsAttributes,
|
|
||||||
$onChild,
|
|
||||||
$onChildCheck,
|
|
||||||
$onText,
|
|
||||||
$popPara,
|
|
||||||
$pushGlyphs,
|
|
||||||
$pushPara,
|
|
||||||
$removeChild,
|
|
||||||
$resolvePrototypes,
|
|
||||||
$root,
|
|
||||||
$searchNode,
|
|
||||||
$setId,
|
|
||||||
$setSetAttributes,
|
|
||||||
$setValue,
|
|
||||||
$tabIndex,
|
|
||||||
$text,
|
|
||||||
$toHTML,
|
|
||||||
$toPages,
|
|
||||||
$toString,
|
|
||||||
$toStyle,
|
|
||||||
$uid,
|
|
||||||
ContentObject,
|
ContentObject,
|
||||||
IntegerObject,
|
IntegerObject,
|
||||||
Option01,
|
Option01,
|
||||||
|
@ -27,8 +27,7 @@ import {
|
|||||||
$pushGlyphs,
|
$pushGlyphs,
|
||||||
$text,
|
$text,
|
||||||
$toHTML,
|
$toHTML,
|
||||||
XmlObject,
|
} from "./symbol_utils.js";
|
||||||
} from "./xfa_object.js";
|
|
||||||
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
||||||
import {
|
import {
|
||||||
fixTextIndent,
|
fixTextIndent,
|
||||||
@ -37,6 +36,7 @@ import {
|
|||||||
setFontFamily,
|
setFontFamily,
|
||||||
} from "./html_utils.js";
|
} from "./html_utils.js";
|
||||||
import { getMeasurement, HTMLResult, stripQuotes } from "./utils.js";
|
import { getMeasurement, HTMLResult, stripQuotes } from "./utils.js";
|
||||||
|
import { XmlObject } from "./xfa_object.js";
|
||||||
|
|
||||||
const XHTML_NS_ID = NamespaceIds.xhtml.id;
|
const XHTML_NS_ID = NamespaceIds.xhtml.id;
|
||||||
const $richText = Symbol();
|
const $richText = Symbol();
|
||||||
|
@ -13,18 +13,19 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
FORMS_VERSION,
|
||||||
|
USERACTIVATION_CALLBACKID,
|
||||||
|
VIEWER_TYPE,
|
||||||
|
VIEWER_VARIATION,
|
||||||
|
VIEWER_VERSION,
|
||||||
|
} from "./app_utils.js";
|
||||||
import { Color } from "./color.js";
|
import { Color } from "./color.js";
|
||||||
import { EventDispatcher } from "./event.js";
|
import { EventDispatcher } from "./event.js";
|
||||||
import { FullScreen } from "./fullscreen.js";
|
import { FullScreen } from "./fullscreen.js";
|
||||||
import { PDFObject } from "./pdf_object.js";
|
import { PDFObject } from "./pdf_object.js";
|
||||||
import { Thermometer } from "./thermometer.js";
|
import { Thermometer } from "./thermometer.js";
|
||||||
|
|
||||||
const VIEWER_TYPE = "PDF.js";
|
|
||||||
const VIEWER_VARIATION = "Full";
|
|
||||||
const VIEWER_VERSION = 21.00720099;
|
|
||||||
const FORMS_VERSION = 21.00720099;
|
|
||||||
const USERACTIVATION_CALLBACKID = 0;
|
|
||||||
|
|
||||||
class App extends PDFObject {
|
class App extends PDFObject {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
super(data);
|
super(data);
|
||||||
@ -654,4 +655,4 @@ class App extends PDFObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { App, USERACTIVATION_CALLBACKID };
|
export { App };
|
||||||
|
31
src/scripting_api/app_utils.js
Normal file
31
src/scripting_api/app_utils.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* Copyright 2020 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const VIEWER_TYPE = "PDF.js";
|
||||||
|
const VIEWER_VARIATION = "Full";
|
||||||
|
const VIEWER_VERSION = 21.00720099;
|
||||||
|
const FORMS_VERSION = 21.00720099;
|
||||||
|
|
||||||
|
const USERACTIVATION_CALLBACKID = 0;
|
||||||
|
const USERACTIVATION_MAXTIME_VALIDITY = 5000;
|
||||||
|
|
||||||
|
export {
|
||||||
|
FORMS_VERSION,
|
||||||
|
USERACTIVATION_CALLBACKID,
|
||||||
|
USERACTIVATION_MAXTIME_VALIDITY,
|
||||||
|
VIEWER_TYPE,
|
||||||
|
VIEWER_VARIATION,
|
||||||
|
VIEWER_VERSION,
|
||||||
|
};
|
@ -13,9 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { USERACTIVATION_CALLBACKID } from "./app.js";
|
import {
|
||||||
|
USERACTIVATION_CALLBACKID,
|
||||||
const USERACTIVATION_MAXTIME_VALIDITY = 5000;
|
USERACTIVATION_MAXTIME_VALIDITY,
|
||||||
|
} from "./app_utils.js";
|
||||||
|
|
||||||
class Event {
|
class Event {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
|
@ -19,7 +19,7 @@ import {
|
|||||||
$getChildrenByClass,
|
$getChildrenByClass,
|
||||||
$getChildrenByName,
|
$getChildrenByName,
|
||||||
$text,
|
$text,
|
||||||
} from "../../src/core/xfa/xfa_object.js";
|
} from "../../src/core/xfa/symbol_utils.js";
|
||||||
import { Binder } from "../../src/core/xfa/bind.js";
|
import { Binder } from "../../src/core/xfa/bind.js";
|
||||||
import { searchNode } from "../../src/core/xfa/som.js";
|
import { searchNode } from "../../src/core/xfa/som.js";
|
||||||
import { XFAParser } from "../../src/core/xfa/parser.js";
|
import { XFAParser } from "../../src/core/xfa/parser.js";
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { $uid } from "../../src/core/xfa/xfa_object.js";
|
import { $uid } from "../../src/core/xfa/symbol_utils.js";
|
||||||
import { DataHandler } from "../../src/core/xfa/data.js";
|
import { DataHandler } from "../../src/core/xfa/data.js";
|
||||||
import { searchNode } from "../../src/core/xfa/som.js";
|
import { searchNode } from "../../src/core/xfa/som.js";
|
||||||
import { XFAParser } from "../../src/core/xfa/parser.js";
|
import { XFAParser } from "../../src/core/xfa/parser.js";
|
||||||
|
Loading…
Reference in New Issue
Block a user