Browse Source

PDF.js version 2.0.424 - See mozilla/pdf.js@fded22c6188d6203b43015f61268b6a098675816

master v2.0.424
pdfjsbot 7 years ago
parent
commit
873f70e0fb
  1. 2
      bower.json
  2. 72
      build/pdf.js
  3. 2
      build/pdf.js.map
  4. 2
      build/pdf.min.js
  5. 172
      build/pdf.worker.js
  6. 2
      build/pdf.worker.js.map
  7. 2
      build/pdf.worker.min.js
  8. 47
      lib/core/annotation.js
  9. 57
      lib/core/document.js
  10. 2
      lib/core/worker.js
  11. 6
      lib/display/api.js
  12. 4
      lib/pdf.js
  13. 4
      lib/pdf.worker.js
  14. 62
      lib/shared/util.js
  15. 121
      lib/test/unit/util_spec.js
  16. 4
      lib/web/pdf_viewer.component.js
  17. 2
      package.json
  18. 4
      web/pdf_viewer.js
  19. 2
      web/pdf_viewer.js.map

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "2.0.421", "version": "2.0.424",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

72
build/pdf.js

@ -105,7 +105,7 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined; exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@ -629,6 +629,36 @@ function isEvalSupported() {
return false; return false;
} }
} }
function getInheritableProperty(_ref) {
var dict = _ref.dict,
key = _ref.key,
_ref$getArray = _ref.getArray,
getArray = _ref$getArray === undefined ? false : _ref$getArray,
_ref$stopWhenFound = _ref.stopWhenFound,
stopWhenFound = _ref$stopWhenFound === undefined ? true : _ref$stopWhenFound;
var LOOP_LIMIT = 100;
var loopCount = 0;
var values = void 0;
while (dict) {
var value = getArray ? dict.getArray(key) : dict.get(key);
if (value !== undefined) {
if (stopWhenFound) {
return value;
}
if (!values) {
values = [];
}
values.push(value);
}
if (++loopCount > LOOP_LIMIT) {
warn('getInheritableProperty: maximum loop count exceeded for "' + key + '"');
break;
}
dict = dict.get('Parent');
}
return values;
}
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
var Util = function UtilClosure() { var Util = function UtilClosure() {
function Util() {} function Util() {}
@ -744,15 +774,6 @@ var Util = function UtilClosure() {
obj1[key] = obj2[key]; obj1[key] = obj2[key];
} }
}; };
Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
while (dict && !dict.has(name)) {
dict = dict.get('Parent');
}
if (!dict) {
return null;
}
return getArray ? dict.getArray(name) : dict.get(name);
};
Util.inherit = function Util_inherit(sub, base, prototype) { Util.inherit = function Util_inherit(sub, base, prototype) {
sub.prototype = Object.create(base.prototype); sub.prototype = Object.create(base.prototype);
sub.prototype.constructor = sub; sub.prototype.constructor = sub;
@ -1143,12 +1164,12 @@ MessageHandler.prototype = {
var sourceName = this.sourceName; var sourceName = this.sourceName;
var targetName = data.sourceName; var targetName = data.sourceName;
var capability = createPromiseCapability(); var capability = createPromiseCapability();
var sendStreamRequest = function sendStreamRequest(_ref) { var sendStreamRequest = function sendStreamRequest(_ref2) {
var stream = _ref.stream, var stream = _ref2.stream,
chunk = _ref.chunk, chunk = _ref2.chunk,
transfers = _ref.transfers, transfers = _ref2.transfers,
success = _ref.success, success = _ref2.success,
reason = _ref.reason; reason = _ref2.reason;
_this3.postMessage({ _this3.postMessage({
sourceName: sourceName, sourceName: sourceName,
@ -1228,10 +1249,10 @@ MessageHandler.prototype = {
var sourceName = this.sourceName; var sourceName = this.sourceName;
var targetName = data.sourceName; var targetName = data.sourceName;
var streamId = data.streamId; var streamId = data.streamId;
var sendStreamResponse = function sendStreamResponse(_ref2) { var sendStreamResponse = function sendStreamResponse(_ref3) {
var stream = _ref2.stream, var stream = _ref3.stream,
success = _ref2.success, success = _ref3.success,
reason = _ref2.reason; reason = _ref3.reason;
_this4.comObj.postMessage({ _this4.comObj.postMessage({
sourceName: sourceName, sourceName: sourceName,
@ -1377,6 +1398,7 @@ exports.createBlob = createBlob;
exports.createPromiseCapability = createPromiseCapability; exports.createPromiseCapability = createPromiseCapability;
exports.createObjectURL = createObjectURL; exports.createObjectURL = createObjectURL;
exports.deprecated = deprecated; exports.deprecated = deprecated;
exports.getInheritableProperty = getInheritableProperty;
exports.getLookupTableFactory = getLookupTableFactory; exports.getLookupTableFactory = getLookupTableFactory;
exports.getVerbosityLevel = getVerbosityLevel; exports.getVerbosityLevel = getVerbosityLevel;
exports.info = info; exports.info = info;
@ -3113,8 +3135,8 @@ exports.GlobalWorkerOptions = GlobalWorkerOptions;
"use strict"; "use strict";
var pdfjsVersion = '2.0.421'; var pdfjsVersion = '2.0.424';
var pdfjsBuild = 'e0fb18a3'; var pdfjsBuild = 'fded22c6';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayAPI = __w_pdfjs_require__(117); var pdfjsDisplayAPI = __w_pdfjs_require__(117);
var pdfjsDisplayTextLayer = __w_pdfjs_require__(124); var pdfjsDisplayTextLayer = __w_pdfjs_require__(124);
@ -8545,7 +8567,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
} }
return worker.messageHandler.sendWithPromise('GetDocRequest', { return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId, docId: docId,
apiVersion: '2.0.421', apiVersion: '2.0.424',
source: { source: {
data: source.data, data: source.data,
url: source.url, url: source.url,
@ -9979,8 +10001,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '2.0.421'; exports.version = version = '2.0.424';
exports.build = build = 'e0fb18a3'; exports.build = build = 'fded22c6';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

2
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

172
build/pdf.worker.js vendored

@ -105,7 +105,7 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined; exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@ -629,6 +629,36 @@ function isEvalSupported() {
return false; return false;
} }
} }
function getInheritableProperty(_ref) {
var dict = _ref.dict,
key = _ref.key,
_ref$getArray = _ref.getArray,
getArray = _ref$getArray === undefined ? false : _ref$getArray,
_ref$stopWhenFound = _ref.stopWhenFound,
stopWhenFound = _ref$stopWhenFound === undefined ? true : _ref$stopWhenFound;
var LOOP_LIMIT = 100;
var loopCount = 0;
var values = void 0;
while (dict) {
var value = getArray ? dict.getArray(key) : dict.get(key);
if (value !== undefined) {
if (stopWhenFound) {
return value;
}
if (!values) {
values = [];
}
values.push(value);
}
if (++loopCount > LOOP_LIMIT) {
warn('getInheritableProperty: maximum loop count exceeded for "' + key + '"');
break;
}
dict = dict.get('Parent');
}
return values;
}
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
var Util = function UtilClosure() { var Util = function UtilClosure() {
function Util() {} function Util() {}
@ -744,15 +774,6 @@ var Util = function UtilClosure() {
obj1[key] = obj2[key]; obj1[key] = obj2[key];
} }
}; };
Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
while (dict && !dict.has(name)) {
dict = dict.get('Parent');
}
if (!dict) {
return null;
}
return getArray ? dict.getArray(name) : dict.get(name);
};
Util.inherit = function Util_inherit(sub, base, prototype) { Util.inherit = function Util_inherit(sub, base, prototype) {
sub.prototype = Object.create(base.prototype); sub.prototype = Object.create(base.prototype);
sub.prototype.constructor = sub; sub.prototype.constructor = sub;
@ -1143,12 +1164,12 @@ MessageHandler.prototype = {
var sourceName = this.sourceName; var sourceName = this.sourceName;
var targetName = data.sourceName; var targetName = data.sourceName;
var capability = createPromiseCapability(); var capability = createPromiseCapability();
var sendStreamRequest = function sendStreamRequest(_ref) { var sendStreamRequest = function sendStreamRequest(_ref2) {
var stream = _ref.stream, var stream = _ref2.stream,
chunk = _ref.chunk, chunk = _ref2.chunk,
transfers = _ref.transfers, transfers = _ref2.transfers,
success = _ref.success, success = _ref2.success,
reason = _ref.reason; reason = _ref2.reason;
_this3.postMessage({ _this3.postMessage({
sourceName: sourceName, sourceName: sourceName,
@ -1228,10 +1249,10 @@ MessageHandler.prototype = {
var sourceName = this.sourceName; var sourceName = this.sourceName;
var targetName = data.sourceName; var targetName = data.sourceName;
var streamId = data.streamId; var streamId = data.streamId;
var sendStreamResponse = function sendStreamResponse(_ref2) { var sendStreamResponse = function sendStreamResponse(_ref3) {
var stream = _ref2.stream, var stream = _ref3.stream,
success = _ref2.success, success = _ref3.success,
reason = _ref2.reason; reason = _ref3.reason;
_this4.comObj.postMessage({ _this4.comObj.postMessage({
sourceName: sourceName, sourceName: sourceName,
@ -1377,6 +1398,7 @@ exports.createBlob = createBlob;
exports.createPromiseCapability = createPromiseCapability; exports.createPromiseCapability = createPromiseCapability;
exports.createObjectURL = createObjectURL; exports.createObjectURL = createObjectURL;
exports.deprecated = deprecated; exports.deprecated = deprecated;
exports.getInheritableProperty = getInheritableProperty;
exports.getLookupTableFactory = getLookupTableFactory; exports.getLookupTableFactory = getLookupTableFactory;
exports.getVerbosityLevel = getVerbosityLevel; exports.getVerbosityLevel = getVerbosityLevel;
exports.info = info; exports.info = info;
@ -22315,8 +22337,8 @@ exports.PostScriptCompiler = PostScriptCompiler;
"use strict"; "use strict";
var pdfjsVersion = '2.0.421'; var pdfjsVersion = '2.0.424';
var pdfjsBuild = 'e0fb18a3'; var pdfjsBuild = 'fded22c6';
var pdfjsCoreWorker = __w_pdfjs_require__(74); var pdfjsCoreWorker = __w_pdfjs_require__(74);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
@ -22529,7 +22551,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null; var cancelXHRs = null;
var WorkerTasks = []; var WorkerTasks = [];
var apiVersion = docParams.apiVersion; var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.421'; var workerVersion = '2.0.424';
if (apiVersion !== null && apiVersion !== workerVersion) { if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".')); throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
} }
@ -28330,59 +28352,46 @@ var Page = function PageClosure() {
}; };
} }
Page.prototype = { Page.prototype = {
getPageProp: function Page_getPageProp(key) { _getInheritableProperty: function _getInheritableProperty(key) {
return this.pageDict.get(key); var getArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
},
getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) { var value = (0, _util.getInheritableProperty)({
var dict = this.pageDict, dict: this.pageDict,
valueArray = null, key: key,
loopCount = 0; getArray: getArray,
var MAX_LOOP_COUNT = 100; stopWhenFound: false
getArray = getArray || false; });
while (dict) { if (!Array.isArray(value)) {
var value = getArray ? dict.getArray(key) : dict.get(key); return value;
if (value !== undefined) {
if (!valueArray) {
valueArray = [];
}
valueArray.push(value);
}
if (++loopCount > MAX_LOOP_COUNT) {
(0, _util.warn)('getInheritedPageProp: maximum loop count exceeded for ' + key);
return valueArray ? valueArray[0] : undefined;
}
dict = dict.get('Parent');
}
if (!valueArray) {
return undefined;
} }
if (valueArray.length === 1 || !(0, _primitives.isDict)(valueArray[0])) { if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
return valueArray[0]; return value[0];
} }
return _primitives.Dict.merge(this.xref, valueArray); return _primitives.Dict.merge(this.xref, value);
}, },
get content() { get content() {
return this.getPageProp('Contents'); return this.pageDict.get('Contents');
}, },
get resources() { get resources() {
return (0, _util.shadow)(this, 'resources', this.getInheritedPageProp('Resources') || _primitives.Dict.empty); return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
}, },
get mediaBox() { get mediaBox() {
var mediaBox = this.getInheritedPageProp('MediaBox', true); var mediaBox = this._getInheritableProperty('MediaBox', true);
if (!Array.isArray(mediaBox) || mediaBox.length !== 4) { if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX); return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
} }
return (0, _util.shadow)(this, 'mediaBox', mediaBox); return (0, _util.shadow)(this, 'mediaBox', mediaBox);
}, },
get cropBox() { get cropBox() {
var cropBox = this.getInheritedPageProp('CropBox', true); var cropBox = this._getInheritableProperty('CropBox', true);
if (!Array.isArray(cropBox) || cropBox.length !== 4) { if (!Array.isArray(cropBox) || cropBox.length !== 4) {
return (0, _util.shadow)(this, 'cropBox', this.mediaBox); return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
} }
return (0, _util.shadow)(this, 'cropBox', cropBox); return (0, _util.shadow)(this, 'cropBox', cropBox);
}, },
get userUnit() { get userUnit() {
var obj = this.getPageProp('UserUnit'); var obj = this.pageDict.get('UserUnit');
if (!(0, _util.isNum)(obj) || obj <= 0) { if (!(0, _util.isNum)(obj) || obj <= 0) {
obj = DEFAULT_USER_UNIT; obj = DEFAULT_USER_UNIT;
} }
@ -28398,7 +28407,7 @@ var Page = function PageClosure() {
return (0, _util.shadow)(this, 'view', intersection || mediaBox); return (0, _util.shadow)(this, 'view', intersection || mediaBox);
}, },
get rotate() { get rotate() {
var rotate = this.getInheritedPageProp('Rotate') || 0; var rotate = this._getInheritableProperty('Rotate') || 0;
if (rotate % 90 !== 0) { if (rotate % 90 !== 0) {
rotate = 0; rotate = 0;
} else if (rotate >= 360) { } else if (rotate >= 360) {
@ -28558,7 +28567,7 @@ var Page = function PageClosure() {
}, },
get annotations() { get annotations() {
var annotations = []; var annotations = [];
var annotationRefs = this.getInheritedPageProp('Annots') || []; var annotationRefs = this._getInheritableProperty('Annots') || [];
for (var i = 0, n = annotationRefs.length; i < n; ++i) { for (var i = 0, n = annotationRefs.length; i < n; ++i) {
var annotationRef = annotationRefs[i]; var annotationRef = annotationRefs[i];
var annotation = _annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory); var annotation = _annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
@ -31844,7 +31853,10 @@ var AnnotationFactory = function () {
case 'Text': case 'Text':
return new TextAnnotation(parameters); return new TextAnnotation(parameters);
case 'Widget': case 'Widget':
var fieldType = _util.Util.getInheritableProperty(dict, 'FT'); var fieldType = (0, _util.getInheritableProperty)({
dict: dict,
key: 'FT'
});
fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null; fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
switch (fieldType) { switch (fieldType) {
case 'Tx': case 'Tx':
@ -32216,13 +32228,29 @@ var WidgetAnnotation = function (_Annotation) {
var data = _this2.data; var data = _this2.data;
data.annotationType = _util.AnnotationType.WIDGET; data.annotationType = _util.AnnotationType.WIDGET;
data.fieldName = _this2._constructFieldName(dict); data.fieldName = _this2._constructFieldName(dict);
data.fieldValue = _util.Util.getInheritableProperty(dict, 'V', true); data.fieldValue = (0, _util.getInheritableProperty)({
dict: dict,
key: 'V',
getArray: true
});
data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || ''); data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || '');
data.defaultAppearance = _util.Util.getInheritableProperty(dict, 'DA') || ''; data.defaultAppearance = (0, _util.getInheritableProperty)({
var fieldType = _util.Util.getInheritableProperty(dict, 'FT'); dict: dict,
key: 'DA'
}) || '';
var fieldType = (0, _util.getInheritableProperty)({
dict: dict,
key: 'FT'
});
data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null; data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
_this2.fieldResources = _util.Util.getInheritableProperty(dict, 'DR') || _primitives.Dict.empty; _this2.fieldResources = (0, _util.getInheritableProperty)({
data.fieldFlags = _util.Util.getInheritableProperty(dict, 'Ff'); dict: dict,
key: 'DR'
}) || _primitives.Dict.empty;
data.fieldFlags = (0, _util.getInheritableProperty)({
dict: dict,
key: 'Ff'
});
if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) { if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
data.fieldFlags = 0; data.fieldFlags = 0;
} }
@ -32285,13 +32313,20 @@ var TextWidgetAnnotation = function (_WidgetAnnotation) {
var _this3 = _possibleConstructorReturn(this, (TextWidgetAnnotation.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation)).call(this, params)); var _this3 = _possibleConstructorReturn(this, (TextWidgetAnnotation.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation)).call(this, params));
var dict = params.dict;
_this3.data.fieldValue = (0, _util.stringToPDFString)(_this3.data.fieldValue || ''); _this3.data.fieldValue = (0, _util.stringToPDFString)(_this3.data.fieldValue || '');
var alignment = _util.Util.getInheritableProperty(params.dict, 'Q'); var alignment = (0, _util.getInheritableProperty)({
dict: dict,
key: 'Q'
});
if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) { if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
alignment = null; alignment = null;
} }
_this3.data.textAlignment = alignment; _this3.data.textAlignment = alignment;
var maximumLength = _util.Util.getInheritableProperty(params.dict, 'MaxLen'); var maximumLength = (0, _util.getInheritableProperty)({
dict: dict,
key: 'MaxLen'
});
if (!Number.isInteger(maximumLength) || maximumLength < 0) { if (!Number.isInteger(maximumLength) || maximumLength < 0) {
maximumLength = null; maximumLength = null;
} }
@ -32411,7 +32446,10 @@ var ChoiceWidgetAnnotation = function (_WidgetAnnotation3) {
var _this5 = _possibleConstructorReturn(this, (ChoiceWidgetAnnotation.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotation)).call(this, params)); var _this5 = _possibleConstructorReturn(this, (ChoiceWidgetAnnotation.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotation)).call(this, params));
_this5.data.options = []; _this5.data.options = [];
var options = _util.Util.getInheritableProperty(params.dict, 'Opt'); var options = (0, _util.getInheritableProperty)({
dict: params.dict,
key: 'Opt'
});
if (Array.isArray(options)) { if (Array.isArray(options)) {
var xref = params.xref; var xref = params.xref;
for (var i = 0, ii = options.length; i < ii; i++) { for (var i = 0, ii = options.length; i < ii; i++) {

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

47
lib/core/annotation.js

@ -77,7 +77,10 @@ var AnnotationFactory = function () {
case 'Text': case 'Text':
return new TextAnnotation(parameters); return new TextAnnotation(parameters);
case 'Widget': case 'Widget':
var fieldType = _util.Util.getInheritableProperty(dict, 'FT'); var fieldType = (0, _util.getInheritableProperty)({
dict: dict,
key: 'FT'
});
fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null; fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
switch (fieldType) { switch (fieldType) {
case 'Tx': case 'Tx':
@ -449,13 +452,29 @@ var WidgetAnnotation = function (_Annotation) {
var data = _this2.data; var data = _this2.data;
data.annotationType = _util.AnnotationType.WIDGET; data.annotationType = _util.AnnotationType.WIDGET;
data.fieldName = _this2._constructFieldName(dict); data.fieldName = _this2._constructFieldName(dict);
data.fieldValue = _util.Util.getInheritableProperty(dict, 'V', true); data.fieldValue = (0, _util.getInheritableProperty)({
dict: dict,
key: 'V',
getArray: true
});
data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || ''); data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || '');
data.defaultAppearance = _util.Util.getInheritableProperty(dict, 'DA') || ''; data.defaultAppearance = (0, _util.getInheritableProperty)({
var fieldType = _util.Util.getInheritableProperty(dict, 'FT'); dict: dict,
key: 'DA'
}) || '';
var fieldType = (0, _util.getInheritableProperty)({
dict: dict,
key: 'FT'
});
data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null; data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
_this2.fieldResources = _util.Util.getInheritableProperty(dict, 'DR') || _primitives.Dict.empty; _this2.fieldResources = (0, _util.getInheritableProperty)({
data.fieldFlags = _util.Util.getInheritableProperty(dict, 'Ff'); dict: dict,
key: 'DR'
}) || _primitives.Dict.empty;
data.fieldFlags = (0, _util.getInheritableProperty)({
dict: dict,
key: 'Ff'
});
if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) { if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
data.fieldFlags = 0; data.fieldFlags = 0;
} }
@ -518,13 +537,20 @@ var TextWidgetAnnotation = function (_WidgetAnnotation) {
var _this3 = _possibleConstructorReturn(this, (TextWidgetAnnotation.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation)).call(this, params)); var _this3 = _possibleConstructorReturn(this, (TextWidgetAnnotation.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation)).call(this, params));
var dict = params.dict;
_this3.data.fieldValue = (0, _util.stringToPDFString)(_this3.data.fieldValue || ''); _this3.data.fieldValue = (0, _util.stringToPDFString)(_this3.data.fieldValue || '');
var alignment = _util.Util.getInheritableProperty(params.dict, 'Q'); var alignment = (0, _util.getInheritableProperty)({
dict: dict,
key: 'Q'
});
if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) { if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
alignment = null; alignment = null;
} }
_this3.data.textAlignment = alignment; _this3.data.textAlignment = alignment;
var maximumLength = _util.Util.getInheritableProperty(params.dict, 'MaxLen'); var maximumLength = (0, _util.getInheritableProperty)({
dict: dict,
key: 'MaxLen'
});
if (!Number.isInteger(maximumLength) || maximumLength < 0) { if (!Number.isInteger(maximumLength) || maximumLength < 0) {
maximumLength = null; maximumLength = null;
} }
@ -644,7 +670,10 @@ var ChoiceWidgetAnnotation = function (_WidgetAnnotation3) {
var _this5 = _possibleConstructorReturn(this, (ChoiceWidgetAnnotation.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotation)).call(this, params)); var _this5 = _possibleConstructorReturn(this, (ChoiceWidgetAnnotation.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotation)).call(this, params));
_this5.data.options = []; _this5.data.options = [];
var options = _util.Util.getInheritableProperty(params.dict, 'Opt'); var options = (0, _util.getInheritableProperty)({
dict: params.dict,
key: 'Opt'
});
if (Array.isArray(options)) { if (Array.isArray(options)) {
var xref = params.xref; var xref = params.xref;
for (var i = 0, ii = options.length; i < ii; i++) { for (var i = 0, ii = options.length; i < ii; i++) {

57
lib/core/document.js

@ -83,59 +83,46 @@ var Page = function PageClosure() {
}; };
} }
Page.prototype = { Page.prototype = {
getPageProp: function Page_getPageProp(key) { _getInheritableProperty: function _getInheritableProperty(key) {
return this.pageDict.get(key); var getArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
},
getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) { var value = (0, _util.getInheritableProperty)({
var dict = this.pageDict, dict: this.pageDict,
valueArray = null, key: key,
loopCount = 0; getArray: getArray,
var MAX_LOOP_COUNT = 100; stopWhenFound: false
getArray = getArray || false; });
while (dict) { if (!Array.isArray(value)) {
var value = getArray ? dict.getArray(key) : dict.get(key); return value;
if (value !== undefined) {
if (!valueArray) {
valueArray = [];
}
valueArray.push(value);
}
if (++loopCount > MAX_LOOP_COUNT) {
(0, _util.warn)('getInheritedPageProp: maximum loop count exceeded for ' + key);
return valueArray ? valueArray[0] : undefined;
}
dict = dict.get('Parent');
}
if (!valueArray) {
return undefined;
} }
if (valueArray.length === 1 || !(0, _primitives.isDict)(valueArray[0])) { if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
return valueArray[0]; return value[0];
} }
return _primitives.Dict.merge(this.xref, valueArray); return _primitives.Dict.merge(this.xref, value);
}, },
get content() { get content() {
return this.getPageProp('Contents'); return this.pageDict.get('Contents');
}, },
get resources() { get resources() {
return (0, _util.shadow)(this, 'resources', this.getInheritedPageProp('Resources') || _primitives.Dict.empty); return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
}, },
get mediaBox() { get mediaBox() {
var mediaBox = this.getInheritedPageProp('MediaBox', true); var mediaBox = this._getInheritableProperty('MediaBox', true);
if (!Array.isArray(mediaBox) || mediaBox.length !== 4) { if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX); return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
} }
return (0, _util.shadow)(this, 'mediaBox', mediaBox); return (0, _util.shadow)(this, 'mediaBox', mediaBox);
}, },
get cropBox() { get cropBox() {
var cropBox = this.getInheritedPageProp('CropBox', true); var cropBox = this._getInheritableProperty('CropBox', true);
if (!Array.isArray(cropBox) || cropBox.length !== 4) { if (!Array.isArray(cropBox) || cropBox.length !== 4) {
return (0, _util.shadow)(this, 'cropBox', this.mediaBox); return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
} }
return (0, _util.shadow)(this, 'cropBox', cropBox); return (0, _util.shadow)(this, 'cropBox', cropBox);
}, },
get userUnit() { get userUnit() {
var obj = this.getPageProp('UserUnit'); var obj = this.pageDict.get('UserUnit');
if (!(0, _util.isNum)(obj) || obj <= 0) { if (!(0, _util.isNum)(obj) || obj <= 0) {
obj = DEFAULT_USER_UNIT; obj = DEFAULT_USER_UNIT;
} }
@ -151,7 +138,7 @@ var Page = function PageClosure() {
return (0, _util.shadow)(this, 'view', intersection || mediaBox); return (0, _util.shadow)(this, 'view', intersection || mediaBox);
}, },
get rotate() { get rotate() {
var rotate = this.getInheritedPageProp('Rotate') || 0; var rotate = this._getInheritableProperty('Rotate') || 0;
if (rotate % 90 !== 0) { if (rotate % 90 !== 0) {
rotate = 0; rotate = 0;
} else if (rotate >= 360) { } else if (rotate >= 360) {
@ -311,7 +298,7 @@ var Page = function PageClosure() {
}, },
get annotations() { get annotations() {
var annotations = []; var annotations = [];
var annotationRefs = this.getInheritedPageProp('Annots') || []; var annotationRefs = this._getInheritableProperty('Annots') || [];
for (var i = 0, n = annotationRefs.length; i < n; ++i) { for (var i = 0, n = annotationRefs.length; i < n; ++i) {
var annotationRef = annotationRefs[i]; var annotationRef = annotationRefs[i];
var annotation = _annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory); var annotation = _annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);

2
lib/core/worker.js

@ -223,7 +223,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null; var cancelXHRs = null;
var WorkerTasks = []; var WorkerTasks = [];
var apiVersion = docParams.apiVersion; var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.421'; var workerVersion = '2.0.424';
if (apiVersion !== null && apiVersion !== workerVersion) { if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".')); throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
} }

6
lib/display/api.js

@ -234,7 +234,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
} }
return worker.messageHandler.sendWithPromise('GetDocRequest', { return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId, docId: docId,
apiVersion: '2.0.421', apiVersion: '2.0.424',
source: { source: {
data: source.data, data: source.data,
url: source.url, url: source.url,
@ -1668,8 +1668,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '2.0.421'; exports.version = version = '2.0.424';
exports.build = build = 'e0fb18a3'; exports.build = build = 'fded22c6';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;

4
lib/pdf.js

@ -21,8 +21,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '2.0.421'; var pdfjsVersion = '2.0.424';
var pdfjsBuild = 'e0fb18a3'; var pdfjsBuild = 'fded22c6';
var pdfjsSharedUtil = require('./shared/util.js'); var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayAPI = require('./display/api.js'); var pdfjsDisplayAPI = require('./display/api.js');
var pdfjsDisplayTextLayer = require('./display/text_layer.js'); var pdfjsDisplayTextLayer = require('./display/text_layer.js');

4
lib/pdf.worker.js vendored

@ -21,7 +21,7 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '2.0.421'; var pdfjsVersion = '2.0.424';
var pdfjsBuild = 'e0fb18a3'; var pdfjsBuild = 'fded22c6';
var pdfjsCoreWorker = require('./core/worker.js'); var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

62
lib/shared/util.js

@ -24,7 +24,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined; exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@ -548,6 +548,36 @@ function isEvalSupported() {
return false; return false;
} }
} }
function getInheritableProperty(_ref) {
var dict = _ref.dict,
key = _ref.key,
_ref$getArray = _ref.getArray,
getArray = _ref$getArray === undefined ? false : _ref$getArray,
_ref$stopWhenFound = _ref.stopWhenFound,
stopWhenFound = _ref$stopWhenFound === undefined ? true : _ref$stopWhenFound;
var LOOP_LIMIT = 100;
var loopCount = 0;
var values = void 0;
while (dict) {
var value = getArray ? dict.getArray(key) : dict.get(key);
if (value !== undefined) {
if (stopWhenFound) {
return value;
}
if (!values) {
values = [];
}
values.push(value);
}
if (++loopCount > LOOP_LIMIT) {
warn('getInheritableProperty: maximum loop count exceeded for "' + key + '"');
break;
}
dict = dict.get('Parent');
}
return values;
}
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
var Util = function UtilClosure() { var Util = function UtilClosure() {
function Util() {} function Util() {}
@ -663,15 +693,6 @@ var Util = function UtilClosure() {
obj1[key] = obj2[key]; obj1[key] = obj2[key];
} }
}; };
Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
while (dict && !dict.has(name)) {
dict = dict.get('Parent');
}
if (!dict) {
return null;
}
return getArray ? dict.getArray(name) : dict.get(name);
};
Util.inherit = function Util_inherit(sub, base, prototype) { Util.inherit = function Util_inherit(sub, base, prototype) {
sub.prototype = Object.create(base.prototype); sub.prototype = Object.create(base.prototype);
sub.prototype.constructor = sub; sub.prototype.constructor = sub;
@ -1062,12 +1083,12 @@ MessageHandler.prototype = {
var sourceName = this.sourceName; var sourceName = this.sourceName;
var targetName = data.sourceName; var targetName = data.sourceName;
var capability = createPromiseCapability(); var capability = createPromiseCapability();
var sendStreamRequest = function sendStreamRequest(_ref) { var sendStreamRequest = function sendStreamRequest(_ref2) {
var stream = _ref.stream, var stream = _ref2.stream,
chunk = _ref.chunk, chunk = _ref2.chunk,
transfers = _ref.transfers, transfers = _ref2.transfers,
success = _ref.success, success = _ref2.success,
reason = _ref.reason; reason = _ref2.reason;
_this3.postMessage({ _this3.postMessage({
sourceName: sourceName, sourceName: sourceName,
@ -1147,10 +1168,10 @@ MessageHandler.prototype = {
var sourceName = this.sourceName; var sourceName = this.sourceName;
var targetName = data.sourceName; var targetName = data.sourceName;
var streamId = data.streamId; var streamId = data.streamId;
var sendStreamResponse = function sendStreamResponse(_ref2) { var sendStreamResponse = function sendStreamResponse(_ref3) {
var stream = _ref2.stream, var stream = _ref3.stream,
success = _ref2.success, success = _ref3.success,
reason = _ref2.reason; reason = _ref3.reason;
_this4.comObj.postMessage({ _this4.comObj.postMessage({
sourceName: sourceName, sourceName: sourceName,
@ -1296,6 +1317,7 @@ exports.createBlob = createBlob;
exports.createPromiseCapability = createPromiseCapability; exports.createPromiseCapability = createPromiseCapability;
exports.createObjectURL = createObjectURL; exports.createObjectURL = createObjectURL;
exports.deprecated = deprecated; exports.deprecated = deprecated;
exports.getInheritableProperty = getInheritableProperty;
exports.getLookupTableFactory = getLookupTableFactory; exports.getLookupTableFactory = getLookupTableFactory;
exports.getVerbosityLevel = getVerbosityLevel; exports.getVerbosityLevel = getVerbosityLevel;
exports.info = info; exports.info = info;

121
lib/test/unit/util_spec.js

@ -25,6 +25,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var _util = require('../../shared/util'); var _util = require('../../shared/util');
var _primitives = require('../../core/primitives');
var _test_utils = require('./test_utils');
describe('util', function () { describe('util', function () {
describe('bytesToString', function () { describe('bytesToString', function () {
it('handles non-array arguments', function () { it('handles non-array arguments', function () {
@ -46,6 +50,123 @@ describe('util', function () {
expect((0, _util.bytesToString)(bytes)).toEqual(string); expect((0, _util.bytesToString)(bytes)).toEqual(string);
}); });
}); });
describe('getInheritableProperty', function () {
it('handles non-dictionary arguments', function () {
expect((0, _util.getInheritableProperty)({
dict: null,
key: 'foo'
})).toEqual(undefined);
expect((0, _util.getInheritableProperty)({
dict: undefined,
key: 'foo'
})).toEqual(undefined);
});
it('handles dictionaries that do not contain the property', function () {
var emptyDict = new _primitives.Dict();
expect((0, _util.getInheritableProperty)({
dict: emptyDict,
key: 'foo'
})).toEqual(undefined);
var filledDict = new _primitives.Dict();
filledDict.set('bar', 'baz');
expect((0, _util.getInheritableProperty)({
dict: filledDict,
key: 'foo'
})).toEqual(undefined);
});
it('fetches the property if it is not inherited', function () {
var ref = new _primitives.Ref(10, 0);
var xref = new _test_utils.XRefMock([{
ref: ref,
data: 'quux'
}]);
var dict = new _primitives.Dict(xref);
dict.set('foo', 'bar');
expect((0, _util.getInheritableProperty)({
dict: dict,
key: 'foo'
})).toEqual('bar');
dict.set('baz', ['qux', ref]);
expect((0, _util.getInheritableProperty)({
dict: dict,
key: 'baz',
getArray: true
})).toEqual(['qux', 'quux']);
});
it('fetches the property if it is inherited and present on one level', function () {
var ref = new _primitives.Ref(10, 0);
var xref = new _test_utils.XRefMock([{
ref: ref,
data: 'quux'
}]);
var firstDict = new _primitives.Dict(xref);
var secondDict = new _primitives.Dict(xref);
firstDict.set('Parent', secondDict);
secondDict.set('foo', 'bar');
expect((0, _util.getInheritableProperty)({
dict: firstDict,
key: 'foo'
})).toEqual('bar');
secondDict.set('baz', ['qux', ref]);
expect((0, _util.getInheritableProperty)({
dict: firstDict,
key: 'baz',
getArray: true
})).toEqual(['qux', 'quux']);
});
it('fetches the property if it is inherited and present on multiple levels', function () {
var ref = new _primitives.Ref(10, 0);
var xref = new _test_utils.XRefMock([{
ref: ref,
data: 'quux'
}]);
var firstDict = new _primitives.Dict(xref);
var secondDict = new _primitives.Dict(xref);
firstDict.set('Parent', secondDict);
firstDict.set('foo', 'bar1');
secondDict.set('foo', 'bar2');
expect((0, _util.getInheritableProperty)({
dict: firstDict,
key: 'foo'
})).toEqual('bar1');
expect((0, _util.getInheritableProperty)({
dict: firstDict,
key: 'foo',
getArray: false,
stopWhenFound: false
})).toEqual(['bar1', 'bar2']);
firstDict.set('baz', ['qux1', ref]);
secondDict.set('baz', ['qux2', ref]);
expect((0, _util.getInheritableProperty)({
dict: firstDict,
key: 'baz',
getArray: true,
stopWhenFound: false
})).toEqual([['qux1', 'quux'], ['qux2', 'quux']]);
});
it('stops searching when the loop limit is reached', function () {
var dict = new _primitives.Dict();
var currentDict = dict;
var parentDict = null;
for (var i = 0; i < 150; i++) {
parentDict = new _primitives.Dict();
currentDict.set('Parent', parentDict);
currentDict = parentDict;
}
parentDict.set('foo', 'bar');
expect((0, _util.getInheritableProperty)({
dict: dict,
key: 'foo'
})).toEqual(undefined);
dict.set('foo', 'baz');
expect((0, _util.getInheritableProperty)({
dict: dict,
key: 'foo',
getArray: false,
stopWhenFound: false
})).toEqual(['baz']);
});
});
describe('isArrayBuffer', function () { describe('isArrayBuffer', function () {
it('handles array buffer values', function () { it('handles array buffer values', function () {
expect((0, _util.isArrayBuffer)(new ArrayBuffer(0))).toEqual(true); expect((0, _util.isArrayBuffer)(new ArrayBuffer(0))).toEqual(true);

4
lib/web/pdf_viewer.component.js

@ -48,8 +48,8 @@ var _pdf_single_page_viewer = require('./pdf_single_page_viewer');
var _pdf_viewer = require('./pdf_viewer.js'); var _pdf_viewer = require('./pdf_viewer.js');
var pdfjsVersion = '2.0.421'; var pdfjsVersion = '2.0.424';
var pdfjsBuild = 'e0fb18a3'; var pdfjsBuild = 'fded22c6';
exports.PDFViewer = _pdf_viewer.PDFViewer; exports.PDFViewer = _pdf_viewer.PDFViewer;
exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer; exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
exports.PDFPageView = _pdf_page_view.PDFPageView; exports.PDFPageView = _pdf_page_view.PDFPageView;

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "2.0.421", "version": "2.0.424",
"main": "build/pdf.js", "main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [

4
web/pdf_viewer.js

@ -3180,8 +3180,8 @@ var _pdf_single_page_viewer = __w_pdfjs_require__(16);
var _pdf_viewer = __w_pdfjs_require__(17); var _pdf_viewer = __w_pdfjs_require__(17);
var pdfjsVersion = '2.0.421'; var pdfjsVersion = '2.0.424';
var pdfjsBuild = 'e0fb18a3'; var pdfjsBuild = 'fded22c6';
exports.PDFViewer = _pdf_viewer.PDFViewer; exports.PDFViewer = _pdf_viewer.PDFViewer;
exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer; exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
exports.PDFPageView = _pdf_page_view.PDFPageView; exports.PDFPageView = _pdf_page_view.PDFPageView;

2
web/pdf_viewer.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save