mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
use ES5 Object operations for lazy properties
This commit is contained in:
parent
07571b0bbf
commit
21c54da9d1
1 changed files with 28 additions and 7 deletions
35
pdf.js
35
pdf.js
|
@ -558,16 +558,37 @@ var PDFDoc = (function () {
|
||||||
this.setup(arrayBuffer);
|
this.setup(arrayBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ShadowGetter(obj, name, value) {
|
||||||
|
Object.defineProperty(obj, name, {
|
||||||
|
value: value,
|
||||||
|
configurable: false,
|
||||||
|
writable: false,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getLinearization: function() {
|
get linearization() {
|
||||||
var linearization = this.linearization;
|
var length = this.stream.length;
|
||||||
if (!linearization)
|
var linearization = false;
|
||||||
return this.linearization = new Linearization(this.stream);
|
if (length) {
|
||||||
|
linearization = new Linearization(this.stream);
|
||||||
|
if (linearization.length != length)
|
||||||
|
linearization = false;
|
||||||
|
}
|
||||||
|
ShadowGetter(this, "linearization", linearization);
|
||||||
return linearization;
|
return linearization;
|
||||||
},
|
},
|
||||||
isLinearized: function() {
|
get startXRef() {
|
||||||
var length = this.stream.length;
|
var startXRef;
|
||||||
return length && this.getLinearization().length == length;
|
var linearization = this.linearization;
|
||||||
|
if (linearization) {
|
||||||
|
// TODO
|
||||||
|
} else {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
ShadowGetter(this, "startXRef", startXRef);
|
||||||
|
return startXRef;
|
||||||
},
|
},
|
||||||
// Find the header, remove leading garbage and setup the stream
|
// Find the header, remove leading garbage and setup the stream
|
||||||
// starting from the header.
|
// starting from the header.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue