rewrote prototype inhertence
This commit is contained in:
parent
2e581a1563
commit
4e72572fe7
50
pdf.js
50
pdf.js
@ -345,8 +345,9 @@ var FlateStream = (function() {
|
||||
DecodeStream.call(this);
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
getBits: function(bits) {
|
||||
constructor.prototype = Object.create(DecodeStream.prototype);
|
||||
|
||||
constructor.prototype.getBits = function(bits) {
|
||||
var codeSize = this.codeSize;
|
||||
var codeBuf = this.codeBuf;
|
||||
var bytes = this.bytes;
|
||||
@ -364,8 +365,8 @@ var FlateStream = (function() {
|
||||
this.codeSize = codeSize -= bits;
|
||||
this.bytesPos = bytesPos;
|
||||
return b;
|
||||
},
|
||||
getCode: function(table) {
|
||||
};
|
||||
constructor.prototype.getCode = function(table) {
|
||||
var codes = table[0];
|
||||
var maxLen = table[1];
|
||||
var codeSize = this.codeSize;
|
||||
@ -389,8 +390,8 @@ var FlateStream = (function() {
|
||||
this.codeSize = (codeSize - codeLen);
|
||||
this.bytesPos = bytesPos;
|
||||
return codeVal;
|
||||
},
|
||||
generateHuffmanTable: function(lengths) {
|
||||
};
|
||||
constructor.prototype.generateHuffmanTable = function(lengths) {
|
||||
var n = lengths.length;
|
||||
|
||||
// find max code length
|
||||
@ -426,8 +427,8 @@ var FlateStream = (function() {
|
||||
}
|
||||
|
||||
return [codes, maxLen];
|
||||
},
|
||||
readBlock: function() {
|
||||
};
|
||||
constructor.prototype.readBlock = function() {
|
||||
function repeat(stream, array, len, offset, what) {
|
||||
var repeat = stream.getBits(len) + offset;
|
||||
while (repeat-- > 0)
|
||||
@ -507,10 +508,10 @@ var FlateStream = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
litCodeTable = this.generateHuffmanTable(
|
||||
codeLengths.slice(0, numLitCodes));
|
||||
distCodeTable = this.generateHuffmanTable(
|
||||
codeLengths.slice(numLitCodes, codes));
|
||||
litCodeTable =
|
||||
this.generateHuffmanTable(codeLengths.slice(0, numLitCodes));
|
||||
distCodeTable =
|
||||
this.generateHuffmanTable(codeLengths.slice(numLitCodes, codes));
|
||||
} else {
|
||||
error("Unknown block type in flate stream");
|
||||
}
|
||||
@ -543,16 +544,8 @@ var FlateStream = (function() {
|
||||
buffer[pos] = buffer[pos - dist];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var thisPrototype = constructor.prototype;
|
||||
var superPrototype = DecodeStream.prototype;
|
||||
for (var i in superPrototype) {
|
||||
if (!thisPrototype[i])
|
||||
thisPrototype[i] = superPrototype[i];
|
||||
}
|
||||
|
||||
return constructor;
|
||||
})();
|
||||
|
||||
@ -586,8 +579,9 @@ var PredictorStream = (function() {
|
||||
DecodeStream.call(this);
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
readBlockTiff : function() {
|
||||
constructor.prototype = Object.create(DecodeStream.prototype);
|
||||
|
||||
constructor.prototype.readBlockTiff = function() {
|
||||
var buffer = this.buffer;
|
||||
var pos = this.pos;
|
||||
|
||||
@ -651,8 +645,8 @@ var PredictorStream = (function() {
|
||||
}
|
||||
}
|
||||
this.bufferLength += rowBytes;
|
||||
},
|
||||
readBlockPng : function() {
|
||||
};
|
||||
constructor.prototype.readBlockPng = function() {
|
||||
var buffer = this.buffer;
|
||||
var pos = this.pos;
|
||||
|
||||
@ -726,16 +720,8 @@ var PredictorStream = (function() {
|
||||
break;
|
||||
}
|
||||
this.bufferLength += rowBytes;
|
||||
},
|
||||
};
|
||||
|
||||
var thisPrototype = constructor.prototype;
|
||||
var superPrototype = DecodeStream.prototype;
|
||||
for (var i in superPrototype) {
|
||||
if (!thisPrototype[i])
|
||||
thisPrototype[i] = superPrototype[i];
|
||||
}
|
||||
|
||||
return constructor;
|
||||
})();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user