Fixes lint warning W004 in src/display/{api, canvas, pattern_helper}.js
This commit is contained in:
parent
df91acf239
commit
4e055169ed
@ -596,8 +596,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
_renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk,
|
_renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk,
|
||||||
intent) {
|
intent) {
|
||||||
var intentState = this.intentStates[intent];
|
var intentState = this.intentStates[intent];
|
||||||
|
var i, ii;
|
||||||
// Add the new chunk to the current operator list.
|
// Add the new chunk to the current operator list.
|
||||||
for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
|
for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
|
||||||
intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
|
intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
|
||||||
intentState.operatorList.argsArray.push(
|
intentState.operatorList.argsArray.push(
|
||||||
operatorListChunk.argsArray[i]);
|
operatorListChunk.argsArray[i]);
|
||||||
@ -605,7 +606,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
|
intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
|
||||||
|
|
||||||
// Notify all the rendering tasks there are more operators to be consumed.
|
// Notify all the rendering tasks there are more operators to be consumed.
|
||||||
for (var i = 0; i < intentState.renderTasks.length; i++) {
|
for (i = 0; i < intentState.renderTasks.length; i++) {
|
||||||
intentState.renderTasks[i].operatorListChanged();
|
intentState.renderTasks[i].operatorListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,17 +887,18 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
var pageIndex = data[1];
|
var pageIndex = data[1];
|
||||||
var type = data[2];
|
var type = data[2];
|
||||||
var pageProxy = this.pageCache[pageIndex];
|
var pageProxy = this.pageCache[pageIndex];
|
||||||
|
var imageData;
|
||||||
if (pageProxy.objs.hasData(id)) {
|
if (pageProxy.objs.hasData(id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'JpegStream':
|
case 'JpegStream':
|
||||||
var imageData = data[3];
|
imageData = data[3];
|
||||||
loadJpegStream(id, imageData, pageProxy.objs);
|
loadJpegStream(id, imageData, pageProxy.objs);
|
||||||
break;
|
break;
|
||||||
case 'Image':
|
case 'Image':
|
||||||
var imageData = data[3];
|
imageData = data[3];
|
||||||
pageProxy.objs.resolve(id, imageData);
|
pageProxy.objs.resolve(id, imageData);
|
||||||
|
|
||||||
// heuristics that will allow not to store large data
|
// heuristics that will allow not to store large data
|
||||||
@ -952,15 +954,16 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
var tmpCtx = tmpCanvas.getContext('2d');
|
var tmpCtx = tmpCanvas.getContext('2d');
|
||||||
tmpCtx.drawImage(img, 0, 0);
|
tmpCtx.drawImage(img, 0, 0);
|
||||||
var data = tmpCtx.getImageData(0, 0, width, height).data;
|
var data = tmpCtx.getImageData(0, 0, width, height).data;
|
||||||
|
var i, j;
|
||||||
|
|
||||||
if (components == 3) {
|
if (components == 3) {
|
||||||
for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
|
for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
|
||||||
buf[j] = data[i];
|
buf[j] = data[i];
|
||||||
buf[j + 1] = data[i + 1];
|
buf[j + 1] = data[i + 1];
|
||||||
buf[j + 2] = data[i + 2];
|
buf[j + 2] = data[i + 2];
|
||||||
}
|
}
|
||||||
} else if (components == 1) {
|
} else if (components == 1) {
|
||||||
for (var i = 0, j = 0; i < rgbaLength; i += 4, j++) {
|
for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
|
||||||
buf[j] = data[i];
|
buf[j] = data[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1003,7 +1006,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
if (pageIndex in this.pagePromises) {
|
if (pageIndex in this.pagePromises) {
|
||||||
return this.pagePromises[pageIndex];
|
return this.pagePromises[pageIndex];
|
||||||
}
|
}
|
||||||
var promise = new PDFJS.LegacyPromise();
|
promise = new PDFJS.LegacyPromise();
|
||||||
this.pagePromises[pageIndex] = promise;
|
this.pagePromises[pageIndex] = promise;
|
||||||
this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
|
this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -453,13 +453,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var partialChunkHeight = height - fullChunks * fullChunkHeight;
|
var partialChunkHeight = height - fullChunks * fullChunkHeight;
|
||||||
|
|
||||||
var chunkImgData = ctx.createImageData(width, fullChunkHeight);
|
var chunkImgData = ctx.createImageData(width, fullChunkHeight);
|
||||||
var srcPos = 0;
|
var srcPos = 0, destPos;
|
||||||
var src = imgData.data;
|
var src = imgData.data;
|
||||||
var dest = chunkImgData.data;
|
var dest = chunkImgData.data;
|
||||||
|
var i, j, thisChunkHeight, elemsInThisChunk;
|
||||||
|
|
||||||
// There are multiple forms in which the pixel data can be passed, and
|
// There are multiple forms in which the pixel data can be passed, and
|
||||||
// imgData.kind tells us which one this is.
|
// imgData.kind tells us which one this is.
|
||||||
|
|
||||||
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
|
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
|
||||||
// Grayscale, 1 bit per pixel (i.e. black-and-white).
|
// Grayscale, 1 bit per pixel (i.e. black-and-white).
|
||||||
var destDataLength = dest.length;
|
var destDataLength = dest.length;
|
||||||
@ -471,11 +471,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var white = 0xFFFFFFFF;
|
var white = 0xFFFFFFFF;
|
||||||
var black = (PDFJS.isLittleEndian || !PDFJS.hasCanvasTypedArrays) ?
|
var black = (PDFJS.isLittleEndian || !PDFJS.hasCanvasTypedArrays) ?
|
||||||
0xFF000000 : 0x000000FF;
|
0xFF000000 : 0x000000FF;
|
||||||
for (var i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
var thisChunkHeight =
|
thisChunkHeight =
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
||||||
var destPos = 0;
|
destPos = 0;
|
||||||
for (var j = 0; j < thisChunkHeight; j++) {
|
for (j = 0; j < thisChunkHeight; j++) {
|
||||||
var srcDiff = srcLength - srcPos;
|
var srcDiff = srcLength - srcPos;
|
||||||
var k = 0;
|
var k = 0;
|
||||||
var kEnd = (srcDiff > fullSrcDiff) ? width : srcDiff * 8 - 7;
|
var kEnd = (srcDiff > fullSrcDiff) ? width : srcDiff * 8 - 7;
|
||||||
@ -510,29 +510,27 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
||||||
// RGBA, 32-bits per pixel.
|
// RGBA, 32-bits per pixel.
|
||||||
|
|
||||||
for (var i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
var thisChunkHeight =
|
thisChunkHeight =
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
||||||
var elemsInThisChunk = imgData.width * thisChunkHeight * 4;
|
elemsInThisChunk = imgData.width * thisChunkHeight * 4;
|
||||||
|
|
||||||
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
||||||
srcPos += elemsInThisChunk;
|
srcPos += elemsInThisChunk;
|
||||||
|
|
||||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
||||||
// RGB, 24-bits per pixel.
|
// RGB, 24-bits per pixel.
|
||||||
for (var i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
var thisChunkHeight =
|
thisChunkHeight =
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
||||||
var elemsInThisChunk = imgData.width * thisChunkHeight * 3;
|
elemsInThisChunk = imgData.width * thisChunkHeight * 3;
|
||||||
var destPos = 0;
|
destPos = 0;
|
||||||
for (var j = 0; j < elemsInThisChunk; j += 3) {
|
for (j = 0; j < elemsInThisChunk; j += 3) {
|
||||||
dest[destPos++] = src[srcPos++];
|
dest[destPos++] = src[srcPos++];
|
||||||
dest[destPos++] = src[srcPos++];
|
dest[destPos++] = src[srcPos++];
|
||||||
dest[destPos++] = src[srcPos++];
|
dest[destPos++] = src[srcPos++];
|
||||||
@ -540,9 +538,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
}
|
}
|
||||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
error('bad image kind: ' + imgData.kind);
|
error('bad image kind: ' + imgData.kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1311,6 +1308,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var glyphsLength = glyphs.length;
|
var glyphsLength = glyphs.length;
|
||||||
var vertical = font.vertical;
|
var vertical = font.vertical;
|
||||||
var defaultVMetrics = font.defaultVMetrics;
|
var defaultVMetrics = font.defaultVMetrics;
|
||||||
|
var i, glyph, width;
|
||||||
|
var VERTICAL_TEXT_ROTATION = Math.PI / 2;
|
||||||
|
|
||||||
if (fontSize === 0) {
|
if (fontSize === 0) {
|
||||||
return;
|
return;
|
||||||
@ -1324,9 +1323,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
ctx.scale(textHScale, 1);
|
ctx.scale(textHScale, 1);
|
||||||
|
|
||||||
for (var i = 0; i < glyphsLength; ++i) {
|
for (i = 0; i < glyphsLength; ++i) {
|
||||||
|
glyph = glyphs[i];
|
||||||
var glyph = glyphs[i];
|
|
||||||
if (glyph === null) {
|
if (glyph === null) {
|
||||||
// word break
|
// word break
|
||||||
this.ctx.translate(wordSpacing, 0);
|
this.ctx.translate(wordSpacing, 0);
|
||||||
@ -1342,8 +1340,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
this.restore();
|
this.restore();
|
||||||
|
|
||||||
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
||||||
var width = (transformed[0] * fontSize + charSpacing) *
|
width = ((transformed[0] * fontSize + charSpacing) *
|
||||||
current.fontDirection;
|
current.fontDirection);
|
||||||
|
|
||||||
ctx.translate(width, 0);
|
ctx.translate(width, 0);
|
||||||
current.x += width * textHScale;
|
current.x += width * textHScale;
|
||||||
@ -1371,8 +1369,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
ctx.lineWidth = lineWidth;
|
ctx.lineWidth = lineWidth;
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
for (var i = 0; i < glyphsLength; ++i) {
|
for (i = 0; i < glyphsLength; ++i) {
|
||||||
var glyph = glyphs[i];
|
glyph = glyphs[i];
|
||||||
if (glyph === null) {
|
if (glyph === null) {
|
||||||
// word break
|
// word break
|
||||||
x += current.fontDirection * wordSpacing;
|
x += current.fontDirection * wordSpacing;
|
||||||
@ -1387,7 +1385,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
vx = -vx * fontSize * current.fontMatrix[0];
|
vx = -vx * fontSize * current.fontMatrix[0];
|
||||||
var vy = vmetric[2] * fontSize * current.fontMatrix[0];
|
var vy = vmetric[2] * fontSize * current.fontMatrix[0];
|
||||||
}
|
}
|
||||||
var width = vmetric ? -vmetric[0] : glyph.width;
|
width = vmetric ? -vmetric[0] : glyph.width;
|
||||||
var charWidth = width * fontSize * current.fontMatrix[0] +
|
var charWidth = width * fontSize * current.fontMatrix[0] +
|
||||||
charSpacing * current.fontDirection;
|
charSpacing * current.fontDirection;
|
||||||
var accent = glyph.accent;
|
var accent = glyph.accent;
|
||||||
@ -1509,6 +1507,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
this.current.strokeColor = color;
|
this.current.strokeColor = color;
|
||||||
},
|
},
|
||||||
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR, cs) {
|
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR, cs) {
|
||||||
|
var pattern;
|
||||||
if (IR[0] == 'TilingPattern') {
|
if (IR[0] == 'TilingPattern') {
|
||||||
var args = IR[1];
|
var args = IR[1];
|
||||||
var base = cs.base;
|
var base = cs.base;
|
||||||
@ -1518,10 +1517,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
color = base.getRgb(args, 0);
|
color = base.getRgb(args, 0);
|
||||||
}
|
}
|
||||||
var pattern = new TilingPattern(IR, color, this.ctx, this.objs,
|
pattern = new TilingPattern(IR, color, this.ctx, this.objs,
|
||||||
this.commonObjs, this.baseTransform);
|
this.commonObjs, this.baseTransform);
|
||||||
} else {
|
} else {
|
||||||
var pattern = getShadingPatternFromIR(IR);
|
pattern = getShadingPatternFromIR(IR);
|
||||||
}
|
}
|
||||||
return pattern;
|
return pattern;
|
||||||
},
|
},
|
||||||
@ -1999,12 +1998,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var c = currentTransform[2], d = currentTransform[3];
|
var c = currentTransform[2], d = currentTransform[3];
|
||||||
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
|
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
|
||||||
|
|
||||||
var imgToPaint;
|
var imgToPaint, tmpCanvas;
|
||||||
// instanceof HTMLElement does not work in jsdom node.js module
|
// instanceof HTMLElement does not work in jsdom node.js module
|
||||||
if (imgData instanceof HTMLElement || !imgData.data) {
|
if (imgData instanceof HTMLElement || !imgData.data) {
|
||||||
imgToPaint = imgData;
|
imgToPaint = imgData;
|
||||||
} else {
|
} else {
|
||||||
var tmpCanvas = CachedCanvases.getCanvas('inlineImage', width, height);
|
tmpCanvas = CachedCanvases.getCanvas('inlineImage', width, height);
|
||||||
var tmpCtx = tmpCanvas.context;
|
var tmpCtx = tmpCanvas.context;
|
||||||
putBinaryImageData(tmpCtx, imgData);
|
putBinaryImageData(tmpCtx, imgData);
|
||||||
imgToPaint = tmpCanvas.canvas;
|
imgToPaint = tmpCanvas.canvas;
|
||||||
@ -2026,8 +2025,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
newHeight = Math.ceil(paintHeight / 2);
|
newHeight = Math.ceil(paintHeight / 2);
|
||||||
heightScale /= paintHeight / newHeight;
|
heightScale /= paintHeight / newHeight;
|
||||||
}
|
}
|
||||||
var tmpCanvas = CachedCanvases.getCanvas(tmpCanvasId,
|
tmpCanvas = CachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
|
||||||
newWidth, newHeight);
|
|
||||||
tmpCtx = tmpCanvas.context;
|
tmpCtx = tmpCanvas.context;
|
||||||
tmpCtx.clearRect(0, 0, newWidth, newHeight);
|
tmpCtx.clearRect(0, 0, newWidth, newHeight);
|
||||||
tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight,
|
tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight,
|
||||||
|
@ -117,12 +117,13 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||||||
function drawFigure(data, figure, context) {
|
function drawFigure(data, figure, context) {
|
||||||
var ps = figure.coords;
|
var ps = figure.coords;
|
||||||
var cs = figure.colors;
|
var cs = figure.colors;
|
||||||
|
var i, ii;
|
||||||
switch (figure.type) {
|
switch (figure.type) {
|
||||||
case 'lattice':
|
case 'lattice':
|
||||||
var verticesPerRow = figure.verticesPerRow;
|
var verticesPerRow = figure.verticesPerRow;
|
||||||
var rows = Math.floor(ps.length / verticesPerRow) - 1;
|
var rows = Math.floor(ps.length / verticesPerRow) - 1;
|
||||||
var cols = verticesPerRow - 1;
|
var cols = verticesPerRow - 1;
|
||||||
for (var i = 0; i < rows; i++) {
|
for (i = 0; i < rows; i++) {
|
||||||
var q = i * verticesPerRow;
|
var q = i * verticesPerRow;
|
||||||
for (var j = 0; j < cols; j++, q++) {
|
for (var j = 0; j < cols; j++, q++) {
|
||||||
drawTriangle(data, context,
|
drawTriangle(data, context,
|
||||||
@ -135,7 +136,7 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'triangles':
|
case 'triangles':
|
||||||
for (var i = 0, ii = ps.length; i < ii; i += 3) {
|
for (i = 0, ii = ps.length; i < ii; i += 3) {
|
||||||
drawTriangle(data, context,
|
drawTriangle(data, context,
|
||||||
ps[i], ps[i + 1], ps[i + 2],
|
ps[i], ps[i + 1], ps[i + 2],
|
||||||
cs[i], cs[i + 1], cs[i + 2]);
|
cs[i], cs[i + 1], cs[i + 2]);
|
||||||
@ -414,7 +415,7 @@ var TilingPattern = (function TilingPatternClosure() {
|
|||||||
getPattern: function TilingPattern_getPattern(ctx, owner) {
|
getPattern: function TilingPattern_getPattern(ctx, owner) {
|
||||||
var temporaryPatternCanvas = this.createPatternCanvas(owner);
|
var temporaryPatternCanvas = this.createPatternCanvas(owner);
|
||||||
|
|
||||||
var ctx = this.ctx;
|
ctx = this.ctx;
|
||||||
ctx.setTransform.apply(ctx, this.baseTransform);
|
ctx.setTransform.apply(ctx, this.baseTransform);
|
||||||
ctx.transform.apply(ctx, this.matrix);
|
ctx.transform.apply(ctx, this.matrix);
|
||||||
this.scaleToContext();
|
this.scaleToContext();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user