[Pkg-javascript-commits] [pdf.js] 75/141: Fixes lint warning W004 in src/shared
David Prévot
taffit at moszumanska.debian.org
Sat Apr 19 22:40:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 10f80bda235700f0b0efedc14a84c12dba0c1b1d
Author: Tim van der Meij <timvandermeij at gmail.com>
Date: Mon Apr 7 21:05:17 2014 +0200
Fixes lint warning W004 in src/shared
---
src/shared/annotation.js | 9 ++++++---
src/shared/colorspace.js | 49 ++++++++++++++++++++++++++---------------------
src/shared/fonts_utils.js | 21 +++++++++++---------
src/shared/function.js | 16 +++++++++-------
src/shared/util.js | 10 ++++++----
test/reporter.js | 2 --
6 files changed, 60 insertions(+), 47 deletions(-)
diff --git a/src/shared/annotation.js b/src/shared/annotation.js
index 69e723c..31bbf1a 100644
--- a/src/shared/annotation.js
+++ b/src/shared/annotation.js
@@ -112,7 +112,8 @@ var Annotation = (function AnnotationClosure() {
var isInvalid = false;
var numPositive = 0;
for (var i = 0; i < dashArrayLength; i++) {
- if (+dashArray[i] < 0) {
+ var validNumber = (+dashArray[i] >= 0);
+ if (!validNumber) {
isInvalid = true;
break;
} else if (dashArray[i] > 0) {
@@ -673,10 +674,12 @@ var TextAnnotation = (function TextAnnotationClosure() {
var content = document.createElement('div');
content.className = 'annotTextContent';
content.setAttribute('hidden', true);
+
+ var i, ii;
if (item.hasBgColor) {
var color = item.color;
var rgb = [];
- for (var i = 0; i < 3; ++i) {
+ for (i = 0; i < 3; ++i) {
// Enlighten the color (70%)
var c = Math.round(color[i] * 255);
rgb[i] = Math.round((255 - c) * 0.7) + c;
@@ -693,7 +696,7 @@ var TextAnnotation = (function TextAnnotationClosure() {
} else {
var e = document.createElement('span');
var lines = item.content.split(/(?:\r\n?|\n)/);
- for (var i = 0, ii = lines.length; i < ii; ++i) {
+ for (i = 0, ii = lines.length; i < ii; ++i) {
var line = lines[i];
e.appendChild(document.createTextNode(line));
if (i < (ii - 1)) {
diff --git a/src/shared/colorspace.js b/src/shared/colorspace.js
index 2cf181a..d2e9c34 100644
--- a/src/shared/colorspace.js
+++ b/src/shared/colorspace.js
@@ -85,10 +85,10 @@ var ColorSpace = (function ColorSpaceClosure() {
var rgbBuf = null;
var numComponentColors = 1 << bpc;
var needsResizing = originalHeight != height || originalWidth != width;
+ var i, ii;
if (this.isPassthrough(bpc)) {
rgbBuf = comps;
-
} else if (this.numComps === 1 && count > numComponentColors &&
this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
// Optimization: create a color map when there is just one component and
@@ -102,18 +102,20 @@ var ColorSpace = (function ColorSpaceClosure() {
// we are reparsing colorspaces too much?).
var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) :
new Uint16Array(numComponentColors);
- for (var i = 0; i < numComponentColors; i++) {
+ var key;
+ for (i = 0; i < numComponentColors; i++) {
allColors[i] = i;
}
var colorMap = new Uint8Array(numComponentColors * 3);
this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc,
/* alpha01 = */ 0);
+ var destPos, rgbPos;
if (!needsResizing) {
// Fill in the RGB values directly into |dest|.
- var destPos = 0;
- for (var i = 0; i < count; ++i) {
- var key = comps[i] * 3;
+ destPos = 0;
+ for (i = 0; i < count; ++i) {
+ key = comps[i] * 3;
dest[destPos++] = colorMap[key];
dest[destPos++] = colorMap[key + 1];
dest[destPos++] = colorMap[key + 2];
@@ -121,9 +123,9 @@ var ColorSpace = (function ColorSpaceClosure() {
}
} else {
rgbBuf = new Uint8Array(count * 3);
- var rgbPos = 0;
- for (var i = 0; i < count; ++i) {
- var key = comps[i] * 3;
+ rgbPos = 0;
+ for (i = 0; i < count; ++i) {
+ key = comps[i] * 3;
rgbBuf[rgbPos++] = colorMap[key];
rgbBuf[rgbPos++] = colorMap[key + 1];
rgbBuf[rgbPos++] = colorMap[key + 2];
@@ -146,9 +148,9 @@ var ColorSpace = (function ColorSpaceClosure() {
rgbBuf = PDFImage.resize(rgbBuf, bpc, 3, originalWidth,
originalHeight, width, height);
}
- var rgbPos = 0;
- var destPos = 0;
- for (var i = 0, ii = width * actualHeight; i < ii; i++) {
+ rgbPos = 0;
+ destPos = 0;
+ for (i = 0, ii = width * actualHeight; i < ii; i++) {
dest[destPos++] = rgbBuf[rgbPos++];
dest[destPos++] = rgbBuf[rgbPos++];
dest[destPos++] = rgbBuf[rgbPos++];
@@ -174,6 +176,7 @@ var ColorSpace = (function ColorSpaceClosure() {
ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
var name = isArray(IR) ? IR[0] : IR;
+ var whitePoint, blackPoint;
switch (name) {
case 'DeviceGrayCS':
@@ -183,8 +186,8 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'DeviceCmykCS':
return this.singletons.cmyk;
case 'CalGrayCS':
- var whitePoint = IR[1].WhitePoint;
- var blackPoint = IR[1].BlackPoint;
+ whitePoint = IR[1].WhitePoint;
+ blackPoint = IR[1].BlackPoint;
var gamma = IR[1].Gamma;
return new CalGrayCS(whitePoint, blackPoint, gamma);
case 'PatternCS':
@@ -206,8 +209,8 @@ var ColorSpace = (function ColorSpaceClosure() {
return new AlternateCS(numComps, ColorSpace.fromIR(alt),
PDFFunction.fromIR(tintFnIR));
case 'LabCS':
- var whitePoint = IR[1].WhitePoint;
- var blackPoint = IR[1].BlackPoint;
+ whitePoint = IR[1].WhitePoint;
+ blackPoint = IR[1].BlackPoint;
var range = IR[1].Range;
return new LabCS(whitePoint, blackPoint, range);
default:
@@ -252,6 +255,7 @@ var ColorSpace = (function ColorSpaceClosure() {
} else if (isArray(cs)) {
mode = cs[0].name;
this.mode = mode;
+ var numComps, params;
switch (mode) {
case 'DeviceGray':
@@ -264,14 +268,14 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'CMYK':
return 'DeviceCmykCS';
case 'CalGray':
- var params = cs[1].getAll();
+ params = cs[1].getAll();
return ['CalGrayCS', params];
case 'CalRGB':
return 'DeviceRgbCS';
case 'ICCBased':
var stream = xref.fetchIfRef(cs[1]);
var dict = stream.dict;
- var numComps = dict.get('N');
+ numComps = dict.get('N');
if (numComps == 1) {
return 'DeviceGrayCS';
} else if (numComps == 3) {
@@ -298,7 +302,7 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'Separation':
case 'DeviceN':
var name = cs[1];
- var numComps = 1;
+ numComps = 1;
if (isName(name)) {
numComps = 1;
} else if (isArray(name)) {
@@ -308,7 +312,7 @@ var ColorSpace = (function ColorSpaceClosure() {
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
return ['AlternateCS', numComps, alt, tintFnIR];
case 'Lab':
- var params = cs[1].getAll();
+ params = cs[1].getAll();
return ['LabCS', params];
default:
error('unimplemented color space object "' + mode + '"');
@@ -403,13 +407,14 @@ var AlternateCS = (function AlternateCSClosure() {
var numComps = this.numComps;
var scaled = new Float32Array(numComps);
- for (var i = 0; i < count; i++) {
- for (var j = 0; j < numComps; j++) {
+ var i, j;
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < numComps; j++) {
scaled[j] = src[srcOffset++] * scale;
}
var tinted = tintFn(scaled);
if (usesZeroToOneRange) {
- for (var j = 0; j < baseNumComps; j++) {
+ for (j = 0; j < baseNumComps; j++) {
baseBuf[pos++] = tinted[j] * 255;
}
} else {
diff --git a/src/shared/fonts_utils.js b/src/shared/fonts_utils.js
index a14d921..a2dc4dc 100644
--- a/src/shared/fonts_utils.js
+++ b/src/shared/fonts_utils.js
@@ -37,20 +37,21 @@ function readCharset(aStream, aCharstrings) {
var format = aStream.getByte();
var count = aCharstrings.length - 1;
+ var i, sid;
if (format === 0) {
charset['.notdef'] = readCharstringEncoding(aCharstrings[0]);
- for (var i = 1; i < count + 1; i++) {
- var sid = aStream.getByte() << 8 | aStream.getByte();
+ for (i = 1; i < count + 1; i++) {
+ sid = aStream.getByte() << 8 | aStream.getByte();
charset[CFFStrings[sid]] = readCharstringEncoding(aCharstrings[i]);
}
} else if (format == 1) {
- for (var i = 1; i < count + 1; i++) {
+ for (i = 1; i < count + 1; i++) {
var first = aStream.getByte();
first = (first << 8) | aStream.getByte();
var numLeft = aStream.getByte();
for (var j = 0; j <= numLeft; j++) {
- var sid = first++;
+ sid = first++;
charset[CFFStrings[sid]] = readCharstringEncoding(aCharstrings[j]);
}
}
@@ -223,7 +224,8 @@ function readFontIndexData(aStream, aIsByte) {
}
var offsets = [];
- for (var i = 0; i < count + 1; i++) {
+ var i;
+ for (i = 0; i < count + 1; i++) {
offsets.push(getNextOffset());
}
@@ -233,7 +235,7 @@ function readFontIndexData(aStream, aIsByte) {
// Now extract the objects
var relativeOffset = aStream.pos;
var objects = [];
- for (var i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
var offset = offsets[i];
aStream.pos = relativeOffset + offset - 1;
@@ -332,14 +334,15 @@ var Type2Parser = function type2Parser(aFilePath) {
dump('strings: ' + strings);
// Fill up the Strings dictionary with the new unique strings
- for (var i = 0; i < strings.length; i++) {
+ var i;
+ for (i = 0; i < strings.length; i++) {
CFFStrings.push(strings[i].join(''));
}
// Parse the TopDict operator
var objects = [];
var count = topDict.length;
- for (var i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
parseAsToken(topDict[i], CFFDictDataMap);
}
@@ -356,7 +359,7 @@ var Type2Parser = function type2Parser(aFilePath) {
aStream.pos = priv.offset;
var privateDict = [];
- for (var i = 0; i < priv.size; i++) {
+ for (i = 0; i < priv.size; i++) {
privateDict.push(aStream.getByte());
}
dump('privateData:' + privateDict);
diff --git a/src/shared/function.js b/src/shared/function.js
index fe0bedb..1ed30ad 100644
--- a/src/shared/function.js
+++ b/src/shared/function.js
@@ -27,8 +27,9 @@ var PDFFunction = (function PDFFunctionClosure() {
return {
getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps,
str) {
+ var i, ii;
var length = 1;
- for (var i = 0, ii = size.length; i < ii; i++) {
+ for (i = 0, ii = size.length; i < ii; i++) {
length *= size[i];
}
length *= outputSize;
@@ -41,7 +42,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var strBytes = str.getBytes((length * bps + 7) / 8);
var strIdx = 0;
- for (var i = 0; i < length; i++) {
+ for (i = 0; i < length; i++) {
while (codeSize < bps) {
codeBuf <<= 8;
codeBuf |= strBytes[strIdx++];
@@ -184,13 +185,14 @@ var PDFFunction = (function PDFFunctionClosure() {
var cubeVertices = 1 << m;
var cubeN = new Float64Array(cubeVertices);
var cubeVertex = new Uint32Array(cubeVertices);
- for (var j = 0; j < cubeVertices; j++) {
+ var i, j;
+ for (j = 0; j < cubeVertices; j++) {
cubeN[j] = 1;
}
var k = n, pos = 1;
// Map x_i to y_j for 0 <= i < m using the sampled function.
- for (var i = 0; i < m; ++i) {
+ for (i = 0; i < m; ++i) {
// x_i' = min(max(x_i, Domain_2i), Domain_2i+1)
var domain_2i = domain[i][0];
var domain_2i_1 = domain[i][1];
@@ -211,7 +213,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var n1 = e - e0; // (e - e0) / (e1 - e0);
var offset0 = e0 * k;
var offset1 = offset0 + k; // e1 * k
- for (var j = 0; j < cubeVertices; j++) {
+ for (j = 0; j < cubeVertices; j++) {
if (j & pos) {
cubeN[j] *= n1;
cubeVertex[j] += offset1;
@@ -226,10 +228,10 @@ var PDFFunction = (function PDFFunctionClosure() {
}
var y = new Float64Array(n);
- for (var j = 0; j < n; ++j) {
+ for (j = 0; j < n; ++j) {
// Sum all cube vertices' samples portions
var rj = 0;
- for (var i = 0; i < cubeVertices; i++) {
+ for (i = 0; i < cubeVertices; i++) {
rj += samples[cubeVertex[i] + j] * cubeN[i];
}
diff --git a/src/shared/util.js b/src/shared/util.js
index 01e7fbf..1aed2d5 100644
--- a/src/shared/util.js
+++ b/src/shared/util.js
@@ -237,9 +237,10 @@ function combineUrl(baseUrl, url) {
if (/^[a-z][a-z0-9+\-.]*:/i.test(url)) {
return url;
}
+ var i;
if (url.charAt(0) == '/') {
// absolute path
- var i = baseUrl.indexOf('://');
+ i = baseUrl.indexOf('://');
if (url.charAt(1) === '/') {
++i;
} else {
@@ -248,7 +249,7 @@ function combineUrl(baseUrl, url) {
return baseUrl.substring(0, i) + url;
} else {
// relative path
- var pathLength = baseUrl.length, i;
+ var pathLength = baseUrl.length;
i = baseUrl.lastIndexOf('#');
pathLength = i >= 0 ? i : pathLength;
i = baseUrl.lastIndexOf('?', pathLength);
@@ -1263,17 +1264,18 @@ var StatTimer = (function StatTimerClosure() {
delete this.started[name];
},
toString: function StatTimer_toString() {
+ var i, ii;
var times = this.times;
var out = '';
// Find the longest name for padding purposes.
var longest = 0;
- for (var i = 0, ii = times.length; i < ii; ++i) {
+ for (i = 0, ii = times.length; i < ii; ++i) {
var name = times[i]['name'];
if (name.length > longest) {
longest = name.length;
}
}
- for (var i = 0, ii = times.length; i < ii; ++i) {
+ for (i = 0, ii = times.length; i < ii; ++i) {
var span = times[i];
var duration = span.end - span.start;
out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
diff --git a/test/reporter.js b/test/reporter.js
index a9bcc8a..cd56bef 100644
--- a/test/reporter.js
+++ b/test/reporter.js
@@ -28,8 +28,6 @@ module.exports = {
var err = r.error;
switch (err.code) {
- case 'W004': // variable is already defined
- break;
default:
len++;
str += file + ': line ' + err.line + ', col ' +
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list