Fix some jslint warnings.
This commit is contained in:
parent
bdfba05779
commit
ef2f3cdc24
84
pdf.js
84
pdf.js
@ -276,11 +276,11 @@ var FakeStream = (function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor.prototype.getBytes = function(length) {
|
constructor.prototype.getBytes = function(length) {
|
||||||
var pos = this.pos;
|
var end, pos = this.pos;
|
||||||
|
|
||||||
if (length) {
|
if (length) {
|
||||||
this.ensureBuffer(pos + length);
|
this.ensureBuffer(pos + length);
|
||||||
var end = pos + length;
|
end = pos + length;
|
||||||
|
|
||||||
while (!this.eof && this.bufferLength < end)
|
while (!this.eof && this.bufferLength < end)
|
||||||
this.readBlock();
|
this.readBlock();
|
||||||
@ -290,7 +290,7 @@ var FakeStream = (function() {
|
|||||||
end = bufEnd;
|
end = bufEnd;
|
||||||
} else {
|
} else {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
var end = this.bufferLength;
|
end = this.bufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pos = end;
|
this.pos = end;
|
||||||
@ -2056,7 +2056,7 @@ var CCITTFaxStream = (function() {
|
|||||||
constructor.prototype.eatBits = function(n) {
|
constructor.prototype.eatBits = function(n) {
|
||||||
if ((this.inputBits -= n) < 0)
|
if ((this.inputBits -= n) < 0)
|
||||||
this.inputBits = 0;
|
this.inputBits = 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
@ -2359,7 +2359,7 @@ var Lexer = (function() {
|
|||||||
|
|
||||||
constructor.isSpace = function(ch) {
|
constructor.isSpace = function(ch) {
|
||||||
return ch == ' ' || ch == '\t';
|
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.
|
||||||
@ -2432,7 +2432,8 @@ var Lexer = (function() {
|
|||||||
var stream = this.stream;
|
var stream = this.stream;
|
||||||
var ch;
|
var ch;
|
||||||
do {
|
do {
|
||||||
switch (ch = stream.getChar()) {
|
ch = stream.getChar();
|
||||||
|
switch (ch) {
|
||||||
case undefined:
|
case undefined:
|
||||||
warn('Unterminated string');
|
warn('Unterminated string');
|
||||||
done = true;
|
done = true;
|
||||||
@ -2449,7 +2450,8 @@ var Lexer = (function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\':
|
||||||
switch (ch = stream.getChar()) {
|
ch = stream.getChar();
|
||||||
|
switch (ch) {
|
||||||
case undefined:
|
case undefined:
|
||||||
warn('Unterminated string');
|
warn('Unterminated string');
|
||||||
done = true;
|
done = true;
|
||||||
@ -2802,7 +2804,7 @@ var Parser = (function() {
|
|||||||
if (xref)
|
if (xref)
|
||||||
length = xref.fetchIfRef(length);
|
length = xref.fetchIfRef(length);
|
||||||
if (!IsInt(length)) {
|
if (!IsInt(length)) {
|
||||||
error('Bad ' + Length + ' attribute in stream');
|
error('Bad ' + length + ' attribute in stream');
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3160,7 +3162,7 @@ var XRef = (function() {
|
|||||||
if (!IsCmd(obj3, 'obj')) {
|
if (!IsCmd(obj3, 'obj')) {
|
||||||
// some bad pdfs use "obj1234" and really mean 1234
|
// some bad pdfs use "obj1234" and really mean 1234
|
||||||
if (obj3.cmd.indexOf('obj') == 0) {
|
if (obj3.cmd.indexOf('obj') == 0) {
|
||||||
var num = parseInt(obj3.cmd.substring(3));
|
num = parseInt(obj3.cmd.substring(3));
|
||||||
if (!isNaN(num))
|
if (!isNaN(num))
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@ -3190,7 +3192,7 @@ var XRef = (function() {
|
|||||||
var i, entries = [], nums = [];
|
var i, entries = [], nums = [];
|
||||||
// read the object numbers to populate cache
|
// read the object numbers to populate cache
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
var num = parser.getObj();
|
num = parser.getObj();
|
||||||
if (!IsInt(num)) {
|
if (!IsInt(num)) {
|
||||||
error('invalid object number in the ObjStm stream: ' + num);
|
error('invalid object number in the ObjStm stream: ' + num);
|
||||||
}
|
}
|
||||||
@ -4175,7 +4177,7 @@ var PartialEvaluator = (function() {
|
|||||||
return function(gfx) {
|
return function(gfx) {
|
||||||
for (var i = 0, length = argsArray.length; i < length; i++)
|
for (var i = 0, length = argsArray.length; i < length; i++)
|
||||||
gfx[fnArray[i]].apply(gfx, argsArray[i]);
|
gfx[fnArray[i]].apply(gfx, argsArray[i]);
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
translateFont: function(fontDict, xref, resources) {
|
translateFont: function(fontDict, xref, resources) {
|
||||||
@ -5221,7 +5223,7 @@ var CanvasGraphics = (function() {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
var Util = (function() {
|
var Util = (function() {
|
||||||
function constructor() {};
|
function constructor() {}
|
||||||
constructor.makeCssRgb = function makergb(r, g, b) {
|
constructor.makeCssRgb = function makergb(r, g, b) {
|
||||||
var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0;
|
var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0;
|
||||||
return 'rgb(' + ri + ',' + gi + ',' + bi + ')';
|
return 'rgb(' + ri + ',' + gi + ',' + bi + ')';
|
||||||
@ -5244,7 +5246,7 @@ var ColorSpace = (function() {
|
|||||||
// Constructor should define this.numComps, this.defaultColor, this.name
|
// Constructor should define this.numComps, this.defaultColor, this.name
|
||||||
function constructor() {
|
function constructor() {
|
||||||
error('should not call ColorSpace constructor');
|
error('should not call ColorSpace constructor');
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
// Input: array of size numComps representing color component values
|
// Input: array of size numComps representing color component values
|
||||||
@ -5279,18 +5281,14 @@ var ColorSpace = (function() {
|
|||||||
case 'DeviceGray':
|
case 'DeviceGray':
|
||||||
case 'G':
|
case 'G':
|
||||||
return new DeviceGrayCS();
|
return new DeviceGrayCS();
|
||||||
break;
|
|
||||||
case 'DeviceRGB':
|
case 'DeviceRGB':
|
||||||
case 'RGB':
|
case 'RGB':
|
||||||
return new DeviceRgbCS();
|
return new DeviceRgbCS();
|
||||||
break;
|
|
||||||
case 'DeviceCMYK':
|
case 'DeviceCMYK':
|
||||||
case 'CMYK':
|
case 'CMYK':
|
||||||
return new DeviceCmykCS();
|
return new DeviceCmykCS();
|
||||||
break;
|
|
||||||
case 'Pattern':
|
case 'Pattern':
|
||||||
return new PatternCS(null);
|
return new PatternCS(null);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
error('unrecognized colorspace ' + mode);
|
error('unrecognized colorspace ' + mode);
|
||||||
}
|
}
|
||||||
@ -5302,30 +5300,25 @@ var ColorSpace = (function() {
|
|||||||
case 'DeviceGray':
|
case 'DeviceGray':
|
||||||
case 'G':
|
case 'G':
|
||||||
return new DeviceGrayCS();
|
return new DeviceGrayCS();
|
||||||
break;
|
|
||||||
case 'DeviceRGB':
|
case 'DeviceRGB':
|
||||||
case 'RGB':
|
case 'RGB':
|
||||||
return new DeviceRgbCS();
|
return new DeviceRgbCS();
|
||||||
break;
|
|
||||||
case 'DeviceCMYK':
|
case 'DeviceCMYK':
|
||||||
case 'CMYK':
|
case 'CMYK':
|
||||||
return new DeviceCmykCS();
|
return new DeviceCmykCS();
|
||||||
break;
|
|
||||||
case 'CalGray':
|
case 'CalGray':
|
||||||
return new DeviceGrayCS();
|
return new DeviceGrayCS();
|
||||||
break;
|
|
||||||
case 'CalRGB':
|
case 'CalRGB':
|
||||||
return new DeviceRgbCS();
|
return new DeviceRgbCS();
|
||||||
break;
|
|
||||||
case 'ICCBased':
|
case 'ICCBased':
|
||||||
var stream = xref.fetchIfRef(cs[1]);
|
var stream = xref.fetchIfRef(cs[1]);
|
||||||
var dict = stream.dict;
|
var dict = stream.dict;
|
||||||
var numComps = dict.get('N');
|
var numComps = dict.get('N');
|
||||||
if (numComps == 1)
|
if (numComps == 1)
|
||||||
return new DeviceGrayCS();
|
return new DeviceGrayCS();
|
||||||
else if (numComps == 3)
|
if (numComps == 3)
|
||||||
return new DeviceRgbCS();
|
return new DeviceRgbCS();
|
||||||
else if (numComps == 4)
|
if (numComps == 4)
|
||||||
return new DeviceCmykCS();
|
return new DeviceCmykCS();
|
||||||
break;
|
break;
|
||||||
case 'Pattern':
|
case 'Pattern':
|
||||||
@ -5333,19 +5326,16 @@ var ColorSpace = (function() {
|
|||||||
if (baseCS)
|
if (baseCS)
|
||||||
baseCS = ColorSpace.parse(baseCS, xref, res);
|
baseCS = ColorSpace.parse(baseCS, xref, res);
|
||||||
return new PatternCS(baseCS);
|
return new PatternCS(baseCS);
|
||||||
break;
|
|
||||||
case 'Indexed':
|
case 'Indexed':
|
||||||
var base = ColorSpace.parse(cs[1], xref, res);
|
var base = ColorSpace.parse(cs[1], xref, res);
|
||||||
var hiVal = cs[2] + 1;
|
var hiVal = cs[2] + 1;
|
||||||
var lookup = xref.fetchIfRef(cs[3]);
|
var lookup = xref.fetchIfRef(cs[3]);
|
||||||
return new IndexedCS(base, hiVal, lookup);
|
return new IndexedCS(base, hiVal, lookup);
|
||||||
break;
|
|
||||||
case 'Separation':
|
case 'Separation':
|
||||||
var name = cs[1];
|
var name = cs[1];
|
||||||
var alt = ColorSpace.parse(cs[2], xref, res);
|
var alt = ColorSpace.parse(cs[2], xref, res);
|
||||||
var tintFn = new PDFFunction(xref, xref.fetchIfRef(cs[3]));
|
var tintFn = new PDFFunction(xref, xref.fetchIfRef(cs[3]));
|
||||||
return new SeparationCS(alt, tintFn);
|
return new SeparationCS(alt, tintFn);
|
||||||
break;
|
|
||||||
case 'Lab':
|
case 'Lab':
|
||||||
case 'DeviceN':
|
case 'DeviceN':
|
||||||
default:
|
default:
|
||||||
@ -5435,7 +5425,7 @@ var IndexedCS = (function() {
|
|||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getRgb: function indexcs_getRgb(color) {
|
getRgb: function indexcs_getRgb(color) {
|
||||||
var numComps = base.numComps;
|
var numComps = this.base.numComps;
|
||||||
|
|
||||||
var start = color[0] * numComps;
|
var start = color[0] * numComps;
|
||||||
var c = [];
|
var c = [];
|
||||||
@ -5471,7 +5461,7 @@ var DeviceGrayCS = (function() {
|
|||||||
this.name = 'DeviceGray';
|
this.name = 'DeviceGray';
|
||||||
this.numComps = 1;
|
this.numComps = 1;
|
||||||
this.defaultColor = [0];
|
this.defaultColor = [0];
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getRgb: function graycs_getRgb(color) {
|
getRgb: function graycs_getRgb(color) {
|
||||||
@ -5606,7 +5596,7 @@ var Pattern = (function() {
|
|||||||
// Constructor should define this.getPattern
|
// Constructor should define this.getPattern
|
||||||
function constructor() {
|
function constructor() {
|
||||||
error('should not call Pattern constructor');
|
error('should not call Pattern constructor');
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
// Input: current Canvas context
|
// Input: current Canvas context
|
||||||
@ -5670,14 +5660,14 @@ var Pattern = (function() {
|
|||||||
default:
|
default:
|
||||||
return new DummyShading();
|
return new DummyShading();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var DummyShading = (function() {
|
var DummyShading = (function() {
|
||||||
function constructor() {
|
function constructor() {
|
||||||
this.type = 'Pattern';
|
this.type = 'Pattern';
|
||||||
};
|
}
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getPattern: function dummy_getpattern() {
|
getPattern: function dummy_getpattern() {
|
||||||
return 'hotpink';
|
return 'hotpink';
|
||||||
@ -5707,13 +5697,15 @@ var RadialAxialShading = (function() {
|
|||||||
var t0 = 0.0, t1 = 1.0;
|
var t0 = 0.0, t1 = 1.0;
|
||||||
if (dict.has('Domain')) {
|
if (dict.has('Domain')) {
|
||||||
var domainArr = dict.get('Domain');
|
var domainArr = dict.get('Domain');
|
||||||
t0 = domainArr[0], t1 = domainArr[1];
|
t0 = domainArr[0];
|
||||||
|
t1 = domainArr[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
var extendStart = false, extendEnd = false;
|
var extendStart = false, extendEnd = false;
|
||||||
if (dict.has('Extend')) {
|
if (dict.has('Extend')) {
|
||||||
var extendArr = dict.get('Extend');
|
var extendArr = dict.get('Extend');
|
||||||
extendStart = extendArr[0], extendEnd = extendArr[1];
|
extendStart = extendArr[0];
|
||||||
|
extendEnd = extendArr[1];
|
||||||
TODO('Support extend');
|
TODO('Support extend');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5742,7 +5734,7 @@ var RadialAxialShading = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.colorStops = colorStops;
|
this.colorStops = colorStops;
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getPattern: function() {
|
getPattern: function() {
|
||||||
@ -5807,7 +5799,7 @@ var TilingPattern = (function() {
|
|||||||
var e = m[4] * tm[0] + m[5] * tm[2] + tm[4];
|
var e = m[4] * tm[0] + m[5] * tm[2] + tm[4];
|
||||||
var f = m[4] * tm[1] + m[5] * tm[3] + tm[5];
|
var f = m[4] * tm[1] + m[5] * tm[3] + tm[5];
|
||||||
return [a, b, c, d, e, f];
|
return [a, b, c, d, e, f];
|
||||||
};
|
}
|
||||||
|
|
||||||
TODO('TilingType');
|
TODO('TilingType');
|
||||||
|
|
||||||
@ -5879,7 +5871,7 @@ var TilingPattern = (function() {
|
|||||||
graphics.execute(code, xref, res);
|
graphics.execute(code, xref, res);
|
||||||
|
|
||||||
this.canvas = tmpCanvas;
|
this.canvas = tmpCanvas;
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getPattern: function tiling_getPattern() {
|
getPattern: function tiling_getPattern() {
|
||||||
@ -5958,7 +5950,7 @@ var PDFImage = (function() {
|
|||||||
} else if (smask) {
|
} else if (smask) {
|
||||||
this.smask = new PDFImage(xref, res, smask);
|
this.smask = new PDFImage(xref, res, smask);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getComponents: function getComponents(buffer, decodeMap) {
|
getComponents: function getComponents(buffer, decodeMap) {
|
||||||
@ -6133,7 +6125,7 @@ var PDFFunction = (function() {
|
|||||||
error('Unknown type of function');
|
error('Unknown type of function');
|
||||||
|
|
||||||
typeFn.call(this, fn, dict, xref);
|
typeFn.call(this, fn, dict, xref);
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
constructSampled: function(str, dict) {
|
constructSampled: function(str, dict) {
|
||||||
@ -6179,7 +6171,7 @@ var PDFFunction = (function() {
|
|||||||
else if (v < min)
|
else if (v < min)
|
||||||
v = min;
|
v = min;
|
||||||
return v;
|
return v;
|
||||||
}
|
};
|
||||||
|
|
||||||
if (inputSize != args.length)
|
if (inputSize != args.length)
|
||||||
error('Incorrect number of arguments: ' + inputSize + ' != ' +
|
error('Incorrect number of arguments: ' + inputSize + ' != ' +
|
||||||
@ -6229,7 +6221,7 @@ var PDFFunction = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
getSampleArray: function(size, outputSize, bps, str) {
|
getSampleArray: function(size, outputSize, bps, str) {
|
||||||
var length = 1;
|
var length = 1;
|
||||||
@ -6277,7 +6269,7 @@ var PDFFunction = (function() {
|
|||||||
out.push(c0[j] + (x^n * diff[i]));
|
out.push(c0[j] + (x^n * diff[i]));
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
constructStiched: function(fn, dict, xref) {
|
constructStiched: function(fn, dict, xref) {
|
||||||
var domain = dict.get('Domain');
|
var domain = dict.get('Domain');
|
||||||
@ -6305,7 +6297,7 @@ var PDFFunction = (function() {
|
|||||||
else if (v < min)
|
else if (v < min)
|
||||||
v = min;
|
v = min;
|
||||||
return v;
|
return v;
|
||||||
}
|
};
|
||||||
|
|
||||||
// clip to domain
|
// clip to domain
|
||||||
var v = clip(args[0], domain[0], domain[1]);
|
var v = clip(args[0], domain[0], domain[1]);
|
||||||
@ -6330,11 +6322,13 @@ var PDFFunction = (function() {
|
|||||||
|
|
||||||
// call the appropropriate function
|
// call the appropropriate function
|
||||||
return fns[i].func([v2]);
|
return fns[i].func([v2]);
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
constructPostScript: function() {
|
constructPostScript: function() {
|
||||||
TODO('unhandled type of function');
|
TODO('unhandled type of function');
|
||||||
this.func = function() { return [255, 105, 180]; }
|
this.func = function() {
|
||||||
|
return [255, 105, 180];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user