Remove some duplication in *simple* shadowed getters in src/core/
-code
In these cases there's no good reason, in my opinion, to duplicate the `shadow`-lines since that unnecessarily increases the risk of simple typos (see the previous patch).
This commit is contained in:
parent
1450da4168
commit
cd94a44ca1
@ -82,10 +82,11 @@ class Catalog {
|
||||
|
||||
get version() {
|
||||
const version = this._catDict.get("Version");
|
||||
if (!isName(version)) {
|
||||
return shadow(this, "version", null);
|
||||
}
|
||||
return shadow(this, "version", version.name);
|
||||
return shadow(
|
||||
this,
|
||||
"version",
|
||||
version instanceof Name ? version.name : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,10 +95,11 @@ class Catalog {
|
||||
*/
|
||||
get needsRendering() {
|
||||
const needsRendering = this._catDict.get("NeedsRendering");
|
||||
if (!isBool(needsRendering)) {
|
||||
return shadow(this, "needsRendering", false);
|
||||
}
|
||||
return shadow(this, "needsRendering", needsRendering);
|
||||
return shadow(
|
||||
this,
|
||||
"needsRendering",
|
||||
typeof needsRendering === "boolean" ? needsRendering : false
|
||||
);
|
||||
}
|
||||
|
||||
get collection() {
|
||||
|
@ -263,12 +263,13 @@ class Page {
|
||||
}
|
||||
|
||||
get xfaData() {
|
||||
if (this.xfaFactory) {
|
||||
return shadow(this, "xfaData", {
|
||||
bbox: this.xfaFactory.getBoundingBox(this.pageIndex),
|
||||
});
|
||||
}
|
||||
return shadow(this, "xfaData", null);
|
||||
return shadow(
|
||||
this,
|
||||
"xfaData",
|
||||
this.xfaFactory
|
||||
? { bbox: this.xfaFactory.getBoundingBox(this.pageIndex) }
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
save(handler, task, annotationStorage) {
|
||||
@ -784,11 +785,14 @@ class PDFDocument {
|
||||
}
|
||||
|
||||
get numPages() {
|
||||
let num = 0;
|
||||
if (this.xfaFactory) {
|
||||
return shadow(this, "numPages", this.xfaFactory.numberPages);
|
||||
num = this.xfaFactory.numberPages;
|
||||
} else if (this.linearization) {
|
||||
num = this.linearization.numPages;
|
||||
} else {
|
||||
num = this.catalog.numPages;
|
||||
}
|
||||
const linearization = this.linearization;
|
||||
const num = linearization ? linearization.numPages : this.catalog.numPages;
|
||||
return shadow(this, "numPages", num);
|
||||
}
|
||||
|
||||
@ -883,16 +887,16 @@ class PDFDocument {
|
||||
}
|
||||
|
||||
get xfaFactory() {
|
||||
let data;
|
||||
if (
|
||||
this.pdfManager.enableXfa &&
|
||||
this.catalog.needsRendering &&
|
||||
this.formInfo.hasXfa &&
|
||||
!this.formInfo.hasAcroForm
|
||||
) {
|
||||
const data = this.xfaData;
|
||||
return shadow(this, "xfaFactory", data ? new XFAFactory(data) : null);
|
||||
data = this.xfaData;
|
||||
}
|
||||
return shadow(this, "xfaFactory", null);
|
||||
return shadow(this, "xfaFactory", data ? new XFAFactory(data) : null);
|
||||
}
|
||||
|
||||
get isPureXfa() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user