Merge pull request #2639 from jbuck/jshint

jshint experimentation
This commit is contained in:
Yury Delendik 2013-01-31 20:11:26 -08:00
commit 43d6c6f1ab
26 changed files with 255 additions and 148 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ build/
tags
.DS_Store
Makefile
node_modules/

19
.jshintrc Normal file
View File

@ -0,0 +1,19 @@
{
// Environments
"browser": true,
"devel": true,
"es5": true,
"worker": true,
// Enforcing
// Relaxing
"boss": true,
"funcscope": true,
"globalstrict": true,
"loopfunc": true,
"maxerr": 1000,
"nonstandard": true,
"sub": true,
"validthis": true
}

View File

@ -1,3 +1,8 @@
/* jshint node:true */
/* globals cp, ls, test */
'use strict';
require('../shelljs/make');
var fs = require('fs'),
path = require('path'),
@ -30,7 +35,7 @@ function preprocess(inFilename, outFilename, defines) {
var writeLine = typeof outFilename === 'function' ? outFilename :
function(line) {
out += line + '\n';
}
};
function include(file) {
var realPath = fs.realpathSync(inFilename);
var dir = path.dirname(realPath);

View File

@ -1,5 +1,9 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* jshint node:true */
/* globals cat, echo, exit, ls */
'use strict';
function checkIfCrlfIsPresent(files) {
var failed = [];

30
make.js
View File

@ -1,5 +1,7 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* jshint node:true */
/* globals cat, cd, cp, echo, env, exec, exit, find, ls, mkdir, mv, process, rm, sed, target, test */
'use strict';
@ -39,7 +41,7 @@ var DEFINES = {
target.all = function() {
// Don't do anything by default
echo('Please specify a target. Available targets:');
for (t in target)
for (var t in target)
if (t !== 'all') echo(' ' + t);
};
@ -611,8 +613,9 @@ target.chrome = function() {
exit(1);
}
var manifest;
try {
var manifest = JSON.parse(cat(browserManifest));
manifest = JSON.parse(cat(browserManifest));
} catch (e) {
echo('Malformed browser manifest file');
echo(e.message);
@ -971,6 +974,29 @@ target.lint = function() {
crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
};
//
// make jshint
//
target.jshint = function() {
cd(ROOT_DIR);
echo();
echo('### Linting JS files (this can take a while!)');
var LINT_FILES = ['make.js',
'external/builder/',
'external/crlfchecker/',
'src/',
//'web/*.js',
//'test/*.js',
//'test/unit/*.js',
//'extensions/firefox/*.js',
//'extensions/firefox/components/*.js',
//'extensions/chrome/*.js'
];
exec('jshint --reporter test/reporter.js ' + LINT_FILES.join(' '));
};
//
// make clean
//

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals CanvasGraphics, combineUrl, createScratchCanvas, error, ErrorFont, Font, FontLoader, globalScope, info, isArrayBuffer, loadJpegStream, MessageHandler, PDFJS, PDFObjects, Promise, StatTimer, warn, WorkerMessageHandler */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -282,7 +283,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
promise.reject(error);
else
promise.resolve();
};
}
var continueCallback = params.continueCallback;
// Once the operatorList and fonts are loaded, do the actual rendering.
@ -383,7 +384,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var continueWrapper;
if (continueCallback)
continueWrapper = function() { continueCallback(next); }
continueWrapper = function() { continueCallback(next); };
else
continueWrapper = next;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals PDFJS */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -68,11 +69,11 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
];
function isOdd(i) {
return (i & 1) != 0;
return (i & 1) !== 0;
}
function isEven(i) {
return (i & 1) == 0;
return (i & 1) === 0;
}
function findUnequal(arr, start, value) {
@ -146,8 +147,8 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
function bidi(str, startLevel) {
var isLTR = true;
var strLength = str.length;
if (strLength == 0)
return new BidiResult(str, ltr);
if (strLength === 0)
return new BidiResult(str, isLTR);
// get types, fill arrays
@ -180,7 +181,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
// if there are no rtl characters then no bidi needed
// if less than 30% chars are rtl then string is primarily ltr
// if more than 30% chars are rtl then string is primarily rtl
if (numBidi == 0) {
if (numBidi === 0) {
isLTR = true;
return new BidiResult(str, isLTR);
}

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals ColorSpace, DeviceCmykCS, DeviceGrayCS, DeviceRgbCS, error, FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageData, isArray, isNum, isString, Pattern, TilingPattern, TODO, Util, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -238,7 +239,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
buf = imgArray[imgArrayPos++];
mask = 128;
}
if (!(buf & mask) == inverseDecode) {
if (!(buf & mask) === inverseDecode) {
buffer[bufferPos] = 0;
}
bufferPos += 4;
@ -932,7 +933,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var lineWidth = current.lineWidth;
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
var scale = Math.sqrt(a1 * a1 + b1 * b1);
if (scale == 0 || lineWidth == 0)
if (scale === 0 || lineWidth === 0)
lineWidth = this.getSinglePixelWidth();
else
lineWidth /= scale;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals error, info, input, isArray, isDict, isName, isStream, isString, PDFFunction, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -240,7 +241,7 @@ var ColorSpace = (function ColorSpaceClosure() {
return true;
}
for (var i = 0, ii = decode.length; i < ii; i += 2) {
if (decode[i] != 0 || decode[i + 1] != 1)
if (decode[i] !== 0 || decode[i + 1] != 1)
return false;
}
return true;
@ -1288,7 +1289,7 @@ var LabCS = (function LabCSClosure() {
this.bmin = -100;
this.bmax = 100;
}
};
}
// Function g(x) from spec
function fn_g(x) {

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals assertWellFormed, calculateMD5, Catalog, error, info, isArray, isArrayBuffer, isDict, isName, isStream, isString, Lexer, Linearization, NullStream, PartialEvaluator, shadow, Stream, StreamsSequenceStream, stringToPDFString, TODO, Util, warn, XRef */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -76,7 +77,7 @@ function getPdf(arg, callback) {
calledErrorBack = true;
params.error();
}
}
};
}
xhr.onreadystatechange = function getPdfOnreadystatechange(e) {
@ -156,7 +157,7 @@ var Page = (function PageClosure() {
get rotate() {
var rotate = this.inheritPageProp('Rotate') || 0;
// Normalize rotation so it's a multiple of 90 and between 0 and 270
if (rotate % 90 != 0) {
if (rotate % 90 !== 0) {
rotate = 0;
} else if (rotate >= 360) {
rotate = rotate % 360;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals bytesToString, DecryptStream, error, isInt, isName, Name, PasswordException, stringToBytes */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -373,7 +374,7 @@ var AES128Cipher = (function AES128CipherClosure() {
this.buffer = buffer;
this.bufferLength = bufferLength;
this.iv = iv;
if (result.length == 0)
if (result.length === 0)
return new Uint8Array([]);
if (result.length == 1)
return result[0];
@ -553,7 +554,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
this.algorithm = algorithm;
var keyLength = dict.get('Length') || 40;
if (!isInt(keyLength) ||
keyLength < 40 || (keyLength % 8) != 0)
keyLength < 40 || (keyLength % 8) !== 0)
error('invalid key length');
// prepare keys
var ownerPassword = stringToBytes(dict.get('O'));
@ -618,7 +619,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
function buildCipherConstructor(cf, name, num, gen, key) {
var cryptFilter = cf.get(name.name);
var cfm;
if (cryptFilter != null)
if (cryptFilter !== null && cryptFilter !== undefined)
cfm = cryptFilter.get('CFM');
if (!cfm || cfm.name == 'None') {
return function cipherTransformFactoryBuildCipherConstructorNone() {

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals assert, assertWellFormed, ColorSpace, Dict, Encodings, error, ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode, FontFlags, IDENTITY_MATRIX, info, isArray, isCmd, isDict, isEOF, isName, isNum, isStream, isString, JpegStream, Lexer, Metrics, Name, Parser, Pattern, PDFImage, PDFJS, serifFonts, stdFontMap, symbolsFonts, TilingPattern, TODO, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -542,7 +543,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
fnArray.push(fn);
argsArray.push(args);
args = [];
} else if (obj != null) {
} else if (obj !== null && obj !== undefined) {
args.push(obj instanceof Dict ? obj.getAll() : obj);
assertWellFormed(args.length <= 33, 'Too many arguments');
}
@ -796,7 +797,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
args = [];
} else if (obj != null) {
} else if (obj !== null && obj !== undefined) {
assertWellFormed(args.length <= 33, 'Too many arguments');
args.push(obj);
}
@ -1010,7 +1011,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var result = [];
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
if (glyphID == 0)
if (glyphID === 0)
continue;
var code = j >> 1;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals assert, bytesToString, CIDToUnicodeMaps, error, ExpertCharset, ExpertSubsetCharset, FileReaderSync, globalScope, GlyphsUnicode, info, isArray, isNum, ISOAdobeCharset, isWorker, PDFJS, Stream, stringToBytes, TextDecoder, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -507,7 +508,7 @@ var FontLoader = {
// Add the font to the DOM only once or skip if the font
// is already loaded.
if (font.attached || font.loading == false) {
if (font.attached || font.loading === false) {
continue;
}
font.attached = true;
@ -2425,7 +2426,7 @@ var Font = (function FontClosure() {
this.encoding = properties.baseEncoding;
this.loading = true;
};
}
var numFonts = 0;
function getUniqueName() {
@ -2438,7 +2439,7 @@ var Font = (function FontClosure() {
array[i] = str.charCodeAt(i);
return array;
};
}
function arrayToString(arr) {
var str = '';
@ -2446,16 +2447,16 @@ var Font = (function FontClosure() {
str += String.fromCharCode(arr[i]);
return str;
};
}
function int16(bytes) {
return (bytes[0] << 8) + (bytes[1] & 0xff);
};
}
function int32(bytes) {
return (bytes[0] << 24) + (bytes[1] << 16) +
(bytes[2] << 8) + (bytes[3] & 0xff);
};
}
function getMaxPower2(number) {
var maxPower = 0;
@ -2469,26 +2470,26 @@ var Font = (function FontClosure() {
for (var i = 1; i < maxPower; i++)
value *= 2;
return value;
};
}
function string16(value) {
return String.fromCharCode((value >> 8) & 0xff) +
String.fromCharCode(value & 0xff);
};
}
function safeString16(value) {
// clamp value to the 16-bit int range
value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
return String.fromCharCode((value >> 8) & 0xff) +
String.fromCharCode(value & 0xff);
};
}
function string32(value) {
return String.fromCharCode((value >> 24) & 0xff) +
String.fromCharCode((value >> 16) & 0xff) +
String.fromCharCode((value >> 8) & 0xff) +
String.fromCharCode(value & 0xff);
};
}
function createOpenTypeHeader(sfnt, file, numTables) {
// Windows hates the Mac TrueType sfnt version number
@ -2514,7 +2515,7 @@ var Font = (function FontClosure() {
file.file += header;
file.virtualOffset += header.length;
};
}
function createTableEntry(file, tag, data) {
// offset
@ -2540,7 +2541,7 @@ var Font = (function FontClosure() {
string32(offset) + string32(length));
file.file += tableEntry;
file.virtualOffset += data.length;
};
}
function getRanges(glyphs) {
// Array.sort() sorts by characters, not numerically, so convert to an
@ -2569,7 +2570,7 @@ var Font = (function FontClosure() {
}
return ranges;
};
}
function createCmapTable(glyphs, deltas) {
var ranges = getRanges(glyphs);
@ -2646,7 +2647,7 @@ var Font = (function FontClosure() {
'\x00\x04' + // format
string16(format314.length + 4) + // length
format314);
};
}
function validateOS2Table(os2) {
var stream = new Stream(os2.data);
@ -2769,7 +2770,7 @@ var Font = (function FontClosure() {
string16(0) + // usDefaultChar
string16(firstCharIndex || properties.firstChar) + // usBreakChar
'\x00\x03'; // usMaxContext
};
}
function createPostTable(properties) {
var angle = Math.floor(properties.italicAngle * (Math.pow(2, 16)));
@ -2782,7 +2783,7 @@ var Font = (function FontClosure() {
'\x00\x00\x00\x00' + // maxMemType42
'\x00\x00\x00\x00' + // minMemType1
'\x00\x00\x00\x00'; // maxMemType1
};
}
function createNameTable(name, proto) {
if (!proto) {
@ -2925,7 +2926,7 @@ var Font = (function FontClosure() {
offset: offset,
data: data
};
};
}
function readOpenTypeHeader(ttf) {
return {
@ -2935,7 +2936,7 @@ var Font = (function FontClosure() {
entrySelector: int16(ttf.getBytes(2)),
rangeShift: int16(ttf.getBytes(2))
};
};
}
function createGlyphNameMap(glyphs, ids, properties) {
var glyphNames = properties.glyphNames;
@ -3171,7 +3172,7 @@ var Font = (function FontClosure() {
mappings: mappings,
hasShortCmap: hasShortCmap
};
};
}
function sanitizeMetrics(font, header, metrics, numGlyphs) {
if (!header) {
@ -3207,7 +3208,7 @@ var Font = (function FontClosure() {
entries += '\x00\x00';
metrics.data = stringToArray(entries);
}
};
}
function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart) {
if (sourceEnd - sourceStart <= 12) {
@ -3357,7 +3358,7 @@ var Font = (function FontClosure() {
startOffset = endOffset;
}
if (writeOffset == 0) {
if (writeOffset === 0) {
// glyf table cannot be empty -- redoing the glyf and loca tables
// to have single glyph with one point
var simpleGlyph = new Uint8Array(
@ -3484,7 +3485,7 @@ var Font = (function FontClosure() {
offset: int16(font.getBytes(2))
};
// using only Macintosh and Windows platform/encoding names
if ((r.platform == 1 && r.encoding == 0 && r.language == 0) ||
if ((r.platform == 1 && r.encoding === 0 && r.language === 0) ||
(r.platform == 3 && r.encoding == 1 && r.language == 0x409)) {
records.push(r);
}
@ -3516,7 +3517,7 @@ var Font = (function FontClosure() {
var data = os2Table.data;
// usWinAscent == 0 makes font unreadable by windows
var usWinAscent = (data[74] << 8) | data[75];
if (usWinAscent == 0)
if (usWinAscent === 0)
return false;
return true;
@ -3747,7 +3748,7 @@ var Font = (function FontClosure() {
// Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth
// Sometimes it's 0. That needs to be fixed
if (hhea.data[10] == 0 && hhea.data[11] == 0) {
if (hhea.data[10] === 0 && hhea.data[11] === 0) {
hhea.data[10] = 0xFF;
hhea.data[11] = 0xFF;
}
@ -4211,7 +4212,7 @@ var Font = (function FontClosure() {
var firstChar = properties.firstChar, lastChar = properties.lastChar;
var map = [];
if (properties.composite) {
var isIdentityMap = this.cidToUnicode.length == 0;
var isIdentityMap = this.cidToUnicode.length === 0;
for (var i = firstChar, ii = lastChar; i <= ii; i++) {
// TODO missing map the character according font's CMap
var cid = i;
@ -4352,7 +4353,7 @@ var Font = (function FontClosure() {
if (!charcode && 'toUnicode' in this)
charcode = this.toUnicode.indexOf(glyphUnicode);
// setting it to unicode if negative or undefined
if (!(charcode > 0))
if (charcode <= 0)
charcode = glyphUnicode;
// trying to get width via charcode
width = this.widths[charcode];
@ -4660,7 +4661,6 @@ var Type1CharString = (function Type1CharStringClosure() {
break;
case 11: // return
return error;
break;
case 13: // hsbw
if (this.stack.length < 2) {
error = true;
@ -5033,7 +5033,7 @@ var Type1Parser = function type1Parser() {
var blueArray = readNumberArray(eexecStr, i + 1);
// *Blue* values may contain invalid data: disables reading of
// those values when hinting is disabled.
if (blueArray.length > 0 && (blueArray.length % 2) == 0 &&
if (blueArray.length > 0 && (blueArray.length % 2) === 0 &&
HINTING_ENABLED) {
program.properties.privateData[token.substring(1)] = blueArray;
}
@ -5649,7 +5649,7 @@ var CFFParser = (function CFFParserClosure() {
while (bytes[offset] != 1)
++offset;
if (offset != 0) {
if (offset !== 0) {
info('cff data is shifted');
bytes = bytes.subarray(offset);
this.bytes = bytes;
@ -5739,7 +5739,7 @@ var CFFParser = (function CFFParserClosure() {
var start = pos;
var end = pos;
if (count != 0) {
if (count !== 0) {
var offsetSize = bytes[pos++];
// add 1 for offset to determine size of last object
var startPos = pos + ((count + 1) * offsetSize) - 1;
@ -5796,8 +5796,8 @@ var CFFParser = (function CFFParserClosure() {
}
return strings;
},
createDict: function CFFParser_createDict(type, dict, strings) {
var cffDict = new type(strings);
createDict: function CFFParser_createDict(Type, dict, strings) {
var cffDict = new Type(strings);
var types = cffDict.types;
for (var i = 0, ii = dict.length; i < ii; ++i) {
@ -5825,7 +5825,7 @@ var CFFParser = (function CFFParserClosure() {
var validationCommand = null;
if (value == 12) {
var q = data[j++];
if (q == 0) {
if (q === 0) {
// The CFF specification state that the 'dotsection' command
// (12, 0) is deprecated and treated as a no-op, but all Type2
// charstrings processors should support them. Unfortunately
@ -5929,7 +5929,7 @@ var CFFParser = (function CFFParserClosure() {
privateDict.subrsIndex = subrsIndex.obj;
},
parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
if (pos == 0) {
if (pos === 0) {
return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE,
ISOAdobeCharset);
} else if (pos == 1) {
@ -6000,7 +6000,7 @@ var CFFParser = (function CFFParserClosure() {
}
}
if (pos == 0 || pos == 1) {
if (pos === 0 || pos == 1) {
predefined = true;
format = pos;
var baseEncoding = pos ? Encodings.ExpertEncoding :
@ -6253,7 +6253,7 @@ var CFFTopDict = (function CFFTopDictClosure() {
[[12, 5], 'PaintType', 'num', 0],
[[12, 6], 'CharstringType', 'num', 2],
[[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'],
[.001, 0, 0, .001, 0, 0]],
[0.001, 0, 0, 0.001, 0, 0]],
[13, 'UniqueID', 'num', null],
[5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]],
[[12, 8], 'StrokeWidth', 'num', 0],
@ -6423,7 +6423,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
array[i] = str.charCodeAt(i);
return array;
};
}
function CFFCompiler(cff) {
this.cff = cff;
}
@ -6506,7 +6506,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
return output.data;
},
encodeNumber: function CFFCompiler_encodeNumber(value) {
if (parseFloat(value) == parseInt(value) && !isNaN(value)) // isInt
if (parseFloat(value) == parseInt(value, 10) && !isNaN(value)) // isInt
return this.encodeInteger(value);
else
return this.encodeFloat(value);
@ -6706,7 +6706,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
// If there is no object, just create an index. This technically
// should just be [0, 0] but OTS has an issue with that.
if (count == 0)
if (count === 0)
return [0, 0, 0];
var data = [(count >> 8) & 0xFF, count & 0xff];

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals EOF, error, isArray, isBool, Lexer, TODO */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -80,7 +81,7 @@ var PDFFunction = (function PDFFunctionClosure() {
return this.constructInterpolatedFromIR(IR);
case CONSTRUCT_STICHED:
return this.constructStichedFromIR(IR);
case CONSTRUCT_POSTSCRIPT:
//case CONSTRUCT_POSTSCRIPT:
default:
return this.constructPostScriptFromIR(IR);
}
@ -233,7 +234,7 @@ var PDFFunction = (function PDFFunctionClosure() {
}
return y;
}
};
},
constructInterpolated: function PDFFunction_constructInterpolated(str,
@ -270,7 +271,7 @@ var PDFFunction = (function PDFFunctionClosure() {
return out;
}
};
},
constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals ColorSpace, error, isArray, isStream, JpegStream, Name, Promise, Stream, TODO, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -260,7 +261,7 @@ var PDFImage = (function PDFImageClosure() {
var buf = 0;
for (var i = 0, ii = length; i < ii; ++i) {
if (i % rowComps == 0) {
if (i % rowComps === 0) {
mask = 0;
buf = 0;
} else {
@ -278,7 +279,7 @@ var PDFImage = (function PDFImageClosure() {
// The general case that handles all other bpc values.
var bits = 0, buf = 0;
for (var i = 0, ii = length; i < ii; ++i) {
if (i % rowComps == 0) {
if (i % rowComps === 0) {
buf = 0;
bits = 0;
}
@ -374,7 +375,7 @@ var PDFImage = (function PDFImageClosure() {
buf = imgArray[imgArrayPos++];
mask = 128;
}
if (!(buf & mask) == inverseDecode) {
if (!(buf & mask) === inverseDecode) {
buffer[bufferPos] = 0;
}
bufferPos += 4;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals error, shadow */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -123,7 +124,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
return d;
} else {
this.chigh -= qeIcx;
if ((this.a & 0x8000) == 0) {
if ((this.a & 0x8000) === 0) {
var d = this.exchangeMps(cx);
this.renormD();
return d;
@ -134,14 +135,14 @@ var Jbig2Image = (function Jbig2ImageClosure() {
},
renormD: function ArithmeticDecoder_renormD() {
do {
if (this.ct == 0)
if (this.ct === 0)
this.byteIn();
this.a <<= 1;
this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
this.clow = (this.clow << 1) & 0xFFFF;
this.ct--;
} while ((this.a & 0x8000) == 0);
} while ((this.a & 0x8000) === 0);
},
exchangeMps: function ArithmeticDecoder_exchangeMps(cx) {
var d;
@ -261,7 +262,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
break;
default:
v = v * 2 + bit;
if (--toRead == 0)
if (--toRead === 0)
state = 0;
continue;
}
@ -437,7 +438,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
offsetX, offsetY, prediction, at,
decodingContext) {
var codingTemplate = RefinementTemplates[templateIndex].coding;
if (templateIndex == 0)
if (templateIndex === 0)
codingTemplate = codingTemplate.concat([at[0]]);
var codingTemplateLength = codingTemplate.length;
var codingTemplateX = new Int32Array(codingTemplateLength);
@ -447,7 +448,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
codingTemplateY[k] = codingTemplate[k].y;
}
var referenceTemplate = RefinementTemplates[templateIndex].reference;
if (templateIndex == 0)
if (templateIndex === 0)
referenceTemplate = referenceTemplate.concat([at[1]]);
var referenceTemplateLength = referenceTemplate.length;
var referenceTemplateX = new Int32Array(referenceTemplateLength);
@ -530,7 +531,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
var totalWidth = 0;
while (true) {
var deltaWidth = decodeInteger(contextCache, 'IADW', decoder); // 6.5.7
if (deltaWidth == null)
if (deltaWidth === null)
break; // OOB
currentWidth += deltaWidth;
totalWidth += currentWidth;
@ -657,7 +658,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
i++;
var deltaS = decodeInteger(contextCache, 'IADS', decoder); // 6.4.8
if (deltaS == null)
if (deltaS === null)
break; // OOB
currentS += deltaS + dsOffset;
} while (true);
@ -779,7 +780,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
dictionary.refinementTemplate = (dictionaryFlags >> 12) & 1;
position += 2;
if (!dictionary.huffman) {
var atLength = dictionary.template == 0 ? 4 : 1;
var atLength = dictionary.template === 0 ? 4 : 1;
var at = [];
for (var i = 0; i < atLength; i++) {
at.push({
@ -865,7 +866,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
genericRegion.template = (genericRegionSegmentFlags >> 1) & 3;
genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
if (!genericRegion.mmr) {
var atLength = genericRegion.template == 0 ? 4 : 1;
var atLength = genericRegion.template === 0 ? 4 : 1;
var at = [];
for (var i = 0; i < atLength; i++) {
at.push({

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals error, globalScope, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -43,7 +44,7 @@ var JpxImage = (function JpxImageClosure() {
xhr.send(null);
},
parse: function JpxImage_parse(data) {
function ReadUint(data, offset, bytes) {
function readUint(data, offset, bytes) {
var n = 0;
for (var i = 0; i < bytes; i++)
n = n * 256 + (data[offset + i] & 0xFF);
@ -52,15 +53,15 @@ var JpxImage = (function JpxImageClosure() {
var position = 0, length = data.length;
while (position < length) {
var headerSize = 8;
var lbox = ReadUint(data, position, 4);
var tbox = ReadUint(data, position + 4, 4);
var lbox = readUint(data, position, 4);
var tbox = readUint(data, position + 4, 4);
position += headerSize;
if (lbox == 1) {
lbox = ReadUint(data, position, 8);
lbox = readUint(data, position, 8);
position += 8;
headerSize += 8;
}
if (lbox == 0)
if (lbox === 0)
lbox = length - position + headerSize;
if (lbox < headerSize)
error('JPX error: Invalid box field size');
@ -289,7 +290,7 @@ var JpxImage = (function JpxImageClosure() {
tile.partsCount = data[position + 9];
context.mainHeader = false;
if (tile.partIndex == 0) {
if (tile.partIndex === 0) {
// reset component specific settings
tile.COD = context.COD;
tile.COC = context.COC.slice(0); // clone of the global COC
@ -300,7 +301,7 @@ var JpxImage = (function JpxImageClosure() {
break;
case 0xFF93: // Start of data (SOD)
var tile = context.currentTile;
if (tile.partIndex == 0) {
if (tile.partIndex === 0) {
initializeTile(context, tile.index);
buildPackets(context);
}
@ -631,7 +632,7 @@ var JpxImage = (function JpxImageClosure() {
resolutions.push(resolution);
var subband;
if (r == 0) {
if (r === 0) {
// one sub-band (LL) with last decomposition
subband = {};
subband.type = 'LL';
@ -733,7 +734,7 @@ var JpxImage = (function JpxImageClosure() {
}
function readCodingpasses() {
var value = readBits(1);
if (value == 0)
if (value === 0)
return 1;
value = (value << 1) | readBits(1);
if (value == 0x02)
@ -853,7 +854,7 @@ var JpxImage = (function JpxImageClosure() {
var codeblock = codeblocks[i];
var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
var blockHeight = codeblock.tby1_ - codeblock.tby0_;
if (blockWidth == 0 || blockHeight == 0)
if (blockWidth === 0 || blockHeight === 0)
continue;
if (!('data' in codeblock))
continue;
@ -905,7 +906,7 @@ var JpxImage = (function JpxImageClosure() {
var n = (bitModel.coefficentsSign[position] ? -1 : 1) *
bitModel.coefficentsMagnitude[position];
var nb = bitModel.bitsDecoded[position], correction;
if (transformation == 0 || mb > nb) {
if (transformation === 0 || mb > nb) {
// use r only if transformation is irreversible or
// not all bitplanes were decoded for reversible transformation
n += n < 0 ? n - r : n > 0 ? n + r : 0;
@ -974,7 +975,7 @@ var JpxImage = (function JpxImageClosure() {
}
var transformation = codingStyleParameters.transformation;
var transform = transformation == 0 ? new IrreversibleTransform() :
var transform = transformation === 0 ? new IrreversibleTransform() :
new ReversibleTransform();
var result = transform.calculate(subbandCoefficients,
component.tcx0, component.tcy0);
@ -1304,7 +1305,7 @@ var JpxImage = (function JpxImageClosure() {
return d;
} else {
this.chigh -= qeIcx;
if ((this.a & 0x8000) == 0) {
if ((this.a & 0x8000) === 0) {
var d = this.exchangeMps(cx);
this.renormD();
return d;
@ -1315,14 +1316,14 @@ var JpxImage = (function JpxImageClosure() {
},
renormD: function ArithmeticDecoder_renormD() {
do {
if (this.ct == 0)
if (this.ct === 0)
this.byteIn();
this.a <<= 1;
this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
this.clow = (this.clow << 1) & 0xFFFF;
this.ct--;
} while ((this.a & 0x8000) == 0);
} while ((this.a & 0x8000) === 0);
},
exchangeMps: function ArithmeticDecoder_exchangeMps(cx) {
var d;
@ -1558,12 +1559,12 @@ var JpxImage = (function JpxImageClosure() {
// significant but not those that have just become
if (!coefficentsMagnitude[index] ||
(processingFlags[index] & processedMask) != 0)
(processingFlags[index] & processedMask) !== 0)
continue;
var contextLabel = 16;
if ((processingFlags[index] &
firstMagnitudeBitMask) != 0) {
firstMagnitudeBitMask) !== 0) {
processingFlags[i * width + j] ^= firstMagnitudeBitMask;
// first refinement
var significance = neighborsSignificance[index];
@ -1604,14 +1605,14 @@ var JpxImage = (function JpxImageClosure() {
// using the property: labels[neighborsSignificance[index]] == 0
// when neighborsSignificance[index] == 0
var allEmpty = i0 + 3 < height &&
processingFlags[index0] == 0 &&
processingFlags[index0 + oneRowDown] == 0 &&
processingFlags[index0 + twoRowsDown] == 0 &&
processingFlags[index0 + threeRowsDown] == 0 &&
neighborsSignificance[index0] == 0 &&
neighborsSignificance[index0 + oneRowDown] == 0 &&
neighborsSignificance[index0 + twoRowsDown] == 0 &&
neighborsSignificance[index0 + threeRowsDown] == 0;
processingFlags[index0] === 0 &&
processingFlags[index0 + oneRowDown] === 0 &&
processingFlags[index0 + twoRowsDown] === 0 &&
processingFlags[index0 + threeRowsDown] === 0 &&
neighborsSignificance[index0] === 0 &&
neighborsSignificance[index0 + oneRowDown] === 0 &&
neighborsSignificance[index0 + twoRowsDown] === 0 &&
neighborsSignificance[index0 + threeRowsDown] === 0;
var i1 = 0, index = index0;
var cx, i;
if (allEmpty) {
@ -1647,7 +1648,7 @@ var JpxImage = (function JpxImageClosure() {
break;
if (coefficentsMagnitude[index] ||
(processingFlags[index] & processedMask) != 0)
(processingFlags[index] & processedMask) !== 0)
continue;
var contextLabel = labels[neighborsSignificance[index]];
@ -1733,7 +1734,7 @@ var JpxImage = (function JpxImageClosure() {
for (var v = 0; v < height; v++) {
if (width == 1) {
// if width = 1, when u0 even keep items as is, when odd divide by 2
if ((u0 % 1) != 0) {
if ((u0 % 1) !== 0) {
items[v * width] /= 2;
}
continue;
@ -1768,7 +1769,7 @@ var JpxImage = (function JpxImageClosure() {
for (var u = 0; u < width; u++) {
if (height == 1) {
// if height = 1, when v0 even keep items as is, when odd divide by 2
if ((v0 % 1) != 0) {
if ((v0 % 1) !== 0) {
items[u] /= 2;
}
continue;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals Document, error, PDFJS */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals assertWellFormed, bytesToString, CipherTransformFactory, error, info, InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef, isStream, JpegStream, Lexer, log, Page, Parser, Promise, shadow, stringToPDFString, stringToUTF8String, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -100,7 +101,7 @@ var Dict = (function DictClosure() {
callback(key, this.get(key));
}
};
};
}
return Dict;
})();
@ -442,7 +443,7 @@ var XRef = (function XRefClosure() {
for (j = 0; j < typeFieldWidth; ++j)
type = (type << 8) | stream.getByte();
// if type field is absent, its default value = 1
if (typeFieldWidth == 0)
if (typeFieldWidth === 0)
type = 1;
for (j = 0; j < offsetFieldWidth; ++j)
offset = (offset << 8) | stream.getByte();
@ -678,7 +679,7 @@ var XRef = (function XRefClosure() {
}
if (!isCmd(obj3, 'obj')) {
// some bad pdfs use "obj1234" and really mean 1234
if (obj3.cmd.indexOf('obj') == 0) {
if (obj3.cmd.indexOf('obj') === 0) {
num = parseInt(obj3.cmd.substring(3), 10);
if (!isNaN(num))
return num;

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals Ascii85Stream, AsciiHexStream, CCITTFaxStream, Cmd, Dict, error, FlateStream, isArray, isCmd, isDict, isInt, isName, isNum, isRef, isString, Jbig2Stream, JpegStream, JpxStream, LZWStream, Name, NullStream, PredictorStream, Ref, RunLengthStream, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -133,7 +134,7 @@ var Parser = (function ParserClosure() {
// searching for the /EI\s/
var state = 0, ch;
while (state != 4 && (ch = stream.getByte()) != null) {
while (state != 4 && (ch = stream.getByte()) !== null && ch !== undefined) {
switch (ch) {
case 0x20:
case 0x0D:
@ -364,7 +365,7 @@ var Lexer = (function LexerClosure() {
str += ch;
break;
case ')':
if (--numParen == 0) {
if (--numParen === 0) {
done = true;
} else {
str += ch;
@ -540,6 +541,7 @@ var Lexer = (function LexerClosure() {
stream.skip();
return Cmd.get('>>');
}
return Cmd.get(ch);
case '{':
case '}':
return Cmd.get(ch);

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals CanvasGraphics, ColorSpace, createScratchCanvas, DeviceRgbCS, error, info, isArray, isPDFFunction, isStream, PDFFunction, TODO, Util, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals bytesToString, ColorSpace, Dict, EOF, error, info, Jbig2Image, JpegImage, JpxImage, Lexer */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -247,7 +248,7 @@ var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
function streamSequenceStreamReadBlock() {
var streams = this.streams;
if (streams.length == 0) {
if (streams.length === 0) {
this.eof = true;
return;
}
@ -367,7 +368,7 @@ var FlateStream = (function FlateStreamClosure() {
error('Invalid header in flate stream: ' + cmf + ', ' + flg);
if ((cmf & 0x0f) != 0x08)
error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
if ((((cmf << 8) + flg) % 31) != 0)
if ((((cmf << 8) + flg) % 31) !== 0)
error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
if (flg & 0x20)
error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
@ -421,7 +422,7 @@ var FlateStream = (function FlateStreamClosure() {
var code = codes[codeBuf & ((1 << maxLen) - 1)];
var codeLen = code >> 16;
var codeVal = code & 0xffff;
if (codeSize == 0 || codeSize < codeLen || codeLen == 0)
if (codeSize === 0 || codeSize < codeLen || codeLen === 0)
error('Bad encoding in flate stream');
this.codeBuf = (codeBuf >> codeLen);
this.codeSize = (codeSize - codeLen);
@ -475,7 +476,7 @@ var FlateStream = (function FlateStreamClosure() {
this.eof = true;
hdr >>= 1;
if (hdr == 0) { // uncompressed block
if (hdr === 0) { // uncompressed block
var bytes = this.bytes;
var bytesPos = this.bytesPos;
var b;
@ -708,7 +709,7 @@ var PredictorStream = (function PredictorStreamClosure() {
var buffer = this.ensureBuffer(bufferLength + rowBytes);
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
if (prevRow.length == 0)
if (prevRow.length === 0)
prevRow = new Uint8Array(rowBytes);
var j = bufferLength;
@ -793,10 +794,10 @@ var JpegStream = (function JpegStreamClosure() {
// Looking for APP14, 'Adobe'
for (var i = 0; i < maxBytesScanned; ++i) {
if (bytes[i] == 0xFF && bytes[i + 1] == 0xEE &&
bytes[i + 2] == 0x00 && bytes[i + 3] == 0x0E &&
bytes[i + 2] === 0x00 && bytes[i + 3] == 0x0E &&
bytes[i + 4] == 0x41 && bytes[i + 5] == 0x64 &&
bytes[i + 6] == 0x6F && bytes[i + 7] == 0x62 &&
bytes[i + 8] == 0x65 && bytes[i + 9] == 0x00)
bytes[i + 8] == 0x65 && bytes[i + 9] === 0x00)
return true;
// scanning until frame tag
if (bytes[i] == 0xFF && bytes[i + 1] == 0xC0)
@ -1053,7 +1054,7 @@ var DecryptStream = (function DecryptStreamClosure() {
DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
var chunk = this.str.getBytes(chunkSize);
if (!chunk || chunk.length == 0) {
if (!chunk || chunk.length === 0) {
this.eof = true;
return;
}
@ -1695,7 +1696,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
this.columns = params.get('Columns') || 1728;
this.rows = params.get('Rows') || 0;
var eoblock = params.get('EndOfBlock');
if (eoblock == null)
if (eoblock === null || eoblock === undefined)
eoblock = true;
this.eoblock = eoblock;
this.black = params.get('BlackIs1') || false;
@ -1714,7 +1715,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
this.buf = EOF;
var code1;
while ((code1 = this.lookBits(12)) == 0) {
while ((code1 = this.lookBits(12)) === 0) {
this.eatBits(1);
}
if (code1 == 1) {
@ -1798,7 +1799,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
var refPos, blackPixels, bits;
if (this.outputBits == 0) {
if (this.outputBits === 0) {
if (this.eof)
return null;
@ -1972,7 +1973,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
this.eof = true;
} else {
code1 = this.lookBits(12);
while (code1 == 0) {
while (code1 === 0) {
this.eatBits(1);
code1 = this.lookBits(12);
}
@ -2040,7 +2041,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
if (this.outputBits >= 8) {
this.buf = (this.codingPos & 1) ? 0 : 0xFF;
this.outputBits -= 8;
if (this.outputBits == 0 && codingLine[this.codingPos] < columns) {
if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
this.codingPos++;
this.outputBits = (codingLine[this.codingPos] -
codingLine[this.codingPos - 1]);
@ -2139,7 +2140,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
if (code == EOF)
return 1;
if ((code >> 5) == 0)
if ((code >> 5) === 0)
p = whiteTable1[code];
else
p = whiteTable2[code >> 3];
@ -2170,9 +2171,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
code = this.lookBits(13);
if (code == EOF)
return 1;
if ((code >> 7) == 0)
if ((code >> 7) === 0)
p = blackTable1[code];
else if ((code >> 9) == 0 && (code >> 7) != 0)
else if ((code >> 9) === 0 && (code >> 7) !== 0)
p = blackTable2[(code >> 1) - 64];
else
p = blackTable3[code >> 7];
@ -2202,8 +2203,8 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
var c;
while (this.inputBits < n) {
if ((c = this.str.getByte()) == null) {
if (this.inputBits == 0)
if ((c = this.str.getByte()) === null || c === undefined) {
if (this.inputBits === 0)
return EOF;
return ((this.inputBuf << (n - this.inputBits)) &
(0xFFFF >> (16 - n)));
@ -2256,7 +2257,7 @@ var LZWStream = (function LZWStreamClosure() {
var cachedData = this.cachedData;
while (bitsCached < n) {
var c = this.str.getByte();
if (c == null) {
if (c === null || c === undefined) {
this.eof = true;
return null;
}

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals Cmd, DeviceCmykCS, Dict, globalScope, INFOS, MozBlobBuilder, Name, PDFJS, Ref, WARNINGS, verbosity */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -253,7 +254,7 @@ var Util = PDFJS.Util = (function UtilClosure() {
m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
];
}
};
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
// For coordinate systems whose origin lies in the bottom-left, this
@ -270,7 +271,7 @@ var Util = PDFJS.Util = (function UtilClosure() {
r[3] = rect[1];
}
return r;
}
};
// Returns a rectangle [x1, y1, x2, y2] corresponding to the
// intersection of rect1 and rect2. If no intersection, returns 'false'
@ -278,7 +279,7 @@ var Util = PDFJS.Util = (function UtilClosure() {
Util.intersect = function Util_intersect(rect1, rect2) {
function compare(a, b) {
return a - b;
};
}
// Order points along the axes
var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
@ -338,15 +339,15 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
case 270:
rotateA = 0; rotateB = -1; rotateC = -1; rotateD = 0;
break;
case 360:
case 0:
//case 360:
//case 0:
default:
rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1;
break;
}
var offsetCanvasX, offsetCanvasY;
var width, height;
if (rotateA == 0) {
if (rotateA === 0) {
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
width = Math.abs(viewBox[3] - viewBox[1]) * scale;
@ -468,11 +469,11 @@ function isArray(v) {
}
function isStream(v) {
return typeof v == 'object' && v != null && ('getChar' in v);
return typeof v == 'object' && v !== null && v !== undefined && ('getChar' in v);
}
function isArrayBuffer(v) {
return typeof v == 'object' && v != null && ('byteLength' in v);
return typeof v == 'object' && v !== null && v !== undefined && ('byteLength' in v);
}
function isRef(v) {
@ -517,7 +518,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
this.error = null;
this.exception = null;
// If you build a promise and pass in some data it's already resolved.
if (data != null) {
if (data !== null && data !== undefined) {
this.isResolved = true;
this._data = data;
this.hasData = true;
@ -528,7 +529,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
this.callbacks = [];
this.errbacks = [];
this.progressbacks = [];
};
}
/**
* Builds a promise that is resolved when all the passed in promises are
* resolved.

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals CFFDictDataMap, CFFDictPrivateDataMap, CFFEncodingMap, CFFStrings, Components, Dict, dump, error, isNum, log, netscape, Stream, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -15,6 +16,8 @@
* limitations under the License.
*/
'use strict';
/*
* The Type2 reader code below is only used for debugging purpose since Type2
* is only a CharString format and is never used directly as a Font file.
@ -33,7 +36,7 @@ function readCharset(aStream, aCharstrings) {
var format = aStream.getByte();
var count = aCharstrings.length - 1;
if (format == 0) {
if (format === 0) {
charset['.notdef'] = readCharstringEncoding(aCharstrings[0]);
for (var i = 1; i < count + 1; i++) {
@ -250,7 +253,7 @@ var Type2Parser = function type2Parser(aFilePath) {
var xhr = new XMLHttpRequest();
xhr.open('GET', aFilePath, false);
xhr.mozResponseType = xhr.responseType = 'arraybuffer';
xhr.expected = (document.URL.indexOf('file:') == 0) ? 0 : 200;
xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200;
xhr.send(null);
this.data = new Stream(xhr.mozResponseArrayBuffer || xhr.mozResponse ||
xhr.responseArrayBuffer || xhr.response);
@ -365,7 +368,7 @@ var Type2Parser = function type2Parser(aFilePath) {
// Read Charset
dump('Read Charset for ' + charStrings.length + ' glyphs');
var charsetEntry = font.get('charset');
if (charsetEntry == 0) {
if (charsetEntry === 0) {
error('Need to support CFFISOAdobeCharset');
} else if (charsetEntry == 1) {
error('Need to support CFFExpert');

View File

@ -1,5 +1,6 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals CanvasGraphics, error, globalScope, InvalidPDFException, log, MissingPDFException, PasswordException, PDFDocument, PDFJS, Promise, Stream, UnknownErrorException, warn */
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -252,19 +253,21 @@ var WorkerMessageHandler = {
var minimumStackMessage =
'worker.js: while trying to getPage() and getOperatorList()';
var wrappedException;
// Turn the error into an obj that can be serialized
if (typeof e === 'string') {
e = {
wrappedException = {
message: e,
stack: minimumStackMessage
};
} else if (typeof e === 'object') {
e = {
wrappedException = {
message: e.message || e.toString(),
stack: e.stack || minimumStackMessage
};
} else {
e = {
wrappedException = {
message: 'Unknown exception type: ' + (typeof e),
stack: minimumStackMessage
};
@ -272,7 +275,7 @@ var WorkerMessageHandler = {
handler.send('PageError', {
pageNum: pageNum,
error: e
error: wrappedException
});
return;
}
@ -284,7 +287,7 @@ var WorkerMessageHandler = {
var fonts = {};
for (var i = 0, ii = dependency.length; i < ii; i++) {
var dep = dependency[i];
if (dep.indexOf('g_font_') == 0) {
if (dep.indexOf('g_font_') === 0) {
fonts[dep] = true;
}
}
@ -341,7 +344,7 @@ var workerConsole = {
timeEnd: function timeEnd(name) {
var time = consoleTimer[name];
if (time == null) {
if (!time) {
error('Unkown timer name ' + name);
}
this.log('Timer:', name, Date.now() - time);

28
test/reporter.js Normal file
View File

@ -0,0 +1,28 @@
"use strict";
module.exports = {
reporter: function (res) {
var len = 0;
var str = "";
res.forEach(function (r) {
var file = r.file;
var err = r.error;
switch(err.code) {
case 'W004': // variable is already defined
case 'W018': // confusing use of !
break;
default:
len++;
str += file + ": line " + err.line + ", col " +
err.character + ", " + err.reason + "\n";
}
});
if (str) {
process.stdout.write(str + "\n" + len + " error" +
((len === 1) ? "" : "s") + "\n");
}
}
};