Browse Source

Updated pdf.js to 1.0.1040

pull/198/head
Joachim Bauch 10 years ago
parent
commit
b448296ed0
  1. 249
      static/js/libs/pdf/pdf.js
  2. 841
      static/js/libs/pdf/pdf.worker.js

249
static/js/libs/pdf/pdf.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.907'; PDFJS.version = '1.0.1040';
PDFJS.build = 'e9072ac'; PDFJS.build = '997096f';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -601,10 +601,10 @@ var Util = PDFJS.Util = (function UtilClosure() {
// makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids // makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
// creating many intermediate strings. // creating many intermediate strings.
Util.makeCssRgb = function Util_makeCssRgb(rgb) { Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
rgbBuf[1] = rgb[0]; rgbBuf[1] = r;
rgbBuf[3] = rgb[1]; rgbBuf[3] = g;
rgbBuf[5] = rgb[2]; rgbBuf[5] = b;
return rgbBuf.join(''); return rgbBuf.join('');
}; };
@ -3111,9 +3111,17 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
// Minimal font size that would be used during canvas fillText operations. // Minimal font size that would be used during canvas fillText operations.
var MIN_FONT_SIZE = 16; var MIN_FONT_SIZE = 16;
// Maximum font size that would be used during canvas fillText operations.
var MAX_FONT_SIZE = 100;
var MAX_GROUP_SIZE = 4096; var MAX_GROUP_SIZE = 4096;
// Heuristic value used when enforcing minimum line widths.
var MIN_WIDTH_FACTOR = 0.65;
var COMPILE_TYPE3_GLYPHS = true; var COMPILE_TYPE3_GLYPHS = true;
var MAX_SIZE_TO_COMPILE = 1000;
var FULL_CHUNK_HEIGHT = 16;
function createScratchCanvas(width, height) { function createScratchCanvas(width, height) {
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
@ -3247,7 +3255,7 @@ var CachedCanvases = (function CachedCanvasesClosure() {
getCanvas: function CachedCanvases_getCanvas(id, width, height, getCanvas: function CachedCanvases_getCanvas(id, width, height,
trackTransform) { trackTransform) {
var canvasEntry; var canvasEntry;
if (id in cache) { if (cache[id] !== undefined) {
canvasEntry = cache[id]; canvasEntry = cache[id];
canvasEntry.canvas.width = width; canvasEntry.canvas.width = width;
canvasEntry.canvas.height = height; canvasEntry.canvas.height = height;
@ -3461,6 +3469,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
// Default fore and background colors // Default fore and background colors
this.fillColor = '#000000'; this.fillColor = '#000000';
this.strokeColor = '#000000'; this.strokeColor = '#000000';
this.patternFill = false;
// Note: fill alpha applies to all non-stroking operations // Note: fill alpha applies to all non-stroking operations
this.fillAlpha = 1; this.fillAlpha = 1;
this.strokeAlpha = 1; this.strokeAlpha = 1;
@ -3513,6 +3522,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (canvasCtx) { if (canvasCtx) {
addContextCurrentTransform(canvasCtx); addContextCurrentTransform(canvasCtx);
} }
this.cachedGetSinglePixelWidth = null;
} }
function putBinaryImageData(ctx, imgData) { function putBinaryImageData(ctx, imgData) {
@ -3533,13 +3543,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// that's ok; any such pixels are ignored. // that's ok; any such pixels are ignored.
var height = imgData.height, width = imgData.width; var height = imgData.height, width = imgData.width;
var fullChunkHeight = 16; var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
var fracChunks = height / fullChunkHeight; var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
var fullChunks = Math.floor(fracChunks); var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
var totalChunks = Math.ceil(fracChunks);
var partialChunkHeight = height - fullChunks * fullChunkHeight;
var chunkImgData = ctx.createImageData(width, fullChunkHeight); var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
var srcPos = 0, destPos; var srcPos = 0, destPos;
var src = imgData.data; var src = imgData.data;
var dest = chunkImgData.data; var dest = chunkImgData.data;
@ -3559,7 +3567,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
0xFF000000 : 0x000000FF; 0xFF000000 : 0x000000FF;
for (i = 0; i < totalChunks; i++) { for (i = 0; i < totalChunks; i++) {
thisChunkHeight = thisChunkHeight =
(i < fullChunks) ? fullChunkHeight : partialChunkHeight; (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
destPos = 0; destPos = 0;
for (j = 0; j < thisChunkHeight; j++) { for (j = 0; j < thisChunkHeight; j++) {
var srcDiff = srcLength - srcPos; var srcDiff = srcLength - srcPos;
@ -3594,19 +3602,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
dest32[destPos++] = 0; dest32[destPos++] = 0;
} }
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
} }
} else if (imgData.kind === ImageKind.RGBA_32BPP) { } else if (imgData.kind === ImageKind.RGBA_32BPP) {
// RGBA, 32-bits per pixel. // RGBA, 32-bits per pixel.
j = 0; j = 0;
elemsInThisChunk = width * fullChunkHeight * 4; elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
for (i = 0; i < fullChunks; i++) { for (i = 0; i < fullChunks; i++) {
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
srcPos += elemsInThisChunk; srcPos += elemsInThisChunk;
ctx.putImageData(chunkImgData, 0, j); ctx.putImageData(chunkImgData, 0, j);
j += fullChunkHeight; j += FULL_CHUNK_HEIGHT;
} }
if (i < totalChunks) { if (i < totalChunks) {
elemsInThisChunk = width * partialChunkHeight * 4; elemsInThisChunk = width * partialChunkHeight * 4;
@ -3616,11 +3624,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} else if (imgData.kind === ImageKind.RGB_24BPP) { } else if (imgData.kind === ImageKind.RGB_24BPP) {
// RGB, 24-bits per pixel. // RGB, 24-bits per pixel.
thisChunkHeight = fullChunkHeight; thisChunkHeight = FULL_CHUNK_HEIGHT;
elemsInThisChunk = width * thisChunkHeight; elemsInThisChunk = width * thisChunkHeight;
for (i = 0; i < totalChunks; i++) { for (i = 0; i < totalChunks; i++) {
if (i >= fullChunks) { if (i >= fullChunks) {
thisChunkHeight =partialChunkHeight; thisChunkHeight = partialChunkHeight;
elemsInThisChunk = width * thisChunkHeight; elemsInThisChunk = width * thisChunkHeight;
} }
@ -3631,7 +3639,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
dest[destPos++] = src[srcPos++]; dest[destPos++] = src[srcPos++];
dest[destPos++] = 255; dest[destPos++] = 255;
} }
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
} }
} else { } else {
error('bad image kind: ' + imgData.kind); error('bad image kind: ' + imgData.kind);
@ -3640,20 +3648,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
function putBinaryImageMask(ctx, imgData) { function putBinaryImageMask(ctx, imgData) {
var height = imgData.height, width = imgData.width; var height = imgData.height, width = imgData.width;
var fullChunkHeight = 16; var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
var fracChunks = height / fullChunkHeight; var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
var fullChunks = Math.floor(fracChunks); var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
var totalChunks = Math.ceil(fracChunks);
var partialChunkHeight = height - fullChunks * fullChunkHeight;
var chunkImgData = ctx.createImageData(width, fullChunkHeight); var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
var srcPos = 0; var srcPos = 0;
var src = imgData.data; var src = imgData.data;
var dest = chunkImgData.data; var dest = chunkImgData.data;
for (var i = 0; i < totalChunks; i++) { for (var i = 0; i < totalChunks; i++) {
var thisChunkHeight = var thisChunkHeight =
(i < fullChunks) ? fullChunkHeight : partialChunkHeight; (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
// Expand the mask so it can be used by the canvas. Any required // Expand the mask so it can be used by the canvas. Any required
// inversion has already been handled. // inversion has already been handled.
@ -3670,7 +3676,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
mask >>= 1; mask >>= 1;
} }
} }
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight); ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
} }
} }
@ -3680,14 +3686,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
'globalCompositeOperation', 'font']; 'globalCompositeOperation', 'font'];
for (var i = 0, ii = properties.length; i < ii; i++) { for (var i = 0, ii = properties.length; i < ii; i++) {
var property = properties[i]; var property = properties[i];
if (property in sourceCtx) { if (sourceCtx[property] !== undefined) {
destCtx[property] = sourceCtx[property]; destCtx[property] = sourceCtx[property];
} }
} }
if ('setLineDash' in sourceCtx) { if (sourceCtx.setLineDash !== undefined) {
destCtx.setLineDash(sourceCtx.getLineDash()); destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset; destCtx.lineDashOffset = sourceCtx.lineDashOffset;
} else if ('mozDash' in sourceCtx) { } else if (sourceCtx.mozDashOffset !== undefined) {
destCtx.mozDash = sourceCtx.mozDash; destCtx.mozDash = sourceCtx.mozDash;
destCtx.mozDashOffset = sourceCtx.mozDashOffset; destCtx.mozDashOffset = sourceCtx.mozDashOffset;
} }
@ -3722,9 +3728,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
function composeSMaskLuminosity(maskData, layerData) { function composeSMaskLuminosity(maskData, layerData) {
var length = maskData.length; var length = maskData.length;
for (var i = 3; i < length; i += 4) { for (var i = 3; i < length; i += 4) {
var y = ((maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000 var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
(maskData[i - 2] * 152) + // * 0.59 .... (maskData[i - 2] * 152) + // * 0.59 ....
(maskData[i - 1] * 28)) | 0; // * 0.11 .... (maskData[i - 1] * 28); // * 0.11 ....
layerData[i] = (layerData[i] * y) >> 16; layerData[i] = (layerData[i] * y) >> 16;
} }
} }
@ -3744,7 +3750,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} }
// processing image in chunks to save memory // processing image in chunks to save memory
var PIXELS_TO_PROCESS = 65536; var PIXELS_TO_PROCESS = 1048576;
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width)); var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
for (var row = 0; row < height; row += chunkSize) { for (var row = 0; row < height; row += chunkSize) {
var chunkHeight = Math.min(chunkSize, height - row); var chunkHeight = Math.min(chunkSize, height - row);
@ -3914,7 +3920,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}, },
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) { setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
var ctx = this.ctx; var ctx = this.ctx;
if ('setLineDash' in ctx) { if (ctx.setLineDash !== undefined) {
ctx.setLineDash(dashArray); ctx.setLineDash(dashArray);
ctx.lineDashOffset = dashPhase; ctx.lineDashOffset = dashPhase;
} else { } else {
@ -4049,10 +4055,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current = this.stateStack.pop(); this.current = this.stateStack.pop();
this.ctx.restore(); this.ctx.restore();
this.cachedGetSinglePixelWidth = null;
} }
}, },
transform: function CanvasGraphics_transform(a, b, c, d, e, f) { transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
this.ctx.transform(a, b, c, d, e, f); this.ctx.transform(a, b, c, d, e, f);
this.cachedGetSinglePixelWidth = null;
}, },
// Path // Path
@ -4126,9 +4136,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx; var ctx = this.ctx;
var strokeColor = this.current.strokeColor; var strokeColor = this.current.strokeColor;
if (this.current.lineWidth === 0) { // Prevent drawing too thin lines by enforcing a minimum line width.
ctx.lineWidth = this.getSinglePixelWidth(); ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
} this.current.lineWidth);
// For stroke we want to temporarily change the global alpha to the // For stroke we want to temporarily change the global alpha to the
// stroking alpha. // stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha; ctx.globalAlpha = this.current.strokeAlpha;
@ -4157,10 +4167,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor; var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
var needRestore = false; var needRestore = false;
if (fillColor && fillColor.hasOwnProperty('type') && if (isPatternFill) {
fillColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx, this); ctx.fillStyle = fillColor.getPattern(ctx, this);
needRestore = true; needRestore = true;
@ -4311,9 +4321,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// Keeping the font at minimal size and using the fontSizeScale to change // Keeping the font at minimal size and using the fontSizeScale to change
// the current transformation matrix before the fillText/strokeText. // the current transformation matrix before the fillText/strokeText.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227 // See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
var browserFontSize = size >= MIN_FONT_SIZE ? size : MIN_FONT_SIZE; var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE :
this.current.fontSizeScale = browserFontSize !== MIN_FONT_SIZE ? 1.0 : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
size / MIN_FONT_SIZE; this.current.fontSizeScale = size / browserFontSize;
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
this.ctx.font = rule; this.ctx.font = rule;
@ -4453,7 +4463,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var lineWidth = current.lineWidth; var lineWidth = current.lineWidth;
var scale = current.textMatrixScale; var scale = current.textMatrixScale;
if (scale === 0 || lineWidth === 0) { if (scale === 0 || lineWidth === 0) {
lineWidth = this.getSinglePixelWidth(); var fillStrokeMode = current.textRenderingMode &
TextRenderingMode.FILL_STROKE_MASK;
if (fillStrokeMode === TextRenderingMode.STROKE ||
fillStrokeMode === TextRenderingMode.FILL_STROKE) {
this.cachedGetSinglePixelWidth = null;
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
}
} else { } else {
lineWidth /= scale; lineWidth /= scale;
} }
@ -4548,9 +4564,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var textHScale = current.textHScale * fontDirection; var textHScale = current.textHScale * fontDirection;
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX; var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
var glyphsLength = glyphs.length; var glyphsLength = glyphs.length;
var isTextInvisible =
current.textRenderingMode === TextRenderingMode.INVISIBLE;
var i, glyph, width; var i, glyph, width;
if (fontSize === 0) { if (isTextInvisible || fontSize === 0) {
return; return;
} }
@ -4632,16 +4650,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}, },
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) { setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
this.current.fillColor = this.getColorN_Pattern(arguments); this.current.fillColor = this.getColorN_Pattern(arguments);
this.current.patternFill = true;
}, },
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.ctx.strokeStyle = color; this.ctx.strokeStyle = color;
this.current.strokeColor = color; this.current.strokeColor = color;
}, },
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.ctx.fillStyle = color; this.ctx.fillStyle = color;
this.current.fillColor = color; this.current.fillColor = color;
this.current.patternFill = false;
}, },
shadingFill: function CanvasGraphics_shadingFill(patternIR) { shadingFill: function CanvasGraphics_shadingFill(patternIR) {
@ -4900,11 +4920,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) { paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
var ctx = this.ctx; var ctx = this.ctx;
var width = img.width, height = img.height; var width = img.width, height = img.height;
var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
var glyph = this.processingType3; var glyph = this.processingType3;
if (COMPILE_TYPE3_GLYPHS && glyph && !('compiled' in glyph)) { if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
var MAX_SIZE_TO_COMPILE = 1000;
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) { if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
glyph.compiled = glyph.compiled =
compileType3Glyph({data: img.data, width: width, height: height}); compileType3Glyph({data: img.data, width: width, height: height});
@ -4926,9 +4947,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
maskCtx.globalCompositeOperation = 'source-in'; maskCtx.globalCompositeOperation = 'source-in';
var fillColor = this.current.fillColor; maskCtx.fillStyle = isPatternFill ?
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') ?
fillColor.getPattern(maskCtx, this) : fillColor; fillColor.getPattern(maskCtx, this) : fillColor;
maskCtx.fillRect(0, 0, width, height); maskCtx.fillRect(0, 0, width, height);
@ -4942,7 +4961,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
scaleY, positions) { scaleY, positions) {
var width = imgData.width; var width = imgData.width;
var height = imgData.height; var height = imgData.height;
var ctx = this.ctx; var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height); var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
var maskCtx = maskCanvas.context; var maskCtx = maskCanvas.context;
@ -4952,14 +4972,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
maskCtx.globalCompositeOperation = 'source-in'; maskCtx.globalCompositeOperation = 'source-in';
var fillColor = this.current.fillColor; maskCtx.fillStyle = isPatternFill ?
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') && fillColor.getPattern(maskCtx, this) : fillColor;
fillColor.type === 'Pattern') ?
fillColor.getPattern(maskCtx, this) : fillColor;
maskCtx.fillRect(0, 0, width, height); maskCtx.fillRect(0, 0, width, height);
maskCtx.restore(); maskCtx.restore();
var ctx = this.ctx;
for (var i = 0, ii = positions.length; i < ii; i += 2) { for (var i = 0, ii = positions.length; i < ii; i += 2) {
ctx.save(); ctx.save();
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]); ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
@ -4974,6 +4993,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
function CanvasGraphics_paintImageMaskXObjectGroup(images) { function CanvasGraphics_paintImageMaskXObjectGroup(images) {
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
for (var i = 0, ii = images.length; i < ii; i++) { for (var i = 0, ii = images.length; i < ii; i++) {
var image = images[i]; var image = images[i];
var width = image.width, height = image.height; var width = image.width, height = image.height;
@ -4986,9 +5007,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
maskCtx.globalCompositeOperation = 'source-in'; maskCtx.globalCompositeOperation = 'source-in';
var fillColor = this.current.fillColor; maskCtx.fillStyle = isPatternFill ?
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') ?
fillColor.getPattern(maskCtx, this) : fillColor; fillColor.getPattern(maskCtx, this) : fillColor;
maskCtx.fillRect(0, 0, width, height); maskCtx.fillRect(0, 0, width, height);
@ -5191,11 +5210,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
ctx.beginPath(); ctx.beginPath();
}, },
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
var inverse = this.ctx.mozCurrentTransformInverse; if (this.cachedGetSinglePixelWidth === null) {
// max of the current horizontal and vertical scale var inverse = this.ctx.mozCurrentTransformInverse;
return Math.sqrt(Math.max( // max of the current horizontal and vertical scale
(inverse[0] * inverse[0] + inverse[1] * inverse[1]), this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(
(inverse[2] * inverse[2] + inverse[3] * inverse[3]))); (inverse[0] * inverse[0] + inverse[1] * inverse[1]),
(inverse[2] * inverse[2] + inverse[3] * inverse[3])));
}
return this.cachedGetSinglePixelWidth;
}, },
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
var transform = this.ctx.mozCurrentTransform; var transform = this.ctx.mozCurrentTransform;
@ -5263,7 +5285,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
} }
var currentGL, currentCanvas; var currentGL, currentCanvas;
function generageGL() { function generateGL() {
if (currentGL) { if (currentGL) {
return; return;
} }
@ -5321,7 +5343,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
function initSmaskGL() { function initSmaskGL() {
var canvas, gl; var canvas, gl;
generageGL(); generateGL();
canvas = currentCanvas; canvas = currentCanvas;
currentCanvas = null; currentCanvas = null;
gl = currentGL; gl = currentGL;
@ -5453,7 +5475,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
function initFiguresGL() { function initFiguresGL() {
var canvas, gl; var canvas, gl;
generageGL(); generateGL();
canvas = currentCanvas; canvas = currentCanvas;
currentCanvas = null; currentCanvas = null;
gl = currentGL; gl = currentGL;
@ -5621,7 +5643,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
} }
var enabled = false; var enabled = false;
try { try {
generageGL(); generateGL();
enabled = !!currentGL; enabled = !!currentGL;
} catch (e) { } } catch (e) { }
return shadow(this, 'isEnabled', enabled); return shadow(this, 'isEnabled', enabled);
@ -6014,7 +6036,7 @@ var TilingPattern = (function TilingPatternClosure() {
context.strokeStyle = ctx.strokeStyle; context.strokeStyle = ctx.strokeStyle;
break; break;
case PaintType.UNCOLORED: case PaintType.UNCOLORED:
var cssColor = Util.makeCssRgb(color); var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
context.fillStyle = cssColor; context.fillStyle = cssColor;
context.strokeStyle = cssColor; context.strokeStyle = cssColor;
break; break;
@ -6373,7 +6395,6 @@ var FontFaceObject = (function FontFaceObjectClosure() {
})(); })();
var HIGHLIGHT_OFFSET = 4; // px
var ANNOT_MIN_SIZE = 10; // px var ANNOT_MIN_SIZE = 10; // px
var AnnotationUtils = (function AnnotationUtilsClosure() { var AnnotationUtils = (function AnnotationUtilsClosure() {
@ -6400,43 +6421,36 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
style.fontFamily = fontFamily + fallbackName; style.fontFamily = fontFamily + fallbackName;
} }
// TODO(mack): Remove this, it's not really that helpful. function initContainer(item, drawBorder) {
function getEmptyContainer(tagName, rect, borderWidth) { var container = document.createElement('section');
var bWidth = borderWidth || 0; var cstyle = container.style;
var element = document.createElement(tagName); var width = item.rect[2] - item.rect[0];
element.style.borderWidth = bWidth + 'px'; var height = item.rect[3] - item.rect[1];
var width = rect[2] - rect[0] - 2 * bWidth;
var height = rect[3] - rect[1] - 2 * bWidth; var bWidth = item.borderWidth || 0;
element.style.width = width + 'px'; if (bWidth) {
element.style.height = height + 'px'; width = width - 2 * bWidth;
return element; height = height - 2 * bWidth;
} cstyle.borderWidth = bWidth + 'px';
var color = item.color;
function initContainer(item) { if (drawBorder && color) {
var container = getEmptyContainer('section', item.rect, item.borderWidth); cstyle.borderStyle = 'solid';
container.style.backgroundColor = item.color; cstyle.borderColor = Util.makeCssRgb(Math.round(color[0] * 255),
Math.round(color[1] * 255),
var color = item.color; Math.round(color[2] * 255));
var rgb = []; }
for (var i = 0; i < 3; ++i) {
rgb[i] = Math.round(color[i] * 255);
} }
item.colorCssRgb = Util.makeCssRgb(rgb); cstyle.width = width + 'px';
cstyle.height = height + 'px';
var highlight = document.createElement('div');
highlight.className = 'annotationHighlight';
highlight.style.left = highlight.style.top = -HIGHLIGHT_OFFSET + 'px';
highlight.style.right = highlight.style.bottom = -HIGHLIGHT_OFFSET + 'px';
highlight.setAttribute('hidden', true);
item.highlightElement = highlight;
container.appendChild(item.highlightElement);
return container; return container;
} }
function getHtmlElementForTextWidgetAnnotation(item, commonObjs) { function getHtmlElementForTextWidgetAnnotation(item, commonObjs) {
var element = getEmptyContainer('div', item.rect, 0); var element = document.createElement('div');
var width = item.rect[2] - item.rect[0];
var height = item.rect[3] - item.rect[1];
element.style.width = width + 'px';
element.style.height = height + 'px';
element.style.display = 'table'; element.style.display = 'table';
var content = document.createElement('div'); var content = document.createElement('div');
@ -6466,7 +6480,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
} }
var container = initContainer(item); var container = initContainer(item, false);
container.className = 'annotText'; container.className = 'annotText';
var image = document.createElement('img'); var image = document.createElement('img');
@ -6491,13 +6505,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
var i, ii; var i, ii;
if (item.hasBgColor) { if (item.hasBgColor) {
var color = item.color; var color = item.color;
var rgb = [];
for (i = 0; i < 3; ++i) { // Enlighten the color (70%)
// Enlighten the color (70%) var BACKGROUND_ENLIGHT = 0.7;
var c = Math.round(color[i] * 255); var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
rgb[i] = Math.round((255 - c) * 0.7) + c; var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];
} var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];
content.style.backgroundColor = Util.makeCssRgb(rgb); content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,
(g * 255) | 0,
(b * 255) | 0);
} }
var title = document.createElement('h1'); var title = document.createElement('h1');
@ -6573,12 +6589,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
} }
function getHtmlElementForLinkAnnotation(item) { function getHtmlElementForLinkAnnotation(item) {
var container = initContainer(item); var container = initContainer(item, true);
container.className = 'annotLink'; container.className = 'annotLink';
container.style.borderColor = item.colorCssRgb;
container.style.borderStyle = 'solid';
var link = document.createElement('a'); var link = document.createElement('a');
link.href = link.title = item.url || ''; link.href = link.title = item.url || '';
@ -7409,11 +7422,11 @@ var SVGGraphics = (function SVGGraphicsClosure() {
this.current.miterLimit = limit; this.current.miterLimit = limit;
}, },
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.current.strokeColor = color; this.current.strokeColor = color;
}, },
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) { setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.current.fillColor = color; this.current.fillColor = color;
this.current.tspan = document.createElementNS(NS, 'svg:tspan'); this.current.tspan = document.createElementNS(NS, 'svg:tspan');
this.current.xcoords = []; this.current.xcoords = [];

841
static/js/libs/pdf/pdf.worker.js vendored

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save