Merge pull request #5120 from Snuffleupagus/strict-equalities-src-core-2

Add strict equalities in src/core/* (part 2)
This commit is contained in:
Tim van der Meij 2014-08-02 13:51:14 +02:00
commit cb59b5772b
7 changed files with 51 additions and 51 deletions

View File

@ -2210,7 +2210,7 @@ var Font = (function FontClosure() {
this.toFontChar = []; this.toFontChar = [];
if (properties.type == 'Type3') { if (properties.type === 'Type3') {
for (charCode = 0; charCode < 256; charCode++) { for (charCode = 0; charCode < 256; charCode++) {
this.toFontChar[charCode] = (this.differences[charCode] || this.toFontChar[charCode] = (this.differences[charCode] ||
properties.defaultEncoding[charCode]); properties.defaultEncoding[charCode]);
@ -2240,13 +2240,13 @@ var Font = (function FontClosure() {
var isStandardFont = fontName in stdFontMap; var isStandardFont = fontName in stdFontMap;
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName; fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
this.bold = (fontName.search(/bold/gi) != -1); this.bold = (fontName.search(/bold/gi) !== -1);
this.italic = ((fontName.search(/oblique/gi) != -1) || this.italic = ((fontName.search(/oblique/gi) !== -1) ||
(fontName.search(/italic/gi) != -1)); (fontName.search(/italic/gi) !== -1));
// Use 'name' instead of 'fontName' here because the original // Use 'name' instead of 'fontName' here because the original
// name ArialBlack for example will be replaced by Helvetica. // name ArialBlack for example will be replaced by Helvetica.
this.black = (name.search(/Black/g) != -1); this.black = (name.search(/Black/g) !== -1);
// if at least one width is present, remeasure all chars when exists // if at least one width is present, remeasure all chars when exists
this.remeasure = Object.keys(this.widths).length > 0; this.remeasure = Object.keys(this.widths).length > 0;
@ -2295,7 +2295,7 @@ var Font = (function FontClosure() {
} }
// Some fonts might use wrong font types for Type1C or CIDFontType0C // Some fonts might use wrong font types for Type1C or CIDFontType0C
if (subtype == 'Type1C' && (type != 'Type1' && type != 'MMType1')) { if (subtype === 'Type1C' && (type !== 'Type1' && type !== 'MMType1')) {
// Some TrueType fonts by mistake claim Type1C // Some TrueType fonts by mistake claim Type1C
if (isTrueTypeFile(file)) { if (isTrueTypeFile(file)) {
subtype = 'TrueType'; subtype = 'TrueType';
@ -2303,7 +2303,7 @@ var Font = (function FontClosure() {
type = 'Type1'; type = 'Type1';
} }
} }
if (subtype == 'CIDFontType0C' && type != 'CIDFontType0') { if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
type = 'CIDFontType0'; type = 'CIDFontType0';
} }
// XXX: Temporarily change the type for open type so we trigger a warning. // XXX: Temporarily change the type for open type so we trigger a warning.
@ -2400,7 +2400,7 @@ var Font = (function FontClosure() {
function createOpenTypeHeader(sfnt, file, numTables) { function createOpenTypeHeader(sfnt, file, numTables) {
// Windows hates the Mac TrueType sfnt version number // Windows hates the Mac TrueType sfnt version number
if (sfnt == 'true') { if (sfnt === 'true') {
sfnt = string32(0x00010000); sfnt = string32(0x00010000);
} }
@ -2554,7 +2554,7 @@ var Font = (function FontClosure() {
var codeIndices = [codes[n].glyphId]; var codeIndices = [codes[n].glyphId];
++n; ++n;
var end = start; var end = start;
while (n < length && end + 1 == codes[n].fontCharCode) { while (n < length && end + 1 === codes[n].fontCharCode) {
codeIndices.push(codes[n].glyphId); codeIndices.push(codes[n].glyphId);
++end; ++end;
++n; ++n;
@ -2935,7 +2935,7 @@ var Font = (function FontClosure() {
var data = file.getBytes(length); var data = file.getBytes(length);
file.pos = previousPosition; file.pos = previousPosition;
if (tag == 'head') { if (tag === 'head') {
// clearing checksum adjustment // clearing checksum adjustment
data[8] = data[9] = data[10] = data[11] = 0; data[8] = data[9] = data[10] = data[11] = 0;
data[17] |= 0x20; //Set font optimized for cleartype flag data[17] |= 0x20; //Set font optimized for cleartype flag
@ -2986,7 +2986,7 @@ var Font = (function FontClosure() {
var offset = font.getInt32() >>> 0; var offset = font.getInt32() >>> 0;
var useTable = false; var useTable = false;
if (platformId == 1 && encodingId === 0) { if (platformId === 1 && encodingId === 0) {
useTable = true; useTable = true;
// Continue the loop since there still may be a higher priority // Continue the loop since there still may be a higher priority
// table. // table.
@ -3088,7 +3088,7 @@ var Font = (function FontClosure() {
offsetIndex = segment.offsetIndex; offsetIndex = segment.offsetIndex;
for (j = start; j <= end; j++) { for (j = start; j <= end; j++) {
if (j == 0xFFFF) { if (j === 0xFFFF) {
continue; continue;
} }
@ -3104,7 +3104,7 @@ var Font = (function FontClosure() {
}); });
} }
} }
} else if (format == 6) { } else if (format === 6) {
// Format 6 is a 2-bytes dense mapping, which means the font data // Format 6 is a 2-bytes dense mapping, which means the font data
// lives glue together even if they are pretty far in the unicode // lives glue together even if they are pretty far in the unicode
// table. (This looks weird, so I can have missed something), this // table. (This looks weird, so I can have missed something), this
@ -3412,7 +3412,7 @@ var Font = (function FontClosure() {
break; break;
case 0x00020000: case 0x00020000:
var numGlyphs = font.getUint16(); var numGlyphs = font.getUint16();
if (numGlyphs != maxpNumGlyphs) { if (numGlyphs !== maxpNumGlyphs) {
valid = false; valid = false;
break; break;
} }
@ -3488,8 +3488,8 @@ var Font = (function FontClosure() {
offset: font.getUint16() offset: font.getUint16()
}; };
// using only Macintosh and Windows platform/encoding names // 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)) { (r.platform === 3 && r.encoding === 1 && r.language === 0x409)) {
records.push(r); records.push(r);
} }
} }
@ -3823,7 +3823,7 @@ var Font = (function FontClosure() {
} }
var dupFirstEntry = false; var dupFirstEntry = false;
if (properties.type == 'CIDFontType2' && properties.toUnicode && if (properties.type === 'CIDFontType2' && properties.toUnicode &&
properties.toUnicode[0] > '\u0000') { properties.toUnicode[0] > '\u0000') {
// oracle's defect (see 3427), duplicating first entry // oracle's defect (see 3427), duplicating first entry
dupFirstEntry = true; dupFirstEntry = true;
@ -4532,7 +4532,7 @@ var Font = (function FontClosure() {
charcode = chars.charCodeAt(i); charcode = chars.charCodeAt(i);
glyph = this.charToGlyph(charcode); glyph = this.charToGlyph(charcode);
glyphs.push(glyph); glyphs.push(glyph);
if (charcode == 0x20) { if (charcode === 0x20) {
glyphs.push(null); glyphs.push(null);
} }
} }
@ -5370,7 +5370,7 @@ var Type1Font = function Type1Font(name, file, properties) {
var headerBlockLength = properties.length1; var headerBlockLength = properties.length1;
var eexecBlockLength = properties.length2; var eexecBlockLength = properties.length2;
var pfbHeader = file.peekBytes(PFB_HEADER_SIZE); var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
var pfbHeaderPresent = pfbHeader[0] == 0x80 && pfbHeader[1] == 0x01; var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
if (pfbHeaderPresent) { if (pfbHeaderPresent) {
file.skip(PFB_HEADER_SIZE); file.skip(PFB_HEADER_SIZE);
headerBlockLength = (pfbHeader[5] << 24) | (pfbHeader[4] << 16) | headerBlockLength = (pfbHeader[5] << 24) | (pfbHeader[4] << 16) |
@ -5528,7 +5528,7 @@ Type1Font.prototype = {
// thought mapping names that aren't in the standard strings to .notdef // thought mapping names that aren't in the standard strings to .notdef
// was fine, however in issue818 when mapping them all to .notdef the // was fine, however in issue818 when mapping them all to .notdef the
// adieresis glyph no longer worked. // adieresis glyph no longer worked.
if (index == -1) { if (index === -1) {
index = 0; index = 0;
} }
charsetArray.push((index >> 8) & 0xff, index & 0xff); charsetArray.push((index >> 8) & 0xff, index & 0xff);
@ -5886,12 +5886,12 @@ var CFFParser = (function CFFParserClosure() {
var b1 = b >> 4; var b1 = b >> 4;
var b2 = b & 15; var b2 = b & 15;
if (b1 == eof) { if (b1 === eof) {
break; break;
} }
str += lookup[b1]; str += lookup[b1];
if (b2 == eof) { if (b2 === eof) {
break; break;
} }
str += lookup[b2]; str += lookup[b2];
@ -6011,7 +6011,7 @@ var CFFParser = (function CFFParserClosure() {
for (var j = 0; j < length;) { for (var j = 0; j < length;) {
var value = data[j++]; var value = data[j++];
var validationCommand = null; var validationCommand = null;
if (value == 12) { if (value === 12) {
var q = data[j++]; var q = data[j++];
if (q === 0) { if (q === 0) {
// The CFF specification state that the 'dotsection' command // The CFF specification state that the 'dotsection' command
@ -6029,7 +6029,7 @@ var CFFParser = (function CFFParserClosure() {
stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16; stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16;
j += 2; j += 2;
stackSize++; stackSize++;
} else if (value == 14) { } else if (value === 14) {
if (stackSize >= 4) { if (stackSize >= 4) {
stackSize -= 4; stackSize -= 4;
if (SEAC_ANALYSIS_ENABLED) { if (SEAC_ANALYSIS_ENABLED) {
@ -6046,12 +6046,12 @@ var CFFParser = (function CFFParserClosure() {
-((value - 251) << 8) - data[j] - 108); -((value - 251) << 8) - data[j] - 108);
j++; j++;
stackSize++; stackSize++;
} else if (value == 255) { // number (32 bit) } else if (value === 255) { // number (32 bit)
stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) | stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) |
(data[j + 2] << 8) | data[j + 3]) / 65536; (data[j + 2] << 8) | data[j + 3]) / 65536;
j += 4; j += 4;
stackSize++; stackSize++;
} else if (value == 19 || value == 20) { } else if (value === 19 || value === 20) {
hints += stackSize >> 1; hints += stackSize >> 1;
j += (hints + 7) >> 3; // skipping right amount of hints flag data j += (hints + 7) >> 3; // skipping right amount of hints flag data
stackSize = 0; stackSize = 0;
@ -6144,10 +6144,10 @@ var CFFParser = (function CFFParserClosure() {
if (pos === 0) { if (pos === 0) {
return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE,
ISOAdobeCharset); ISOAdobeCharset);
} else if (pos == 1) { } else if (pos === 1) {
return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT,
ExpertCharset); ExpertCharset);
} else if (pos == 2) { } else if (pos === 2) {
return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET,
ExpertSubsetCharset); ExpertSubsetCharset);
} }
@ -6215,14 +6215,14 @@ var CFFParser = (function CFFParserClosure() {
} }
} }
if (pos === 0 || pos == 1) { if (pos === 0 || pos === 1) {
predefined = true; predefined = true;
format = pos; format = pos;
var baseEncoding = pos ? Encodings.ExpertEncoding : var baseEncoding = pos ? Encodings.ExpertEncoding :
Encodings.StandardEncoding; Encodings.StandardEncoding;
for (i = 0, ii = charset.length; i < ii; i++) { for (i = 0, ii = charset.length; i < ii; i++) {
var index = baseEncoding.indexOf(charset[i]); var index = baseEncoding.indexOf(charset[i]);
if (index != -1) { if (index !== -1) {
encoding[index] = i; encoding[index] = i;
} }
} }
@ -6749,7 +6749,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
return output.data; return output.data;
}, },
encodeNumber: function CFFCompiler_encodeNumber(value) { encodeNumber: function CFFCompiler_encodeNumber(value) {
if (parseFloat(value) == parseInt(value, 10) && !isNaN(value)) { // isInt if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) { // isInt
return this.encodeInteger(value); return this.encodeInteger(value);
} else { } else {
return this.encodeFloat(value); return this.encodeFloat(value);

View File

@ -173,7 +173,7 @@ var PDFFunction = (function PDFFunctionClosure() {
//var mask = IR[8]; //var mask = IR[8];
var range = IR[9]; var range = IR[9];
if (m != args.length) { if (m !== args.length) {
error('Incorrect number of arguments: ' + m + ' != ' + error('Incorrect number of arguments: ' + m + ' != ' +
args.length); args.length);
} }
@ -275,7 +275,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var length = diff.length; var length = diff.length;
return function constructInterpolatedFromIRResult(args) { return function constructInterpolatedFromIRResult(args) {
var x = n == 1 ? args[0] : Math.pow(args[0], n); var x = (n === 1 ? args[0] : Math.pow(args[0], n));
var out = []; var out = [];
for (var j = 0; j < length; ++j) { for (var j = 0; j < length; ++j) {
@ -295,7 +295,7 @@ var PDFFunction = (function PDFFunctionClosure() {
} }
var inputSize = domain.length / 2; var inputSize = domain.length / 2;
if (inputSize != 1) { if (inputSize !== 1) {
error('Bad domain for stiched function'); error('Bad domain for stiched function');
} }
@ -439,7 +439,7 @@ var PDFFunction = (function PDFFunctionClosure() {
function isPDFFunction(v) { function isPDFFunction(v) {
var fnDict; var fnDict;
if (typeof v != 'object') { if (typeof v !== 'object') {
return false; return false;
} else if (isDict(v)) { } else if (isDict(v)) {
fnDict = v; fnDict = v;
@ -513,7 +513,7 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
var operator, a, b; var operator, a, b;
while (counter < length) { while (counter < length) {
operator = operators[counter++]; operator = operators[counter++];
if (typeof operator == 'number') { if (typeof operator === 'number') {
// Operator is really an operand and should be pushed to the stack. // Operator is really an operand and should be pushed to the stack.
stack.push(operator); stack.push(operator);
continue; continue;
@ -594,7 +594,7 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
case 'eq': case 'eq':
b = stack.pop(); b = stack.pop();
a = stack.pop(); a = stack.pop();
stack.push(a == b); stack.push(a === b);
break; break;
case 'exch': case 'exch':
stack.roll(2, 1); stack.roll(2, 1);
@ -661,7 +661,7 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
case 'ne': case 'ne':
b = stack.pop(); b = stack.pop();
a = stack.pop(); a = stack.pop();
stack.push(a != b); stack.push(a !== b);
break; break;
case 'neg': case 'neg':
a = stack.pop(); a = stack.pop();
@ -721,7 +721,7 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
b = stack.pop(); b = stack.pop();
a = stack.pop(); a = stack.pop();
if (isBool(a) && isBool(b)) { if (isBool(a) && isBool(b)) {
stack.push(a != b); stack.push(a !== b);
} else { } else {
stack.push(a ^ b); stack.push(a ^ b);
} }

View File

@ -48,7 +48,7 @@ var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
update: function MurmurHash3_64_update(input) { update: function MurmurHash3_64_update(input) {
var useUint32ArrayView = alwaysUseUint32ArrayView; var useUint32ArrayView = alwaysUseUint32ArrayView;
var i; var i;
if (typeof input == 'string') { if (typeof input === 'string') {
var data = new Uint8Array(input.length * 2); var data = new Uint8Array(input.length * 2);
var length = 0; var length = 0;
for (i = 0; i < input.length; i++) { for (i = 0; i < input.length; i++) {

View File

@ -98,12 +98,12 @@ var Dict = (function DictClosure() {
get: function Dict_get(key1, key2, key3) { get: function Dict_get(key1, key2, key3) {
var value; var value;
var xref = this.xref; var xref = this.xref;
if (typeof (value = this.map[key1]) != 'undefined' || key1 in this.map || if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
typeof key2 == 'undefined') { typeof key2 === 'undefined') {
return xref ? xref.fetchIfRef(value) : value; return xref ? xref.fetchIfRef(value) : value;
} }
if (typeof (value = this.map[key2]) != 'undefined' || key2 in this.map || if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
typeof key3 == 'undefined') { typeof key3 === 'undefined') {
return xref ? xref.fetchIfRef(value) : value; return xref ? xref.fetchIfRef(value) : value;
} }
value = this.map[key3] || null; value = this.map[key3] || null;
@ -652,7 +652,7 @@ var Catalog = (function CatalogClosure() {
for (var i = 0; i < kids.length; i++) { for (var i = 0; i < kids.length; i++) {
var kid = kids[i]; var kid = kids[i];
assert(isRef(kid), 'kids must be a ref'); assert(isRef(kid), 'kids must be a ref');
if (kid.num == kidRef.num) { if (kid.num === kidRef.num) {
found = true; found = true;
break; break;
} }
@ -976,7 +976,7 @@ var XRef = (function XRefClosure() {
// finding byte sequence // finding byte sequence
while (offset < dataLength) { while (offset < dataLength) {
var i = 0; var i = 0;
while (i < length && data[offset + i] == what[i]) { while (i < length && data[offset + i] === what[i]) {
++i; ++i;
} }
if (i >= length) { if (i >= length) {

View File

@ -195,13 +195,13 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
var coordsArr = this.coordsArr; var coordsArr = this.coordsArr;
var shadingType = this.shadingType; var shadingType = this.shadingType;
var type, p0, p1, r0, r1; var type, p0, p1, r0, r1;
if (shadingType == PatternType.AXIAL) { if (shadingType === PatternType.AXIAL) {
p0 = [coordsArr[0], coordsArr[1]]; p0 = [coordsArr[0], coordsArr[1]];
p1 = [coordsArr[2], coordsArr[3]]; p1 = [coordsArr[2], coordsArr[3]];
r0 = null; r0 = null;
r1 = null; r1 = null;
type = 'axial'; type = 'axial';
} else if (shadingType == PatternType.RADIAL) { } else if (shadingType === PatternType.RADIAL) {
p0 = [coordsArr[0], coordsArr[1]]; p0 = [coordsArr[0], coordsArr[1]];
p1 = [coordsArr[3], coordsArr[4]]; p1 = [coordsArr[3], coordsArr[4]];
r0 = coordsArr[2]; r0 = coordsArr[2];

View File

@ -31,7 +31,7 @@ var PostScriptParser = (function PostScriptParserClosure() {
this.token = this.lexer.getToken(); this.token = this.lexer.getToken();
}, },
accept: function PostScriptParser_accept(type) { accept: function PostScriptParser_accept(type) {
if (this.token.type == type) { if (this.token.type === type) {
this.nextToken(); this.nextToken();
return true; return true;
} }
@ -158,7 +158,7 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
if (ch === 0x0A || ch === 0x0D) { if (ch === 0x0A || ch === 0x0D) {
comment = false; comment = false;
} }
} else if (ch == 0x25) { // '%' } else if (ch === 0x25) { // '%'
comment = true; comment = true;
} else if (!Lexer.isSpace(ch)) { } else if (!Lexer.isSpace(ch)) {
break; break;

View File

@ -141,7 +141,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
}, },
onError: function onError(status) { onError: function onError(status) {
if (status == 404) { if (status === 404) {
var exception = new MissingPDFException('Missing PDF "' + var exception = new MissingPDFException('Missing PDF "' +
source.url + '".'); source.url + '".');
handler.send('MissingPDF', { exception: exception }); handler.send('MissingPDF', { exception: exception });