Merge pull request #4414 from Snuffleupagus/src-shared-braces
Add braces to single line statements in src/shared
This commit is contained in:
commit
df2248d5b9
@ -401,8 +401,9 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
var j, jj;
|
||||
for (j = 0, jj = kids.length; j < jj; j++) {
|
||||
var kidRef = kids[j];
|
||||
if (kidRef.num == ref.num && kidRef.gen == ref.gen)
|
||||
if (kidRef.num == ref.num && kidRef.gen == ref.gen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fieldName.unshift('`' + j);
|
||||
}
|
||||
@ -695,8 +696,9 @@ var TextAnnotation = (function TextAnnotationClosure() {
|
||||
for (var i = 0, ii = lines.length; i < ii; ++i) {
|
||||
var line = lines[i];
|
||||
e.appendChild(document.createTextNode(line));
|
||||
if (i < (ii - 1))
|
||||
if (i < (ii - 1)) {
|
||||
e.appendChild(document.createElement('br'));
|
||||
}
|
||||
}
|
||||
text.appendChild(e);
|
||||
|
||||
|
@ -166,9 +166,9 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
|
||||
ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
|
||||
var IR = ColorSpace.parseToIR(cs, xref, res);
|
||||
if (IR instanceof AlternateCS)
|
||||
if (IR instanceof AlternateCS) {
|
||||
return IR;
|
||||
|
||||
}
|
||||
return ColorSpace.fromIR(IR);
|
||||
};
|
||||
|
||||
@ -189,8 +189,9 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
return new CalGrayCS(whitePoint, blackPoint, gamma);
|
||||
case 'PatternCS':
|
||||
var basePatternCS = IR[1];
|
||||
if (basePatternCS)
|
||||
if (basePatternCS) {
|
||||
basePatternCS = ColorSpace.fromIR(basePatternCS);
|
||||
}
|
||||
return new PatternCS(basePatternCS);
|
||||
case 'IndexedCS':
|
||||
var baseIndexedCS = IR[1];
|
||||
@ -220,8 +221,9 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
var colorSpaces = res.get('ColorSpace');
|
||||
if (isDict(colorSpaces)) {
|
||||
var refcs = colorSpaces.get(cs.name);
|
||||
if (refcs)
|
||||
if (refcs) {
|
||||
cs = refcs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,17 +272,19 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
var stream = xref.fetchIfRef(cs[1]);
|
||||
var dict = stream.dict;
|
||||
var numComps = dict.get('N');
|
||||
if (numComps == 1)
|
||||
if (numComps == 1) {
|
||||
return 'DeviceGrayCS';
|
||||
if (numComps == 3)
|
||||
} else if (numComps == 3) {
|
||||
return 'DeviceRgbCS';
|
||||
if (numComps == 4)
|
||||
} else if (numComps == 4) {
|
||||
return 'DeviceCmykCS';
|
||||
}
|
||||
break;
|
||||
case 'Pattern':
|
||||
var basePatternCS = cs[1];
|
||||
if (basePatternCS)
|
||||
if (basePatternCS) {
|
||||
basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
|
||||
}
|
||||
return ['PatternCS', basePatternCS];
|
||||
case 'Indexed':
|
||||
case 'I':
|
||||
@ -295,10 +299,11 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
case 'DeviceN':
|
||||
var name = cs[1];
|
||||
var numComps = 1;
|
||||
if (isName(name))
|
||||
if (isName(name)) {
|
||||
numComps = 1;
|
||||
else if (isArray(name))
|
||||
} else if (isArray(name)) {
|
||||
numComps = name.length;
|
||||
}
|
||||
var alt = ColorSpace.parseToIR(cs[2], xref, res);
|
||||
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
|
||||
return ['AlternateCS', numComps, alt, tintFnIR];
|
||||
@ -323,16 +328,18 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
* @param {Number} n Number of components the color space has.
|
||||
*/
|
||||
ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
|
||||
if (!decode)
|
||||
if (!decode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (n * 2 !== decode.length) {
|
||||
warn('The decode map is not the correct length');
|
||||
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;
|
||||
};
|
||||
@ -459,8 +466,9 @@ var IndexedCS = (function IndexedCSClosure() {
|
||||
lookupArray.set(bytes);
|
||||
} else if (isString(lookup)) {
|
||||
lookupArray = new Uint8Array(length);
|
||||
for (var i = 0; i < length; ++i)
|
||||
for (var i = 0; i < length; ++i) {
|
||||
lookupArray[i] = lookup.charCodeAt(i);
|
||||
}
|
||||
} else if (lookup instanceof Uint8Array || lookup instanceof Array) {
|
||||
lookupArray = lookup;
|
||||
} else {
|
||||
@ -793,8 +801,9 @@ var LabCS = (function LabCSClosure() {
|
||||
this.numComps = 3;
|
||||
this.defaultColor = new Float32Array([0, 0, 0]);
|
||||
|
||||
if (!whitePoint)
|
||||
if (!whitePoint) {
|
||||
error('WhitePoint missing - required for color space Lab');
|
||||
}
|
||||
blackPoint = blackPoint || [0, 0, 0];
|
||||
range = range || [-100, 100, -100, 100];
|
||||
|
||||
@ -814,8 +823,9 @@ var LabCS = (function LabCSClosure() {
|
||||
this.ZB = blackPoint[2];
|
||||
|
||||
// Validate vars as per spec
|
||||
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1)
|
||||
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
|
||||
error('Invalid WhitePoint components, no fallback available');
|
||||
}
|
||||
|
||||
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
|
||||
info('Invalid BlackPoint, falling back to default');
|
||||
@ -833,10 +843,11 @@ var LabCS = (function LabCSClosure() {
|
||||
|
||||
// Function g(x) from spec
|
||||
function fn_g(x) {
|
||||
if (x >= 6 / 29)
|
||||
if (x >= 6 / 29) {
|
||||
return x * x * x;
|
||||
else
|
||||
} else {
|
||||
return (108 / 841) * (x - 4 / 29);
|
||||
}
|
||||
}
|
||||
|
||||
function decode(value, high1, low2, high2) {
|
||||
|
@ -67,8 +67,9 @@ function readCharset(aStream, aCharstrings) {
|
||||
* chapter 3.1.
|
||||
*/
|
||||
function readCharstringEncoding(aString) {
|
||||
if (!aString)
|
||||
if (!aString) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var charstringTokens = [];
|
||||
|
||||
@ -222,8 +223,9 @@ function readFontIndexData(aStream, aIsByte) {
|
||||
}
|
||||
|
||||
var offsets = [];
|
||||
for (var i = 0; i < count + 1; i++)
|
||||
for (var i = 0; i < count + 1; i++) {
|
||||
offsets.push(getNextOffset());
|
||||
}
|
||||
|
||||
dump('Found ' + count + ' objects at offsets :' +
|
||||
offsets + ' (offsize: ' + offsize + ')');
|
||||
@ -237,8 +239,9 @@ function readFontIndexData(aStream, aIsByte) {
|
||||
|
||||
var data = [];
|
||||
var length = offsets[i + 1] - 1;
|
||||
for (var j = offset - 1; j < length; j++)
|
||||
for (var j = offset - 1; j < length; j++) {
|
||||
data.push(aIsByte ? aStream.getByte() : aStream.getChar());
|
||||
}
|
||||
objects.push(data);
|
||||
}
|
||||
|
||||
@ -294,8 +297,9 @@ var Type2Parser = function type2Parser(aFilePath) {
|
||||
default:
|
||||
if (token.operand && token.operand.length) {
|
||||
var array = [];
|
||||
for (var j = 0; j < token.operand.length; j++)
|
||||
for (var j = 0; j < token.operand.length; j++) {
|
||||
array.push(stack.pop());
|
||||
}
|
||||
font.set(token.name, array);
|
||||
} else {
|
||||
font.set(token.name, stack.pop());
|
||||
@ -328,14 +332,16 @@ 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++)
|
||||
for (var 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 (var i = 0; i < count; i++) {
|
||||
parseAsToken(topDict[i], CFFDictDataMap);
|
||||
}
|
||||
|
||||
// Read the Global Subr Index that comes just after the Strings Index
|
||||
// (cf. "The Compact Font Format Specification" Chapter 16)
|
||||
@ -350,13 +356,15 @@ var Type2Parser = function type2Parser(aFilePath) {
|
||||
aStream.pos = priv.offset;
|
||||
|
||||
var privateDict = [];
|
||||
for (var i = 0; i < priv.size; i++)
|
||||
for (var i = 0; i < priv.size; i++) {
|
||||
privateDict.push(aStream.getByte());
|
||||
}
|
||||
dump('privateData:' + privateDict);
|
||||
parseAsToken(privateDict, CFFDictPrivateDataMap);
|
||||
|
||||
for (var p in font.map)
|
||||
for (var p in font.map) {
|
||||
dump(p + '::' + font.get(p));
|
||||
}
|
||||
|
||||
// Read CharStrings Index
|
||||
var charStringsOffset = font.get('CharStrings');
|
||||
@ -402,8 +410,9 @@ var Type2Parser = function type2Parser(aFilePath) {
|
||||
* writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".cff");
|
||||
*/
|
||||
function writeToFile(aBytes, aFilePath) {
|
||||
if (!('netscape' in window))
|
||||
if (!('netscape' in window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var Cc = Components.classes,
|
||||
|
@ -28,8 +28,9 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps,
|
||||
str) {
|
||||
var length = 1;
|
||||
for (var i = 0, ii = size.length; i < ii; i++)
|
||||
for (var i = 0, ii = size.length; i < ii; i++) {
|
||||
length *= size[i];
|
||||
}
|
||||
length *= outputSize;
|
||||
|
||||
var array = [];
|
||||
@ -55,8 +56,9 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
|
||||
getIR: function PDFFunction_getIR(xref, fn) {
|
||||
var dict = fn.dict;
|
||||
if (!dict)
|
||||
if (!dict) {
|
||||
dict = fn;
|
||||
}
|
||||
|
||||
var types = [this.constructSampled,
|
||||
null,
|
||||
@ -66,8 +68,9 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
|
||||
var typeNum = dict.get('FunctionType');
|
||||
var typeFn = types[typeNum];
|
||||
if (!typeFn)
|
||||
if (!typeFn) {
|
||||
error('Unknown type of function');
|
||||
}
|
||||
|
||||
return typeFn.call(this, fn, dict, xref);
|
||||
},
|
||||
@ -107,8 +110,9 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
var domain = dict.get('Domain');
|
||||
var range = dict.get('Range');
|
||||
|
||||
if (!domain || !range)
|
||||
if (!domain || !range) {
|
||||
error('No domain or range');
|
||||
}
|
||||
|
||||
var inputSize = domain.length / 2;
|
||||
var outputSize = range.length / 2;
|
||||
@ -136,10 +140,11 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
encode = toMultiArray(encode);
|
||||
|
||||
var decode = dict.get('Decode');
|
||||
if (!decode)
|
||||
if (!decode) {
|
||||
decode = range;
|
||||
else
|
||||
} else {
|
||||
decode = toMultiArray(decode);
|
||||
}
|
||||
|
||||
var samples = this.getSampleArray(size, outputSize, bps, str);
|
||||
|
||||
@ -167,9 +172,10 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
var mask = IR[8];
|
||||
var range = IR[9];
|
||||
|
||||
if (m != args.length)
|
||||
if (m != args.length) {
|
||||
error('Incorrect number of arguments: ' + m + ' != ' +
|
||||
args.length);
|
||||
}
|
||||
|
||||
var x = args;
|
||||
|
||||
@ -178,8 +184,9 @@ 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++)
|
||||
for (var 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.
|
||||
@ -222,8 +229,9 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
for (var j = 0; j < n; ++j) {
|
||||
// Sum all cube vertices' samples portions
|
||||
var rj = 0;
|
||||
for (var i = 0; i < cubeVertices; i++)
|
||||
for (var i = 0; i < cubeVertices; i++) {
|
||||
rj += samples[cubeVertex[i] + j] * cubeN[i];
|
||||
}
|
||||
|
||||
// r_j' = Interpolate(r_j, 0, 2^BitsPerSample - 1,
|
||||
// Decode_2j, Decode_2j+1)
|
||||
@ -243,13 +251,15 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
var c1 = dict.get('C1') || [1];
|
||||
var n = dict.get('N');
|
||||
|
||||
if (!isArray(c0) || !isArray(c1))
|
||||
if (!isArray(c0) || !isArray(c1)) {
|
||||
error('Illegal dictionary for interpolated function');
|
||||
}
|
||||
|
||||
var length = c0.length;
|
||||
var diff = [];
|
||||
for (var i = 0; i < length; ++i)
|
||||
for (var i = 0; i < length; ++i) {
|
||||
diff.push(c1[i] - c0[i]);
|
||||
}
|
||||
|
||||
return [CONSTRUCT_INTERPOLATED, c0, diff, n];
|
||||
},
|
||||
@ -266,8 +276,9 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
var x = n == 1 ? args[0] : Math.pow(args[0], n);
|
||||
|
||||
var out = [];
|
||||
for (var j = 0; j < length; ++j)
|
||||
for (var j = 0; j < length; ++j) {
|
||||
out.push(c0[j] + (x * diff[j]));
|
||||
}
|
||||
|
||||
return out;
|
||||
|
||||
@ -277,17 +288,20 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
|
||||
var domain = dict.get('Domain');
|
||||
|
||||
if (!domain)
|
||||
if (!domain) {
|
||||
error('No domain');
|
||||
}
|
||||
|
||||
var inputSize = domain.length / 2;
|
||||
if (inputSize != 1)
|
||||
if (inputSize != 1) {
|
||||
error('Bad domain for stiched function');
|
||||
}
|
||||
|
||||
var fnRefs = dict.get('Functions');
|
||||
var fns = [];
|
||||
for (var i = 0, ii = fnRefs.length; i < ii; ++i)
|
||||
for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
|
||||
fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
|
||||
}
|
||||
|
||||
var bounds = dict.get('Bounds');
|
||||
var encode = dict.get('Encode');
|
||||
@ -308,10 +322,11 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
|
||||
return function constructStichedFromIRResult(args) {
|
||||
var clip = function constructStichedFromIRClip(v, min, max) {
|
||||
if (v > max)
|
||||
if (v > max) {
|
||||
v = max;
|
||||
else if (v < min)
|
||||
} else if (v < min) {
|
||||
v = min;
|
||||
}
|
||||
return v;
|
||||
};
|
||||
|
||||
@ -319,17 +334,20 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
var v = clip(args[0], domain[0], domain[1]);
|
||||
// calulate which bound the value is in
|
||||
for (var i = 0, ii = bounds.length; i < ii; ++i) {
|
||||
if (v < bounds[i])
|
||||
if (v < bounds[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// encode value into domain of function
|
||||
var dmin = domain[0];
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
dmin = bounds[i - 1];
|
||||
}
|
||||
var dmax = domain[1];
|
||||
if (i < bounds.length)
|
||||
if (i < bounds.length) {
|
||||
dmax = bounds[i];
|
||||
}
|
||||
|
||||
var rmin = encode[2 * i];
|
||||
var rmax = encode[2 * i + 1];
|
||||
@ -346,11 +364,13 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
var domain = dict.get('Domain');
|
||||
var range = dict.get('Range');
|
||||
|
||||
if (!domain)
|
||||
if (!domain) {
|
||||
error('No domain.');
|
||||
}
|
||||
|
||||
if (!range)
|
||||
if (!range) {
|
||||
error('No range.');
|
||||
}
|
||||
|
||||
var lexer = new PostScriptLexer(fn);
|
||||
var parser = new PostScriptParser(lexer);
|
||||
@ -376,18 +396,20 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||
}
|
||||
|
||||
var key = initialStack.join('_');
|
||||
if (cache.has(key))
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key);
|
||||
}
|
||||
|
||||
var stack = evaluator.execute(initialStack);
|
||||
var transformed = [];
|
||||
for (i = numOutputs - 1; i >= 0; --i) {
|
||||
var out = stack.pop();
|
||||
var rangeIndex = 2 * i;
|
||||
if (out < range[rangeIndex])
|
||||
if (out < range[rangeIndex]) {
|
||||
out = range[rangeIndex];
|
||||
else if (out > range[rangeIndex + 1])
|
||||
} else if (out > range[rangeIndex + 1]) {
|
||||
out = range[rangeIndex + 1];
|
||||
}
|
||||
transformed[i] = out;
|
||||
}
|
||||
cache.set(key, transformed);
|
||||
@ -430,21 +452,25 @@ var PostScriptStack = (function PostScriptStackClosure() {
|
||||
|
||||
PostScriptStack.prototype = {
|
||||
push: function PostScriptStack_push(value) {
|
||||
if (this.stack.length >= MAX_STACK_SIZE)
|
||||
if (this.stack.length >= MAX_STACK_SIZE) {
|
||||
error('PostScript function stack overflow.');
|
||||
}
|
||||
this.stack.push(value);
|
||||
},
|
||||
pop: function PostScriptStack_pop() {
|
||||
if (this.stack.length <= 0)
|
||||
if (this.stack.length <= 0) {
|
||||
error('PostScript function stack underflow.');
|
||||
}
|
||||
return this.stack.pop();
|
||||
},
|
||||
copy: function PostScriptStack_copy(n) {
|
||||
if (this.stack.length + n >= MAX_STACK_SIZE)
|
||||
if (this.stack.length + n >= MAX_STACK_SIZE) {
|
||||
error('PostScript function stack overflow.');
|
||||
}
|
||||
var stack = this.stack;
|
||||
for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++)
|
||||
for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
|
||||
stack.push(stack[i]);
|
||||
}
|
||||
},
|
||||
index: function PostScriptStack_index(n) {
|
||||
this.push(this.stack[this.stack.length - n - 1]);
|
||||
@ -490,8 +516,9 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
|
||||
case 'jz': // jump if false
|
||||
b = stack.pop();
|
||||
a = stack.pop();
|
||||
if (!a)
|
||||
if (!a) {
|
||||
counter = b;
|
||||
}
|
||||
break;
|
||||
case 'j': // jump
|
||||
a = stack.pop();
|
||||
@ -511,10 +538,11 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
|
||||
case 'and':
|
||||
b = stack.pop();
|
||||
a = stack.pop();
|
||||
if (isBool(a) && isBool(b))
|
||||
if (isBool(a) && isBool(b)) {
|
||||
stack.push(a && b);
|
||||
else
|
||||
} else {
|
||||
stack.push(a & b);
|
||||
}
|
||||
break;
|
||||
case 'atan':
|
||||
a = stack.pop();
|
||||
@ -523,10 +551,11 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
|
||||
case 'bitshift':
|
||||
b = stack.pop();
|
||||
a = stack.pop();
|
||||
if (a > 0)
|
||||
if (a > 0) {
|
||||
stack.push(a << b);
|
||||
else
|
||||
} else {
|
||||
stack.push(a >> b);
|
||||
}
|
||||
break;
|
||||
case 'ceiling':
|
||||
a = stack.pop();
|
||||
@ -633,18 +662,20 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
|
||||
break;
|
||||
case 'not':
|
||||
a = stack.pop();
|
||||
if (isBool(a) && isBool(b))
|
||||
if (isBool(a) && isBool(b)) {
|
||||
stack.push(a && b);
|
||||
else
|
||||
} else {
|
||||
stack.push(a & b);
|
||||
}
|
||||
break;
|
||||
case 'or':
|
||||
b = stack.pop();
|
||||
a = stack.pop();
|
||||
if (isBool(a) && isBool(b))
|
||||
if (isBool(a) && isBool(b)) {
|
||||
stack.push(a || b);
|
||||
else
|
||||
} else {
|
||||
stack.push(a | b);
|
||||
}
|
||||
break;
|
||||
case 'pop':
|
||||
stack.pop();
|
||||
@ -682,10 +713,11 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
|
||||
case 'xor':
|
||||
b = stack.pop();
|
||||
a = stack.pop();
|
||||
if (isBool(a) && isBool(b))
|
||||
if (isBool(a) && isBool(b)) {
|
||||
stack.push(a != b);
|
||||
else
|
||||
} else {
|
||||
stack.push(a ^ b);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error('Unknown operator ' + operator);
|
||||
|
@ -195,8 +195,9 @@ function backtrace() {
|
||||
}
|
||||
|
||||
function assert(cond, msg) {
|
||||
if (!cond)
|
||||
if (!cond) {
|
||||
error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
var UNSUPPORTED_FEATURES = PDFJS.UNSUPPORTED_FEATURES = {
|
||||
@ -227,10 +228,12 @@ var UnsupportedManager = PDFJS.UnsupportedManager =
|
||||
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
||||
// absolute URL, it will be returned as is.
|
||||
function combineUrl(baseUrl, url) {
|
||||
if (!url)
|
||||
if (!url) {
|
||||
return baseUrl;
|
||||
if (/^[a-z][a-z0-9+\-.]*:/i.test(url))
|
||||
}
|
||||
if (/^[a-z][a-z0-9+\-.]*:/i.test(url)) {
|
||||
return url;
|
||||
}
|
||||
if (url.charAt(0) == '/') {
|
||||
// absolute path
|
||||
var i = baseUrl.indexOf('://');
|
||||
@ -279,8 +282,9 @@ PDFJS.isValidUrl = isValidUrl;
|
||||
// In a well-formed PDF, |cond| holds. If it doesn't, subsequent
|
||||
// behavior is undefined.
|
||||
function assertWellFormed(cond, msg) {
|
||||
if (!cond)
|
||||
if (!cond) {
|
||||
error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
function shadow(obj, prop, value) {
|
||||
@ -397,8 +401,9 @@ function bytesToString(bytes) {
|
||||
function stringToBytes(str) {
|
||||
var length = str.length;
|
||||
var bytes = new Uint8Array(length);
|
||||
for (var n = 0; n < length; ++n)
|
||||
for (var n = 0; n < length; ++n) {
|
||||
bytes[n] = str.charCodeAt(n) & 0xFF;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -802,14 +807,15 @@ function isRef(v) {
|
||||
|
||||
function isPDFFunction(v) {
|
||||
var fnDict;
|
||||
if (typeof v != 'object')
|
||||
if (typeof v != 'object') {
|
||||
return false;
|
||||
else if (isDict(v))
|
||||
} else if (isDict(v)) {
|
||||
fnDict = v;
|
||||
else if (isStream(v))
|
||||
} else if (isStream(v)) {
|
||||
fnDict = v.dict;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return fnDict.has('FunctionType');
|
||||
}
|
||||
|
||||
@ -1030,8 +1036,9 @@ var LegacyPromise = PDFJS.LegacyPromise = (function LegacyPromiseClosure() {
|
||||
}
|
||||
results[i] = value;
|
||||
unresolved--;
|
||||
if (unresolved === 0)
|
||||
if (unresolved === 0) {
|
||||
resolveAll(results);
|
||||
}
|
||||
};
|
||||
})(i);
|
||||
if (Promise.isPromise(promise)) {
|
||||
@ -1121,8 +1128,9 @@ var LegacyPromise = PDFJS.LegacyPromise = (function LegacyPromiseClosure() {
|
||||
|
||||
var StatTimer = (function StatTimerClosure() {
|
||||
function rpad(str, pad, length) {
|
||||
while (str.length < length)
|
||||
while (str.length < length) {
|
||||
str += pad;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function StatTimer() {
|
||||
@ -1132,17 +1140,21 @@ var StatTimer = (function StatTimerClosure() {
|
||||
}
|
||||
StatTimer.prototype = {
|
||||
time: function StatTimer_time(name) {
|
||||
if (!this.enabled)
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
if (name in this.started)
|
||||
}
|
||||
if (name in this.started) {
|
||||
warn('Timer is already running for ' + name);
|
||||
}
|
||||
this.started[name] = Date.now();
|
||||
},
|
||||
timeEnd: function StatTimer_timeEnd(name) {
|
||||
if (!this.enabled)
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
if (!(name in this.started))
|
||||
}
|
||||
if (!(name in this.started)) {
|
||||
warn('Timer has not been started for ' + name);
|
||||
}
|
||||
this.times.push({
|
||||
'name': name,
|
||||
'start': this.started[name],
|
||||
@ -1158,8 +1170,9 @@ var StatTimer = (function StatTimerClosure() {
|
||||
var longest = 0;
|
||||
for (var i = 0, ii = times.length; i < ii; ++i) {
|
||||
var name = times[i]['name'];
|
||||
if (name.length > longest)
|
||||
if (name.length > longest) {
|
||||
longest = name.length;
|
||||
}
|
||||
}
|
||||
for (var i = 0, ii = times.length; i < ii; ++i) {
|
||||
var span = times[i];
|
||||
@ -1173,8 +1186,9 @@ var StatTimer = (function StatTimerClosure() {
|
||||
})();
|
||||
|
||||
PDFJS.createBlob = function createBlob(data, contentType) {
|
||||
if (typeof Blob !== 'undefined')
|
||||
if (typeof Blob !== 'undefined') {
|
||||
return new Blob([data], { type: contentType });
|
||||
}
|
||||
// Blob builder is deprecated in FF14 and removed in FF18.
|
||||
var bb = new MozBlobBuilder();
|
||||
bb.append(data);
|
||||
|
Loading…
Reference in New Issue
Block a user