Browse Source

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

Add strict equalities in src/core/* (part 1)
Tim van der Meij 11 years ago
parent
commit
00eea3ddb9
  1. 2
      src/core/annotation.js
  2. 2
      src/core/arithmetic_decoder.js
  3. 55
      src/core/bidi.js
  4. 12
      src/core/colorspace.js
  5. 2
      src/core/core.js
  6. 2
      src/core/evaluator.js

2
src/core/annotation.js

@ -357,7 +357,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
var j, jj; var j, jj;
for (j = 0, jj = kids.length; j < jj; j++) { for (j = 0, jj = kids.length; j < jj; j++) {
var kidRef = kids[j]; var kidRef = kids[j];
if (kidRef.num == ref.num && kidRef.gen == ref.gen) { if (kidRef.num === ref.num && kidRef.gen === ref.gen) {
break; break;
} }
} }

2
src/core/arithmetic_decoder.js

@ -99,7 +99,7 @@ var ArithmeticDecoder = (function ArithmeticDecoderClosure() {
byteIn: function ArithmeticDecoder_byteIn() { byteIn: function ArithmeticDecoder_byteIn() {
var data = this.data; var data = this.data;
var bp = this.bp; var bp = this.bp;
if (data[bp] == 0xFF) { if (data[bp] === 0xFF) {
var b1 = data[bp + 1]; var b1 = data[bp + 1];
if (b1 > 0x8F) { if (b1 > 0x8F) {
this.clow += 0xFF00; this.clow += 0xFF00;

55
src/core/bidi.js

@ -78,7 +78,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
function findUnequal(arr, start, value) { function findUnequal(arr, start, value) {
for (var j = start, jj = arr.length; j < jj; ++j) { for (var j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] != value) { if (arr[j] !== value) {
return j; return j;
} }
} }
@ -138,7 +138,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
} else if (0x0700 <= charCode && charCode <= 0x08AC) { } else if (0x0700 <= charCode && charCode <= 0x08AC) {
charType = 'AL'; charType = 'AL';
} }
if (charType == 'R' || charType == 'AL' || charType == 'AN') { if (charType === 'R' || charType === 'AL' || charType === 'AN') {
numBidi++; numBidi++;
} }
types[i] = charType; types[i] = charType;
@ -153,7 +153,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
return createBidiText(str, isLTR); return createBidiText(str, isLTR);
} }
if (startLevel == -1) { if (startLevel === -1) {
if ((strLength / numBidi) < 0.3) { if ((strLength / numBidi) < 0.3) {
isLTR = true; isLTR = true;
startLevel = 0; startLevel = 0;
@ -182,7 +182,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
*/ */
var lastType = sor; var lastType = sor;
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
if (types[i] == 'NSM') { if (types[i] === 'NSM') {
types[i] = lastType; types[i] = lastType;
} else { } else {
lastType = types[i]; lastType = types[i];
@ -198,9 +198,9 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
var t; var t;
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
t = types[i]; t = types[i];
if (t == 'EN') { if (t === 'EN') {
types[i] = (lastType == 'AL') ? 'AN' : 'EN'; types[i] = (lastType === 'AL') ? 'AN' : 'EN';
} else if (t == 'R' || t == 'L' || t == 'AL') { } else if (t === 'R' || t === 'L' || t === 'AL') {
lastType = t; lastType = t;
} }
} }
@ -210,7 +210,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
*/ */
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
t = types[i]; t = types[i];
if (t == 'AL') { if (t === 'AL') {
types[i] = 'R'; types[i] = 'R';
} }
} }
@ -221,11 +221,12 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
type changes to that type: type changes to that type:
*/ */
for (i = 1; i < strLength - 1; ++i) { for (i = 1; i < strLength - 1; ++i) {
if (types[i] == 'ES' && types[i - 1] == 'EN' && types[i + 1] == 'EN') { if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
types[i] = 'EN'; types[i] = 'EN';
} }
if (types[i] == 'CS' && (types[i - 1] == 'EN' || types[i - 1] == 'AN') && if (types[i] === 'CS' &&
types[i + 1] == types[i - 1]) { (types[i - 1] === 'EN' || types[i - 1] === 'AN') &&
types[i + 1] === types[i - 1]) {
types[i] = types[i - 1]; types[i] = types[i - 1];
} }
} }
@ -235,18 +236,18 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
to all European numbers: to all European numbers:
*/ */
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
if (types[i] == 'EN') { if (types[i] === 'EN') {
// do before // do before
var j; var j;
for (j = i - 1; j >= 0; --j) { for (j = i - 1; j >= 0; --j) {
if (types[j] != 'ET') { if (types[j] !== 'ET') {
break; break;
} }
types[j] = 'EN'; types[j] = 'EN';
} }
// do after // do after
for (j = i + 1; j < strLength; --j) { for (j = i + 1; j < strLength; --j) {
if (types[j] != 'ET') { if (types[j] !== 'ET') {
break; break;
} }
types[j] = 'EN'; types[j] = 'EN';
@ -259,7 +260,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
*/ */
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
t = types[i]; t = types[i];
if (t == 'WS' || t == 'ES' || t == 'ET' || t == 'CS') { if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
types[i] = 'ON'; types[i] = 'ON';
} }
} }
@ -272,9 +273,9 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
lastType = sor; lastType = sor;
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
t = types[i]; t = types[i];
if (t == 'EN') { if (t === 'EN') {
types[i] = ((lastType == 'L') ? 'L' : 'EN'); types[i] = ((lastType === 'L') ? 'L' : 'EN');
} else if (t == 'R' || t == 'L') { } else if (t === 'R' || t === 'L') {
lastType = t; lastType = t;
} }
} }
@ -286,7 +287,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
end-of-level-run (eor) are used at level run boundaries. end-of-level-run (eor) are used at level run boundaries.
*/ */
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
if (types[i] == 'ON') { if (types[i] === 'ON') {
var end = findUnequal(types, i + 1, 'ON'); var end = findUnequal(types, i + 1, 'ON');
var before = sor; var before = sor;
if (i > 0) { if (i > 0) {
@ -297,13 +298,13 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
if (end + 1 < strLength) { if (end + 1 < strLength) {
after = types[end + 1]; after = types[end + 1];
} }
if (before != 'L') { if (before !== 'L') {
before = 'R'; before = 'R';
} }
if (after != 'L') { if (after !== 'L') {
after = 'R'; after = 'R';
} }
if (before == after) { if (before === after) {
setValues(types, i, end, before); setValues(types, i, end, before);
} }
i = end - 1; // reset to end (-1 so next iteration is ok) i = end - 1; // reset to end (-1 so next iteration is ok)
@ -314,7 +315,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
N2. Any remaining neutrals take the embedding direction. N2. Any remaining neutrals take the embedding direction.
*/ */
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
if (types[i] == 'ON') { if (types[i] === 'ON') {
types[i] = e; types[i] = e;
} }
} }
@ -329,13 +330,13 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
for (i = 0; i < strLength; ++i) { for (i = 0; i < strLength; ++i) {
t = types[i]; t = types[i];
if (isEven(levels[i])) { if (isEven(levels[i])) {
if (t == 'R') { if (t === 'R') {
levels[i] += 1; levels[i] += 1;
} else if (t == 'AN' || t == 'EN') { } else if (t === 'AN' || t === 'EN') {
levels[i] += 2; levels[i] += 2;
} }
} else { // isOdd } else { // isOdd
if (t == 'L' || t == 'AN' || t == 'EN') { if (t === 'L' || t === 'AN' || t === 'EN') {
levels[i] += 1; levels[i] += 1;
} }
} }
@ -414,7 +415,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
var result = ''; var result = '';
for (i = 0, ii = chars.length; i < ii; ++i) { for (i = 0, ii = chars.length; i < ii; ++i) {
var ch = chars[i]; var ch = chars[i];
if (ch != '<' && ch != '>') { if (ch !== '<' && ch !== '>') {
result += ch; result += ch;
} }
} }

12
src/core/colorspace.js

@ -84,7 +84,7 @@ var ColorSpace = (function ColorSpaceClosure() {
var count = originalWidth * originalHeight; var count = originalWidth * originalHeight;
var rgbBuf = null; var rgbBuf = null;
var numComponentColors = 1 << bpc; var numComponentColors = 1 << bpc;
var needsResizing = originalHeight != height || originalWidth != width; var needsResizing = originalHeight !== height || originalWidth !== width;
var i, ii; var i, ii;
if (this.isPassthrough(bpc)) { if (this.isPassthrough(bpc)) {
@ -277,11 +277,11 @@ var ColorSpace = (function ColorSpaceClosure() {
var stream = xref.fetchIfRef(cs[1]); var stream = xref.fetchIfRef(cs[1]);
var dict = stream.dict; var dict = stream.dict;
numComps = dict.get('N'); numComps = dict.get('N');
if (numComps == 1) { if (numComps === 1) {
return 'DeviceGrayCS'; return 'DeviceGrayCS';
} else if (numComps == 3) { } else if (numComps === 3) {
return 'DeviceRgbCS'; return 'DeviceRgbCS';
} else if (numComps == 4) { } else if (numComps === 4) {
return 'DeviceCmykCS'; return 'DeviceCmykCS';
} }
break; break;
@ -342,7 +342,7 @@ var ColorSpace = (function ColorSpaceClosure() {
return true; return true;
} }
for (var i = 0, ii = decode.length; i < ii; i += 2) { 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 false;
} }
} }
@ -607,7 +607,7 @@ var DeviceRgbCS = (function DeviceRgbCSClosure() {
return (inputLength * (3 + alpha01) / 3) | 0; return (inputLength * (3 + alpha01) / 3) | 0;
}, },
isPassthrough: function DeviceRgbCS_isPassthrough(bits) { isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
return bits == 8; return bits === 8;
}, },
fillRgb: ColorSpace.prototype.fillRgb, fillRgb: ColorSpace.prototype.fillRgb,
isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) { isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {

2
src/core/core.js

@ -311,7 +311,7 @@ var PDFDocument = (function PDFDocumentClosure() {
var str = strBuf.join(''); var str = strBuf.join('');
stream.pos = pos; stream.pos = pos;
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle); var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
if (index == -1) { if (index === -1) {
return false; /* not found */ return false; /* not found */
} }
stream.pos += index; stream.pos += index;

2
src/core/evaluator.js

@ -1436,7 +1436,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
firstWidth = glyphWidth; firstWidth = glyphWidth;
continue; continue;
} }
if (firstWidth != glyphWidth) { if (firstWidth !== glyphWidth) {
isMonospace = false; isMonospace = false;
break; break;
} }

Loading…
Cancel
Save