Browse Source

Fix a bunch of warnings from Firebug strict mode

Vivien Nicolas 14 years ago
parent
commit
3955ed1b4c
  1. 27
      fonts.js
  2. 54
      pdf.js

27
fonts.js

@ -599,16 +599,16 @@ var Font = (function () {
return font.getBytes(); return font.getBytes();
}, },
convert: function font_convert(name, font, properties) { convert: function font_convert(fontName, font, properties) {
var otf = new Uint8Array(kMaxFontFileSize); var otf = new Uint8Array(kMaxFontFileSize);
function createNameTable(name) { function createNameTable(name) {
var names = [ var names = [
"See original licence", // Copyright "See original licence", // Copyright
name, // Font family fontName, // Font family
"undefined", // Font subfamily (font weight) "undefined", // Font subfamily (font weight)
"uniqueID", // Unique ID "uniqueID", // Unique ID
name, // Full font name fontName, // Full font name
"0.1", // Version "0.1", // Version
"undefined", // Postscript name "undefined", // Postscript name
"undefined", // Trademark "undefined", // Trademark
@ -616,7 +616,7 @@ var Font = (function () {
"undefined" // Designer "undefined" // Designer
]; ];
var name = var nameTable =
"\x00\x00" + // format "\x00\x00" + // format
"\x00\x0A" + // Number of names Record "\x00\x0A" + // Number of names Record
"\x00\x7E"; // Storage "\x00\x7E"; // Storage
@ -633,13 +633,13 @@ var Font = (function () {
"\x00\x00" + // name ID "\x00\x00" + // name ID
string16(str.length) + string16(str.length) +
string16(strOffset); string16(strOffset);
name += nameRecord; nameTable += nameRecord;
strOffset += str.length; strOffset += str.length;
} }
name += names.join(""); nameTable += names.join("");
return name; return nameTable;
} }
// Required Tables // Required Tables
@ -885,6 +885,9 @@ var FontsUtils = {
bytes.set([value >> 24, value >> 16, value >> 8, value]); bytes.set([value >> 24, value >> 16, value >> 8, value]);
return [bytes[0], bytes[1], bytes[2], bytes[3]]; return [bytes[0], bytes[1], bytes[2], bytes[3]];
} }
error("This number of bytes " + bytesCount + " is not supported");
return null;
}, },
bytesToInteger: function fu_bytesToInteger(bytesArray) { bytesToInteger: function fu_bytesToInteger(bytesArray) {
@ -1238,7 +1241,7 @@ var CFF = function(name, file, properties) {
}; };
CFF.prototype = { CFF.prototype = {
createCFFIndexHeader: function(objects, isByte) { createCFFIndexHeader: function cff_createCFFIndexHeader(objects, isByte) {
// First 2 bytes contains the number of objects contained into this index // First 2 bytes contains the number of objects contained into this index
var count = objects.length; var count = objects.length;
@ -1275,18 +1278,18 @@ CFF.prototype = {
return data; return data;
}, },
encodeNumber: function(value) { encodeNumber: function cff_encodeNumber(value) {
var x = 0; var x = 0;
if (value >= -32768 && value <= 32767) { if (value >= -32768 && value <= 32767) {
return [ 28, value >> 8, value & 0xFF ]; return [ 28, value >> 8, value & 0xFF ];
} else if (value >= (-2147483647-1) && value <= 2147483647) { } else if (value >= (-2147483647-1) && value <= 2147483647) {
return [ 0xFF, value >> 24, Value >> 16, value >> 8, value & 0xFF ]; return [ 0xFF, value >> 24, Value >> 16, value >> 8, value & 0xFF ];
} else {
error("Value: " + value + " is not allowed");
} }
error("Value: " + value + " is not allowed");
return null;
}, },
getOrderedCharStrings: function(glyphs) { getOrderedCharStrings: function cff_getOrderedCharStrings(glyphs) {
var charstrings = []; var charstrings = [];
for (var i = 0; i < glyphs.length; i++) { for (var i = 0; i < glyphs.length; i++) {

54
pdf.js

@ -71,14 +71,14 @@ var Stream = (function() {
get length() { get length() {
return this.end - this.start; return this.end - this.start;
}, },
getByte: function() { getByte: function stream_getByte() {
if (this.pos >= this.end) if (this.pos >= this.end)
return; return null;
return this.bytes[this.pos++]; return this.bytes[this.pos++];
}, },
// returns subarray of original buffer // returns subarray of original buffer
// should only be read // should only be read
getBytes: function(length) { getBytes: function stream_getBytes(length) {
var bytes = this.bytes; var bytes = this.bytes;
var pos = this.pos; var pos = this.pos;
var strEnd = this.end; var strEnd = this.end;
@ -93,28 +93,28 @@ var Stream = (function() {
this.pos = end; this.pos = end;
return bytes.subarray(pos, end); return bytes.subarray(pos, end);
}, },
lookChar: function() { lookChar: function stream_lookChar() {
if (this.pos >= this.end) if (this.pos >= this.end)
return; return null;
return String.fromCharCode(this.bytes[this.pos]); return String.fromCharCode(this.bytes[this.pos]);
}, },
getChar: function() { getChar: function stream_getChar() {
if (this.pos >= this.end) if (this.pos >= this.end)
return; return null;
return String.fromCharCode(this.bytes[this.pos++]); return String.fromCharCode(this.bytes[this.pos++]);
}, },
skip: function(n) { skip: function stream_skip(n) {
if (!n) if (!n)
n = 1; n = 1;
this.pos += n; this.pos += n;
}, },
reset: function() { reset: function stream_reset() {
this.pos = this.start; this.pos = this.start;
}, },
moveStart: function() { moveStart: function stream_moveStart() {
this.start = this.pos; this.start = this.pos;
}, },
makeSubStream: function(start, length, dict) { makeSubStream: function stream_makeSubstream(start, length, dict) {
return new Stream(this.bytes.buffer, start, length, dict); return new Stream(this.bytes.buffer, start, length, dict);
} }
}; };
@ -146,7 +146,7 @@ var DecodeStream = (function() {
} }
constructor.prototype = { constructor.prototype = {
ensureBuffer: function(requested) { ensureBuffer: function decodestream_ensureBuffer(requested) {
var buffer = this.buffer; var buffer = this.buffer;
var current = buffer ? buffer.byteLength : 0; var current = buffer ? buffer.byteLength : 0;
if (requested < current) if (requested < current)
@ -159,16 +159,16 @@ var DecodeStream = (function() {
buffer2[i] = buffer[i]; buffer2[i] = buffer[i];
return this.buffer = buffer2; return this.buffer = buffer2;
}, },
getByte: function() { getByte: function decodestream_getByte() {
var pos = this.pos; var pos = this.pos;
while (this.bufferLength <= pos) { while (this.bufferLength <= pos) {
if (this.eof) if (this.eof)
return; return null;
this.readBlock(); this.readBlock();
} }
return this.buffer[this.pos++]; return this.buffer[this.pos++];
}, },
getBytes: function(length) { getBytes: function decodestream_getBytes(length) {
var pos = this.pos; var pos = this.pos;
if (length) { if (length) {
@ -191,25 +191,25 @@ var DecodeStream = (function() {
this.pos = end; this.pos = end;
return this.buffer.subarray(pos, end) return this.buffer.subarray(pos, end)
}, },
lookChar: function() { lookChar: function decodestream_lookChar() {
var pos = this.pos; var pos = this.pos;
while (this.bufferLength <= pos) { while (this.bufferLength <= pos) {
if (this.eof) if (this.eof)
return; return null;
this.readBlock(); this.readBlock();
} }
return String.fromCharCode(this.buffer[this.pos]); return String.fromCharCode(this.buffer[this.pos]);
}, },
getChar: function() { getChar: function decodestream_getChar() {
var pos = this.pos; var pos = this.pos;
while (this.bufferLength <= pos) { while (this.bufferLength <= pos) {
if (this.eof) if (this.eof)
return; return null;
this.readBlock(); this.readBlock();
} }
return String.fromCharCode(this.buffer[this.pos++]); return String.fromCharCode(this.buffer[this.pos++]);
}, },
skip: function(n) { skip: function decodestream_skip(n) {
if (!n) if (!n)
n = 1; n = 1;
this.pos += n; this.pos += n;
@ -635,6 +635,7 @@ var PredictorStream = (function() {
var rowBytes = this.rowBytes = (columns * colors * bits + 7) >> 3; var rowBytes = this.rowBytes = (columns * colors * bits + 7) >> 3;
DecodeStream.call(this); DecodeStream.call(this);
return this;
} }
constructor.prototype = Object.create(DecodeStream.prototype); constructor.prototype = Object.create(DecodeStream.prototype);
@ -905,7 +906,9 @@ var Dict = (function() {
constructor.prototype = { constructor.prototype = {
get: function(key) { get: function(key) {
if (key in this.map)
return this.map[key]; return this.map[key];
return null;
}, },
get2: function(key1, key2) { get2: function(key1, key2) {
return this.get(key1) || this.get(key2); return this.get(key1) || this.get(key2);
@ -1590,7 +1593,7 @@ var XRef = (function() {
} }
constructor.prototype = { constructor.prototype = {
readXRefTable: function(parser) { readXRefTable: function readXRefTable(parser) {
var obj; var obj;
while (true) { while (true) {
if (IsCmd(obj = parser.getObj(), "trailer")) if (IsCmd(obj = parser.getObj(), "trailer"))
@ -1661,7 +1664,7 @@ var XRef = (function() {
return dict; return dict;
}, },
readXRefStream: function(stream) { readXRefStream: function readXRefStream(stream) {
var streamParameters = stream.parameters; var streamParameters = stream.parameters;
var length = streamParameters.get("Length"); var length = streamParameters.get("Length");
var byteWidths = streamParameters.get("W"); var byteWidths = streamParameters.get("W");
@ -1713,7 +1716,7 @@ var XRef = (function() {
this.readXRef(prev); this.readXRef(prev);
return streamParameters; return streamParameters;
}, },
readXRef: function(startXRef) { readXRef: function readXref(startXRef) {
var stream = this.stream; var stream = this.stream;
stream.pos = startXRef; stream.pos = startXRef;
var parser = new Parser(new Lexer(stream), true); var parser = new Parser(new Lexer(stream), true);
@ -1731,6 +1734,7 @@ var XRef = (function() {
return this.readXRefStream(obj); return this.readXRefStream(obj);
} }
error("Invalid XRef"); error("Invalid XRef");
return null;
}, },
getEntry: function(i) { getEntry: function(i) {
var e = this.entries[i]; var e = this.entries[i];
@ -2396,7 +2400,7 @@ var CanvasGraphics = (function() {
if (!fd) if (!fd)
// XXX deprecated "special treatment" for standard // XXX deprecated "special treatment" for standard
// fonts? What do we need to do here? // fonts? What do we need to do here?
return; return null;
var descriptor = xref.fetch(fd); var descriptor = xref.fetch(fd);
var fontName = descriptor.get("FontName"); var fontName = descriptor.get("FontName");
@ -3037,7 +3041,7 @@ var CanvasGraphics = (function() {
this.restore(); this.restore();
TODO("Inverse pattern is painted"); TODO("Inverse pattern is painted");
var pattern = this.ctx.createPattern(tmpCanvas, "repeat"); pattern = this.ctx.createPattern(tmpCanvas, "repeat");
this.ctx.fillStyle = pattern; this.ctx.fillStyle = pattern;
}, },
setStrokeGray: function(gray) { setStrokeGray: function(gray) {

Loading…
Cancel
Save