use strict mode and fix violators

This commit is contained in:
Chris Jones 2011-06-18 23:18:46 -07:00
parent 7f102a189e
commit 92fa629d10
5 changed files with 27 additions and 11 deletions

View File

@ -1,6 +1,8 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
"use strict";
/** /**
* Maximum file size of the font. * Maximum file size of the font.
*/ */
@ -1042,7 +1044,8 @@ var Type1Parser = function() {
this.extractFontProgram = function t1_extractFontProgram(aStream) { this.extractFontProgram = function t1_extractFontProgram(aStream) {
var eexecString = decrypt(aStream, kEexecEncryptionKey, 4); var eexecString = decrypt(aStream, kEexecEncryptionKey, 4);
var subrs = [], glyphs = []; var subrs = [], glyphs = [];
var inSubrs = inGlyphs = false; var inGlyphs = false;
var inSubrs = false;
var glyph = ""; var glyph = "";
var token = ""; var token = "";

View File

@ -1,3 +1,8 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
"use strict";
var GlyphsUnicode = { var GlyphsUnicode = {
A: 0x0041, A: 0x0041,
AE: 0x00C6, AE: 0x00C6,

View File

@ -1,6 +1,8 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- / /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
"use strict";
var PDFViewer = { var PDFViewer = {
queryParams: {}, queryParams: {},

18
pdf.js
View File

@ -1,6 +1,8 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- / /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
"use strict";
var ERRORS = 0, WARNINGS = 1, TODOS = 5; var ERRORS = 0, WARNINGS = 1, TODOS = 5;
var verbosity = WARNINGS; var verbosity = WARNINGS;
@ -389,6 +391,12 @@ var FlateStream = (function() {
return [codes, maxLen]; return [codes, maxLen];
}, },
readBlock: function() { readBlock: function() {
function repeat(stream, array, len, offset, what) {
var repeat = stream.getBits(len) + offset;
while (repeat-- > 0)
array[i++] = what;
}
var stream = this.stream; var stream = this.stream;
// read block header // read block header
@ -449,11 +457,6 @@ var FlateStream = (function() {
var codes = numLitCodes + numDistCodes; var codes = numLitCodes + numDistCodes;
var codeLengths = new Array(codes); var codeLengths = new Array(codes);
while (i < codes) { while (i < codes) {
function repeat(stream, array, len, offset, what) {
var repeat = stream.getBits(len) + offset;
while (repeat-- > 0)
array[i++] = what;
}
var code = this.getCode(codeLenCodeTab); var code = this.getCode(codeLenCodeTab);
if (code == 16) { if (code == 16) {
repeat(this, codeLengths, 2, 3, len); repeat(this, codeLengths, 2, 3, len);
@ -813,6 +816,7 @@ var Lexer = (function() {
var done = false; var done = false;
var str = ""; var str = "";
var stream = this.stream; var stream = this.stream;
var ch;
do { do {
switch (ch = stream.getChar()) { switch (ch = stream.getChar()) {
case undefined: case undefined:
@ -1573,7 +1577,7 @@ var Catalog = (function() {
return shadow(this, "toplevelPagesDict", obj); return shadow(this, "toplevelPagesDict", obj);
}, },
get numPages() { get numPages() {
obj = this.toplevelPagesDict.get("Count"); var obj = this.toplevelPagesDict.get("Count");
assertWellFormed(IsInt(obj), assertWellFormed(IsInt(obj),
"page count in top level pages object is not an integer"); "page count in top level pages object is not an integer");
// shadow the prototype getter // shadow the prototype getter
@ -2527,7 +2531,7 @@ var CanvasGraphics = (function() {
error("No support for array of functions"); error("No support for array of functions");
else if (!IsPDFFunction(fnObj)) else if (!IsPDFFunction(fnObj))
error("Invalid function"); error("Invalid function");
fn = new PDFFunction(this.xref, fnObj); var fn = new PDFFunction(this.xref, fnObj);
var gradient = this.ctx.createLinearGradient(x0, y0, x1, y1); var gradient = this.ctx.createLinearGradient(x0, y0, x1, y1);
var step = (t1 - t0) / 10; var step = (t1 - t0) / 10;

View File

@ -1,12 +1,14 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- / /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
var pdfDocument, canvas, pageDisplay, pageNum, pageInterval; "use strict";
var pdfDocument, canvas, numPages, pageDisplay, pageNum, pageInterval;
function load(userInput) { function load(userInput) {
canvas = document.getElementById("canvas"); canvas = document.getElementById("canvas");
canvas.mozOpaque = true; canvas.mozOpaque = true;
pageNum = parseInt(queryParams().page) || 1; pageNum = parseInt(queryParams().page) || 1;
fileName = userInput; var fileName = userInput;
if (!userInput) { if (!userInput) {
fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf"; fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
} }
@ -26,7 +28,7 @@ function queryParams() {
function open(url) { function open(url) {
document.title = url; document.title = url;
req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open("GET", url); req.open("GET", url);
req.mozResponseType = req.responseType = "arraybuffer"; req.mozResponseType = req.responseType = "arraybuffer";
req.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200; req.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200;