Bug 1232015 - Update pdf.js to version 1.3.72. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2015-12-11 14:06:30 -05:00
parent fdc6fdcbf9
commit 014670ac32
4 changed files with 57 additions and 25 deletions

View File

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.3.56
Current extension version is: 1.3.72

View File

@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.3.56';
PDFJS.build = 'e2aca38';
PDFJS.version = '1.3.72';
PDFJS.build = '4d6f3c8';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -4030,27 +4030,29 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
}
function composeSMaskAlpha(maskData, layerData) {
function composeSMaskAlpha(maskData, layerData, transferMap) {
var length = maskData.length;
var scale = 1 / 255;
for (var i = 3; i < length; i += 4) {
var alpha = maskData[i];
var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
layerData[i] = (layerData[i] * alpha * scale) | 0;
}
}
function composeSMaskLuminosity(maskData, layerData) {
function composeSMaskLuminosity(maskData, layerData, transferMap) {
var length = maskData.length;
for (var i = 3; i < length; i += 4) {
var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
(maskData[i - 2] * 152) + // * 0.59 ....
(maskData[i - 1] * 28); // * 0.11 ....
layerData[i] = (layerData[i] * y) >> 16;
layerData[i] = transferMap ?
(layerData[i] * transferMap[y >> 8]) >> 8 :
(layerData[i] * y) >> 16;
}
}
function genericComposeSMask(maskCtx, layerCtx, width, height,
subtype, backdrop) {
subtype, backdrop, transferMap) {
var hasBackdrop = !!backdrop;
var r0 = hasBackdrop ? backdrop[0] : 0;
var g0 = hasBackdrop ? backdrop[1] : 0;
@ -4074,7 +4076,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (hasBackdrop) {
composeSMaskBackdrop(maskData.data, r0, g0, b0);
}
composeFn(maskData.data, layerData.data);
composeFn(maskData.data, layerData.data, transferMap);
maskCtx.putImageData(layerData, 0, row);
}
@ -4088,7 +4090,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
smask.offsetX, smask.offsetY);
var backdrop = smask.backdrop || null;
if (WebGLUtils.isEnabled) {
if (!smask.transferMap && WebGLUtils.isEnabled) {
var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask,
{subtype: smask.subtype, backdrop: backdrop});
ctx.setTransform(1, 0, 0, 1, 0, 0);
@ -4096,7 +4098,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return;
}
genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height,
smask.subtype, backdrop);
smask.subtype, backdrop, smask.transferMap);
ctx.drawImage(mask, 0, 0);
}
@ -4842,16 +4844,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
scaledY = 0;
}
if (font.remeasure && width > 0 && this.isFontSubpixelAAEnabled) {
// some standard fonts may not have the exact width, trying to
// rescale per character
if (font.remeasure && width > 0) {
// Some standard fonts may not have the exact width: rescale per
// character if measured width is greater than expected glyph width
// and subpixel-aa is enabled, otherwise just center the glyph.
var measuredWidth = ctx.measureText(character).width * 1000 /
fontSize * fontSizeScale;
var characterScaleX = width / measuredWidth;
restoreNeeded = true;
ctx.save();
ctx.scale(characterScaleX, 1);
scaledX /= characterScaleX;
if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
var characterScaleX = width / measuredWidth;
restoreNeeded = true;
ctx.save();
ctx.scale(characterScaleX, 1);
scaledX /= characterScaleX;
} else if (width !== measuredWidth) {
scaledX += (width - measuredWidth) / 2000 *
fontSize / fontSizeScale;
}
}
if (simpleFillText && !accent) {
@ -5147,7 +5155,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
scaleX: scaleX,
scaleY: scaleY,
subtype: group.smask.subtype,
backdrop: group.smask.backdrop
backdrop: group.smask.backdrop,
transferMap: group.smask.transferMap || null
});
} else {
// Setup the current ctx so when the group is popped we draw it at the

View File

@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.3.56';
PDFJS.build = 'e2aca38';
PDFJS.version = '1.3.72';
PDFJS.build = '4d6f3c8';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -10536,6 +10536,22 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
subtype: smask.get('S').name,
backdrop: smask.get('BC')
};
// The SMask might have a alpha/luminosity value transfer function --
// we will build a map of integer values in range 0..255 to be fast.
var transferObj = smask.get('TR');
if (isPDFFunction(transferObj)) {
var transferFn = PDFFunction.parse(this.xref, transferObj);
var transferMap = new Uint8Array(256);
var tmp = new Float32Array(1);
for (var i = 0; i < 255; i++) {
tmp[0] = i / 255;
transferFn(tmp, 0, tmp, 0);
transferMap[i] = (tmp[0] * 255) | 0;
}
smaskOptions.transferMap = transferMap;
}
return this.buildFormXObject(resources, smaskContent, smaskOptions,
operatorList, task, stateManager.state.clone());
},
@ -16226,6 +16242,9 @@ function reverseIfRtl(chars) {
}
function adjustWidths(properties) {
if (!properties.fontMatrix) {
return;
}
if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
return;
}
@ -16349,7 +16368,7 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
},
charCodeOf: function (v) {
error('should not call .charCodeOf');
return (isInt(v) && v >= this.firstChar && v <= this.lastChar) ? v : -1;
}
};
@ -16740,6 +16759,8 @@ var Font = (function FontClosure() {
// view of the sanitizer
data = this.checkAndRepair(name, file, properties);
if (this.isOpenType) {
adjustWidths(properties);
type = 'OpenType';
}
break;
@ -18172,6 +18193,8 @@ var Font = (function FontClosure() {
cffFile = new Stream(tables['CFF '].data);
cff = new CFFFont(cffFile, properties);
adjustWidths(properties);
return this.convert(name, cff, properties);
}
@ -18793,7 +18816,7 @@ var Font = (function FontClosure() {
}
}
// ... via toUnicode map
if (!charcode && 'toUnicode' in this) {
if (!charcode && this.toUnicode) {
charcode = this.toUnicode.charCodeOf(glyphUnicode);
}
// setting it to unicode if negative or undefined

View File

@ -1530,7 +1530,7 @@ var PDFLinkService = (function () {
return pdfOpenParams;
}
}
return '';
return this.getAnchorUrl('');
},
/**