factor out isSpace

This commit is contained in:
Andreas Gal 2011-05-08 11:32:53 -07:00
parent 506828d522
commit a2dcda8be5

28
pdf.js
View File

@ -70,7 +70,7 @@ var Stream = (function() {
return constructor; return constructor;
})(); })();
var StringStream = (function () { var StringStream = (function() {
function constructor(str) { function constructor(str) {
var length = str.length; var length = str.length;
var bytes = new Uint8Array(length); var bytes = new Uint8Array(length);
@ -84,7 +84,15 @@ var StringStream = (function () {
return constructor; return constructor;
})(); })();
var DecryptStream = (function () { var FlateStream = (function() {
const codeLenCodeMap = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
11, 4, 12, 3, 13, 2, 14, 1, 15];
function constructor(str, pred, columns, colors, bits) {
}
})();
var DecryptStream = (function() {
function constructor(str, fileKey, encAlgorithm, keyLength) { function constructor(str, fileKey, encAlgorithm, keyLength) {
// TODO // TODO
} }
@ -214,6 +222,10 @@ var Lexer = (function() {
this.stream = stream; this.stream = stream;
} }
constructor.isSpace = function(ch) {
return ch == " " || ch == "\t";
}
// A '1' in this array means the character is white space. A '1' or // A '1' in this array means the character is white space. A '1' or
// '2' means the character ends a name or command. // '2' means the character ends a name or command.
var specialChars = [ var specialChars = [
@ -660,6 +672,8 @@ var Parser = (function() {
return stream; return stream;
}, },
makeFilter: function(stream, name, params) { makeFilter: function(stream, name, params) {
print(name);
print(uneval(params));
// TODO // TODO
return stream; return stream;
} }
@ -668,7 +682,7 @@ var Parser = (function() {
return constructor; return constructor;
})(); })();
var Linearization = (function () { var Linearization = (function() {
function constructor(stream) { function constructor(stream) {
this.parser = new Parser(new Lexer(stream), false); this.parser = new Parser(new Lexer(stream), false);
var obj1 = this.parser.getObj(); var obj1 = this.parser.getObj();
@ -744,7 +758,7 @@ var Linearization = (function () {
return constructor; return constructor;
})(); })();
var XRef = (function () { var XRef = (function() {
function constructor(stream, startXRef, mainXRefEntriesOffset) { function constructor(stream, startXRef, mainXRefEntriesOffset) {
this.stream = stream; this.stream = stream;
this.entries = []; this.entries = [];
@ -856,7 +870,7 @@ var XRef = (function () {
return constructor; return constructor;
})(); })();
var PDFDoc = (function () { var PDFDoc = (function() {
function constructor(stream) { function constructor(stream) {
this.stream = stream; this.stream = stream;
this.setup(); this.setup();
@ -892,7 +906,7 @@ var PDFDoc = (function () {
if (stream.find("startxref", 1024, true)) { if (stream.find("startxref", 1024, true)) {
stream.skip(9); stream.skip(9);
var ch; var ch;
while ((ch = stream.getChar()) == " " || ch == "\t") while (Lexer.isSpace(ch = stream.getChar()))
; ;
var str = ""; var str = "";
while ((ch - "0") <= 9) { while ((ch - "0") <= 9) {
@ -1186,7 +1200,7 @@ var CanvasGraphics = (function() {
this.ctx.scale(cw / mediaBox.width, -ch / mediaBox.height); this.ctx.scale(cw / mediaBox.width, -ch / mediaBox.height);
this.ctx.translate(0, -mediaBox.height); this.ctx.translate(0, -mediaBox.height);
}, },
endDrawing: function () { endDrawing: function() {
this.ctx.restore(); this.ctx.restore();
}, },