зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265738 - Update pdf.js to version 1.4.258. r=bdahl
This commit is contained in:
Родитель
fa0ac6acc2
Коммит
88067ca7d7
|
@ -1,3 +1,3 @@
|
|||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 1.4.213
|
||||
Current extension version is: 1.4.258
|
||||
|
|
|
@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
|
|||
// Use strict in our context only - users might not want it
|
||||
'use strict';
|
||||
|
||||
var pdfjsVersion = '1.4.213';
|
||||
var pdfjsBuild = '1c253e6';
|
||||
var pdfjsVersion = '1.4.258';
|
||||
var pdfjsBuild = '990150c';
|
||||
|
||||
var pdfjsFilePath =
|
||||
typeof document !== 'undefined' && document.currentScript ?
|
||||
|
@ -316,15 +316,6 @@ var UNSUPPORTED_FEATURES = {
|
|||
font: 'font'
|
||||
};
|
||||
|
||||
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
||||
// absolute URL, it will be returned as is.
|
||||
function combineUrl(baseUrl, url) {
|
||||
if (!url) {
|
||||
return baseUrl;
|
||||
}
|
||||
return new URL(url, baseUrl).href;
|
||||
}
|
||||
|
||||
// Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
|
||||
function isSameOrigin(baseUrl, otherUrl) {
|
||||
try {
|
||||
|
@ -342,7 +333,7 @@ function isSameOrigin(baseUrl, otherUrl) {
|
|||
|
||||
// Validates if URL is safe and allowed, e.g. to avoid XSS.
|
||||
function isValidUrl(url, allowRelative) {
|
||||
if (!url) {
|
||||
if (!url || typeof url !== 'string') {
|
||||
return false;
|
||||
}
|
||||
// RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
|
||||
|
@ -1434,7 +1425,6 @@ exports.arrayByteLength = arrayByteLength;
|
|||
exports.arraysToBytes = arraysToBytes;
|
||||
exports.assert = assert;
|
||||
exports.bytesToString = bytesToString;
|
||||
exports.combineUrl = combineUrl;
|
||||
exports.createBlob = createBlob;
|
||||
exports.createPromiseCapability = createPromiseCapability;
|
||||
exports.createObjectURL = createObjectURL;
|
||||
|
@ -1556,15 +1546,15 @@ var LinkTargetStringMap = [
|
|||
/**
|
||||
* @typedef ExternalLinkParameters
|
||||
* @typedef {Object} ExternalLinkParameters
|
||||
* @property {string} url
|
||||
* @property {LinkTarget} target
|
||||
* @property {string} rel
|
||||
* @property {string} url - An absolute URL.
|
||||
* @property {LinkTarget} target - The link target.
|
||||
* @property {string} rel - The link relationship.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds various attributes (href, title, target, rel) to hyperlinks.
|
||||
* @param {HTMLLinkElement} link - The link element.
|
||||
* @param {ExternalLinkParameters} params - An object with the properties.
|
||||
* @param {ExternalLinkParameters} params
|
||||
*/
|
||||
function addLinkAttributes(link, params) {
|
||||
var url = params && params.url;
|
||||
|
@ -1576,7 +1566,7 @@ function addLinkAttributes(link, params) {
|
|||
target = getDefaultSetting('externalLinkTarget');
|
||||
}
|
||||
link.target = LinkTargetStringMap[target];
|
||||
// Strip referrer from the URL.
|
||||
|
||||
var rel = params.rel;
|
||||
if (typeof rel === 'undefined') {
|
||||
rel = getDefaultSetting('externalLinkRel');
|
||||
|
@ -1931,6 +1921,7 @@ var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
|
|||
var AnnotationType = sharedUtil.AnnotationType;
|
||||
var Util = sharedUtil.Util;
|
||||
var addLinkAttributes = displayDOMUtils.addLinkAttributes;
|
||||
var LinkTarget = displayDOMUtils.LinkTarget;
|
||||
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
|
||||
var warn = sharedUtil.warn;
|
||||
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||
|
@ -2178,13 +2169,16 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
|
|||
this.container.className = 'linkAnnotation';
|
||||
|
||||
var link = document.createElement('a');
|
||||
addLinkAttributes(link, { url: this.data.url });
|
||||
addLinkAttributes(link, {
|
||||
url: this.data.url,
|
||||
target: (this.data.newWindow ? LinkTarget.BLANK : undefined),
|
||||
});
|
||||
|
||||
if (!this.data.url) {
|
||||
if (this.data.action) {
|
||||
this._bindNamedAction(link, this.data.action);
|
||||
} else {
|
||||
this._bindLink(link, ('dest' in this.data) ? this.data.dest : null);
|
||||
this._bindLink(link, (this.data.dest || null));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3620,6 +3614,9 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||
var EXPECTED_SCALE = 1.1;
|
||||
// MAX_PATTERN_SIZE is used to avoid OOM situation.
|
||||
var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough
|
||||
// We need to keep transparent border around our pattern for fill():
|
||||
// createPattern with 'no-repeat' will bleed edges accross entire area.
|
||||
var BORDER_SIZE = 2;
|
||||
|
||||
var offsetX = Math.floor(bounds[0]);
|
||||
var offsetY = Math.floor(bounds[1]);
|
||||
|
@ -3642,17 +3639,22 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||
scaleY: 1 / scaleY
|
||||
};
|
||||
|
||||
var paddedWidth = width + BORDER_SIZE * 2;
|
||||
var paddedHeight = height + BORDER_SIZE * 2;
|
||||
|
||||
var canvas, tmpCanvas, i, ii;
|
||||
if (WebGLUtils.isEnabled) {
|
||||
canvas = WebGLUtils.drawFigures(width, height, backgroundColor,
|
||||
figures, context);
|
||||
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=972126
|
||||
tmpCanvas = cachedCanvases.getCanvas('mesh', width, height, false);
|
||||
tmpCanvas.context.drawImage(canvas, 0, 0);
|
||||
tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight,
|
||||
false);
|
||||
tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
|
||||
canvas = tmpCanvas.canvas;
|
||||
} else {
|
||||
tmpCanvas = cachedCanvases.getCanvas('mesh', width, height, false);
|
||||
tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight,
|
||||
false);
|
||||
var tmpCtx = tmpCanvas.context;
|
||||
|
||||
var data = tmpCtx.createImageData(width, height);
|
||||
|
@ -3668,11 +3670,13 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||
for (i = 0; i < figures.length; i++) {
|
||||
drawFigure(data, figures[i], context);
|
||||
}
|
||||
tmpCtx.putImageData(data, 0, 0);
|
||||
tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
|
||||
canvas = tmpCanvas.canvas;
|
||||
}
|
||||
|
||||
return {canvas: canvas, offsetX: offsetX, offsetY: offsetY,
|
||||
return {canvas: canvas,
|
||||
offsetX: offsetX - BORDER_SIZE * scaleX,
|
||||
offsetY: offsetY - BORDER_SIZE * scaleY,
|
||||
scaleX: scaleX, scaleY: scaleY};
|
||||
}
|
||||
return createMeshCanvas;
|
||||
|
@ -4303,7 +4307,8 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
|
|||
this.fillAlpha = 1;
|
||||
this.strokeAlpha = 1;
|
||||
this.lineWidth = 1;
|
||||
this.activeSMask = null; // nonclonable field (see the save method below)
|
||||
this.activeSMask = null;
|
||||
this.resumeSMaskCtx = null; // nonclonable field (see the save method below)
|
||||
|
||||
this.old = old;
|
||||
}
|
||||
|
@ -4740,6 +4745,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
},
|
||||
|
||||
endDrawing: function CanvasGraphics_endDrawing() {
|
||||
// Finishing all opened operations such as SMask group painting.
|
||||
if (this.current.activeSMask !== null) {
|
||||
this.endSMaskGroup();
|
||||
}
|
||||
|
||||
this.ctx.restore();
|
||||
|
||||
if (this.transparentCanvas) {
|
||||
|
@ -4848,7 +4858,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
break;
|
||||
case 'SMask':
|
||||
if (this.current.activeSMask) {
|
||||
this.endSMaskGroup();
|
||||
// If SMask is currrenly used, it needs to be suspended or
|
||||
// finished. Suspend only makes sense when at least one save()
|
||||
// was performed and state needs to be reverted on restore().
|
||||
if (this.stateStack.length > 0 &&
|
||||
(this.stateStack[this.stateStack.length - 1].activeSMask ===
|
||||
this.current.activeSMask)) {
|
||||
this.suspendSMaskGroup();
|
||||
} else {
|
||||
this.endSMaskGroup();
|
||||
}
|
||||
}
|
||||
this.current.activeSMask = value ? this.tempSMask : null;
|
||||
if (this.current.activeSMask) {
|
||||
|
@ -4877,6 +4896,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
|
||||
groupCtx.transform.apply(groupCtx, currentTransform);
|
||||
|
||||
activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
|
||||
|
||||
copyCtxState(currentCtx, groupCtx);
|
||||
this.ctx = groupCtx;
|
||||
this.setGState([
|
||||
|
@ -4887,6 +4908,43 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
this.groupStack.push(currentCtx);
|
||||
this.groupLevel++;
|
||||
},
|
||||
suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
|
||||
// Similar to endSMaskGroup, the intermediate canvas has to be composed
|
||||
// and future ctx state restored.
|
||||
var groupCtx = this.ctx;
|
||||
this.groupLevel--;
|
||||
this.ctx = this.groupStack.pop();
|
||||
|
||||
composeSMask(this.ctx, this.current.activeSMask, groupCtx);
|
||||
this.ctx.restore();
|
||||
this.ctx.save(); // save is needed since SMask will be resumed.
|
||||
copyCtxState(groupCtx, this.ctx);
|
||||
|
||||
// Saving state for resuming.
|
||||
this.current.resumeSMaskCtx = groupCtx;
|
||||
// Transform was changed in the SMask canvas, reflecting this change on
|
||||
// this.ctx.
|
||||
var deltaTransform = Util.transform(
|
||||
this.current.activeSMask.startTransformInverse,
|
||||
groupCtx.mozCurrentTransform);
|
||||
this.ctx.transform.apply(this.ctx, deltaTransform);
|
||||
|
||||
// SMask was composed, the results at the groupCtx can be cleared.
|
||||
groupCtx.save();
|
||||
groupCtx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
|
||||
groupCtx.restore();
|
||||
},
|
||||
resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
|
||||
// Resuming state saved by suspendSMaskGroup. We don't need to restore
|
||||
// any groupCtx state since restore() command (the only caller) will do
|
||||
// that for us. See also beginSMaskGroup.
|
||||
var groupCtx = this.current.resumeSMaskCtx;
|
||||
var currentCtx = this.ctx;
|
||||
this.ctx = groupCtx;
|
||||
this.groupStack.push(currentCtx);
|
||||
this.groupLevel++;
|
||||
},
|
||||
endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
|
||||
var groupCtx = this.ctx;
|
||||
this.groupLevel--;
|
||||
|
@ -4895,20 +4953,34 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
composeSMask(this.ctx, this.current.activeSMask, groupCtx);
|
||||
this.ctx.restore();
|
||||
copyCtxState(groupCtx, this.ctx);
|
||||
// Transform was changed in the SMask canvas, reflecting this change on
|
||||
// this.ctx.
|
||||
var deltaTransform = Util.transform(
|
||||
this.current.activeSMask.startTransformInverse,
|
||||
groupCtx.mozCurrentTransform);
|
||||
this.ctx.transform.apply(this.ctx, deltaTransform);
|
||||
},
|
||||
save: function CanvasGraphics_save() {
|
||||
this.ctx.save();
|
||||
var old = this.current;
|
||||
this.stateStack.push(old);
|
||||
this.current = old.clone();
|
||||
this.current.activeSMask = null;
|
||||
this.current.resumeSMaskCtx = null;
|
||||
},
|
||||
restore: function CanvasGraphics_restore() {
|
||||
if (this.stateStack.length !== 0) {
|
||||
if (this.current.activeSMask !== null) {
|
||||
this.endSMaskGroup();
|
||||
}
|
||||
// SMask was suspended, we just need to resume it.
|
||||
if (this.current.resumeSMaskCtx) {
|
||||
this.resumeSMaskGroup();
|
||||
}
|
||||
// SMask has to be finished once there is no states that are using the
|
||||
// same SMask.
|
||||
if (this.current.activeSMask !== null && (this.stateStack.length === 0 ||
|
||||
this.stateStack[this.stateStack.length - 1].activeSMask !==
|
||||
this.current.activeSMask)) {
|
||||
this.endSMaskGroup();
|
||||
}
|
||||
|
||||
if (this.stateStack.length !== 0) {
|
||||
this.current = this.stateStack.pop();
|
||||
this.ctx.restore();
|
||||
|
||||
|
@ -5696,7 +5768,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
scaleY: scaleY,
|
||||
subtype: group.smask.subtype,
|
||||
backdrop: group.smask.backdrop,
|
||||
transferMap: group.smask.transferMap || null
|
||||
transferMap: group.smask.transferMap || null,
|
||||
startTransformInverse: null, // used during suspend operation
|
||||
});
|
||||
} else {
|
||||
// Setup the current ctx so when the group is popped we draw it at the
|
||||
|
@ -5716,6 +5789,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
]);
|
||||
this.groupStack.push(currentCtx);
|
||||
this.groupLevel++;
|
||||
|
||||
// Reseting mask state, masks will be applied on restore of the group.
|
||||
this.current.activeSMask = null;
|
||||
},
|
||||
|
||||
endGroup: function CanvasGraphics_endGroup(group) {
|
||||
|
@ -6146,7 +6222,6 @@ var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
|
|||
var UnknownErrorException = sharedUtil.UnknownErrorException;
|
||||
var Util = sharedUtil.Util;
|
||||
var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||
var combineUrl = sharedUtil.combineUrl;
|
||||
var error = sharedUtil.error;
|
||||
var deprecated = sharedUtil.deprecated;
|
||||
var getVerbosityLevel = sharedUtil.getVerbosityLevel;
|
||||
|
@ -6281,7 +6356,7 @@ function getDocument(src, pdfDataRangeTransport,
|
|||
for (var key in source) {
|
||||
if (key === 'url' && typeof window !== 'undefined') {
|
||||
// The full path is required in the 'url' field.
|
||||
params[key] = combineUrl(window.location.href, source[key]);
|
||||
params[key] = new URL(source[key], window.location).href;
|
||||
continue;
|
||||
} else if (key === 'range') {
|
||||
rangeTransport = source[key];
|
||||
|
|
|
@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {}));
|
|||
// Use strict in our context only - users might not want it
|
||||
'use strict';
|
||||
|
||||
var pdfjsVersion = '1.4.213';
|
||||
var pdfjsBuild = '1c253e6';
|
||||
var pdfjsVersion = '1.4.258';
|
||||
var pdfjsBuild = '990150c';
|
||||
|
||||
var pdfjsFilePath =
|
||||
typeof document !== 'undefined' && document.currentScript ?
|
||||
|
@ -2337,15 +2337,6 @@ var UNSUPPORTED_FEATURES = {
|
|||
font: 'font'
|
||||
};
|
||||
|
||||
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
||||
// absolute URL, it will be returned as is.
|
||||
function combineUrl(baseUrl, url) {
|
||||
if (!url) {
|
||||
return baseUrl;
|
||||
}
|
||||
return new URL(url, baseUrl).href;
|
||||
}
|
||||
|
||||
// Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
|
||||
function isSameOrigin(baseUrl, otherUrl) {
|
||||
try {
|
||||
|
@ -2363,7 +2354,7 @@ function isSameOrigin(baseUrl, otherUrl) {
|
|||
|
||||
// Validates if URL is safe and allowed, e.g. to avoid XSS.
|
||||
function isValidUrl(url, allowRelative) {
|
||||
if (!url) {
|
||||
if (!url || typeof url !== 'string') {
|
||||
return false;
|
||||
}
|
||||
// RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
|
||||
|
@ -3455,7 +3446,6 @@ exports.arrayByteLength = arrayByteLength;
|
|||
exports.arraysToBytes = arraysToBytes;
|
||||
exports.assert = assert;
|
||||
exports.bytesToString = bytesToString;
|
||||
exports.combineUrl = combineUrl;
|
||||
exports.createBlob = createBlob;
|
||||
exports.createPromiseCapability = createPromiseCapability;
|
||||
exports.createObjectURL = createObjectURL;
|
||||
|
@ -18786,6 +18776,7 @@ var createObjectURL = sharedUtil.createObjectURL;
|
|||
var shadow = sharedUtil.shadow;
|
||||
var warn = sharedUtil.warn;
|
||||
var Dict = corePrimitives.Dict;
|
||||
var isDict = corePrimitives.isDict;
|
||||
var Jbig2Image = coreJbig2.Jbig2Image;
|
||||
var JpegImage = coreJpg.JpegImage;
|
||||
var JpxImage = coreJpx.JpxImage;
|
||||
|
@ -19427,6 +19418,9 @@ var FlateStream = (function FlateStreamClosure() {
|
|||
|
||||
var PredictorStream = (function PredictorStreamClosure() {
|
||||
function PredictorStream(str, maybeLength, params) {
|
||||
if (!isDict(params)) {
|
||||
return str; // no prediction
|
||||
}
|
||||
var predictor = this.predictor = params.get('Predictor') || 1;
|
||||
|
||||
if (predictor <= 1) {
|
||||
|
@ -31517,10 +31511,42 @@ var isName = corePrimitives.isName;
|
|||
var isStream = corePrimitives.isStream;
|
||||
var PDFFunction = coreFunction.PDFFunction;
|
||||
|
||||
var coreImage; // see _setCoreImage below
|
||||
var PDFImage; // = coreImage.PDFImage;
|
||||
|
||||
var ColorSpace = (function ColorSpaceClosure() {
|
||||
/**
|
||||
* Resizes an RGB image with 3 components.
|
||||
* @param {TypedArray} src - The source buffer.
|
||||
* @param {Number} bpc - Number of bits per component.
|
||||
* @param {Number} w1 - Original width.
|
||||
* @param {Number} h1 - Original height.
|
||||
* @param {Number} w2 - New width.
|
||||
* @param {Number} h2 - New height.
|
||||
* @param {Number} alpha01 - Size reserved for the alpha channel.
|
||||
* @param {TypedArray} dest - The destination buffer.
|
||||
*/
|
||||
function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
|
||||
var COMPONENTS = 3;
|
||||
alpha01 = alpha01 !== 1 ? 0 : alpha01;
|
||||
var xRatio = w1 / w2;
|
||||
var yRatio = h1 / h2;
|
||||
var i, j, py, newIndex = 0, oldIndex;
|
||||
var xScaled = new Uint16Array(w2);
|
||||
var w1Scanline = w1 * COMPONENTS;
|
||||
|
||||
for (i = 0; i < w2; i++) {
|
||||
xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
|
||||
}
|
||||
for (i = 0; i < h2; i++) {
|
||||
py = Math.floor(i * yRatio) * w1Scanline;
|
||||
for (j = 0; j < w2; j++) {
|
||||
oldIndex = py + xScaled[j];
|
||||
dest[newIndex++] = src[oldIndex++];
|
||||
dest[newIndex++] = src[oldIndex++];
|
||||
dest[newIndex++] = src[oldIndex++];
|
||||
newIndex += alpha01;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor should define this.numComps, this.defaultColor, this.name
|
||||
function ColorSpace() {
|
||||
error('should not call ColorSpace constructor');
|
||||
|
@ -31646,8 +31672,8 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
|
||||
if (rgbBuf) {
|
||||
if (needsResizing) {
|
||||
PDFImage.resize(rgbBuf, bpc, 3, originalWidth, originalHeight, width,
|
||||
height, dest, alpha01);
|
||||
resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight,
|
||||
width, height, alpha01, dest);
|
||||
} else {
|
||||
rgbPos = 0;
|
||||
destPos = 0;
|
||||
|
@ -32767,13 +32793,6 @@ var LabCS = (function LabCSClosure() {
|
|||
return LabCS;
|
||||
})();
|
||||
|
||||
// TODO refactor to remove dependency on image.js
|
||||
function _setCoreImage(coreImage_) {
|
||||
coreImage = coreImage_;
|
||||
PDFImage = coreImage_.PDFImage;
|
||||
}
|
||||
exports._setCoreImage = _setCoreImage;
|
||||
|
||||
exports.ColorSpace = ColorSpace;
|
||||
}));
|
||||
|
||||
|
@ -32823,6 +32842,39 @@ var PDFImage = (function PDFImageClosure() {
|
|||
return (value < 0 ? 0 : (value > max ? max : value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes an image mask with 1 component.
|
||||
* @param {TypedArray} src - The source buffer.
|
||||
* @param {Number} bpc - Number of bits per component.
|
||||
* @param {Number} w1 - Original width.
|
||||
* @param {Number} h1 - Original height.
|
||||
* @param {Number} w2 - New width.
|
||||
* @param {Number} h2 - New height.
|
||||
* @returns {TypedArray} The resized image mask buffer.
|
||||
*/
|
||||
function resizeImageMask(src, bpc, w1, h1, w2, h2) {
|
||||
var length = w2 * h2;
|
||||
var dest = (bpc <= 8 ? new Uint8Array(length) :
|
||||
(bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length)));
|
||||
var xRatio = w1 / w2;
|
||||
var yRatio = h1 / h2;
|
||||
var i, j, py, newIndex = 0, oldIndex;
|
||||
var xScaled = new Uint16Array(w2);
|
||||
var w1Scanline = w1;
|
||||
|
||||
for (i = 0; i < w2; i++) {
|
||||
xScaled[i] = Math.floor(i * xRatio);
|
||||
}
|
||||
for (i = 0; i < h2; i++) {
|
||||
py = Math.floor(i * yRatio) * w1Scanline;
|
||||
for (j = 0; j < w2; j++) {
|
||||
oldIndex = py + xScaled[j];
|
||||
dest[newIndex++] = src[oldIndex];
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
function PDFImage(xref, res, image, inline, smask, mask, isMask) {
|
||||
this.image = image;
|
||||
var dict = image.dict;
|
||||
|
@ -32964,66 +33016,6 @@ var PDFImage = (function PDFImageClosure() {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Resize an image using the nearest neighbor algorithm. Currently only
|
||||
* supports one and three component images.
|
||||
* @param {TypedArray} pixels The original image with one component.
|
||||
* @param {Number} bpc Number of bits per component.
|
||||
* @param {Number} components Number of color components, 1 or 3 is supported.
|
||||
* @param {Number} w1 Original width.
|
||||
* @param {Number} h1 Original height.
|
||||
* @param {Number} w2 New width.
|
||||
* @param {Number} h2 New height.
|
||||
* @param {TypedArray} dest (Optional) The destination buffer.
|
||||
* @param {Number} alpha01 (Optional) Size reserved for the alpha channel.
|
||||
* @return {TypedArray} Resized image data.
|
||||
*/
|
||||
PDFImage.resize = function PDFImage_resize(pixels, bpc, components,
|
||||
w1, h1, w2, h2, dest, alpha01) {
|
||||
|
||||
if (components !== 1 && components !== 3) {
|
||||
error('Unsupported component count for resizing.');
|
||||
}
|
||||
|
||||
var length = w2 * h2 * components;
|
||||
var temp = dest ? dest : (bpc <= 8 ? new Uint8Array(length) :
|
||||
(bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length)));
|
||||
var xRatio = w1 / w2;
|
||||
var yRatio = h1 / h2;
|
||||
var i, j, py, newIndex = 0, oldIndex;
|
||||
var xScaled = new Uint16Array(w2);
|
||||
var w1Scanline = w1 * components;
|
||||
if (alpha01 !== 1) {
|
||||
alpha01 = 0;
|
||||
}
|
||||
|
||||
for (j = 0; j < w2; j++) {
|
||||
xScaled[j] = Math.floor(j * xRatio) * components;
|
||||
}
|
||||
|
||||
if (components === 1) {
|
||||
for (i = 0; i < h2; i++) {
|
||||
py = Math.floor(i * yRatio) * w1Scanline;
|
||||
for (j = 0; j < w2; j++) {
|
||||
oldIndex = py + xScaled[j];
|
||||
temp[newIndex++] = pixels[oldIndex];
|
||||
}
|
||||
}
|
||||
} else if (components === 3) {
|
||||
for (i = 0; i < h2; i++) {
|
||||
py = Math.floor(i * yRatio) * w1Scanline;
|
||||
for (j = 0; j < w2; j++) {
|
||||
oldIndex = py + xScaled[j];
|
||||
temp[newIndex++] = pixels[oldIndex++];
|
||||
temp[newIndex++] = pixels[oldIndex++];
|
||||
temp[newIndex++] = pixels[oldIndex++];
|
||||
newIndex += alpha01;
|
||||
}
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
PDFImage.createMask =
|
||||
function PDFImage_createMask(imgArray, width, height,
|
||||
imageIsFromDecodeStream, inverseDecode) {
|
||||
|
@ -33194,8 +33186,8 @@ var PDFImage = (function PDFImageClosure() {
|
|||
alphaBuf = new Uint8Array(sw * sh);
|
||||
smask.fillGrayBuffer(alphaBuf);
|
||||
if (sw !== width || sh !== height) {
|
||||
alphaBuf = PDFImage.resize(alphaBuf, smask.bpc, 1, sw, sh, width,
|
||||
height);
|
||||
alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh,
|
||||
width, height);
|
||||
}
|
||||
} else if (mask) {
|
||||
if (mask instanceof PDFImage) {
|
||||
|
@ -33211,8 +33203,8 @@ var PDFImage = (function PDFImageClosure() {
|
|||
}
|
||||
|
||||
if (sw !== width || sh !== height) {
|
||||
alphaBuf = PDFImage.resize(alphaBuf, mask.bpc, 1, sw, sh, width,
|
||||
height);
|
||||
alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh,
|
||||
width, height);
|
||||
}
|
||||
} else if (isArray(mask)) {
|
||||
// Color key mask: if any of the compontents are outside the range
|
||||
|
@ -33448,9 +33440,6 @@ var PDFImage = (function PDFImageClosure() {
|
|||
})();
|
||||
|
||||
exports.PDFImage = PDFImage;
|
||||
|
||||
// TODO refactor to remove dependency on colorspace.js
|
||||
coreColorSpace._setCoreImage(exports);
|
||||
}));
|
||||
|
||||
|
||||
|
@ -37436,13 +37425,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
});
|
||||
},
|
||||
|
||||
extractDataStructures: function
|
||||
partialEvaluatorExtractDataStructures(dict, baseDict,
|
||||
xref, properties) {
|
||||
extractDataStructures:
|
||||
function PartialEvaluator_extractDataStructures(dict, baseDict,
|
||||
xref, properties) {
|
||||
// 9.10.2
|
||||
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
|
||||
var toUnicodePromise = toUnicode ?
|
||||
this.readToUnicode(toUnicode) : Promise.resolve(undefined);
|
||||
this.readToUnicode(toUnicode) : Promise.resolve(undefined);
|
||||
|
||||
if (properties.composite) {
|
||||
// CIDSystemInfo helps to match CID to glyphs
|
||||
|
@ -37540,9 +37529,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
/**
|
||||
* Builds a char code to unicode map based on section 9.10 of the spec.
|
||||
* @param {Object} properties Font properties object.
|
||||
* @return {Promise} A Promise resolving to ToUnicodeMap object.
|
||||
* @return {Promise} A Promise that is resolved with a
|
||||
* {ToUnicodeMap|IdentityToUnicodeMap} object.
|
||||
*/
|
||||
buildToUnicode: function partialEvaluator_buildToUnicode(properties) {
|
||||
buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
|
||||
// Section 9.10.2 Mapping Character Codes to Unicode Values
|
||||
if (properties.toUnicode && properties.toUnicode.length !== 0) {
|
||||
return Promise.resolve(properties.toUnicode);
|
||||
|
@ -37643,7 +37633,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
// c) Construct a second CMap name by concatenating the registry and
|
||||
// ordering obtained in step (b) in the format registry–ordering–UCS2
|
||||
// (for example, Adobe–Japan1–UCS2).
|
||||
var ucs2CMapName = new Name(registry + '-' + ordering + '-UCS2');
|
||||
var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
|
||||
// d) Obtain the CMap with the name constructed in step (c) (available
|
||||
// from the ASN Web site; see the Bibliography).
|
||||
return CMapFactory.create(ucs2CMapName, this.options.cMapOptions,
|
||||
|
@ -39062,6 +39052,8 @@ var AnnotationFlag = sharedUtil.AnnotationFlag;
|
|||
var AnnotationType = sharedUtil.AnnotationType;
|
||||
var OPS = sharedUtil.OPS;
|
||||
var Util = sharedUtil.Util;
|
||||
var isBool = sharedUtil.isBool;
|
||||
var isString = sharedUtil.isString;
|
||||
var isArray = sharedUtil.isArray;
|
||||
var isInt = sharedUtil.isInt;
|
||||
var isValidUrl = sharedUtil.isValidUrl;
|
||||
|
@ -39730,68 +39722,93 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
|
|||
var data = this.data;
|
||||
data.annotationType = AnnotationType.LINK;
|
||||
|
||||
var action = dict.get('A');
|
||||
var action = dict.get('A'), url, dest;
|
||||
if (action && isDict(action)) {
|
||||
var linkType = action.get('S').name;
|
||||
if (linkType === 'URI') {
|
||||
var url = action.get('URI');
|
||||
if (isName(url)) {
|
||||
// Some bad PDFs do not put parentheses around relative URLs.
|
||||
url = '/' + url.name;
|
||||
} else if (url) {
|
||||
url = addDefaultProtocolToUrl(url);
|
||||
}
|
||||
// TODO: pdf spec mentions urls can be relative to a Base
|
||||
// entry in the dictionary.
|
||||
if (!isValidUrl(url, false)) {
|
||||
url = '';
|
||||
}
|
||||
// According to ISO 32000-1:2008, section 12.6.4.7,
|
||||
// URI should to be encoded in 7-bit ASCII.
|
||||
// Some bad PDFs may have URIs in UTF-8 encoding, see Bugzilla 1122280.
|
||||
try {
|
||||
data.url = stringToUTF8String(url);
|
||||
} catch (e) {
|
||||
// Fall back to a simple copy.
|
||||
data.url = url;
|
||||
}
|
||||
} else if (linkType === 'GoTo') {
|
||||
data.dest = action.get('D');
|
||||
} else if (linkType === 'GoToR') {
|
||||
var urlDict = action.get('F');
|
||||
if (isDict(urlDict)) {
|
||||
// We assume that the 'url' is a Filspec dictionary
|
||||
// and fetch the url without checking any further
|
||||
url = urlDict.get('F') || '';
|
||||
}
|
||||
switch (linkType) {
|
||||
case 'URI':
|
||||
url = action.get('URI');
|
||||
if (isName(url)) {
|
||||
// Some bad PDFs do not put parentheses around relative URLs.
|
||||
url = '/' + url.name;
|
||||
} else if (url) {
|
||||
url = addDefaultProtocolToUrl(url);
|
||||
}
|
||||
// TODO: pdf spec mentions urls can be relative to a Base
|
||||
// entry in the dictionary.
|
||||
break;
|
||||
|
||||
// TODO: pdf reference says that GoToR
|
||||
// can also have 'NewWindow' attribute
|
||||
if (!isValidUrl(url, false)) {
|
||||
url = '';
|
||||
}
|
||||
data.url = url;
|
||||
data.dest = action.get('D');
|
||||
} else if (linkType === 'Named') {
|
||||
data.action = action.get('N').name;
|
||||
} else {
|
||||
warn('unrecognized link type: ' + linkType);
|
||||
case 'GoTo':
|
||||
dest = action.get('D');
|
||||
break;
|
||||
|
||||
case 'GoToR':
|
||||
var urlDict = action.get('F');
|
||||
if (isDict(urlDict)) {
|
||||
// We assume that we found a FileSpec dictionary
|
||||
// and fetch the URL without checking any further.
|
||||
url = urlDict.get('F') || null;
|
||||
} else if (isString(urlDict)) {
|
||||
url = urlDict;
|
||||
}
|
||||
|
||||
// NOTE: the destination is relative to the *remote* document.
|
||||
var remoteDest = action.get('D');
|
||||
if (remoteDest) {
|
||||
if (isName(remoteDest)) {
|
||||
remoteDest = remoteDest.name;
|
||||
}
|
||||
if (isString(remoteDest) && isString(url)) {
|
||||
var baseUrl = url.split('#')[0];
|
||||
url = baseUrl + '#' + remoteDest;
|
||||
}
|
||||
}
|
||||
// The 'NewWindow' property, equal to `LinkTarget.BLANK`.
|
||||
var newWindow = action.get('NewWindow');
|
||||
if (isBool(newWindow)) {
|
||||
data.newWindow = newWindow;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Named':
|
||||
data.action = action.get('N').name;
|
||||
break;
|
||||
|
||||
default:
|
||||
warn('unrecognized link type: ' + linkType);
|
||||
}
|
||||
} else if (dict.has('Dest')) {
|
||||
// simple destination link
|
||||
var dest = dict.get('Dest');
|
||||
} else if (dict.has('Dest')) { // Simple destination link.
|
||||
dest = dict.get('Dest');
|
||||
}
|
||||
|
||||
if (url) {
|
||||
if (isValidUrl(url, /* allowRelative = */ false)) {
|
||||
data.url = tryConvertUrlEncoding(url);
|
||||
}
|
||||
}
|
||||
if (dest) {
|
||||
data.dest = isName(dest) ? dest.name : dest;
|
||||
}
|
||||
}
|
||||
|
||||
// Lets URLs beginning with 'www.' default to using the 'http://' protocol.
|
||||
function addDefaultProtocolToUrl(url) {
|
||||
if (url && url.indexOf('www.') === 0) {
|
||||
if (isString(url) && url.indexOf('www.') === 0) {
|
||||
return ('http://' + url);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function tryConvertUrlEncoding(url) {
|
||||
// According to ISO 32000-1:2008, section 12.6.4.7, URIs should be encoded
|
||||
// in 7-bit ASCII. Some bad PDFs use UTF-8 encoding, see Bugzilla 1122280.
|
||||
try {
|
||||
return stringToUTF8String(url);
|
||||
} catch (e) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(LinkAnnotation, Annotation, {});
|
||||
|
||||
return LinkAnnotation;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals pdfjsLib */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -65,7 +64,7 @@ var FontInspector = (function FontInspectorClosure() {
|
|||
name: 'Font Inspector',
|
||||
panel: null,
|
||||
manager: null,
|
||||
init: function init() {
|
||||
init: function init(pdfjsLib) {
|
||||
var panel = this.panel;
|
||||
panel.setAttribute('style', 'padding: 5px;');
|
||||
var tmp = document.createElement('button');
|
||||
|
@ -291,7 +290,7 @@ var Stepper = (function StepperClosure() {
|
|||
this.operatorListIdx = 0;
|
||||
}
|
||||
Stepper.prototype = {
|
||||
init: function init() {
|
||||
init: function init(pdfjsLib) {
|
||||
var panel = this.panel;
|
||||
var content = c('div', 'c=continue, s=step');
|
||||
var table = c('table');
|
||||
|
@ -458,7 +457,7 @@ var Stats = (function Stats() {
|
|||
name: 'Stats',
|
||||
panel: null,
|
||||
manager: null,
|
||||
init: function init() {
|
||||
init: function init(pdfjsLib) {
|
||||
this.panel.setAttribute('style', 'padding: 5px;');
|
||||
pdfjsLib.PDFJS.enableStats = true;
|
||||
},
|
||||
|
@ -532,7 +531,7 @@ var PDFBug = (function PDFBugClosure() {
|
|||
});
|
||||
}
|
||||
},
|
||||
init: function init() {
|
||||
init: function init(pdfjsLib) {
|
||||
/*
|
||||
* Basic Layout:
|
||||
* PDFBug
|
||||
|
@ -576,7 +575,7 @@ var PDFBug = (function PDFBugClosure() {
|
|||
tool.panel = panel;
|
||||
tool.manager = this;
|
||||
if (tool.enabled) {
|
||||
tool.init();
|
||||
tool.init(pdfjsLib);
|
||||
} else {
|
||||
panel.textContent = tool.name + ' is disabled. To enable add ' +
|
||||
' "' + tool.id + '" to the pdfBug parameter ' +
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче