Merge pull request #4465 from Snuffleupagus/src-display-braces
Fix coding style in src/display
This commit is contained in:
commit
67c686027c
@ -27,14 +27,15 @@
|
||||
* above this value will not be drawn. Use -1 for no limit.
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
|
||||
PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ?
|
||||
-1 : PDFJS.maxImageSize);
|
||||
|
||||
/**
|
||||
* The url of where the predefined Adobe CMaps are located. Include trailing
|
||||
* slash.
|
||||
* @var {string}
|
||||
*/
|
||||
PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
|
||||
PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
|
||||
|
||||
/*
|
||||
* By default fonts are converted to OpenType fonts and loaded via font face
|
||||
@ -42,16 +43,16 @@ PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
|
||||
* that constructs the glyphs with primitive path commands.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ?
|
||||
false : PDFJS.disableFontFace;
|
||||
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
|
||||
false : PDFJS.disableFontFace);
|
||||
|
||||
/**
|
||||
* Path for image resources, mainly for annotation icons. Include trailing
|
||||
* slash.
|
||||
* @var {string}
|
||||
*/
|
||||
PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
|
||||
'' : PDFJS.imageResourcesPath;
|
||||
PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ?
|
||||
'' : PDFJS.imageResourcesPath);
|
||||
|
||||
/**
|
||||
* Disable the web worker and run all code on the main thread. This will happen
|
||||
@ -59,8 +60,8 @@ PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
|
||||
* to workers.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
|
||||
false : PDFJS.disableWorker;
|
||||
PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
|
||||
false : PDFJS.disableWorker);
|
||||
|
||||
/**
|
||||
* Path and filename of the worker file. Required when the worker is enabled in
|
||||
@ -68,7 +69,7 @@ PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
|
||||
* loaded based on the location of the pdf.js file.
|
||||
* @var {string}
|
||||
*/
|
||||
PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
|
||||
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
||||
|
||||
/**
|
||||
* Disable range request loading of PDF files. When enabled and if the server
|
||||
@ -76,8 +77,8 @@ PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
|
||||
* Enabled (false) by default.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableRange = PDFJS.disableRange === undefined ?
|
||||
false : PDFJS.disableRange;
|
||||
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
||||
false : PDFJS.disableRange);
|
||||
|
||||
/**
|
||||
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
|
||||
@ -85,28 +86,28 @@ PDFJS.disableRange = PDFJS.disableRange === undefined ?
|
||||
* the current page. This default behavior can be disabled.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ?
|
||||
false : PDFJS.disableAutoFetch;
|
||||
PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
|
||||
false : PDFJS.disableAutoFetch);
|
||||
|
||||
/**
|
||||
* Enables special hooks for debugging PDF.js.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
|
||||
PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug);
|
||||
|
||||
/**
|
||||
* Enables transfer usage in postMessage for ArrayBuffers.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ?
|
||||
true : PDFJS.postMessageTransfers;
|
||||
PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ?
|
||||
true : PDFJS.postMessageTransfers);
|
||||
|
||||
/**
|
||||
* Disables URL.createObjectURL usage.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ?
|
||||
false : PDFJS.disableCreateObjectURL;
|
||||
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
||||
false : PDFJS.disableCreateObjectURL);
|
||||
|
||||
/**
|
||||
* Controls the logging level.
|
||||
@ -116,8 +117,8 @@ PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ?
|
||||
* - infos
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.verbosity = PDFJS.verbosity === undefined ?
|
||||
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity;
|
||||
PDFJS.verbosity = (PDFJS.verbosity === undefined ?
|
||||
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity);
|
||||
|
||||
/**
|
||||
* Document initialization / loading parameters object.
|
||||
@ -172,8 +173,9 @@ PDFJS.getDocument = function getDocument(source,
|
||||
'string or a parameter object');
|
||||
}
|
||||
|
||||
if (!source.url && !source.data)
|
||||
if (!source.url && !source.data) {
|
||||
error('Invalid parameter array, need either .data or .url');
|
||||
}
|
||||
|
||||
// copy/use all keys as is except 'url' -- full path is required
|
||||
var params = {};
|
||||
@ -187,8 +189,8 @@ PDFJS.getDocument = function getDocument(source,
|
||||
|
||||
workerInitializedPromise = new PDFJS.LegacyPromise();
|
||||
workerReadyPromise = new PDFJS.LegacyPromise();
|
||||
transport = new WorkerTransport(workerInitializedPromise,
|
||||
workerReadyPromise, pdfDataRangeTransport, progressCallback);
|
||||
transport = new WorkerTransport(workerInitializedPromise, workerReadyPromise,
|
||||
pdfDataRangeTransport, progressCallback);
|
||||
workerInitializedPromise.then(function transportInitialized() {
|
||||
transport.passwordCallback = passwordCallback;
|
||||
transport.fetchDocument(params);
|
||||
@ -287,7 +289,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||
var metadata = this.pdfInfo.metadata;
|
||||
promise.resolve({
|
||||
info: info,
|
||||
metadata: metadata ? new PDFJS.Metadata(metadata) : null
|
||||
metadata: (metadata ? new PDFJS.Metadata(metadata) : null)
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
@ -387,8 +389,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
* with transforms required for rendering.
|
||||
*/
|
||||
getViewport: function PDFPageProxy_getViewport(scale, rotate) {
|
||||
if (arguments.length < 2)
|
||||
if (arguments.length < 2) {
|
||||
rotate = this.rotate;
|
||||
}
|
||||
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0);
|
||||
},
|
||||
/**
|
||||
@ -396,8 +399,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
* annotation objects.
|
||||
*/
|
||||
getAnnotations: function PDFPageProxy_getAnnotations() {
|
||||
if (this.annotationsPromise)
|
||||
if (this.annotationsPromise) {
|
||||
return this.annotationsPromise;
|
||||
}
|
||||
|
||||
var promise = new PDFJS.LegacyPromise();
|
||||
this.annotationsPromise = promise;
|
||||
@ -429,9 +433,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
// this call to render.
|
||||
this.pendingDestroy = false;
|
||||
|
||||
var renderingIntent = 'intent' in params ?
|
||||
(params.intent == 'print' ? 'print' : 'display') :
|
||||
'display';
|
||||
var renderingIntent = ('intent' in params ?
|
||||
(params.intent == 'print' ? 'print' : 'display') : 'display');
|
||||
|
||||
if (!this.intentStates[renderingIntent]) {
|
||||
this.intentStates[renderingIntent] = {};
|
||||
@ -457,9 +460,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
}
|
||||
|
||||
var internalRenderTask = new InternalRenderTask(complete, params,
|
||||
this.objs, this.commonObjs,
|
||||
intentState.operatorList,
|
||||
this.pageNumber);
|
||||
this.objs,
|
||||
this.commonObjs,
|
||||
intentState.operatorList,
|
||||
this.pageNumber);
|
||||
if (!intentState.renderTasks) {
|
||||
intentState.renderTasks = [];
|
||||
}
|
||||
@ -535,8 +539,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
if (!this.pendingDestroy ||
|
||||
Object.keys(this.intentStates).some(function(intent) {
|
||||
var intentState = this.intentStates[intent];
|
||||
return intentState.renderTasks.length !== 0 ||
|
||||
intentState.receivingOperatorList;
|
||||
return (intentState.renderTasks.length !== 0 ||
|
||||
intentState.receivingOperatorList);
|
||||
}, this)) {
|
||||
return;
|
||||
}
|
||||
@ -591,7 +595,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
*/
|
||||
var WorkerTransport = (function WorkerTransportClosure() {
|
||||
function WorkerTransport(workerInitializedPromise, workerReadyPromise,
|
||||
pdfDataRangeTransport, progressCallback) {
|
||||
pdfDataRangeTransport, progressCallback) {
|
||||
this.pdfDataRangeTransport = pdfDataRangeTransport;
|
||||
|
||||
this.workerReadyPromise = workerReadyPromise;
|
||||
@ -815,8 +819,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
messageHandler.on('commonobj', function transportObj(data) {
|
||||
var id = data[0];
|
||||
var type = data[1];
|
||||
if (this.commonObjs.hasData(id))
|
||||
if (this.commonObjs.hasData(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'Font':
|
||||
@ -893,17 +898,19 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
messageHandler.on('PageError', function transportError(data, intent) {
|
||||
var page = this.pageCache[data.pageNum - 1];
|
||||
var intentState = page.intentStates[intent];
|
||||
if (intentState.displayReadyPromise)
|
||||
if (intentState.displayReadyPromise) {
|
||||
intentState.displayReadyPromise.reject(data.error);
|
||||
else
|
||||
} else {
|
||||
error(data.error);
|
||||
}
|
||||
}, this);
|
||||
|
||||
messageHandler.on('JpegDecode', function(data, deferred) {
|
||||
var imageUrl = data[0];
|
||||
var components = data[1];
|
||||
if (components != 3 && components != 1)
|
||||
if (components != 3 && components != 1) {
|
||||
error('Only 3 component or 1 component can be returned');
|
||||
}
|
||||
|
||||
var img = new Image();
|
||||
img.onload = (function messageHandler_onloadClosure() {
|
||||
@ -963,8 +970,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
}
|
||||
|
||||
var pageIndex = pageNumber - 1;
|
||||
if (pageIndex in this.pagePromises)
|
||||
if (pageIndex in this.pagePromises) {
|
||||
return this.pagePromises[pageIndex];
|
||||
}
|
||||
var promise = new PDFJS.LegacyPromise();
|
||||
this.pagePromises[pageIndex] = promise;
|
||||
this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
|
||||
@ -1033,8 +1041,9 @@ var PDFObjects = (function PDFObjectsClosure() {
|
||||
* Ensures there is an object defined for `objId`.
|
||||
*/
|
||||
ensureObj: function PDFObjects_ensureObj(objId) {
|
||||
if (this.objs[objId])
|
||||
if (this.objs[objId]) {
|
||||
return this.objs[objId];
|
||||
}
|
||||
|
||||
var obj = {
|
||||
promise: new LegacyPromise(),
|
||||
@ -1069,8 +1078,9 @@ var PDFObjects = (function PDFObjectsClosure() {
|
||||
|
||||
// If there isn't an object yet or the object isn't resolved, then the
|
||||
// data isn't ready yet!
|
||||
if (!obj || !obj.resolved)
|
||||
if (!obj || !obj.resolved) {
|
||||
error('Requesting object that isn\'t resolved yet ' + objId);
|
||||
}
|
||||
|
||||
return obj.data;
|
||||
},
|
||||
|
@ -297,7 +297,9 @@ function compileType3Glyph(imgData) {
|
||||
var type = points[p], p0 = p, pp;
|
||||
do {
|
||||
var step = steps[type];
|
||||
do { p += step; } while (!points[p]);
|
||||
do {
|
||||
p += step;
|
||||
} while (!points[p]);
|
||||
|
||||
pp = points[p];
|
||||
if (pp !== 5 && pp !== 10) {
|
||||
@ -976,8 +978,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
||||
var ctx = this.ctx;
|
||||
var strokeColor = this.current.strokeColor;
|
||||
if (this.current.lineWidth === 0)
|
||||
if (this.current.lineWidth === 0) {
|
||||
ctx.lineWidth = this.getSinglePixelWidth();
|
||||
}
|
||||
// For stroke we want to temporarily change the global alpha to the
|
||||
// stroking alpha.
|
||||
ctx.globalAlpha = this.current.strokeAlpha;
|
||||
@ -992,8 +995,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
} else {
|
||||
ctx.stroke();
|
||||
}
|
||||
if (consumePath)
|
||||
if (consumePath) {
|
||||
this.consumePath();
|
||||
}
|
||||
// Restore the global alpha to the fill alpha
|
||||
ctx.globalAlpha = this.current.fillAlpha;
|
||||
},
|
||||
@ -1117,11 +1121,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
var fontObj = this.commonObjs.get(fontRefName);
|
||||
var current = this.current;
|
||||
|
||||
if (!fontObj)
|
||||
if (!fontObj) {
|
||||
error('Can\'t find font for ' + fontRefName);
|
||||
}
|
||||
|
||||
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix :
|
||||
FONT_IDENTITY_MATRIX;
|
||||
current.fontMatrix = (fontObj.fontMatrix ?
|
||||
fontObj.fontMatrix : FONT_IDENTITY_MATRIX);
|
||||
|
||||
// A valid matrix needs all main diagonal elements to be non-zero
|
||||
// This also ensures we bypass FF bugzilla bug #719844.
|
||||
@ -1142,8 +1147,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
this.current.font = fontObj;
|
||||
this.current.fontSize = size;
|
||||
|
||||
if (fontObj.coded)
|
||||
if (fontObj.coded) {
|
||||
return; // we don't need ctx.font for Type3 fonts
|
||||
}
|
||||
|
||||
var name = fontObj.loadedName || 'sans-serif';
|
||||
var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') :
|
||||
@ -1362,13 +1368,15 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
var lineWidth = current.lineWidth;
|
||||
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
|
||||
var scale = Math.sqrt(a1 * a1 + b1 * b1);
|
||||
if (scale === 0 || lineWidth === 0)
|
||||
if (scale === 0 || lineWidth === 0) {
|
||||
lineWidth = this.getSinglePixelWidth();
|
||||
else
|
||||
} else {
|
||||
lineWidth /= scale;
|
||||
}
|
||||
|
||||
if (textSelection)
|
||||
if (textSelection) {
|
||||
geom = this.createTextGeometry();
|
||||
}
|
||||
|
||||
if (fontSizeScale != 1.0) {
|
||||
ctx.scale(fontSizeScale, fontSizeScale);
|
||||
@ -1490,8 +1498,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
current.x += spacingLength;
|
||||
}
|
||||
|
||||
if (textSelection)
|
||||
if (textSelection) {
|
||||
spacingAccumulator += spacingLength;
|
||||
}
|
||||
} else {
|
||||
var shownCanvasWidth = this.showText(e, true);
|
||||
|
||||
@ -1695,8 +1704,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
this.save();
|
||||
this.baseTransformStack.push(this.baseTransform);
|
||||
|
||||
if (matrix && isArray(matrix) && 6 == matrix.length)
|
||||
if (matrix && isArray(matrix) && 6 == matrix.length) {
|
||||
this.transform.apply(this, matrix);
|
||||
}
|
||||
|
||||
this.baseTransform = this.ctx.mozCurrentTransform;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user