mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 04:47:21 +02:00
Compare commits
No commits in common. "e06b32c8318026e0c72d478c79e7a94bc8fee524" and "5da507f279b535e44254d05976c2a8ce881f4380" have entirely different histories.
e06b32c831
...
5da507f279
@ -3488,8 +3488,8 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
|
|||||||
// always make the field value an array with zero, one or multiple items.
|
// always make the field value an array with zero, one or multiple items.
|
||||||
if (typeof this.data.fieldValue === "string") {
|
if (typeof this.data.fieldValue === "string") {
|
||||||
this.data.fieldValue = [this.data.fieldValue];
|
this.data.fieldValue = [this.data.fieldValue];
|
||||||
} else {
|
} else if (!this.data.fieldValue) {
|
||||||
this.data.fieldValue ||= [];
|
this.data.fieldValue = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The specs say that we should have an indices array only with
|
// The specs say that we should have an indices array only with
|
||||||
|
|||||||
@ -998,7 +998,9 @@ class Catalog {
|
|||||||
warn(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`);
|
warn(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prefs ??= Object.create(null);
|
if (!prefs) {
|
||||||
|
prefs = Object.create(null);
|
||||||
|
}
|
||||||
prefs[key] = prefValue;
|
prefs[key] = prefValue;
|
||||||
}
|
}
|
||||||
return shadow(this, "viewerPreferences", prefs);
|
return shadow(this, "viewerPreferences", prefs);
|
||||||
@ -1040,7 +1042,9 @@ class Catalog {
|
|||||||
const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
|
const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
|
||||||
for (const [key, value] of nameTree.getAll()) {
|
for (const [key, value] of nameTree.getAll()) {
|
||||||
const fs = new FileSpec(value, this.xref);
|
const fs = new FileSpec(value, this.xref);
|
||||||
attachments ??= Object.create(null);
|
if (!attachments) {
|
||||||
|
attachments = Object.create(null);
|
||||||
|
}
|
||||||
attachments[stringToPDFString(key)] = fs.serializable;
|
attachments[stringToPDFString(key)] = fs.serializable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1054,7 +1058,9 @@ class Catalog {
|
|||||||
if (obj instanceof Dict && obj.has("XFAImages")) {
|
if (obj instanceof Dict && obj.has("XFAImages")) {
|
||||||
const nameTree = new NameTree(obj.getRaw("XFAImages"), this.xref);
|
const nameTree = new NameTree(obj.getRaw("XFAImages"), this.xref);
|
||||||
for (const [key, value] of nameTree.getAll()) {
|
for (const [key, value] of nameTree.getAll()) {
|
||||||
xfaImages ??= new Dict(this.xref);
|
if (!xfaImages) {
|
||||||
|
xfaImages = new Dict(this.xref);
|
||||||
|
}
|
||||||
xfaImages.set(stringToPDFString(key), value);
|
xfaImages.set(stringToPDFString(key), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1532,7 +1532,9 @@ class PDFDocument {
|
|||||||
warn(`Bad value, for custom key "${key}", in Info: ${value}.`);
|
warn(`Bad value, for custom key "${key}", in Info: ${value}.`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
docInfo.Custom ??= Object.create(null);
|
if (!docInfo.Custom) {
|
||||||
|
docInfo.Custom = Object.create(null);
|
||||||
|
}
|
||||||
docInfo.Custom[key] = customValue;
|
docInfo.Custom[key] = customValue;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,9 @@ class XFAParser extends XMLParserBase {
|
|||||||
}
|
}
|
||||||
} else if (name.startsWith("xmlns:")) {
|
} else if (name.startsWith("xmlns:")) {
|
||||||
const prefix = name.substring("xmlns:".length);
|
const prefix = name.substring("xmlns:".length);
|
||||||
prefixes ??= [];
|
if (!prefixes) {
|
||||||
|
prefixes = [];
|
||||||
|
}
|
||||||
prefixes.push({ prefix, value });
|
prefixes.push({ prefix, value });
|
||||||
} else {
|
} else {
|
||||||
const i = name.indexOf(":");
|
const i = name.indexOf(":");
|
||||||
@ -100,7 +102,10 @@ class XFAParser extends XMLParserBase {
|
|||||||
} else {
|
} else {
|
||||||
// Attributes can have their own namespace.
|
// Attributes can have their own namespace.
|
||||||
// For example in data, we can have <foo xfa:dataNode="dataGroup"/>
|
// For example in data, we can have <foo xfa:dataNode="dataGroup"/>
|
||||||
const nsAttrs = (attributeObj[$nsAttributes] ??= Object.create(null));
|
let nsAttrs = attributeObj[$nsAttributes];
|
||||||
|
if (!nsAttrs) {
|
||||||
|
nsAttrs = attributeObj[$nsAttributes] = Object.create(null);
|
||||||
|
}
|
||||||
const [ns, attrName] = [name.slice(0, i), name.slice(i + 1)];
|
const [ns, attrName] = [name.slice(0, i), name.slice(i + 1)];
|
||||||
const attrs = (nsAttrs[ns] ||= Object.create(null));
|
const attrs = (nsAttrs[ns] ||= Object.create(null));
|
||||||
attrs[attrName] = value;
|
attrs[attrName] = value;
|
||||||
|
|||||||
@ -2462,7 +2462,9 @@ class ExclGroup extends XFAObject {
|
|||||||
|
|
||||||
setAccess(this, attributes.class);
|
setAccess(this, attributes.class);
|
||||||
|
|
||||||
this[$extra] ||= Object.create(null);
|
if (!this[$extra]) {
|
||||||
|
this[$extra] = Object.create(null);
|
||||||
|
}
|
||||||
|
|
||||||
Object.assign(this[$extra], {
|
Object.assign(this[$extra], {
|
||||||
children,
|
children,
|
||||||
@ -2951,7 +2953,9 @@ class Field extends XFAObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.attributes.style ||= Object.create(null);
|
if (!ui.attributes.style) {
|
||||||
|
ui.attributes.style = Object.create(null);
|
||||||
|
}
|
||||||
|
|
||||||
let aElement = null;
|
let aElement = null;
|
||||||
|
|
||||||
@ -3044,7 +3048,9 @@ class Field extends XFAObject {
|
|||||||
caption.attributes.class[0] = "xfaCaptionForCheckButton";
|
caption.attributes.class[0] = "xfaCaptionForCheckButton";
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.attributes.class ||= [];
|
if (!ui.attributes.class) {
|
||||||
|
ui.attributes.class = [];
|
||||||
|
}
|
||||||
|
|
||||||
ui.children.splice(0, 0, caption);
|
ui.children.splice(0, 0, caption);
|
||||||
|
|
||||||
@ -4061,9 +4067,11 @@ class PageArea extends XFAObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[$getNextPage]() {
|
[$getNextPage]() {
|
||||||
this[$extra] ||= {
|
if (!this[$extra]) {
|
||||||
numberOfUse: 0,
|
this[$extra] = {
|
||||||
};
|
numberOfUse: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const parent = this[$getParent]();
|
const parent = this[$getParent]();
|
||||||
if (parent.relation === "orderedOccurrence") {
|
if (parent.relation === "orderedOccurrence") {
|
||||||
@ -4082,9 +4090,11 @@ class PageArea extends XFAObject {
|
|||||||
|
|
||||||
[$toHTML]() {
|
[$toHTML]() {
|
||||||
// TODO: incomplete.
|
// TODO: incomplete.
|
||||||
this[$extra] ||= {
|
if (!this[$extra]) {
|
||||||
numberOfUse: 1,
|
this[$extra] = {
|
||||||
};
|
numberOfUse: 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const children = [];
|
const children = [];
|
||||||
this[$extra].children = children;
|
this[$extra].children = children;
|
||||||
@ -4176,11 +4186,13 @@ class PageSet extends XFAObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[$getNextPage]() {
|
[$getNextPage]() {
|
||||||
this[$extra] ||= {
|
if (!this[$extra]) {
|
||||||
numberOfUse: 1,
|
this[$extra] = {
|
||||||
pageIndex: -1,
|
numberOfUse: 1,
|
||||||
pageSetIndex: -1,
|
pageIndex: -1,
|
||||||
};
|
pageSetIndex: -1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (this.relation === "orderedOccurrence") {
|
if (this.relation === "orderedOccurrence") {
|
||||||
if (this[$extra].pageIndex + 1 < this.pageArea.children.length) {
|
if (this[$extra].pageIndex + 1 < this.pageArea.children.length) {
|
||||||
@ -5055,7 +5067,9 @@ class Subform extends XFAObject {
|
|||||||
|
|
||||||
setAccess(this, attributes.class);
|
setAccess(this, attributes.class);
|
||||||
|
|
||||||
this[$extra] ||= Object.create(null);
|
if (!this[$extra]) {
|
||||||
|
this[$extra] = Object.create(null);
|
||||||
|
}
|
||||||
|
|
||||||
Object.assign(this[$extra], {
|
Object.assign(this[$extra], {
|
||||||
children,
|
children,
|
||||||
@ -5481,7 +5495,9 @@ class Template extends XFAObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pageArea ||= pageAreas[0];
|
if (!pageArea) {
|
||||||
|
pageArea = pageAreas[0];
|
||||||
|
}
|
||||||
|
|
||||||
pageArea[$extra] = {
|
pageArea[$extra] = {
|
||||||
numberOfUse: 1,
|
numberOfUse: 1,
|
||||||
|
|||||||
@ -202,15 +202,18 @@ class App extends PDFObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get constants() {
|
get constants() {
|
||||||
return (this._constants ??= Object.freeze({
|
if (!this._constants) {
|
||||||
align: Object.freeze({
|
this._constants = Object.freeze({
|
||||||
left: 0,
|
align: Object.freeze({
|
||||||
center: 1,
|
left: 0,
|
||||||
right: 2,
|
center: 1,
|
||||||
top: 3,
|
right: 2,
|
||||||
bottom: 4,
|
top: 3,
|
||||||
}),
|
bottom: 4,
|
||||||
}));
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this._constants;
|
||||||
}
|
}
|
||||||
|
|
||||||
set constants(_) {
|
set constants(_) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user