commit
43d6c6f1ab
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ build/
|
|||||||
tags
|
tags
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Makefile
|
Makefile
|
||||||
|
node_modules/
|
||||||
|
19
.jshintrc
Normal file
19
.jshintrc
Normal 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
|
||||||
|
}
|
7
external/builder/builder.js
vendored
7
external/builder/builder.js
vendored
@ -1,3 +1,8 @@
|
|||||||
|
/* jshint node:true */
|
||||||
|
/* globals cp, ls, test */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
require('../shelljs/make');
|
require('../shelljs/make');
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
@ -30,7 +35,7 @@ function preprocess(inFilename, outFilename, defines) {
|
|||||||
var writeLine = typeof outFilename === 'function' ? outFilename :
|
var writeLine = typeof outFilename === 'function' ? outFilename :
|
||||||
function(line) {
|
function(line) {
|
||||||
out += line + '\n';
|
out += line + '\n';
|
||||||
}
|
};
|
||||||
function include(file) {
|
function include(file) {
|
||||||
var realPath = fs.realpathSync(inFilename);
|
var realPath = fs.realpathSync(inFilename);
|
||||||
var dir = path.dirname(realPath);
|
var dir = path.dirname(realPath);
|
||||||
|
4
external/crlfchecker/crlfchecker.js
vendored
4
external/crlfchecker/crlfchecker.js
vendored
@ -1,5 +1,9 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* jshint node:true */
|
||||||
|
/* globals cat, echo, exit, ls */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
function checkIfCrlfIsPresent(files) {
|
function checkIfCrlfIsPresent(files) {
|
||||||
var failed = [];
|
var failed = [];
|
||||||
|
30
make.js
30
make.js
@ -1,5 +1,7 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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';
|
'use strict';
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ var DEFINES = {
|
|||||||
target.all = function() {
|
target.all = function() {
|
||||||
// Don't do anything by default
|
// Don't do anything by default
|
||||||
echo('Please specify a target. Available targets:');
|
echo('Please specify a target. Available targets:');
|
||||||
for (t in target)
|
for (var t in target)
|
||||||
if (t !== 'all') echo(' ' + t);
|
if (t !== 'all') echo(' ' + t);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -611,8 +613,9 @@ target.chrome = function() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var manifest;
|
||||||
try {
|
try {
|
||||||
var manifest = JSON.parse(cat(browserManifest));
|
manifest = JSON.parse(cat(browserManifest));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
echo('Malformed browser manifest file');
|
echo('Malformed browser manifest file');
|
||||||
echo(e.message);
|
echo(e.message);
|
||||||
@ -971,6 +974,29 @@ target.lint = function() {
|
|||||||
crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
|
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
|
// make clean
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -282,7 +283,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
promise.reject(error);
|
promise.reject(error);
|
||||||
else
|
else
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
};
|
}
|
||||||
var continueCallback = params.continueCallback;
|
var continueCallback = params.continueCallback;
|
||||||
|
|
||||||
// Once the operatorList and fonts are loaded, do the actual rendering.
|
// Once the operatorList and fonts are loaded, do the actual rendering.
|
||||||
@ -383,7 +384,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
|
|
||||||
var continueWrapper;
|
var continueWrapper;
|
||||||
if (continueCallback)
|
if (continueCallback)
|
||||||
continueWrapper = function() { continueCallback(next); }
|
continueWrapper = function() { continueCallback(next); };
|
||||||
else
|
else
|
||||||
continueWrapper = next;
|
continueWrapper = next;
|
||||||
|
|
||||||
|
11
src/bidi.js
11
src/bidi.js
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals PDFJS */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -68,11 +69,11 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
function isOdd(i) {
|
function isOdd(i) {
|
||||||
return (i & 1) != 0;
|
return (i & 1) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEven(i) {
|
function isEven(i) {
|
||||||
return (i & 1) == 0;
|
return (i & 1) === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findUnequal(arr, start, value) {
|
function findUnequal(arr, start, value) {
|
||||||
@ -146,8 +147,8 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||||||
function bidi(str, startLevel) {
|
function bidi(str, startLevel) {
|
||||||
var isLTR = true;
|
var isLTR = true;
|
||||||
var strLength = str.length;
|
var strLength = str.length;
|
||||||
if (strLength == 0)
|
if (strLength === 0)
|
||||||
return new BidiResult(str, ltr);
|
return new BidiResult(str, isLTR);
|
||||||
|
|
||||||
// get types, fill arrays
|
// 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 there are no rtl characters then no bidi needed
|
||||||
// if less than 30% chars are rtl then string is primarily ltr
|
// 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 more than 30% chars are rtl then string is primarily rtl
|
||||||
if (numBidi == 0) {
|
if (numBidi === 0) {
|
||||||
isLTR = true;
|
isLTR = true;
|
||||||
return new BidiResult(str, isLTR);
|
return new BidiResult(str, isLTR);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -238,7 +239,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
buf = imgArray[imgArrayPos++];
|
buf = imgArray[imgArrayPos++];
|
||||||
mask = 128;
|
mask = 128;
|
||||||
}
|
}
|
||||||
if (!(buf & mask) == inverseDecode) {
|
if (!(buf & mask) === inverseDecode) {
|
||||||
buffer[bufferPos] = 0;
|
buffer[bufferPos] = 0;
|
||||||
}
|
}
|
||||||
bufferPos += 4;
|
bufferPos += 4;
|
||||||
@ -932,7 +933,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var lineWidth = current.lineWidth;
|
var lineWidth = current.lineWidth;
|
||||||
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
|
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
|
||||||
var scale = Math.sqrt(a1 * a1 + b1 * b1);
|
var scale = Math.sqrt(a1 * a1 + b1 * b1);
|
||||||
if (scale == 0 || lineWidth == 0)
|
if (scale === 0 || lineWidth === 0)
|
||||||
lineWidth = this.getSinglePixelWidth();
|
lineWidth = this.getSinglePixelWidth();
|
||||||
else
|
else
|
||||||
lineWidth /= scale;
|
lineWidth /= scale;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals error, info, input, isArray, isDict, isName, isStream, isString, PDFFunction, warn */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -240,7 +241,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;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1288,7 +1289,7 @@ var LabCS = (function LabCSClosure() {
|
|||||||
this.bmin = -100;
|
this.bmin = -100;
|
||||||
this.bmax = 100;
|
this.bmax = 100;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// Function g(x) from spec
|
// Function g(x) from spec
|
||||||
function fn_g(x) {
|
function fn_g(x) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -76,7 +77,7 @@ function getPdf(arg, callback) {
|
|||||||
calledErrorBack = true;
|
calledErrorBack = true;
|
||||||
params.error();
|
params.error();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.onreadystatechange = function getPdfOnreadystatechange(e) {
|
xhr.onreadystatechange = function getPdfOnreadystatechange(e) {
|
||||||
@ -156,7 +157,7 @@ var Page = (function PageClosure() {
|
|||||||
get rotate() {
|
get rotate() {
|
||||||
var rotate = this.inheritPageProp('Rotate') || 0;
|
var rotate = this.inheritPageProp('Rotate') || 0;
|
||||||
// Normalize rotation so it's a multiple of 90 and between 0 and 270
|
// Normalize rotation so it's a multiple of 90 and between 0 and 270
|
||||||
if (rotate % 90 != 0) {
|
if (rotate % 90 !== 0) {
|
||||||
rotate = 0;
|
rotate = 0;
|
||||||
} else if (rotate >= 360) {
|
} else if (rotate >= 360) {
|
||||||
rotate = rotate % 360;
|
rotate = rotate % 360;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals bytesToString, DecryptStream, error, isInt, isName, Name, PasswordException, stringToBytes */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -373,7 +374,7 @@ var AES128Cipher = (function AES128CipherClosure() {
|
|||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
this.bufferLength = bufferLength;
|
this.bufferLength = bufferLength;
|
||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
if (result.length == 0)
|
if (result.length === 0)
|
||||||
return new Uint8Array([]);
|
return new Uint8Array([]);
|
||||||
if (result.length == 1)
|
if (result.length == 1)
|
||||||
return result[0];
|
return result[0];
|
||||||
@ -553,7 +554,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
this.algorithm = algorithm;
|
this.algorithm = algorithm;
|
||||||
var keyLength = dict.get('Length') || 40;
|
var keyLength = dict.get('Length') || 40;
|
||||||
if (!isInt(keyLength) ||
|
if (!isInt(keyLength) ||
|
||||||
keyLength < 40 || (keyLength % 8) != 0)
|
keyLength < 40 || (keyLength % 8) !== 0)
|
||||||
error('invalid key length');
|
error('invalid key length');
|
||||||
// prepare keys
|
// prepare keys
|
||||||
var ownerPassword = stringToBytes(dict.get('O'));
|
var ownerPassword = stringToBytes(dict.get('O'));
|
||||||
@ -618,7 +619,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
function buildCipherConstructor(cf, name, num, gen, key) {
|
function buildCipherConstructor(cf, name, num, gen, key) {
|
||||||
var cryptFilter = cf.get(name.name);
|
var cryptFilter = cf.get(name.name);
|
||||||
var cfm;
|
var cfm;
|
||||||
if (cryptFilter != null)
|
if (cryptFilter !== null && cryptFilter !== undefined)
|
||||||
cfm = cryptFilter.get('CFM');
|
cfm = cryptFilter.get('CFM');
|
||||||
if (!cfm || cfm.name == 'None') {
|
if (!cfm || cfm.name == 'None') {
|
||||||
return function cipherTransformFactoryBuildCipherConstructorNone() {
|
return function cipherTransformFactoryBuildCipherConstructorNone() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -542,7 +543,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
fnArray.push(fn);
|
fnArray.push(fn);
|
||||||
argsArray.push(args);
|
argsArray.push(args);
|
||||||
args = [];
|
args = [];
|
||||||
} else if (obj != null) {
|
} else if (obj !== null && obj !== undefined) {
|
||||||
args.push(obj instanceof Dict ? obj.getAll() : obj);
|
args.push(obj instanceof Dict ? obj.getAll() : obj);
|
||||||
assertWellFormed(args.length <= 33, 'Too many arguments');
|
assertWellFormed(args.length <= 33, 'Too many arguments');
|
||||||
}
|
}
|
||||||
@ -796,7 +797,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = [];
|
args = [];
|
||||||
} else if (obj != null) {
|
} else if (obj !== null && obj !== undefined) {
|
||||||
assertWellFormed(args.length <= 33, 'Too many arguments');
|
assertWellFormed(args.length <= 33, 'Too many arguments');
|
||||||
args.push(obj);
|
args.push(obj);
|
||||||
}
|
}
|
||||||
@ -1010,7 +1011,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
var result = [];
|
var result = [];
|
||||||
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
||||||
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
||||||
if (glyphID == 0)
|
if (glyphID === 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var code = j >> 1;
|
var code = j >> 1;
|
||||||
|
78
src/fonts.js
78
src/fonts.js
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* 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
|
// Add the font to the DOM only once or skip if the font
|
||||||
// is already loaded.
|
// is already loaded.
|
||||||
if (font.attached || font.loading == false) {
|
if (font.attached || font.loading === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
font.attached = true;
|
font.attached = true;
|
||||||
@ -2425,7 +2426,7 @@ var Font = (function FontClosure() {
|
|||||||
this.encoding = properties.baseEncoding;
|
this.encoding = properties.baseEncoding;
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
var numFonts = 0;
|
var numFonts = 0;
|
||||||
function getUniqueName() {
|
function getUniqueName() {
|
||||||
@ -2438,7 +2439,7 @@ var Font = (function FontClosure() {
|
|||||||
array[i] = str.charCodeAt(i);
|
array[i] = str.charCodeAt(i);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
};
|
}
|
||||||
|
|
||||||
function arrayToString(arr) {
|
function arrayToString(arr) {
|
||||||
var str = '';
|
var str = '';
|
||||||
@ -2446,16 +2447,16 @@ var Font = (function FontClosure() {
|
|||||||
str += String.fromCharCode(arr[i]);
|
str += String.fromCharCode(arr[i]);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
}
|
||||||
|
|
||||||
function int16(bytes) {
|
function int16(bytes) {
|
||||||
return (bytes[0] << 8) + (bytes[1] & 0xff);
|
return (bytes[0] << 8) + (bytes[1] & 0xff);
|
||||||
};
|
}
|
||||||
|
|
||||||
function int32(bytes) {
|
function int32(bytes) {
|
||||||
return (bytes[0] << 24) + (bytes[1] << 16) +
|
return (bytes[0] << 24) + (bytes[1] << 16) +
|
||||||
(bytes[2] << 8) + (bytes[3] & 0xff);
|
(bytes[2] << 8) + (bytes[3] & 0xff);
|
||||||
};
|
}
|
||||||
|
|
||||||
function getMaxPower2(number) {
|
function getMaxPower2(number) {
|
||||||
var maxPower = 0;
|
var maxPower = 0;
|
||||||
@ -2469,26 +2470,26 @@ var Font = (function FontClosure() {
|
|||||||
for (var i = 1; i < maxPower; i++)
|
for (var i = 1; i < maxPower; i++)
|
||||||
value *= 2;
|
value *= 2;
|
||||||
return value;
|
return value;
|
||||||
};
|
}
|
||||||
|
|
||||||
function string16(value) {
|
function string16(value) {
|
||||||
return String.fromCharCode((value >> 8) & 0xff) +
|
return String.fromCharCode((value >> 8) & 0xff) +
|
||||||
String.fromCharCode(value & 0xff);
|
String.fromCharCode(value & 0xff);
|
||||||
};
|
}
|
||||||
|
|
||||||
function safeString16(value) {
|
function safeString16(value) {
|
||||||
// clamp value to the 16-bit int range
|
// clamp value to the 16-bit int range
|
||||||
value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
|
value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
|
||||||
return String.fromCharCode((value >> 8) & 0xff) +
|
return String.fromCharCode((value >> 8) & 0xff) +
|
||||||
String.fromCharCode(value & 0xff);
|
String.fromCharCode(value & 0xff);
|
||||||
};
|
}
|
||||||
|
|
||||||
function string32(value) {
|
function string32(value) {
|
||||||
return String.fromCharCode((value >> 24) & 0xff) +
|
return String.fromCharCode((value >> 24) & 0xff) +
|
||||||
String.fromCharCode((value >> 16) & 0xff) +
|
String.fromCharCode((value >> 16) & 0xff) +
|
||||||
String.fromCharCode((value >> 8) & 0xff) +
|
String.fromCharCode((value >> 8) & 0xff) +
|
||||||
String.fromCharCode(value & 0xff);
|
String.fromCharCode(value & 0xff);
|
||||||
};
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -2514,7 +2515,7 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
file.file += header;
|
file.file += header;
|
||||||
file.virtualOffset += header.length;
|
file.virtualOffset += header.length;
|
||||||
};
|
}
|
||||||
|
|
||||||
function createTableEntry(file, tag, data) {
|
function createTableEntry(file, tag, data) {
|
||||||
// offset
|
// offset
|
||||||
@ -2540,7 +2541,7 @@ var Font = (function FontClosure() {
|
|||||||
string32(offset) + string32(length));
|
string32(offset) + string32(length));
|
||||||
file.file += tableEntry;
|
file.file += tableEntry;
|
||||||
file.virtualOffset += data.length;
|
file.virtualOffset += data.length;
|
||||||
};
|
}
|
||||||
|
|
||||||
function getRanges(glyphs) {
|
function getRanges(glyphs) {
|
||||||
// Array.sort() sorts by characters, not numerically, so convert to an
|
// Array.sort() sorts by characters, not numerically, so convert to an
|
||||||
@ -2569,7 +2570,7 @@ var Font = (function FontClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ranges;
|
return ranges;
|
||||||
};
|
}
|
||||||
|
|
||||||
function createCmapTable(glyphs, deltas) {
|
function createCmapTable(glyphs, deltas) {
|
||||||
var ranges = getRanges(glyphs);
|
var ranges = getRanges(glyphs);
|
||||||
@ -2646,7 +2647,7 @@ var Font = (function FontClosure() {
|
|||||||
'\x00\x04' + // format
|
'\x00\x04' + // format
|
||||||
string16(format314.length + 4) + // length
|
string16(format314.length + 4) + // length
|
||||||
format314);
|
format314);
|
||||||
};
|
}
|
||||||
|
|
||||||
function validateOS2Table(os2) {
|
function validateOS2Table(os2) {
|
||||||
var stream = new Stream(os2.data);
|
var stream = new Stream(os2.data);
|
||||||
@ -2769,7 +2770,7 @@ var Font = (function FontClosure() {
|
|||||||
string16(0) + // usDefaultChar
|
string16(0) + // usDefaultChar
|
||||||
string16(firstCharIndex || properties.firstChar) + // usBreakChar
|
string16(firstCharIndex || properties.firstChar) + // usBreakChar
|
||||||
'\x00\x03'; // usMaxContext
|
'\x00\x03'; // usMaxContext
|
||||||
};
|
}
|
||||||
|
|
||||||
function createPostTable(properties) {
|
function createPostTable(properties) {
|
||||||
var angle = Math.floor(properties.italicAngle * (Math.pow(2, 16)));
|
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' + // maxMemType42
|
||||||
'\x00\x00\x00\x00' + // minMemType1
|
'\x00\x00\x00\x00' + // minMemType1
|
||||||
'\x00\x00\x00\x00'; // maxMemType1
|
'\x00\x00\x00\x00'; // maxMemType1
|
||||||
};
|
}
|
||||||
|
|
||||||
function createNameTable(name, proto) {
|
function createNameTable(name, proto) {
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
@ -2925,7 +2926,7 @@ var Font = (function FontClosure() {
|
|||||||
offset: offset,
|
offset: offset,
|
||||||
data: data
|
data: data
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function readOpenTypeHeader(ttf) {
|
function readOpenTypeHeader(ttf) {
|
||||||
return {
|
return {
|
||||||
@ -2935,7 +2936,7 @@ var Font = (function FontClosure() {
|
|||||||
entrySelector: int16(ttf.getBytes(2)),
|
entrySelector: int16(ttf.getBytes(2)),
|
||||||
rangeShift: int16(ttf.getBytes(2))
|
rangeShift: int16(ttf.getBytes(2))
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function createGlyphNameMap(glyphs, ids, properties) {
|
function createGlyphNameMap(glyphs, ids, properties) {
|
||||||
var glyphNames = properties.glyphNames;
|
var glyphNames = properties.glyphNames;
|
||||||
@ -3171,7 +3172,7 @@ var Font = (function FontClosure() {
|
|||||||
mappings: mappings,
|
mappings: mappings,
|
||||||
hasShortCmap: hasShortCmap
|
hasShortCmap: hasShortCmap
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function sanitizeMetrics(font, header, metrics, numGlyphs) {
|
function sanitizeMetrics(font, header, metrics, numGlyphs) {
|
||||||
if (!header) {
|
if (!header) {
|
||||||
@ -3207,7 +3208,7 @@ var Font = (function FontClosure() {
|
|||||||
entries += '\x00\x00';
|
entries += '\x00\x00';
|
||||||
metrics.data = stringToArray(entries);
|
metrics.data = stringToArray(entries);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart) {
|
function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart) {
|
||||||
if (sourceEnd - sourceStart <= 12) {
|
if (sourceEnd - sourceStart <= 12) {
|
||||||
@ -3357,7 +3358,7 @@ var Font = (function FontClosure() {
|
|||||||
startOffset = endOffset;
|
startOffset = endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writeOffset == 0) {
|
if (writeOffset === 0) {
|
||||||
// glyf table cannot be empty -- redoing the glyf and loca tables
|
// glyf table cannot be empty -- redoing the glyf and loca tables
|
||||||
// to have single glyph with one point
|
// to have single glyph with one point
|
||||||
var simpleGlyph = new Uint8Array(
|
var simpleGlyph = new Uint8Array(
|
||||||
@ -3484,7 +3485,7 @@ var Font = (function FontClosure() {
|
|||||||
offset: int16(font.getBytes(2))
|
offset: int16(font.getBytes(2))
|
||||||
};
|
};
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
@ -3516,7 +3517,7 @@ var Font = (function FontClosure() {
|
|||||||
var data = os2Table.data;
|
var data = os2Table.data;
|
||||||
// usWinAscent == 0 makes font unreadable by windows
|
// usWinAscent == 0 makes font unreadable by windows
|
||||||
var usWinAscent = (data[74] << 8) | data[75];
|
var usWinAscent = (data[74] << 8) | data[75];
|
||||||
if (usWinAscent == 0)
|
if (usWinAscent === 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3747,7 +3748,7 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
// Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth
|
// Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth
|
||||||
// Sometimes it's 0. That needs to be fixed
|
// 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[10] = 0xFF;
|
||||||
hhea.data[11] = 0xFF;
|
hhea.data[11] = 0xFF;
|
||||||
}
|
}
|
||||||
@ -4211,7 +4212,7 @@ var Font = (function FontClosure() {
|
|||||||
var firstChar = properties.firstChar, lastChar = properties.lastChar;
|
var firstChar = properties.firstChar, lastChar = properties.lastChar;
|
||||||
var map = [];
|
var map = [];
|
||||||
if (properties.composite) {
|
if (properties.composite) {
|
||||||
var isIdentityMap = this.cidToUnicode.length == 0;
|
var isIdentityMap = this.cidToUnicode.length === 0;
|
||||||
for (var i = firstChar, ii = lastChar; i <= ii; i++) {
|
for (var i = firstChar, ii = lastChar; i <= ii; i++) {
|
||||||
// TODO missing map the character according font's CMap
|
// TODO missing map the character according font's CMap
|
||||||
var cid = i;
|
var cid = i;
|
||||||
@ -4352,7 +4353,7 @@ var Font = (function FontClosure() {
|
|||||||
if (!charcode && 'toUnicode' in this)
|
if (!charcode && 'toUnicode' in this)
|
||||||
charcode = this.toUnicode.indexOf(glyphUnicode);
|
charcode = this.toUnicode.indexOf(glyphUnicode);
|
||||||
// setting it to unicode if negative or undefined
|
// setting it to unicode if negative or undefined
|
||||||
if (!(charcode > 0))
|
if (charcode <= 0)
|
||||||
charcode = glyphUnicode;
|
charcode = glyphUnicode;
|
||||||
// trying to get width via charcode
|
// trying to get width via charcode
|
||||||
width = this.widths[charcode];
|
width = this.widths[charcode];
|
||||||
@ -4660,7 +4661,6 @@ var Type1CharString = (function Type1CharStringClosure() {
|
|||||||
break;
|
break;
|
||||||
case 11: // return
|
case 11: // return
|
||||||
return error;
|
return error;
|
||||||
break;
|
|
||||||
case 13: // hsbw
|
case 13: // hsbw
|
||||||
if (this.stack.length < 2) {
|
if (this.stack.length < 2) {
|
||||||
error = true;
|
error = true;
|
||||||
@ -5033,7 +5033,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
var blueArray = readNumberArray(eexecStr, i + 1);
|
var blueArray = readNumberArray(eexecStr, i + 1);
|
||||||
// *Blue* values may contain invalid data: disables reading of
|
// *Blue* values may contain invalid data: disables reading of
|
||||||
// those values when hinting is disabled.
|
// those values when hinting is disabled.
|
||||||
if (blueArray.length > 0 && (blueArray.length % 2) == 0 &&
|
if (blueArray.length > 0 && (blueArray.length % 2) === 0 &&
|
||||||
HINTING_ENABLED) {
|
HINTING_ENABLED) {
|
||||||
program.properties.privateData[token.substring(1)] = blueArray;
|
program.properties.privateData[token.substring(1)] = blueArray;
|
||||||
}
|
}
|
||||||
@ -5649,7 +5649,7 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
while (bytes[offset] != 1)
|
while (bytes[offset] != 1)
|
||||||
++offset;
|
++offset;
|
||||||
|
|
||||||
if (offset != 0) {
|
if (offset !== 0) {
|
||||||
info('cff data is shifted');
|
info('cff data is shifted');
|
||||||
bytes = bytes.subarray(offset);
|
bytes = bytes.subarray(offset);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
@ -5739,7 +5739,7 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
var start = pos;
|
var start = pos;
|
||||||
var end = pos;
|
var end = pos;
|
||||||
|
|
||||||
if (count != 0) {
|
if (count !== 0) {
|
||||||
var offsetSize = bytes[pos++];
|
var offsetSize = bytes[pos++];
|
||||||
// add 1 for offset to determine size of last object
|
// add 1 for offset to determine size of last object
|
||||||
var startPos = pos + ((count + 1) * offsetSize) - 1;
|
var startPos = pos + ((count + 1) * offsetSize) - 1;
|
||||||
@ -5796,8 +5796,8 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
}
|
}
|
||||||
return strings;
|
return strings;
|
||||||
},
|
},
|
||||||
createDict: function CFFParser_createDict(type, dict, strings) {
|
createDict: function CFFParser_createDict(Type, dict, strings) {
|
||||||
var cffDict = new type(strings);
|
var cffDict = new Type(strings);
|
||||||
var types = cffDict.types;
|
var types = cffDict.types;
|
||||||
|
|
||||||
for (var i = 0, ii = dict.length; i < ii; ++i) {
|
for (var i = 0, ii = dict.length; i < ii; ++i) {
|
||||||
@ -5825,7 +5825,7 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
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
|
||||||
// (12, 0) is deprecated and treated as a no-op, but all Type2
|
// (12, 0) is deprecated and treated as a no-op, but all Type2
|
||||||
// charstrings processors should support them. Unfortunately
|
// charstrings processors should support them. Unfortunately
|
||||||
@ -5929,7 +5929,7 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
privateDict.subrsIndex = subrsIndex.obj;
|
privateDict.subrsIndex = subrsIndex.obj;
|
||||||
},
|
},
|
||||||
parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
|
parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
|
||||||
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) {
|
||||||
@ -6000,7 +6000,7 @@ 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 :
|
||||||
@ -6253,7 +6253,7 @@ var CFFTopDict = (function CFFTopDictClosure() {
|
|||||||
[[12, 5], 'PaintType', 'num', 0],
|
[[12, 5], 'PaintType', 'num', 0],
|
||||||
[[12, 6], 'CharstringType', 'num', 2],
|
[[12, 6], 'CharstringType', 'num', 2],
|
||||||
[[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'],
|
[[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],
|
[13, 'UniqueID', 'num', null],
|
||||||
[5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]],
|
[5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]],
|
||||||
[[12, 8], 'StrokeWidth', 'num', 0],
|
[[12, 8], 'StrokeWidth', 'num', 0],
|
||||||
@ -6423,7 +6423,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
|||||||
array[i] = str.charCodeAt(i);
|
array[i] = str.charCodeAt(i);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
};
|
}
|
||||||
function CFFCompiler(cff) {
|
function CFFCompiler(cff) {
|
||||||
this.cff = cff;
|
this.cff = cff;
|
||||||
}
|
}
|
||||||
@ -6506,7 +6506,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) && !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);
|
||||||
@ -6706,7 +6706,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
|||||||
|
|
||||||
// If there is no object, just create an index. This technically
|
// If there is no object, just create an index. This technically
|
||||||
// should just be [0, 0] but OTS has an issue with that.
|
// should just be [0, 0] but OTS has an issue with that.
|
||||||
if (count == 0)
|
if (count === 0)
|
||||||
return [0, 0, 0];
|
return [0, 0, 0];
|
||||||
|
|
||||||
var data = [(count >> 8) & 0xFF, count & 0xff];
|
var data = [(count >> 8) & 0xFF, count & 0xff];
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals EOF, error, isArray, isBool, Lexer, TODO */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -80,7 +81,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||||||
return this.constructInterpolatedFromIR(IR);
|
return this.constructInterpolatedFromIR(IR);
|
||||||
case CONSTRUCT_STICHED:
|
case CONSTRUCT_STICHED:
|
||||||
return this.constructStichedFromIR(IR);
|
return this.constructStichedFromIR(IR);
|
||||||
case CONSTRUCT_POSTSCRIPT:
|
//case CONSTRUCT_POSTSCRIPT:
|
||||||
default:
|
default:
|
||||||
return this.constructPostScriptFromIR(IR);
|
return this.constructPostScriptFromIR(IR);
|
||||||
}
|
}
|
||||||
@ -233,7 +234,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return y;
|
return y;
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
constructInterpolated: function PDFFunction_constructInterpolated(str,
|
constructInterpolated: function PDFFunction_constructInterpolated(str,
|
||||||
@ -270,7 +271,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
|
constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals ColorSpace, error, isArray, isStream, JpegStream, Name, Promise, Stream, TODO, warn */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -260,7 +261,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
var buf = 0;
|
var buf = 0;
|
||||||
|
|
||||||
for (var i = 0, ii = length; i < ii; ++i) {
|
for (var i = 0, ii = length; i < ii; ++i) {
|
||||||
if (i % rowComps == 0) {
|
if (i % rowComps === 0) {
|
||||||
mask = 0;
|
mask = 0;
|
||||||
buf = 0;
|
buf = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -278,7 +279,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
// The general case that handles all other bpc values.
|
// The general case that handles all other bpc values.
|
||||||
var bits = 0, buf = 0;
|
var bits = 0, buf = 0;
|
||||||
for (var i = 0, ii = length; i < ii; ++i) {
|
for (var i = 0, ii = length; i < ii; ++i) {
|
||||||
if (i % rowComps == 0) {
|
if (i % rowComps === 0) {
|
||||||
buf = 0;
|
buf = 0;
|
||||||
bits = 0;
|
bits = 0;
|
||||||
}
|
}
|
||||||
@ -374,7 +375,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
buf = imgArray[imgArrayPos++];
|
buf = imgArray[imgArrayPos++];
|
||||||
mask = 128;
|
mask = 128;
|
||||||
}
|
}
|
||||||
if (!(buf & mask) == inverseDecode) {
|
if (!(buf & mask) === inverseDecode) {
|
||||||
buffer[bufferPos] = 0;
|
buffer[bufferPos] = 0;
|
||||||
}
|
}
|
||||||
bufferPos += 4;
|
bufferPos += 4;
|
||||||
|
21
src/jbig2.js
21
src/jbig2.js
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals error, shadow */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -123,7 +124,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
return d;
|
return d;
|
||||||
} else {
|
} else {
|
||||||
this.chigh -= qeIcx;
|
this.chigh -= qeIcx;
|
||||||
if ((this.a & 0x8000) == 0) {
|
if ((this.a & 0x8000) === 0) {
|
||||||
var d = this.exchangeMps(cx);
|
var d = this.exchangeMps(cx);
|
||||||
this.renormD();
|
this.renormD();
|
||||||
return d;
|
return d;
|
||||||
@ -134,14 +135,14 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
},
|
},
|
||||||
renormD: function ArithmeticDecoder_renormD() {
|
renormD: function ArithmeticDecoder_renormD() {
|
||||||
do {
|
do {
|
||||||
if (this.ct == 0)
|
if (this.ct === 0)
|
||||||
this.byteIn();
|
this.byteIn();
|
||||||
|
|
||||||
this.a <<= 1;
|
this.a <<= 1;
|
||||||
this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
|
this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
|
||||||
this.clow = (this.clow << 1) & 0xFFFF;
|
this.clow = (this.clow << 1) & 0xFFFF;
|
||||||
this.ct--;
|
this.ct--;
|
||||||
} while ((this.a & 0x8000) == 0);
|
} while ((this.a & 0x8000) === 0);
|
||||||
},
|
},
|
||||||
exchangeMps: function ArithmeticDecoder_exchangeMps(cx) {
|
exchangeMps: function ArithmeticDecoder_exchangeMps(cx) {
|
||||||
var d;
|
var d;
|
||||||
@ -261,7 +262,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v = v * 2 + bit;
|
v = v * 2 + bit;
|
||||||
if (--toRead == 0)
|
if (--toRead === 0)
|
||||||
state = 0;
|
state = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -437,7 +438,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
offsetX, offsetY, prediction, at,
|
offsetX, offsetY, prediction, at,
|
||||||
decodingContext) {
|
decodingContext) {
|
||||||
var codingTemplate = RefinementTemplates[templateIndex].coding;
|
var codingTemplate = RefinementTemplates[templateIndex].coding;
|
||||||
if (templateIndex == 0)
|
if (templateIndex === 0)
|
||||||
codingTemplate = codingTemplate.concat([at[0]]);
|
codingTemplate = codingTemplate.concat([at[0]]);
|
||||||
var codingTemplateLength = codingTemplate.length;
|
var codingTemplateLength = codingTemplate.length;
|
||||||
var codingTemplateX = new Int32Array(codingTemplateLength);
|
var codingTemplateX = new Int32Array(codingTemplateLength);
|
||||||
@ -447,7 +448,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
codingTemplateY[k] = codingTemplate[k].y;
|
codingTemplateY[k] = codingTemplate[k].y;
|
||||||
}
|
}
|
||||||
var referenceTemplate = RefinementTemplates[templateIndex].reference;
|
var referenceTemplate = RefinementTemplates[templateIndex].reference;
|
||||||
if (templateIndex == 0)
|
if (templateIndex === 0)
|
||||||
referenceTemplate = referenceTemplate.concat([at[1]]);
|
referenceTemplate = referenceTemplate.concat([at[1]]);
|
||||||
var referenceTemplateLength = referenceTemplate.length;
|
var referenceTemplateLength = referenceTemplate.length;
|
||||||
var referenceTemplateX = new Int32Array(referenceTemplateLength);
|
var referenceTemplateX = new Int32Array(referenceTemplateLength);
|
||||||
@ -530,7 +531,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
var totalWidth = 0;
|
var totalWidth = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
var deltaWidth = decodeInteger(contextCache, 'IADW', decoder); // 6.5.7
|
var deltaWidth = decodeInteger(contextCache, 'IADW', decoder); // 6.5.7
|
||||||
if (deltaWidth == null)
|
if (deltaWidth === null)
|
||||||
break; // OOB
|
break; // OOB
|
||||||
currentWidth += deltaWidth;
|
currentWidth += deltaWidth;
|
||||||
totalWidth += currentWidth;
|
totalWidth += currentWidth;
|
||||||
@ -657,7 +658,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
i++;
|
i++;
|
||||||
|
|
||||||
var deltaS = decodeInteger(contextCache, 'IADS', decoder); // 6.4.8
|
var deltaS = decodeInteger(contextCache, 'IADS', decoder); // 6.4.8
|
||||||
if (deltaS == null)
|
if (deltaS === null)
|
||||||
break; // OOB
|
break; // OOB
|
||||||
currentS += deltaS + dsOffset;
|
currentS += deltaS + dsOffset;
|
||||||
} while (true);
|
} while (true);
|
||||||
@ -779,7 +780,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
dictionary.refinementTemplate = (dictionaryFlags >> 12) & 1;
|
dictionary.refinementTemplate = (dictionaryFlags >> 12) & 1;
|
||||||
position += 2;
|
position += 2;
|
||||||
if (!dictionary.huffman) {
|
if (!dictionary.huffman) {
|
||||||
var atLength = dictionary.template == 0 ? 4 : 1;
|
var atLength = dictionary.template === 0 ? 4 : 1;
|
||||||
var at = [];
|
var at = [];
|
||||||
for (var i = 0; i < atLength; i++) {
|
for (var i = 0; i < atLength; i++) {
|
||||||
at.push({
|
at.push({
|
||||||
@ -865,7 +866,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
|
|||||||
genericRegion.template = (genericRegionSegmentFlags >> 1) & 3;
|
genericRegion.template = (genericRegionSegmentFlags >> 1) & 3;
|
||||||
genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
|
genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
|
||||||
if (!genericRegion.mmr) {
|
if (!genericRegion.mmr) {
|
||||||
var atLength = genericRegion.template == 0 ? 4 : 1;
|
var atLength = genericRegion.template === 0 ? 4 : 1;
|
||||||
var at = [];
|
var at = [];
|
||||||
for (var i = 0; i < atLength; i++) {
|
for (var i = 0; i < atLength; i++) {
|
||||||
at.push({
|
at.push({
|
||||||
|
57
src/jpx.js
57
src/jpx.js
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals error, globalScope, warn */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -43,7 +44,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
},
|
},
|
||||||
parse: function JpxImage_parse(data) {
|
parse: function JpxImage_parse(data) {
|
||||||
function ReadUint(data, offset, bytes) {
|
function readUint(data, offset, bytes) {
|
||||||
var n = 0;
|
var n = 0;
|
||||||
for (var i = 0; i < bytes; i++)
|
for (var i = 0; i < bytes; i++)
|
||||||
n = n * 256 + (data[offset + i] & 0xFF);
|
n = n * 256 + (data[offset + i] & 0xFF);
|
||||||
@ -52,15 +53,15 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
var position = 0, length = data.length;
|
var position = 0, length = data.length;
|
||||||
while (position < length) {
|
while (position < length) {
|
||||||
var headerSize = 8;
|
var headerSize = 8;
|
||||||
var lbox = ReadUint(data, position, 4);
|
var lbox = readUint(data, position, 4);
|
||||||
var tbox = ReadUint(data, position + 4, 4);
|
var tbox = readUint(data, position + 4, 4);
|
||||||
position += headerSize;
|
position += headerSize;
|
||||||
if (lbox == 1) {
|
if (lbox == 1) {
|
||||||
lbox = ReadUint(data, position, 8);
|
lbox = readUint(data, position, 8);
|
||||||
position += 8;
|
position += 8;
|
||||||
headerSize += 8;
|
headerSize += 8;
|
||||||
}
|
}
|
||||||
if (lbox == 0)
|
if (lbox === 0)
|
||||||
lbox = length - position + headerSize;
|
lbox = length - position + headerSize;
|
||||||
if (lbox < headerSize)
|
if (lbox < headerSize)
|
||||||
error('JPX error: Invalid box field size');
|
error('JPX error: Invalid box field size');
|
||||||
@ -289,7 +290,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
tile.partsCount = data[position + 9];
|
tile.partsCount = data[position + 9];
|
||||||
|
|
||||||
context.mainHeader = false;
|
context.mainHeader = false;
|
||||||
if (tile.partIndex == 0) {
|
if (tile.partIndex === 0) {
|
||||||
// reset component specific settings
|
// reset component specific settings
|
||||||
tile.COD = context.COD;
|
tile.COD = context.COD;
|
||||||
tile.COC = context.COC.slice(0); // clone of the global COC
|
tile.COC = context.COC.slice(0); // clone of the global COC
|
||||||
@ -300,7 +301,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
break;
|
break;
|
||||||
case 0xFF93: // Start of data (SOD)
|
case 0xFF93: // Start of data (SOD)
|
||||||
var tile = context.currentTile;
|
var tile = context.currentTile;
|
||||||
if (tile.partIndex == 0) {
|
if (tile.partIndex === 0) {
|
||||||
initializeTile(context, tile.index);
|
initializeTile(context, tile.index);
|
||||||
buildPackets(context);
|
buildPackets(context);
|
||||||
}
|
}
|
||||||
@ -631,7 +632,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
resolutions.push(resolution);
|
resolutions.push(resolution);
|
||||||
|
|
||||||
var subband;
|
var subband;
|
||||||
if (r == 0) {
|
if (r === 0) {
|
||||||
// one sub-band (LL) with last decomposition
|
// one sub-band (LL) with last decomposition
|
||||||
subband = {};
|
subband = {};
|
||||||
subband.type = 'LL';
|
subband.type = 'LL';
|
||||||
@ -733,7 +734,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
}
|
}
|
||||||
function readCodingpasses() {
|
function readCodingpasses() {
|
||||||
var value = readBits(1);
|
var value = readBits(1);
|
||||||
if (value == 0)
|
if (value === 0)
|
||||||
return 1;
|
return 1;
|
||||||
value = (value << 1) | readBits(1);
|
value = (value << 1) | readBits(1);
|
||||||
if (value == 0x02)
|
if (value == 0x02)
|
||||||
@ -853,7 +854,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
var codeblock = codeblocks[i];
|
var codeblock = codeblocks[i];
|
||||||
var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
|
var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
|
||||||
var blockHeight = codeblock.tby1_ - codeblock.tby0_;
|
var blockHeight = codeblock.tby1_ - codeblock.tby0_;
|
||||||
if (blockWidth == 0 || blockHeight == 0)
|
if (blockWidth === 0 || blockHeight === 0)
|
||||||
continue;
|
continue;
|
||||||
if (!('data' in codeblock))
|
if (!('data' in codeblock))
|
||||||
continue;
|
continue;
|
||||||
@ -905,7 +906,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
var n = (bitModel.coefficentsSign[position] ? -1 : 1) *
|
var n = (bitModel.coefficentsSign[position] ? -1 : 1) *
|
||||||
bitModel.coefficentsMagnitude[position];
|
bitModel.coefficentsMagnitude[position];
|
||||||
var nb = bitModel.bitsDecoded[position], correction;
|
var nb = bitModel.bitsDecoded[position], correction;
|
||||||
if (transformation == 0 || mb > nb) {
|
if (transformation === 0 || mb > nb) {
|
||||||
// use r only if transformation is irreversible or
|
// use r only if transformation is irreversible or
|
||||||
// not all bitplanes were decoded for reversible transformation
|
// not all bitplanes were decoded for reversible transformation
|
||||||
n += n < 0 ? n - r : n > 0 ? n + r : 0;
|
n += n < 0 ? n - r : n > 0 ? n + r : 0;
|
||||||
@ -974,7 +975,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var transformation = codingStyleParameters.transformation;
|
var transformation = codingStyleParameters.transformation;
|
||||||
var transform = transformation == 0 ? new IrreversibleTransform() :
|
var transform = transformation === 0 ? new IrreversibleTransform() :
|
||||||
new ReversibleTransform();
|
new ReversibleTransform();
|
||||||
var result = transform.calculate(subbandCoefficients,
|
var result = transform.calculate(subbandCoefficients,
|
||||||
component.tcx0, component.tcy0);
|
component.tcx0, component.tcy0);
|
||||||
@ -1304,7 +1305,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
return d;
|
return d;
|
||||||
} else {
|
} else {
|
||||||
this.chigh -= qeIcx;
|
this.chigh -= qeIcx;
|
||||||
if ((this.a & 0x8000) == 0) {
|
if ((this.a & 0x8000) === 0) {
|
||||||
var d = this.exchangeMps(cx);
|
var d = this.exchangeMps(cx);
|
||||||
this.renormD();
|
this.renormD();
|
||||||
return d;
|
return d;
|
||||||
@ -1315,14 +1316,14 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
},
|
},
|
||||||
renormD: function ArithmeticDecoder_renormD() {
|
renormD: function ArithmeticDecoder_renormD() {
|
||||||
do {
|
do {
|
||||||
if (this.ct == 0)
|
if (this.ct === 0)
|
||||||
this.byteIn();
|
this.byteIn();
|
||||||
|
|
||||||
this.a <<= 1;
|
this.a <<= 1;
|
||||||
this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
|
this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
|
||||||
this.clow = (this.clow << 1) & 0xFFFF;
|
this.clow = (this.clow << 1) & 0xFFFF;
|
||||||
this.ct--;
|
this.ct--;
|
||||||
} while ((this.a & 0x8000) == 0);
|
} while ((this.a & 0x8000) === 0);
|
||||||
},
|
},
|
||||||
exchangeMps: function ArithmeticDecoder_exchangeMps(cx) {
|
exchangeMps: function ArithmeticDecoder_exchangeMps(cx) {
|
||||||
var d;
|
var d;
|
||||||
@ -1558,12 +1559,12 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
|
|
||||||
// significant but not those that have just become
|
// significant but not those that have just become
|
||||||
if (!coefficentsMagnitude[index] ||
|
if (!coefficentsMagnitude[index] ||
|
||||||
(processingFlags[index] & processedMask) != 0)
|
(processingFlags[index] & processedMask) !== 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var contextLabel = 16;
|
var contextLabel = 16;
|
||||||
if ((processingFlags[index] &
|
if ((processingFlags[index] &
|
||||||
firstMagnitudeBitMask) != 0) {
|
firstMagnitudeBitMask) !== 0) {
|
||||||
processingFlags[i * width + j] ^= firstMagnitudeBitMask;
|
processingFlags[i * width + j] ^= firstMagnitudeBitMask;
|
||||||
// first refinement
|
// first refinement
|
||||||
var significance = neighborsSignificance[index];
|
var significance = neighborsSignificance[index];
|
||||||
@ -1604,14 +1605,14 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
// using the property: labels[neighborsSignificance[index]] == 0
|
// using the property: labels[neighborsSignificance[index]] == 0
|
||||||
// when neighborsSignificance[index] == 0
|
// when neighborsSignificance[index] == 0
|
||||||
var allEmpty = i0 + 3 < height &&
|
var allEmpty = i0 + 3 < height &&
|
||||||
processingFlags[index0] == 0 &&
|
processingFlags[index0] === 0 &&
|
||||||
processingFlags[index0 + oneRowDown] == 0 &&
|
processingFlags[index0 + oneRowDown] === 0 &&
|
||||||
processingFlags[index0 + twoRowsDown] == 0 &&
|
processingFlags[index0 + twoRowsDown] === 0 &&
|
||||||
processingFlags[index0 + threeRowsDown] == 0 &&
|
processingFlags[index0 + threeRowsDown] === 0 &&
|
||||||
neighborsSignificance[index0] == 0 &&
|
neighborsSignificance[index0] === 0 &&
|
||||||
neighborsSignificance[index0 + oneRowDown] == 0 &&
|
neighborsSignificance[index0 + oneRowDown] === 0 &&
|
||||||
neighborsSignificance[index0 + twoRowsDown] == 0 &&
|
neighborsSignificance[index0 + twoRowsDown] === 0 &&
|
||||||
neighborsSignificance[index0 + threeRowsDown] == 0;
|
neighborsSignificance[index0 + threeRowsDown] === 0;
|
||||||
var i1 = 0, index = index0;
|
var i1 = 0, index = index0;
|
||||||
var cx, i;
|
var cx, i;
|
||||||
if (allEmpty) {
|
if (allEmpty) {
|
||||||
@ -1647,7 +1648,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (coefficentsMagnitude[index] ||
|
if (coefficentsMagnitude[index] ||
|
||||||
(processingFlags[index] & processedMask) != 0)
|
(processingFlags[index] & processedMask) !== 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var contextLabel = labels[neighborsSignificance[index]];
|
var contextLabel = labels[neighborsSignificance[index]];
|
||||||
@ -1733,7 +1734,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
for (var v = 0; v < height; v++) {
|
for (var v = 0; v < height; v++) {
|
||||||
if (width == 1) {
|
if (width == 1) {
|
||||||
// if width = 1, when u0 even keep items as is, when odd divide by 2
|
// 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;
|
items[v * width] /= 2;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -1768,7 +1769,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
for (var u = 0; u < width; u++) {
|
for (var u = 0; u < width; u++) {
|
||||||
if (height == 1) {
|
if (height == 1) {
|
||||||
// if height = 1, when v0 even keep items as is, when odd divide by 2
|
// 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;
|
items[u] /= 2;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals Document, error, PDFJS */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -100,7 +101,7 @@ var Dict = (function DictClosure() {
|
|||||||
callback(key, this.get(key));
|
callback(key, this.get(key));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
return Dict;
|
return Dict;
|
||||||
})();
|
})();
|
||||||
@ -442,7 +443,7 @@ var XRef = (function XRefClosure() {
|
|||||||
for (j = 0; j < typeFieldWidth; ++j)
|
for (j = 0; j < typeFieldWidth; ++j)
|
||||||
type = (type << 8) | stream.getByte();
|
type = (type << 8) | stream.getByte();
|
||||||
// if type field is absent, its default value = 1
|
// if type field is absent, its default value = 1
|
||||||
if (typeFieldWidth == 0)
|
if (typeFieldWidth === 0)
|
||||||
type = 1;
|
type = 1;
|
||||||
for (j = 0; j < offsetFieldWidth; ++j)
|
for (j = 0; j < offsetFieldWidth; ++j)
|
||||||
offset = (offset << 8) | stream.getByte();
|
offset = (offset << 8) | stream.getByte();
|
||||||
@ -678,7 +679,7 @@ var XRef = (function XRefClosure() {
|
|||||||
}
|
}
|
||||||
if (!isCmd(obj3, 'obj')) {
|
if (!isCmd(obj3, 'obj')) {
|
||||||
// some bad pdfs use "obj1234" and really mean 1234
|
// 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);
|
num = parseInt(obj3.cmd.substring(3), 10);
|
||||||
if (!isNaN(num))
|
if (!isNaN(num))
|
||||||
return num;
|
return num;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -133,7 +134,7 @@ var Parser = (function ParserClosure() {
|
|||||||
|
|
||||||
// searching for the /EI\s/
|
// searching for the /EI\s/
|
||||||
var state = 0, ch;
|
var state = 0, ch;
|
||||||
while (state != 4 && (ch = stream.getByte()) != null) {
|
while (state != 4 && (ch = stream.getByte()) !== null && ch !== undefined) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 0x20:
|
case 0x20:
|
||||||
case 0x0D:
|
case 0x0D:
|
||||||
@ -364,7 +365,7 @@ var Lexer = (function LexerClosure() {
|
|||||||
str += ch;
|
str += ch;
|
||||||
break;
|
break;
|
||||||
case ')':
|
case ')':
|
||||||
if (--numParen == 0) {
|
if (--numParen === 0) {
|
||||||
done = true;
|
done = true;
|
||||||
} else {
|
} else {
|
||||||
str += ch;
|
str += ch;
|
||||||
@ -540,6 +541,7 @@ var Lexer = (function LexerClosure() {
|
|||||||
stream.skip();
|
stream.skip();
|
||||||
return Cmd.get('>>');
|
return Cmd.get('>>');
|
||||||
}
|
}
|
||||||
|
return Cmd.get(ch);
|
||||||
case '{':
|
case '{':
|
||||||
case '}':
|
case '}':
|
||||||
return Cmd.get(ch);
|
return Cmd.get(ch);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* globals bytesToString, ColorSpace, Dict, EOF, error, info, Jbig2Image, JpegImage, JpxImage, Lexer */
|
||||||
/* Copyright 2012 Mozilla Foundation
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -247,7 +248,7 @@ var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
|
|||||||
function streamSequenceStreamReadBlock() {
|
function streamSequenceStreamReadBlock() {
|
||||||
|
|
||||||
var streams = this.streams;
|
var streams = this.streams;
|
||||||
if (streams.length == 0) {
|
if (streams.length === 0) {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -367,7 +368,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
error('Invalid header in flate stream: ' + cmf + ', ' + flg);
|
error('Invalid header in flate stream: ' + cmf + ', ' + flg);
|
||||||
if ((cmf & 0x0f) != 0x08)
|
if ((cmf & 0x0f) != 0x08)
|
||||||
error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
|
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);
|
error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
|
||||||
if (flg & 0x20)
|
if (flg & 0x20)
|
||||||
error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
|
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 code = codes[codeBuf & ((1 << maxLen) - 1)];
|
||||||
var codeLen = code >> 16;
|
var codeLen = code >> 16;
|
||||||
var codeVal = code & 0xffff;
|
var codeVal = code & 0xffff;
|
||||||
if (codeSize == 0 || codeSize < codeLen || codeLen == 0)
|
if (codeSize === 0 || codeSize < codeLen || codeLen === 0)
|
||||||
error('Bad encoding in flate stream');
|
error('Bad encoding in flate stream');
|
||||||
this.codeBuf = (codeBuf >> codeLen);
|
this.codeBuf = (codeBuf >> codeLen);
|
||||||
this.codeSize = (codeSize - codeLen);
|
this.codeSize = (codeSize - codeLen);
|
||||||
@ -475,7 +476,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
this.eof = true;
|
this.eof = true;
|
||||||
hdr >>= 1;
|
hdr >>= 1;
|
||||||
|
|
||||||
if (hdr == 0) { // uncompressed block
|
if (hdr === 0) { // uncompressed block
|
||||||
var bytes = this.bytes;
|
var bytes = this.bytes;
|
||||||
var bytesPos = this.bytesPos;
|
var bytesPos = this.bytesPos;
|
||||||
var b;
|
var b;
|
||||||
@ -708,7 +709,7 @@ var PredictorStream = (function PredictorStreamClosure() {
|
|||||||
var buffer = this.ensureBuffer(bufferLength + rowBytes);
|
var buffer = this.ensureBuffer(bufferLength + rowBytes);
|
||||||
|
|
||||||
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
||||||
if (prevRow.length == 0)
|
if (prevRow.length === 0)
|
||||||
prevRow = new Uint8Array(rowBytes);
|
prevRow = new Uint8Array(rowBytes);
|
||||||
|
|
||||||
var j = bufferLength;
|
var j = bufferLength;
|
||||||
@ -793,10 +794,10 @@ var JpegStream = (function JpegStreamClosure() {
|
|||||||
// Looking for APP14, 'Adobe'
|
// Looking for APP14, 'Adobe'
|
||||||
for (var i = 0; i < maxBytesScanned; ++i) {
|
for (var i = 0; i < maxBytesScanned; ++i) {
|
||||||
if (bytes[i] == 0xFF && bytes[i + 1] == 0xEE &&
|
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 + 4] == 0x41 && bytes[i + 5] == 0x64 &&
|
||||||
bytes[i + 6] == 0x6F && bytes[i + 7] == 0x62 &&
|
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;
|
return true;
|
||||||
// scanning until frame tag
|
// scanning until frame tag
|
||||||
if (bytes[i] == 0xFF && bytes[i + 1] == 0xC0)
|
if (bytes[i] == 0xFF && bytes[i + 1] == 0xC0)
|
||||||
@ -1053,7 +1054,7 @@ var DecryptStream = (function DecryptStreamClosure() {
|
|||||||
|
|
||||||
DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
|
DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
|
||||||
var chunk = this.str.getBytes(chunkSize);
|
var chunk = this.str.getBytes(chunkSize);
|
||||||
if (!chunk || chunk.length == 0) {
|
if (!chunk || chunk.length === 0) {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1695,7 +1696,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
this.columns = params.get('Columns') || 1728;
|
this.columns = params.get('Columns') || 1728;
|
||||||
this.rows = params.get('Rows') || 0;
|
this.rows = params.get('Rows') || 0;
|
||||||
var eoblock = params.get('EndOfBlock');
|
var eoblock = params.get('EndOfBlock');
|
||||||
if (eoblock == null)
|
if (eoblock === null || eoblock === undefined)
|
||||||
eoblock = true;
|
eoblock = true;
|
||||||
this.eoblock = eoblock;
|
this.eoblock = eoblock;
|
||||||
this.black = params.get('BlackIs1') || false;
|
this.black = params.get('BlackIs1') || false;
|
||||||
@ -1714,7 +1715,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
this.buf = EOF;
|
this.buf = EOF;
|
||||||
|
|
||||||
var code1;
|
var code1;
|
||||||
while ((code1 = this.lookBits(12)) == 0) {
|
while ((code1 = this.lookBits(12)) === 0) {
|
||||||
this.eatBits(1);
|
this.eatBits(1);
|
||||||
}
|
}
|
||||||
if (code1 == 1) {
|
if (code1 == 1) {
|
||||||
@ -1798,7 +1799,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
|
|
||||||
var refPos, blackPixels, bits;
|
var refPos, blackPixels, bits;
|
||||||
|
|
||||||
if (this.outputBits == 0) {
|
if (this.outputBits === 0) {
|
||||||
if (this.eof)
|
if (this.eof)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -1972,7 +1973,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
this.eof = true;
|
this.eof = true;
|
||||||
} else {
|
} else {
|
||||||
code1 = this.lookBits(12);
|
code1 = this.lookBits(12);
|
||||||
while (code1 == 0) {
|
while (code1 === 0) {
|
||||||
this.eatBits(1);
|
this.eatBits(1);
|
||||||
code1 = this.lookBits(12);
|
code1 = this.lookBits(12);
|
||||||
}
|
}
|
||||||
@ -2040,7 +2041,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
if (this.outputBits >= 8) {
|
if (this.outputBits >= 8) {
|
||||||
this.buf = (this.codingPos & 1) ? 0 : 0xFF;
|
this.buf = (this.codingPos & 1) ? 0 : 0xFF;
|
||||||
this.outputBits -= 8;
|
this.outputBits -= 8;
|
||||||
if (this.outputBits == 0 && codingLine[this.codingPos] < columns) {
|
if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
|
||||||
this.codingPos++;
|
this.codingPos++;
|
||||||
this.outputBits = (codingLine[this.codingPos] -
|
this.outputBits = (codingLine[this.codingPos] -
|
||||||
codingLine[this.codingPos - 1]);
|
codingLine[this.codingPos - 1]);
|
||||||
@ -2139,7 +2140,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
if (code == EOF)
|
if (code == EOF)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((code >> 5) == 0)
|
if ((code >> 5) === 0)
|
||||||
p = whiteTable1[code];
|
p = whiteTable1[code];
|
||||||
else
|
else
|
||||||
p = whiteTable2[code >> 3];
|
p = whiteTable2[code >> 3];
|
||||||
@ -2170,9 +2171,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
code = this.lookBits(13);
|
code = this.lookBits(13);
|
||||||
if (code == EOF)
|
if (code == EOF)
|
||||||
return 1;
|
return 1;
|
||||||
if ((code >> 7) == 0)
|
if ((code >> 7) === 0)
|
||||||
p = blackTable1[code];
|
p = blackTable1[code];
|
||||||
else if ((code >> 9) == 0 && (code >> 7) != 0)
|
else if ((code >> 9) === 0 && (code >> 7) !== 0)
|
||||||
p = blackTable2[(code >> 1) - 64];
|
p = blackTable2[(code >> 1) - 64];
|
||||||
else
|
else
|
||||||
p = blackTable3[code >> 7];
|
p = blackTable3[code >> 7];
|
||||||
@ -2202,8 +2203,8 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|||||||
CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
|
CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
|
||||||
var c;
|
var c;
|
||||||
while (this.inputBits < n) {
|
while (this.inputBits < n) {
|
||||||
if ((c = this.str.getByte()) == null) {
|
if ((c = this.str.getByte()) === null || c === undefined) {
|
||||||
if (this.inputBits == 0)
|
if (this.inputBits === 0)
|
||||||
return EOF;
|
return EOF;
|
||||||
return ((this.inputBuf << (n - this.inputBits)) &
|
return ((this.inputBuf << (n - this.inputBits)) &
|
||||||
(0xFFFF >> (16 - n)));
|
(0xFFFF >> (16 - n)));
|
||||||
@ -2256,7 +2257,7 @@ var LZWStream = (function LZWStreamClosure() {
|
|||||||
var cachedData = this.cachedData;
|
var cachedData = this.cachedData;
|
||||||
while (bitsCached < n) {
|
while (bitsCached < n) {
|
||||||
var c = this.str.getByte();
|
var c = this.str.getByte();
|
||||||
if (c == null) {
|
if (c === null || c === undefined) {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
21
src/util.js
21
src/util.js
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* 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[3] * v[0] + m[4] * v[1] + m[5] * v[2],
|
||||||
m[6] * v[0] + m[7] * v[1] + m[8] * 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)
|
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
|
||||||
// For coordinate systems whose origin lies in the bottom-left, this
|
// 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];
|
r[3] = rect[1];
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
};
|
||||||
|
|
||||||
// Returns a rectangle [x1, y1, x2, y2] corresponding to the
|
// Returns a rectangle [x1, y1, x2, y2] corresponding to the
|
||||||
// intersection of rect1 and rect2. If no intersection, returns 'false'
|
// 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) {
|
Util.intersect = function Util_intersect(rect1, rect2) {
|
||||||
function compare(a, b) {
|
function compare(a, b) {
|
||||||
return a - b;
|
return a - b;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Order points along the axes
|
// Order points along the axes
|
||||||
var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
|
var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
|
||||||
@ -338,15 +339,15 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
|
|||||||
case 270:
|
case 270:
|
||||||
rotateA = 0; rotateB = -1; rotateC = -1; rotateD = 0;
|
rotateA = 0; rotateB = -1; rotateC = -1; rotateD = 0;
|
||||||
break;
|
break;
|
||||||
case 360:
|
//case 360:
|
||||||
case 0:
|
//case 0:
|
||||||
default:
|
default:
|
||||||
rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1;
|
rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var offsetCanvasX, offsetCanvasY;
|
var offsetCanvasX, offsetCanvasY;
|
||||||
var width, height;
|
var width, height;
|
||||||
if (rotateA == 0) {
|
if (rotateA === 0) {
|
||||||
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
|
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
|
||||||
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
|
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
|
||||||
width = Math.abs(viewBox[3] - viewBox[1]) * scale;
|
width = Math.abs(viewBox[3] - viewBox[1]) * scale;
|
||||||
@ -468,11 +469,11 @@ function isArray(v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isStream(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) {
|
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) {
|
function isRef(v) {
|
||||||
@ -517,7 +518,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
|||||||
this.error = null;
|
this.error = null;
|
||||||
this.exception = null;
|
this.exception = null;
|
||||||
// If you build a promise and pass in some data it's already resolved.
|
// 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.isResolved = true;
|
||||||
this._data = data;
|
this._data = data;
|
||||||
this.hasData = true;
|
this.hasData = true;
|
||||||
@ -528,7 +529,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
|||||||
this.callbacks = [];
|
this.callbacks = [];
|
||||||
this.errbacks = [];
|
this.errbacks = [];
|
||||||
this.progressbacks = [];
|
this.progressbacks = [];
|
||||||
};
|
}
|
||||||
/**
|
/**
|
||||||
* Builds a promise that is resolved when all the passed in promises are
|
* Builds a promise that is resolved when all the passed in promises are
|
||||||
* resolved.
|
* resolved.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -15,6 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The Type2 reader code below is only used for debugging purpose since Type2
|
* 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.
|
* 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 format = aStream.getByte();
|
||||||
var count = aCharstrings.length - 1;
|
var count = aCharstrings.length - 1;
|
||||||
if (format == 0) {
|
if (format === 0) {
|
||||||
charset['.notdef'] = readCharstringEncoding(aCharstrings[0]);
|
charset['.notdef'] = readCharstringEncoding(aCharstrings[0]);
|
||||||
|
|
||||||
for (var i = 1; i < count + 1; i++) {
|
for (var i = 1; i < count + 1; i++) {
|
||||||
@ -250,7 +253,7 @@ var Type2Parser = function type2Parser(aFilePath) {
|
|||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', aFilePath, false);
|
xhr.open('GET', aFilePath, false);
|
||||||
xhr.mozResponseType = xhr.responseType = 'arraybuffer';
|
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);
|
xhr.send(null);
|
||||||
this.data = new Stream(xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
this.data = new Stream(xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
||||||
xhr.responseArrayBuffer || xhr.response);
|
xhr.responseArrayBuffer || xhr.response);
|
||||||
@ -365,7 +368,7 @@ var Type2Parser = function type2Parser(aFilePath) {
|
|||||||
// Read Charset
|
// Read Charset
|
||||||
dump('Read Charset for ' + charStrings.length + ' glyphs');
|
dump('Read Charset for ' + charStrings.length + ' glyphs');
|
||||||
var charsetEntry = font.get('charset');
|
var charsetEntry = font.get('charset');
|
||||||
if (charsetEntry == 0) {
|
if (charsetEntry === 0) {
|
||||||
error('Need to support CFFISOAdobeCharset');
|
error('Need to support CFFISOAdobeCharset');
|
||||||
} else if (charsetEntry == 1) {
|
} else if (charsetEntry == 1) {
|
||||||
error('Need to support CFFExpert');
|
error('Need to support CFFExpert');
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* 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
|
/* Copyright 2012 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -252,19 +253,21 @@ var WorkerMessageHandler = {
|
|||||||
var minimumStackMessage =
|
var minimumStackMessage =
|
||||||
'worker.js: while trying to getPage() and getOperatorList()';
|
'worker.js: while trying to getPage() and getOperatorList()';
|
||||||
|
|
||||||
|
var wrappedException;
|
||||||
|
|
||||||
// Turn the error into an obj that can be serialized
|
// Turn the error into an obj that can be serialized
|
||||||
if (typeof e === 'string') {
|
if (typeof e === 'string') {
|
||||||
e = {
|
wrappedException = {
|
||||||
message: e,
|
message: e,
|
||||||
stack: minimumStackMessage
|
stack: minimumStackMessage
|
||||||
};
|
};
|
||||||
} else if (typeof e === 'object') {
|
} else if (typeof e === 'object') {
|
||||||
e = {
|
wrappedException = {
|
||||||
message: e.message || e.toString(),
|
message: e.message || e.toString(),
|
||||||
stack: e.stack || minimumStackMessage
|
stack: e.stack || minimumStackMessage
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
e = {
|
wrappedException = {
|
||||||
message: 'Unknown exception type: ' + (typeof e),
|
message: 'Unknown exception type: ' + (typeof e),
|
||||||
stack: minimumStackMessage
|
stack: minimumStackMessage
|
||||||
};
|
};
|
||||||
@ -272,7 +275,7 @@ var WorkerMessageHandler = {
|
|||||||
|
|
||||||
handler.send('PageError', {
|
handler.send('PageError', {
|
||||||
pageNum: pageNum,
|
pageNum: pageNum,
|
||||||
error: e
|
error: wrappedException
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -284,7 +287,7 @@ var WorkerMessageHandler = {
|
|||||||
var fonts = {};
|
var fonts = {};
|
||||||
for (var i = 0, ii = dependency.length; i < ii; i++) {
|
for (var i = 0, ii = dependency.length; i < ii; i++) {
|
||||||
var dep = dependency[i];
|
var dep = dependency[i];
|
||||||
if (dep.indexOf('g_font_') == 0) {
|
if (dep.indexOf('g_font_') === 0) {
|
||||||
fonts[dep] = true;
|
fonts[dep] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,7 +344,7 @@ var workerConsole = {
|
|||||||
|
|
||||||
timeEnd: function timeEnd(name) {
|
timeEnd: function timeEnd(name) {
|
||||||
var time = consoleTimer[name];
|
var time = consoleTimer[name];
|
||||||
if (time == null) {
|
if (!time) {
|
||||||
error('Unkown timer name ' + name);
|
error('Unkown timer name ' + name);
|
||||||
}
|
}
|
||||||
this.log('Timer:', name, Date.now() - time);
|
this.log('Timer:', name, Date.now() - time);
|
||||||
|
28
test/reporter.js
Normal file
28
test/reporter.js
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user