Browse Source

PDF.js version 1.8.233 - See mozilla/pdf.js@19321937da8ca71d7687a7a66ca2169dcf0a63db

master v1.8.233
pdfjsbot 8 years ago
parent
commit
a3bcdb680a
  1. 2
      bower.json
  2. 2977
      build/pdf.combined.js
  3. 2994
      build/pdf.js
  4. 12
      build/pdf.min.js
  5. 4
      build/pdf.worker.js
  6. 115
      lib/display/annotation_layer.js
  7. 222
      lib/display/api.js
  8. 164
      lib/display/canvas.js
  9. 39
      lib/display/dom_utils.js
  10. 321
      lib/display/font_loader.js
  11. 164
      lib/display/global.js
  12. 11
      lib/display/metadata.js
  13. 44
      lib/display/pattern_helper.js
  14. 1844
      lib/display/svg.js
  15. 31
      lib/display/text_layer.js
  16. 17
      lib/display/webgl.js
  17. 4
      lib/pdf.js
  18. 4
      lib/pdf.worker.js
  19. 5
      lib/web/chromecom.js
  20. 7
      lib/web/download_manager.js
  21. 33
      lib/web/genericcom.js
  22. 60
      lib/web/password_prompt.js
  23. 102
      lib/web/pdf_document_properties.js
  24. 85
      lib/web/pdf_find_bar.js
  25. 10
      lib/web/pdf_find_controller.js
  26. 2
      lib/web/pdf_history.js
  27. 2
      lib/web/pdf_link_service.js
  28. 14
      lib/web/pdf_page_view.js
  29. 18
      lib/web/pdf_thumbnail_view.js
  30. 123
      lib/web/pdf_viewer.js
  31. 2
      lib/web/text_layer_builder.js
  32. 2
      package.json
  33. 8440
      web/pdf_viewer.js

2
bower.json

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

2977
build/pdf.combined.js

File diff suppressed because it is too large Load Diff

2994
build/pdf.js

File diff suppressed because it is too large Load Diff

12
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

4
build/pdf.worker.js vendored

@ -36954,8 +36954,8 @@ exports.Type1Parser = Type1Parser; @@ -36954,8 +36954,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.213';
var pdfjsBuild = 'c6e8ca86';
var pdfjsVersion = '1.8.233';
var pdfjsBuild = '19321937';
var pdfjsCoreWorker = __w_pdfjs_require__(8);
{
__w_pdfjs_require__(19);

115
lib/display/annotation_layer.js

@ -14,28 +14,25 @@ @@ -14,28 +14,25 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var displayDOMUtils = require('./dom_utils.js');
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationType = sharedUtil.AnnotationType;
var stringToPDFString = sharedUtil.stringToPDFString;
var Util = sharedUtil.Util;
var addLinkAttributes = displayDOMUtils.addLinkAttributes;
var LinkTarget = displayDOMUtils.LinkTarget;
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
var warn = sharedUtil.warn;
var CustomStyle = displayDOMUtils.CustomStyle;
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AnnotationLayer = undefined;
var _dom_utils = require('./dom_utils');
var _util = require('../shared/util');
function AnnotationElementFactory() {}
AnnotationElementFactory.prototype = {
create: function AnnotationElementFactory_create(parameters) {
var subtype = parameters.data.annotationType;
switch (subtype) {
case AnnotationType.LINK:
case _util.AnnotationType.LINK:
return new LinkAnnotationElement(parameters);
case AnnotationType.TEXT:
case _util.AnnotationType.TEXT:
return new TextAnnotationElement(parameters);
case AnnotationType.WIDGET:
case _util.AnnotationType.WIDGET:
var fieldType = parameters.data.fieldType;
switch (fieldType) {
case 'Tx':
@ -46,25 +43,25 @@ AnnotationElementFactory.prototype = { @@ -46,25 +43,25 @@ AnnotationElementFactory.prototype = {
} else if (parameters.data.checkBox) {
return new CheckboxWidgetAnnotationElement(parameters);
}
warn('Unimplemented button widget annotation: pushbutton');
(0, _util.warn)('Unimplemented button widget annotation: pushbutton');
break;
case 'Ch':
return new ChoiceWidgetAnnotationElement(parameters);
}
return new WidgetAnnotationElement(parameters);
case AnnotationType.POPUP:
case _util.AnnotationType.POPUP:
return new PopupAnnotationElement(parameters);
case AnnotationType.LINE:
case _util.AnnotationType.LINE:
return new LineAnnotationElement(parameters);
case AnnotationType.HIGHLIGHT:
case _util.AnnotationType.HIGHLIGHT:
return new HighlightAnnotationElement(parameters);
case AnnotationType.UNDERLINE:
case _util.AnnotationType.UNDERLINE:
return new UnderlineAnnotationElement(parameters);
case AnnotationType.SQUIGGLY:
case _util.AnnotationType.SQUIGGLY:
return new SquigglyAnnotationElement(parameters);
case AnnotationType.STRIKEOUT:
case _util.AnnotationType.STRIKEOUT:
return new StrikeOutAnnotationElement(parameters);
case AnnotationType.FILEATTACHMENT:
case _util.AnnotationType.FILEATTACHMENT:
return new FileAttachmentAnnotationElement(parameters);
default:
return new AnnotationElement(parameters);
@ -95,12 +92,12 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -95,12 +92,12 @@ var AnnotationElement = function AnnotationElementClosure() {
var width = data.rect[2] - data.rect[0];
var height = data.rect[3] - data.rect[1];
container.setAttribute('data-annotation-id', data.id);
var rect = Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
_dom_utils.CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
_dom_utils.CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
if (!ignoreBorder && data.borderStyle.width > 0) {
container.style.borderWidth = data.borderStyle.width + 'px';
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
width = width - 2 * data.borderStyle.width;
height = height - 2 * data.borderStyle.width;
}
@ -108,29 +105,29 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -108,29 +105,29 @@ var AnnotationElement = function AnnotationElementClosure() {
var verticalRadius = data.borderStyle.verticalCornerRadius;
if (horizontalRadius > 0 || verticalRadius > 0) {
var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
CustomStyle.setProp('borderRadius', container, radius);
_dom_utils.CustomStyle.setProp('borderRadius', container, radius);
}
switch (data.borderStyle.style) {
case AnnotationBorderStyleType.SOLID:
case _util.AnnotationBorderStyleType.SOLID:
container.style.borderStyle = 'solid';
break;
case AnnotationBorderStyleType.DASHED:
case _util.AnnotationBorderStyleType.DASHED:
container.style.borderStyle = 'dashed';
break;
case AnnotationBorderStyleType.BEVELED:
warn('Unimplemented border style: beveled');
case _util.AnnotationBorderStyleType.BEVELED:
(0, _util.warn)('Unimplemented border style: beveled');
break;
case AnnotationBorderStyleType.INSET:
warn('Unimplemented border style: inset');
case _util.AnnotationBorderStyleType.INSET:
(0, _util.warn)('Unimplemented border style: inset');
break;
case AnnotationBorderStyleType.UNDERLINE:
case _util.AnnotationBorderStyleType.UNDERLINE:
container.style.borderBottomStyle = 'solid';
break;
default:
break;
}
if (data.color) {
container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
} else {
container.style.borderWidth = 0;
}
@ -170,13 +167,13 @@ var LinkAnnotationElement = function LinkAnnotationElementClosure() { @@ -170,13 +167,13 @@ var LinkAnnotationElement = function LinkAnnotationElementClosure() {
function LinkAnnotationElement(parameters) {
AnnotationElement.call(this, parameters, true);
}
Util.inherit(LinkAnnotationElement, AnnotationElement, {
_util.Util.inherit(LinkAnnotationElement, AnnotationElement, {
render: function LinkAnnotationElement_render() {
this.container.className = 'linkAnnotation';
var link = document.createElement('a');
addLinkAttributes(link, {
(0, _dom_utils.addLinkAttributes)(link, {
url: this.data.url,
target: this.data.newWindow ? LinkTarget.BLANK : undefined
target: this.data.newWindow ? _dom_utils.LinkTarget.BLANK : undefined
});
if (!this.data.url) {
if (this.data.action) {
@ -218,7 +215,7 @@ var TextAnnotationElement = function TextAnnotationElementClosure() { @@ -218,7 +215,7 @@ var TextAnnotationElement = function TextAnnotationElementClosure() {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
}
Util.inherit(TextAnnotationElement, AnnotationElement, {
_util.Util.inherit(TextAnnotationElement, AnnotationElement, {
render: function TextAnnotationElement_render() {
this.container.className = 'textAnnotation';
var image = document.createElement('img');
@ -241,7 +238,7 @@ var WidgetAnnotationElement = function WidgetAnnotationElementClosure() { @@ -241,7 +238,7 @@ var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
function WidgetAnnotationElement(parameters, isRenderable) {
AnnotationElement.call(this, parameters, isRenderable);
}
Util.inherit(WidgetAnnotationElement, AnnotationElement, {
_util.Util.inherit(WidgetAnnotationElement, AnnotationElement, {
render: function WidgetAnnotationElement_render() {
return this.container;
}
@ -254,7 +251,7 @@ var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() @@ -254,7 +251,7 @@ var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure()
var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
WidgetAnnotationElement.call(this, parameters, isRenderable);
}
Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
_util.Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
render: function TextWidgetAnnotationElement_render() {
this.container.className = 'textWidgetAnnotation';
var element = null;
@ -314,7 +311,7 @@ var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementCl @@ -314,7 +311,7 @@ var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementCl
function CheckboxWidgetAnnotationElement(parameters) {
WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
}
Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
_util.Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
render: function CheckboxWidgetAnnotationElement_render() {
this.container.className = 'buttonWidgetAnnotation checkBox';
var element = document.createElement('input');
@ -333,7 +330,7 @@ var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationEle @@ -333,7 +330,7 @@ var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationEle
function RadioButtonWidgetAnnotationElement(parameters) {
WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
}
Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
_util.Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
render: function RadioButtonWidgetAnnotationElement_render() {
this.container.className = 'buttonWidgetAnnotation radioButton';
var element = document.createElement('input');
@ -353,7 +350,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur @@ -353,7 +350,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur
function ChoiceWidgetAnnotationElement(parameters) {
WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
}
Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
_util.Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
render: function ChoiceWidgetAnnotationElement_render() {
this.container.className = 'choiceWidgetAnnotation';
var selectElement = document.createElement('select');
@ -386,7 +383,7 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() { @@ -386,7 +383,7 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() {
var isRenderable = !!(parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
}
Util.inherit(PopupAnnotationElement, AnnotationElement, {
_util.Util.inherit(PopupAnnotationElement, AnnotationElement, {
render: function PopupAnnotationElement_render() {
this.container.className = 'popupAnnotation';
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
@ -406,7 +403,7 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() { @@ -406,7 +403,7 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() {
});
var parentLeft = parseFloat(parentElement.style.left);
var parentWidth = parseFloat(parentElement.style.width);
CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
_dom_utils.CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
this.container.style.left = parentLeft + parentWidth + 'px';
this.container.appendChild(popup.render());
return this.container;
@ -438,7 +435,7 @@ var PopupElement = function PopupElementClosure() { @@ -438,7 +435,7 @@ var PopupElement = function PopupElementClosure() {
var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
}
var contents = this._formatContents(this.contents);
var title = document.createElement('h1');
@ -498,7 +495,7 @@ var LineAnnotationElement = function LineAnnotationElementClosure() { @@ -498,7 +495,7 @@ var LineAnnotationElement = function LineAnnotationElementClosure() {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(LineAnnotationElement, AnnotationElement, {
_util.Util.inherit(LineAnnotationElement, AnnotationElement, {
render: function LineAnnotationElement_render() {
this.container.className = 'lineAnnotation';
var data = this.data;
@ -530,7 +527,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() { @@ -530,7 +527,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(HighlightAnnotationElement, AnnotationElement, {
_util.Util.inherit(HighlightAnnotationElement, AnnotationElement, {
render: function HighlightAnnotationElement_render() {
this.container.className = 'highlightAnnotation';
if (!this.data.hasPopup) {
@ -546,7 +543,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() { @@ -546,7 +543,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
_util.Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
render: function UnderlineAnnotationElement_render() {
this.container.className = 'underlineAnnotation';
if (!this.data.hasPopup) {
@ -562,7 +559,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() { @@ -562,7 +559,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
_util.Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
render: function SquigglyAnnotationElement_render() {
this.container.className = 'squigglyAnnotation';
if (!this.data.hasPopup) {
@ -578,7 +575,7 @@ var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() { @@ -578,7 +575,7 @@ var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
_util.Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
render: function StrikeOutAnnotationElement_render() {
this.container.className = 'strikeoutAnnotation';
if (!this.data.hasPopup) {
@ -593,15 +590,15 @@ var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementCl @@ -593,15 +590,15 @@ var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementCl
function FileAttachmentAnnotationElement(parameters) {
AnnotationElement.call(this, parameters, true);
var file = this.data.file;
this.filename = getFilenameFromUrl(file.filename);
this.filename = (0, _dom_utils.getFilenameFromUrl)(file.filename);
this.content = file.content;
this.linkService.onFileAttachmentAnnotation({
id: stringToPDFString(file.filename),
id: (0, _util.stringToPDFString)(file.filename),
filename: file.filename,
content: file.content
});
}
Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
_util.Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
render: function FileAttachmentAnnotationElement_render() {
this.container.className = 'fileAttachmentAnnotation';
var trigger = document.createElement('div');
@ -616,7 +613,7 @@ var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementCl @@ -616,7 +613,7 @@ var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementCl
},
_download: function FileAttachmentAnnotationElement_download() {
if (!this.downloadManager) {
warn('Download cannot be started due to unavailable download manager');
(0, _util.warn)('Download cannot be started due to unavailable download manager');
return;
}
this.downloadManager.downloadData(this.content, this.filename, '');
@ -640,7 +637,7 @@ var AnnotationLayer = function AnnotationLayerClosure() { @@ -640,7 +637,7 @@ var AnnotationLayer = function AnnotationLayerClosure() {
viewport: parameters.viewport,
linkService: parameters.linkService,
downloadManager: parameters.downloadManager,
imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
imageResourcesPath: parameters.imageResourcesPath || (0, _dom_utils.getDefaultSetting)('imageResourcesPath'),
renderInteractiveForms: parameters.renderInteractiveForms || false
});
if (element.isRenderable) {
@ -653,7 +650,7 @@ var AnnotationLayer = function AnnotationLayerClosure() { @@ -653,7 +650,7 @@ var AnnotationLayer = function AnnotationLayerClosure() {
var data = parameters.annotations[i];
var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
if (element) {
CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
_dom_utils.CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
}
}
parameters.div.removeAttribute('hidden');

222
lib/display/api.js

@ -14,44 +14,23 @@ @@ -14,44 +14,23 @@
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.build = exports.version = exports._UnsupportedManager = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.getDocument = 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 sharedUtil = require('../shared/util.js');
var displayFontLoader = require('./font_loader.js');
var displayCanvas = require('./canvas.js');
var displayMetadata = require('./metadata.js');
var displayDOMUtils = require('./dom_utils.js');
var amdRequire;
var InvalidPDFException = sharedUtil.InvalidPDFException;
var MessageHandler = sharedUtil.MessageHandler;
var MissingPDFException = sharedUtil.MissingPDFException;
var PageViewport = sharedUtil.PageViewport;
var PasswordException = sharedUtil.PasswordException;
var StatTimer = sharedUtil.StatTimer;
var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
var UnknownErrorException = sharedUtil.UnknownErrorException;
var Util = sharedUtil.Util;
var createPromiseCapability = sharedUtil.createPromiseCapability;
var error = sharedUtil.error;
var deprecated = sharedUtil.deprecated;
var getVerbosityLevel = sharedUtil.getVerbosityLevel;
var info = sharedUtil.info;
var isInt = sharedUtil.isInt;
var isArray = sharedUtil.isArray;
var isArrayBuffer = sharedUtil.isArrayBuffer;
var isSameOrigin = sharedUtil.isSameOrigin;
var loadJpegStream = sharedUtil.loadJpegStream;
var stringToBytes = sharedUtil.stringToBytes;
var globalScope = sharedUtil.globalScope;
var warn = sharedUtil.warn;
var FontFaceObject = displayFontLoader.FontFaceObject;
var FontLoader = displayFontLoader.FontLoader;
var CanvasGraphics = displayCanvas.CanvasGraphics;
var Metadata = displayMetadata.Metadata;
var RenderingCancelledException = displayDOMUtils.RenderingCancelledException;
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
var _util = require('../shared/util');
var _dom_utils = require('./dom_utils');
var _font_loader = require('./font_loader');
var _canvas = require('./canvas');
var _metadata = require('./metadata');
var DEFAULT_RANGE_CHUNK_SIZE = 65536;
var isWorkerDisabled = false;
var workerSrc;
@ -87,7 +66,7 @@ if (typeof __pdfjsdev_webpack__ === 'undefined') { @@ -87,7 +66,7 @@ if (typeof __pdfjsdev_webpack__ === 'undefined') {
function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
var task = new PDFDocumentLoadingTask();
if (arguments.length > 1) {
deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
(0, _util.deprecated)('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
}
if (pdfDataRangeTransport) {
if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
@ -106,16 +85,16 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb @@ -106,16 +85,16 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb
var source;
if (typeof src === 'string') {
source = { url: src };
} else if (isArrayBuffer(src)) {
} else if ((0, _util.isArrayBuffer)(src)) {
source = { data: src };
} else if (src instanceof PDFDataRangeTransport) {
source = { range: src };
} else {
if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) !== 'object') {
error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
(0, _util.error)('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
}
if (!src.url && !src.data && !src.range) {
error('Invalid parameter object: need either .data, .range or .url');
(0, _util.error)('Invalid parameter object: need either .data, .range or .url');
}
source = src;
}
@ -135,13 +114,13 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb @@ -135,13 +114,13 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb
} else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
var pdfBytes = source[key];
if (typeof pdfBytes === 'string') {
params[key] = stringToBytes(pdfBytes);
params[key] = (0, _util.stringToBytes)(pdfBytes);
} else if ((typeof pdfBytes === 'undefined' ? 'undefined' : _typeof(pdfBytes)) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
params[key] = new Uint8Array(pdfBytes);
} else if (isArrayBuffer(pdfBytes)) {
} else if ((0, _util.isArrayBuffer)(pdfBytes)) {
params[key] = new Uint8Array(pdfBytes);
} else {
error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
(0, _util.error)('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
}
continue;
}
@ -150,9 +129,9 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb @@ -150,9 +129,9 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
params.ignoreErrors = params.stopAtErrors !== true;
var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
var CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory;
if (!worker) {
var workerPort = getDefaultSetting('workerPort');
var workerPort = (0, _dom_utils.getDefaultSetting)('workerPort');
worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
task._worker = worker;
}
@ -165,7 +144,7 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb @@ -165,7 +144,7 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb
if (task.destroyed) {
throw new Error('Loading aborted');
}
var messageHandler = new MessageHandler(docId, workerId, worker.port);
var messageHandler = new _util.MessageHandler(docId, workerId, worker.port);
var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
task._transport = transport;
messageHandler.send('Ready', null);
@ -177,8 +156,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -177,8 +156,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
if (worker.destroyed) {
return Promise.reject(new Error('Worker was destroyed'));
}
source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
source.disableStream = getDefaultSetting('disableStream');
source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
source.chunkedViewerLoading = !!pdfDataRangeTransport;
if (pdfDataRangeTransport) {
source.length = pdfDataRangeTransport.length;
@ -187,11 +166,11 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -187,11 +166,11 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId: docId,
source: source,
disableRange: getDefaultSetting('disableRange'),
maxImageSize: getDefaultSetting('maxImageSize'),
disableFontFace: getDefaultSetting('disableFontFace'),
disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
disableRange: (0, _dom_utils.getDefaultSetting)('disableRange'),
maxImageSize: (0, _dom_utils.getDefaultSetting)('maxImageSize'),
disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'),
disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'),
postMessageTransfers: (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled,
docBaseUrl: source.docBaseUrl,
disableNativeImageDecoder: source.disableNativeImageDecoder,
ignoreErrors: source.ignoreErrors
@ -205,7 +184,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -205,7 +184,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
var nextDocumentId = 0;
function PDFDocumentLoadingTask() {
this._capability = createPromiseCapability();
this._capability = (0, _util.createPromiseCapability)();
this._transport = null;
this._worker = null;
this.docId = 'd' + nextDocumentId++;
@ -242,7 +221,7 @@ var PDFDataRangeTransport = function pdfDataRangeTransportClosure() { @@ -242,7 +221,7 @@ var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
this._rangeListeners = [];
this._progressListeners = [];
this._progressiveReadListeners = [];
this._readyCapability = createPromiseCapability();
this._readyCapability = (0, _util.createPromiseCapability)();
}
PDFDataRangeTransport.prototype = {
addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
@ -349,8 +328,8 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -349,8 +328,8 @@ var PDFPageProxy = function PDFPageProxyClosure() {
this.pageIndex = pageIndex;
this.pageInfo = pageInfo;
this.transport = transport;
this.stats = new StatTimer();
this.stats.enabled = getDefaultSetting('enableStats');
this.stats = new _util.StatTimer();
this.stats.enabled = (0, _dom_utils.getDefaultSetting)('enableStats');
this.commonObjs = transport.commonObjs;
this.objs = new PDFObjects();
this.cleanupAfterRender = false;
@ -378,7 +357,7 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -378,7 +357,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
if (arguments.length < 2) {
rotate = this.rotate;
}
return new PageViewport(this.view, scale, rotate, 0, 0);
return new _util.PageViewport(this.view, scale, rotate, 0, 0);
},
getAnnotations: function PDFPageProxy_getAnnotations(params) {
var intent = params && params.intent || null;
@ -393,14 +372,14 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -393,14 +372,14 @@ var PDFPageProxy = function PDFPageProxyClosure() {
stats.time('Overall');
this.pendingCleanup = false;
var renderingIntent = params.intent === 'print' ? 'print' : 'display';
var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
var canvasFactory = params.canvasFactory || new _dom_utils.DOMCanvasFactory();
if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = Object.create(null);
}
var intentState = this.intentStates[renderingIntent];
if (!intentState.displayReadyCapability) {
intentState.receivingOperatorList = true;
intentState.displayReadyCapability = createPromiseCapability();
intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
intentState.operatorList = {
fnArray: [],
argsArray: [],
@ -421,7 +400,7 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -421,7 +400,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
intentState.renderTasks.push(internalRenderTask);
var renderTask = internalRenderTask.task;
if (params.continueCallback) {
deprecated('render is used with continueCallback parameter');
(0, _util.deprecated)('render is used with continueCallback parameter');
renderTask.onContinue = params.continueCallback;
}
var self = this;
@ -475,7 +454,7 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -475,7 +454,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
opListTask = {};
opListTask.operatorListChanged = operatorListChanged;
intentState.receivingOperatorList = true;
intentState.opListReadCapability = createPromiseCapability();
intentState.opListReadCapability = (0, _util.createPromiseCapability)();
intentState.renderTasks = [];
intentState.renderTasks.push(opListTask);
intentState.operatorList = {
@ -519,7 +498,7 @@ var PDFPageProxy = function PDFPageProxyClosure() { @@ -519,7 +498,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
return Promise.all(waitOn);
},
destroy: function destroy() {
deprecated('page destroy method, use cleanup() instead');
(0, _util.deprecated)('page destroy method, use cleanup() instead');
this.cleanup();
},
cleanup: function PDFPageProxy_cleanup() {
@ -571,13 +550,13 @@ var PDFWorker = function PDFWorkerClosure() { @@ -571,13 +550,13 @@ var PDFWorker = function PDFWorkerClosure() {
if (typeof workerSrc !== 'undefined') {
return workerSrc;
}
if (getDefaultSetting('workerSrc')) {
return getDefaultSetting('workerSrc');
if ((0, _dom_utils.getDefaultSetting)('workerSrc')) {
return (0, _dom_utils.getDefaultSetting)('workerSrc');
}
if (pdfjsFilePath) {
return pdfjsFilePath.replace(/(\.(?:min\.)?js)$/i, '.worker$1');
}
error('No PDFJS.workerSrc specified');
(0, _util.error)('No PDFJS.workerSrc specified');
}
var fakeWorkerFilesLoadedCapability;
function setupFakeWorkerGlobal() {
@ -585,9 +564,9 @@ var PDFWorker = function PDFWorkerClosure() { @@ -585,9 +564,9 @@ var PDFWorker = function PDFWorkerClosure() {
if (fakeWorkerFilesLoadedCapability) {
return fakeWorkerFilesLoadedCapability.promise;
}
fakeWorkerFilesLoadedCapability = createPromiseCapability();
fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
var loader = fakeWorkerFilesLoader || function (callback) {
Util.loadScript(getWorkerSrc(), function () {
_util.Util.loadScript(getWorkerSrc(), function () {
callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
});
};
@ -610,7 +589,7 @@ var PDFWorker = function PDFWorkerClosure() { @@ -610,7 +589,7 @@ var PDFWorker = function PDFWorkerClosure() {
}
var result;
var buffer;
if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
var transferable = transfers && transfers.indexOf(buffer) >= 0;
if (value === buffer) {
result = value;
@ -622,7 +601,7 @@ var PDFWorker = function PDFWorkerClosure() { @@ -622,7 +601,7 @@ var PDFWorker = function PDFWorkerClosure() {
cloned.set(value, result);
return result;
}
result = isArray(value) ? [] : {};
result = (0, _util.isArray)(value) ? [] : {};
cloned.set(value, result);
for (var i in value) {
var desc,
@ -669,7 +648,7 @@ var PDFWorker = function PDFWorkerClosure() { @@ -669,7 +648,7 @@ var PDFWorker = function PDFWorkerClosure() {
function PDFWorker(name, port) {
this.name = name;
this.destroyed = false;
this._readyCapability = createPromiseCapability();
this._readyCapability = (0, _util.createPromiseCapability)();
this._port = null;
this._webWorker = null;
this._messageHandler = null;
@ -691,19 +670,19 @@ var PDFWorker = function PDFWorkerClosure() { @@ -691,19 +670,19 @@ var PDFWorker = function PDFWorkerClosure() {
},
_initializeFromPort: function PDFWorker_initializeFromPort(port) {
this._port = port;
this._messageHandler = new MessageHandler('main', 'worker', port);
this._messageHandler = new _util.MessageHandler('main', 'worker', port);
this._messageHandler.on('ready', function () {});
this._readyCapability.resolve();
},
_initialize: function PDFWorker_initialize() {
if (!isWorkerDisabled && !getDefaultSetting('disableWorker') && typeof Worker !== 'undefined') {
if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker') && typeof Worker !== 'undefined') {
var workerSrc = getWorkerSrc();
try {
if (!isSameOrigin(window.location.href, workerSrc)) {
if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
}
var worker = new Worker(workerSrc);
var messageHandler = new MessageHandler('main', 'worker', worker);
var messageHandler = new _util.MessageHandler('main', 'worker', worker);
var terminateEarly = function () {
worker.removeEventListener('error', onWorkerError);
messageHandler.destroy();
@ -735,7 +714,7 @@ var PDFWorker = function PDFWorkerClosure() { @@ -735,7 +714,7 @@ var PDFWorker = function PDFWorkerClosure() {
isPostMessageTransfersDisabled = true;
}
this._readyCapability.resolve();
messageHandler.send('configure', { verbosity: getVerbosityLevel() });
messageHandler.send('configure', { verbosity: (0, _util.getVerbosityLevel)() });
} else {
this._setupFakeWorker();
messageHandler.destroy();
@ -761,12 +740,12 @@ var PDFWorker = function PDFWorkerClosure() { @@ -761,12 +740,12 @@ var PDFWorker = function PDFWorkerClosure() {
}
}.bind(this));
var sendTest = function sendTest() {
var postMessageTransfers = getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled;
var postMessageTransfers = (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled;
var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]);
try {
messageHandler.send('test', testObj, [testObj.buffer]);
} catch (ex) {
info('Cannot use postMessage transfers');
(0, _util.info)('Cannot use postMessage transfers');
testObj[0] = 0;
messageHandler.send('test', testObj);
}
@ -774,14 +753,14 @@ var PDFWorker = function PDFWorkerClosure() { @@ -774,14 +753,14 @@ var PDFWorker = function PDFWorkerClosure() {
sendTest();
return;
} catch (e) {
info('The worker has been disabled.');
(0, _util.info)('The worker has been disabled.');
}
}
this._setupFakeWorker();
},
_setupFakeWorker: function PDFWorker_setupFakeWorker() {
if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
warn('Setting up fake worker.');
if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker')) {
(0, _util.warn)('Setting up fake worker.');
isWorkerDisabled = true;
}
setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
@ -793,9 +772,9 @@ var PDFWorker = function PDFWorkerClosure() { @@ -793,9 +772,9 @@ var PDFWorker = function PDFWorkerClosure() {
var port = new FakeWorkerPort(isTypedArraysPresent);
this._port = port;
var id = 'fake' + nextFakeWorkerId++;
var workerHandler = new MessageHandler(id + '_worker', id, port);
var workerHandler = new _util.MessageHandler(id + '_worker', id, port);
WorkerMessageHandler.setup(workerHandler, port);
var messageHandler = new MessageHandler(id, id + '_worker', port);
var messageHandler = new _util.MessageHandler(id, id + '_worker', port);
this._messageHandler = messageHandler;
this._readyCapability.resolve();
}.bind(this));
@ -821,17 +800,17 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -821,17 +800,17 @@ var WorkerTransport = function WorkerTransportClosure() {
this.loadingTask = loadingTask;
this.pdfDataRangeTransport = pdfDataRangeTransport;
this.commonObjs = new PDFObjects();
this.fontLoader = new FontLoader(loadingTask.docId);
this.fontLoader = new _font_loader.FontLoader(loadingTask.docId);
this.CMapReaderFactory = new CMapReaderFactory({
baseUrl: getDefaultSetting('cMapUrl'),
isCompressed: getDefaultSetting('cMapPacked')
baseUrl: (0, _dom_utils.getDefaultSetting)('cMapUrl'),
isCompressed: (0, _dom_utils.getDefaultSetting)('cMapPacked')
});
this.destroyed = false;
this.destroyCapability = null;
this._passwordCapability = null;
this.pageCache = [];
this.pagePromises = [];
this.downloadInfoCapability = createPromiseCapability();
this.downloadInfoCapability = (0, _util.createPromiseCapability)();
this.setupMessageHandler();
}
WorkerTransport.prototype = {
@ -840,7 +819,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -840,7 +819,7 @@ var WorkerTransport = function WorkerTransportClosure() {
return this.destroyCapability.promise;
}
this.destroyed = true;
this.destroyCapability = createPromiseCapability();
this.destroyCapability = (0, _util.createPromiseCapability)();
if (this._passwordCapability) {
this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
}
@ -899,31 +878,31 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -899,31 +878,31 @@ var WorkerTransport = function WorkerTransportClosure() {
loadingTask._capability.resolve(pdfDocument);
}, this);
messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
this._passwordCapability = createPromiseCapability();
this._passwordCapability = (0, _util.createPromiseCapability)();
if (loadingTask.onPassword) {
var updatePassword = function (password) {
this._passwordCapability.resolve({ password: password });
}.bind(this);
loadingTask.onPassword(updatePassword, exception.code);
} else {
this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
}
return this._passwordCapability.promise;
}, this);
messageHandler.on('PasswordException', function transportPasswordException(exception) {
loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
}, this);
messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
this.loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
}, this);
messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
this.loadingTask._capability.reject(new MissingPDFException(exception.message));
this.loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
}, this);
messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
this.loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
}, this);
messageHandler.on('UnknownError', function transportUnknownError(exception) {
this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
this.loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
}, this);
messageHandler.on('DataLoaded', function transportPage(data) {
this.downloadInfoCapability.resolve(data);
@ -962,21 +941,21 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -962,21 +941,21 @@ var WorkerTransport = function WorkerTransportClosure() {
var exportedData = data[2];
if ('error' in exportedData) {
var exportedError = exportedData.error;
warn('Error during font loading: ' + exportedError);
(0, _util.warn)('Error during font loading: ' + exportedError);
this.commonObjs.resolve(id, exportedError);
break;
}
var fontRegistry = null;
if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
if ((0, _dom_utils.getDefaultSetting)('pdfBug') && _util.globalScope.FontInspector && _util.globalScope['FontInspector'].enabled) {
fontRegistry = {
registerFont: function registerFont(font, url) {
globalScope['FontInspector'].fontAdded(font, url);
_util.globalScope['FontInspector'].fontAdded(font, url);
}
};
}
var font = new FontFaceObject(exportedData, {
isEvalSuported: getDefaultSetting('isEvalSupported'),
disableFontFace: getDefaultSetting('disableFontFace'),
var font = new _font_loader.FontFaceObject(exportedData, {
isEvalSuported: (0, _dom_utils.getDefaultSetting)('isEvalSupported'),
disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'),
fontRegistry: fontRegistry
});
this.fontLoader.bind([font], function fontReady(fontObjs) {
@ -987,7 +966,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -987,7 +966,7 @@ var WorkerTransport = function WorkerTransportClosure() {
this.commonObjs.resolve(id, data[2]);
break;
default:
error('Got unknown common object type ' + type);
(0, _util.error)('Got unknown common object type ' + type);
}
}, this);
messageHandler.on('obj', function transportObj(data) {
@ -1005,7 +984,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -1005,7 +984,7 @@ var WorkerTransport = function WorkerTransportClosure() {
switch (type) {
case 'JpegStream':
imageData = data[3];
loadJpegStream(id, imageData, pageProxy.objs);
(0, _util.loadJpegStream)(id, imageData, pageProxy.objs);
break;
case 'Image':
imageData = data[3];
@ -1016,7 +995,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -1016,7 +995,7 @@ var WorkerTransport = function WorkerTransportClosure() {
}
break;
default:
error('Got unknown object type ' + type);
(0, _util.error)('Got unknown object type ' + type);
}
}, this);
messageHandler.on('DocProgress', function transportDocProgress(data) {
@ -1040,7 +1019,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -1040,7 +1019,7 @@ var WorkerTransport = function WorkerTransportClosure() {
if (intentState.displayReadyCapability) {
intentState.displayReadyCapability.reject(data.error);
} else {
error(data.error);
(0, _util.error)(data.error);
}
if (intentState.operatorList) {
intentState.operatorList.lastChunk = true;
@ -1121,7 +1100,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -1121,7 +1100,7 @@ var WorkerTransport = function WorkerTransportClosure() {
return this.messageHandler.sendWithPromise('GetData', null);
},
getPage: function WorkerTransport_getPage(pageNumber, capability) {
if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
if (!(0, _util.isInt)(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
return Promise.reject(new Error('Invalid page request'));
}
var pageIndex = pageNumber - 1;
@ -1172,7 +1151,7 @@ var WorkerTransport = function WorkerTransportClosure() { @@ -1172,7 +1151,7 @@ var WorkerTransport = function WorkerTransportClosure() {
return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
return {
info: results[0],
metadata: results[1] ? new Metadata(results[1]) : null
metadata: results[1] ? new _metadata.Metadata(results[1]) : null
};
});
},
@ -1204,7 +1183,7 @@ var PDFObjects = function PDFObjectsClosure() { @@ -1204,7 +1183,7 @@ var PDFObjects = function PDFObjectsClosure() {
return this.objs[objId];
}
var obj = {
capability: createPromiseCapability(),
capability: (0, _util.createPromiseCapability)(),
data: null,
resolved: false
};
@ -1218,7 +1197,7 @@ var PDFObjects = function PDFObjectsClosure() { @@ -1218,7 +1197,7 @@ var PDFObjects = function PDFObjectsClosure() {
}
var obj = this.objs[objId];
if (!obj || !obj.resolved) {
error('Requesting object that isn\'t resolved yet ' + objId);
(0, _util.error)('Requesting object that isn\'t resolved yet ' + objId);
}
return obj.data;
},
@ -1284,7 +1263,7 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -1284,7 +1263,7 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
this.graphicsReady = false;
this.useRequestAnimationFrame = false;
this.cancelled = false;
this.capability = createPromiseCapability();
this.capability = (0, _util.createPromiseCapability)();
this.task = new RenderTask(this);
this._continueBound = this._continue.bind(this);
this._scheduleNextBound = this._scheduleNext.bind(this);
@ -1295,13 +1274,13 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -1295,13 +1274,13 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
if (this.cancelled) {
return;
}
if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
if ((0, _dom_utils.getDefaultSetting)('pdfBug') && _util.globalScope.StepperManager && _util.globalScope.StepperManager.enabled) {
this.stepper = _util.globalScope.StepperManager.create(this.pageNumber - 1);
this.stepper.init(this.operatorList);
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
}
var params = this.params;
this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
this.gfx.beginDrawing(params.transform, params.viewport, transparency);
this.operatorListIdx = 0;
this.graphicsReady = true;
@ -1312,8 +1291,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -1312,8 +1291,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
cancel: function InternalRenderTask_cancel() {
this.running = false;
this.cancelled = true;
if (getDefaultSetting('pdfjsNext')) {
this.callback(new RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas'));
if ((0, _dom_utils.getDefaultSetting)('pdfjsNext')) {
this.callback(new _dom_utils.RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas'));
} else {
this.callback('cancelled');
}
@ -1371,7 +1350,7 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1371,7 +1350,7 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
var listeners = [];
return {
listen: function listen(cb) {
deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
(0, _util.deprecated)('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
listeners.push(cb);
},
notify: function notify(featureId) {
@ -1381,11 +1360,16 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1381,11 +1360,16 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.213';
exports.build = 'c6e8ca86';
var version, build;
{
exports.version = version = '1.8.233';
exports.build = build = '19321937';
}
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;
exports.PDFDocumentProxy = PDFDocumentProxy;
exports.PDFPageProxy = PDFPageProxy;
exports._UnsupportedManager = _UnsupportedManager;
exports._UnsupportedManager = _UnsupportedManager;
exports.version = version;
exports.build = build;

164
lib/display/canvas.js

@ -14,27 +14,17 @@ @@ -14,27 +14,17 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var displayDOMUtils = require('./dom_utils.js');
var displayPatternHelper = require('./pattern_helper.js');
var displayWebGL = require('./webgl.js');
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
var ImageKind = sharedUtil.ImageKind;
var OPS = sharedUtil.OPS;
var TextRenderingMode = sharedUtil.TextRenderingMode;
var Util = sharedUtil.Util;
var assert = sharedUtil.assert;
var info = sharedUtil.info;
var isNum = sharedUtil.isNum;
var isArray = sharedUtil.isArray;
var isLittleEndian = sharedUtil.isLittleEndian;
var error = sharedUtil.error;
var shadow = sharedUtil.shadow;
var warn = sharedUtil.warn;
var TilingPattern = displayPatternHelper.TilingPattern;
var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
var WebGLUtils = displayWebGL.WebGLUtils;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CanvasGraphics = undefined;
var _util = require('../shared/util');
var _pattern_helper = require('./pattern_helper');
var _webgl = require('./webgl');
var MIN_FONT_SIZE = 16;
var MAX_FONT_SIZE = 100;
var MAX_GROUP_SIZE = 4096;
@ -44,7 +34,7 @@ var MAX_SIZE_TO_COMPILE = 1000; @@ -44,7 +34,7 @@ var MAX_SIZE_TO_COMPILE = 1000;
var FULL_CHUNK_HEIGHT = 16;
var IsLittleEndianCached = {
get value() {
return shadow(IsLittleEndianCached, 'value', isLittleEndian());
return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
}
};
function addContextCurrentTransform(ctx) {
@ -295,9 +285,9 @@ var CanvasExtraState = function CanvasExtraStateClosure() { @@ -295,9 +285,9 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
this.alphaIsShape = false;
this.fontSize = 0;
this.fontSizeScale = 1;
this.textMatrix = IDENTITY_MATRIX;
this.textMatrix = _util.IDENTITY_MATRIX;
this.textMatrixScale = 1;
this.fontMatrix = FONT_IDENTITY_MATRIX;
this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
this.leading = 0;
this.x = 0;
this.y = 0;
@ -306,7 +296,7 @@ var CanvasExtraState = function CanvasExtraStateClosure() { @@ -306,7 +296,7 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
this.charSpacing = 0;
this.wordSpacing = 0;
this.textHScale = 1;
this.textRenderingMode = TextRenderingMode.FILL;
this.textRenderingMode = _util.TextRenderingMode.FILL;
this.textRise = 0;
this.fillColor = '#000000';
this.strokeColor = '#000000';
@ -374,7 +364,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -374,7 +364,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var src = imgData.data;
var dest = chunkImgData.data;
var i, j, thisChunkHeight, elemsInThisChunk;
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
var srcLength = src.byteLength;
var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
var dest32DataLength = dest32.length;
@ -416,7 +406,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -416,7 +406,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
}
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
}
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
} else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
j = 0;
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
for (i = 0; i < fullChunks; i++) {
@ -430,7 +420,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -430,7 +420,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
ctx.putImageData(chunkImgData, 0, j);
}
} else if (imgData.kind === ImageKind.RGB_24BPP) {
} else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
thisChunkHeight = FULL_CHUNK_HEIGHT;
elemsInThisChunk = width * thisChunkHeight;
for (i = 0; i < totalChunks; i++) {
@ -448,7 +438,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -448,7 +438,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
}
} else {
error('bad image kind: ' + imgData.kind);
(0, _util.error)('bad image kind: ' + imgData.kind);
}
}
function putBinaryImageMask(ctx, imgData) {
@ -552,8 +542,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -552,8 +542,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var maskCtx = smask.context;
ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
var backdrop = smask.backdrop || null;
if (!smask.transferMap && WebGLUtils.isEnabled) {
var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
if (!smask.transferMap && _webgl.WebGLUtils.isEnabled) {
var composed = _webgl.WebGLUtils.composeSMask(layerCtx.canvas, mask, {
subtype: smask.subtype,
backdrop: backdrop
});
@ -614,7 +604,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -614,7 +604,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
return i;
}
fnId = fnArray[i];
if (fnId !== OPS.dependency) {
if (fnId !== _util.OPS.dependency) {
this[fnId].apply(this, argsArray[i]);
} else {
var deps = argsArray[i];
@ -655,7 +645,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -655,7 +645,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.transparentCanvas = null;
}
this.cachedCanvases.clear();
WebGLUtils.clear();
_webgl.WebGLUtils.clear();
if (this.imageLayer) {
this.imageLayer.endLayout();
}
@ -768,7 +758,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -768,7 +758,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.ctx.save();
copyCtxState(groupCtx, this.ctx);
this.current.resumeSMaskCtx = groupCtx;
var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
this.ctx.transform.apply(this.ctx, deltaTransform);
groupCtx.save();
groupCtx.setTransform(1, 0, 0, 1, 0, 0);
@ -789,7 +779,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -789,7 +779,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
composeSMask(this.ctx, this.current.activeSMask, groupCtx);
this.ctx.restore();
copyCtxState(groupCtx, this.ctx);
var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
this.ctx.transform.apply(this.ctx, deltaTransform);
},
save: function CanvasGraphics_save() {
@ -824,7 +814,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -824,7 +814,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
y = current.y;
for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
switch (ops[i] | 0) {
case OPS.rectangle:
case _util.OPS.rectangle:
x = args[j++];
y = args[j++];
var width = args[j++];
@ -844,35 +834,35 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -844,35 +834,35 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.ctx.lineTo(x, y);
this.ctx.closePath();
break;
case OPS.moveTo:
case _util.OPS.moveTo:
x = args[j++];
y = args[j++];
ctx.moveTo(x, y);
break;
case OPS.lineTo:
case _util.OPS.lineTo:
x = args[j++];
y = args[j++];
ctx.lineTo(x, y);
break;
case OPS.curveTo:
case _util.OPS.curveTo:
x = args[j + 4];
y = args[j + 5];
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
j += 6;
break;
case OPS.curveTo2:
case _util.OPS.curveTo2:
ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
x = args[j + 2];
y = args[j + 3];
j += 4;
break;
case OPS.curveTo3:
case _util.OPS.curveTo3:
x = args[j + 2];
y = args[j + 3];
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
j += 4;
break;
case OPS.closePath:
case _util.OPS.closePath:
ctx.closePath();
break;
}
@ -964,7 +954,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -964,7 +954,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.pendingClip = EO_CLIP;
},
beginText: function CanvasGraphics_beginText() {
this.current.textMatrix = IDENTITY_MATRIX;
this.current.textMatrix = _util.IDENTITY_MATRIX;
this.current.textMatrixScale = 1;
this.current.x = this.current.lineX = 0;
this.current.y = this.current.lineY = 0;
@ -1005,11 +995,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1005,11 +995,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var fontObj = this.commonObjs.get(fontRefName);
var current = this.current;
if (!fontObj) {
error('Can\'t find font for ' + fontRefName);
(0, _util.error)('Can\'t find font for ' + fontRefName);
}
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
warn('Invalid font matrix for font ' + fontRefName);
(0, _util.warn)('Invalid font matrix for font ' + fontRefName);
}
if (size < 0) {
size = -size;
@ -1060,8 +1050,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1060,8 +1050,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var font = current.font;
var textRenderingMode = current.textRenderingMode;
var fontSize = current.fontSize / current.fontSizeScale;
var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
var addToPath;
if (font.disableFontFace || isAddToPathSet) {
addToPath = font.getPathGenerator(this.commonObjs, character);
@ -1071,18 +1061,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1071,18 +1061,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
ctx.translate(x, y);
ctx.beginPath();
addToPath(ctx, fontSize);
if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
ctx.fill();
}
if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
ctx.stroke();
}
ctx.restore();
} else {
if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
ctx.fillText(character, x, y);
}
if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
ctx.strokeText(character, x, y);
}
}
@ -1109,7 +1099,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1109,7 +1099,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
break;
}
}
return shadow(this, 'isFontSubpixelAAEnabled', enabled);
return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
},
showText: function CanvasGraphics_showText(glyphs) {
var current = this.current;
@ -1132,7 +1122,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1132,7 +1122,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var spacingDir = vertical ? 1 : -1;
var defaultVMetrics = font.defaultVMetrics;
var widthAdvanceScale = fontSize * current.fontMatrix[0];
var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace;
ctx.save();
ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y + current.textRise);
@ -1147,8 +1137,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1147,8 +1137,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var lineWidth = current.lineWidth;
var scale = current.textMatrixScale;
if (scale === 0 || lineWidth === 0) {
var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
this.cachedGetSinglePixelWidth = null;
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
}
@ -1164,7 +1154,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1164,7 +1154,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
i;
for (i = 0; i < glyphsLength; ++i) {
var glyph = glyphs[i];
if (isNum(glyph)) {
if ((0, _util.isNum)(glyph)) {
x += spacingDir * glyph * fontSize / 1000;
continue;
}
@ -1234,9 +1224,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1234,9 +1224,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var charSpacing = current.charSpacing;
var wordSpacing = current.wordSpacing;
var textHScale = current.textHScale * fontDirection;
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
var glyphsLength = glyphs.length;
var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
var i, glyph, width, spacingLength;
if (isTextInvisible || fontSize === 0) {
return;
@ -1248,7 +1238,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1248,7 +1238,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
ctx.scale(textHScale, fontDirection);
for (i = 0; i < glyphsLength; ++i) {
glyph = glyphs[i];
if (isNum(glyph)) {
if ((0, _util.isNum)(glyph)) {
spacingLength = spacingDir * glyph * fontSize / 1000;
this.ctx.translate(spacingLength, 0);
current.x += spacingLength * textHScale;
@ -1257,7 +1247,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1257,7 +1247,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
var operatorList = font.charProcOperatorList[glyph.operatorListId];
if (!operatorList) {
warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
(0, _util.warn)('Type3 character \"' + glyph.operatorListId + '\" is not available');
continue;
}
this.processingType3 = glyph;
@ -1266,7 +1256,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1266,7 +1256,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
ctx.transform.apply(ctx, fontMatrix);
this.executeOperatorList(operatorList);
this.restore();
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
width = transformed[0] * fontSize + spacing;
ctx.translate(width, 0);
current.x += width * textHScale;
@ -1291,9 +1281,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1291,9 +1281,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
}
};
pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
} else {
pattern = getShadingPatternFromIR(IR);
pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
}
return pattern;
},
@ -1305,12 +1295,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1305,12 +1295,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.current.patternFill = true;
},
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(r, g, b);
var color = _util.Util.makeCssRgb(r, g, b);
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
},
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(r, g, b);
var color = _util.Util.makeCssRgb(r, g, b);
this.ctx.fillStyle = color;
this.current.fillColor = color;
this.current.patternFill = false;
@ -1318,17 +1308,17 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1318,17 +1308,17 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
var ctx = this.ctx;
this.save();
var pattern = getShadingPatternFromIR(patternIR);
var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
ctx.fillStyle = pattern.getPattern(ctx, this, true);
var inv = ctx.mozCurrentTransformInverse;
if (inv) {
var canvas = ctx.canvas;
var width = canvas.width;
var height = canvas.height;
var bl = Util.applyTransform([0, 0], inv);
var br = Util.applyTransform([0, height], inv);
var ul = Util.applyTransform([width, 0], inv);
var ur = Util.applyTransform([width, height], inv);
var bl = _util.Util.applyTransform([0, 0], inv);
var br = _util.Util.applyTransform([0, height], inv);
var ul = _util.Util.applyTransform([width, 0], inv);
var ur = _util.Util.applyTransform([width, height], inv);
var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
@ -1340,19 +1330,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1340,19 +1330,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.restore();
},
beginInlineImage: function CanvasGraphics_beginInlineImage() {
error('Should not call beginInlineImage');
(0, _util.error)('Should not call beginInlineImage');
},
beginImageData: function CanvasGraphics_beginImageData() {
error('Should not call beginImageData');
(0, _util.error)('Should not call beginImageData');
},
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
this.save();
this.baseTransformStack.push(this.baseTransform);
if (isArray(matrix) && matrix.length === 6) {
if ((0, _util.isArray)(matrix) && matrix.length === 6) {
this.transform.apply(this, matrix);
}
this.baseTransform = this.ctx.mozCurrentTransform;
if (isArray(bbox) && bbox.length === 4) {
if ((0, _util.isArray)(bbox) && bbox.length === 4) {
var width = bbox[2] - bbox[0];
var height = bbox[3] - bbox[1];
this.ctx.rect(bbox[0], bbox[1], width, height);
@ -1368,19 +1358,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1368,19 +1358,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.save();
var currentCtx = this.ctx;
if (!group.isolated) {
info('TODO: Support non-isolated groups.');
(0, _util.info)('TODO: Support non-isolated groups.');
}
if (group.knockout) {
warn('Knockout groups not supported.');
(0, _util.warn)('Knockout groups not supported.');
}
var currentTransform = currentCtx.mozCurrentTransform;
if (group.matrix) {
currentCtx.transform.apply(currentCtx, group.matrix);
}
assert(group.bbox, 'Bounding box is required.');
var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
(0, _util.assert)(group.bbox, 'Bounding box is required.');
var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
var offsetX = Math.floor(bounds[0]);
var offsetY = Math.floor(bounds[1]);
var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
@ -1457,7 +1447,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1457,7 +1447,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
},
beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
this.save();
if (isArray(rect) && rect.length === 4) {
if ((0, _util.isArray)(rect) && rect.length === 4) {
var width = rect[2] - rect[0];
var height = rect[3] - rect[1];
this.ctx.rect(rect[0], rect[1], width, height);
@ -1473,7 +1463,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1473,7 +1463,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
var domImage = this.objs.get(objId);
if (!domImage) {
warn('Dependent image isn\'t ready yet');
(0, _util.warn)('Dependent image isn\'t ready yet');
return;
}
this.save();
@ -1573,7 +1563,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1573,7 +1563,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
var imgData = this.objs.get(objId);
if (!imgData) {
warn('Dependent image isn\'t ready yet');
(0, _util.warn)('Dependent image isn\'t ready yet');
return;
}
this.paintInlineImageXObject(imgData);
@ -1581,7 +1571,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1581,7 +1571,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
var imgData = this.objs.get(objId);
if (!imgData) {
warn('Dependent image isn\'t ready yet');
(0, _util.warn)('Dependent image isn\'t ready yet');
return;
}
var width = imgData.width;
@ -1686,7 +1676,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1686,7 +1676,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
this.ctx.fillRect(0, 0, 1, 1);
},
paintXObject: function CanvasGraphics_paintXObject() {
warn('Unsupported \'paintXObject\' command.');
(0, _util.warn)('Unsupported \'paintXObject\' command.');
},
markPoint: function CanvasGraphics_markPoint(tag) {},
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
@ -1721,8 +1711,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() { @@ -1721,8 +1711,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
}
};
for (var op in OPS) {
CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
for (var op in _util.OPS) {
CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
}
return CanvasGraphics;
}();

39
lib/display/dom_utils.js

@ -14,19 +14,18 @@ @@ -14,19 +14,18 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var assert = sharedUtil.assert;
var removeNullCharacters = sharedUtil.removeNullCharacters;
var warn = sharedUtil.warn;
var deprecated = sharedUtil.deprecated;
var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
var stringToBytes = sharedUtil.stringToBytes;
var CMapCompressionType = sharedUtil.CMapCompressionType;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.getDefaultSetting = exports.LinkTarget = exports.getFilenameFromUrl = exports.isValidUrl = exports.isExternalLinkTargetSet = exports.addLinkAttributes = exports.RenderingCancelledException = exports.CustomStyle = undefined;
var _util = require('../shared/util');
var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
function DOMCanvasFactory() {}
DOMCanvasFactory.prototype = {
create: function DOMCanvasFactory_create(width, height) {
assert(width > 0 && height > 0, 'invalid canvas size');
(0, _util.assert)(width > 0 && height > 0, 'invalid canvas size');
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
canvas.width = width;
@ -37,13 +36,13 @@ DOMCanvasFactory.prototype = { @@ -37,13 +36,13 @@ DOMCanvasFactory.prototype = {
};
},
reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
assert(canvasAndContextPair.canvas, 'canvas is not specified');
assert(width > 0 && height > 0, 'invalid canvas size');
(0, _util.assert)(canvasAndContextPair.canvas, 'canvas is not specified');
(0, _util.assert)(width > 0 && height > 0, 'invalid canvas size');
canvasAndContextPair.canvas.width = width;
canvasAndContextPair.canvas.height = height;
},
destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
assert(canvasAndContextPair.canvas, 'canvas is not specified');
(0, _util.assert)(canvasAndContextPair.canvas, 'canvas is not specified');
canvasAndContextPair.canvas.width = 0;
canvasAndContextPair.canvas.height = 0;
canvasAndContextPair.canvas = null;
@ -77,12 +76,12 @@ var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() { @@ -77,12 +76,12 @@ var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
if (this.isCompressed && request.response) {
data = new Uint8Array(request.response);
} else if (!this.isCompressed && request.responseText) {
data = stringToBytes(request.responseText);
data = (0, _util.stringToBytes)(request.responseText);
}
if (data) {
resolve({
cMapData: data,
compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
compressionType: this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
});
return;
}
@ -147,7 +146,7 @@ var LinkTarget = { @@ -147,7 +146,7 @@ var LinkTarget = {
var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
function addLinkAttributes(link, params) {
var url = params && params.url;
link.href = link.title = url ? removeNullCharacters(url) : '';
link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
if (url) {
var target = params.target;
if (typeof target === 'undefined') {
@ -168,7 +167,7 @@ function getFilenameFromUrl(url) { @@ -168,7 +167,7 @@ function getFilenameFromUrl(url) {
return url.substring(url.lastIndexOf('/', end) + 1, end);
}
function getDefaultSetting(id) {
var globalSettings = sharedUtil.globalScope.PDFJS;
var globalSettings = _util.globalScope.PDFJS;
switch (id) {
case 'pdfBug':
return globalSettings ? globalSettings.pdfBug : false;
@ -214,7 +213,7 @@ function getDefaultSetting(id) { @@ -214,7 +213,7 @@ function getDefaultSetting(id) {
case LinkTarget.TOP:
return globalSettings.externalLinkTarget;
}
warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
(0, _util.warn)('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
globalSettings.externalLinkTarget = LinkTarget.NONE;
return LinkTarget.NONE;
case 'externalLinkRel':
@ -240,17 +239,17 @@ function isExternalLinkTargetSet() { @@ -240,17 +239,17 @@ function isExternalLinkTargetSet() {
}
}
function isValidUrl(url, allowRelative) {
deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
(0, _util.deprecated)('isValidUrl(), please use createValidAbsoluteUrl() instead.');
var baseUrl = allowRelative ? 'http://example.com' : null;
return createValidAbsoluteUrl(url, baseUrl) !== null;
return (0, _util.createValidAbsoluteUrl)(url, baseUrl) !== null;
}
exports.CustomStyle = CustomStyle;
exports.RenderingCancelledException = RenderingCancelledException;
exports.addLinkAttributes = addLinkAttributes;
exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
exports.isValidUrl = isValidUrl;
exports.getFilenameFromUrl = getFilenameFromUrl;
exports.LinkTarget = LinkTarget;
exports.RenderingCancelledException = RenderingCancelledException;
exports.getDefaultSetting = getDefaultSetting;
exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
exports.DOMCanvasFactory = DOMCanvasFactory;

321
lib/display/font_loader.js

@ -14,12 +14,13 @@ @@ -14,12 +14,13 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var assert = sharedUtil.assert;
var bytesToString = sharedUtil.bytesToString;
var string32 = sharedUtil.string32;
var shadow = sharedUtil.shadow;
var warn = sharedUtil.warn;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FontLoader = exports.FontFaceObject = undefined;
var _util = require('../shared/util');
function FontLoader(docId) {
this.docId = docId;
this.styleElement = null;
@ -52,170 +53,176 @@ FontLoader.prototype = { @@ -52,170 +53,176 @@ FontLoader.prototype = {
this.nativeFontFaces.length = 0;
}
};
var getLoadTestFont = function getLoadTestFont() {
return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
};
Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
get: function get() {
return shadow(this, 'loadTestFont', getLoadTestFont());
},
configurable: true
});
FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
this.nativeFontFaces.push(nativeFontFace);
document.fonts.add(nativeFontFace);
};
FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
var rules = [];
var fontsToLoad = [];
var fontLoadPromises = [];
var getNativeFontPromise = function getNativeFontPromise(nativeFontFace) {
return nativeFontFace.loaded.catch(function (e) {
warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
});
{
var getLoadTestFont = function getLoadTestFont() {
return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
};
Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
get: function get() {
return (0, _util.shadow)(this, 'loadTestFont', getLoadTestFont());
},
configurable: true
});
FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
this.nativeFontFaces.push(nativeFontFace);
document.fonts.add(nativeFontFace);
};
var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
for (var i = 0, ii = fonts.length; i < ii; i++) {
var font = fonts[i];
if (font.attached || font.loading === false) {
continue;
FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
var rules = [];
var fontsToLoad = [];
var fontLoadPromises = [];
var getNativeFontPromise = function getNativeFontPromise(nativeFontFace) {
return nativeFontFace.loaded.catch(function (e) {
(0, _util.warn)('Failed to load font "' + nativeFontFace.family + '": ' + e);
});
};
var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
for (var i = 0, ii = fonts.length; i < ii; i++) {
var font = fonts[i];
if (font.attached || font.loading === false) {
continue;
}
font.attached = true;
if (isFontLoadingAPISupported) {
var nativeFontFace = font.createNativeFontFace();
if (nativeFontFace) {
this.addNativeFontFace(nativeFontFace);
fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
}
} else {
var rule = font.createFontFaceRule();
if (rule) {
this.insertRule(rule);
rules.push(rule);
fontsToLoad.push(font);
}
}
}
font.attached = true;
var request = this.queueLoadingCallback(callback);
if (isFontLoadingAPISupported) {
var nativeFontFace = font.createNativeFontFace();
if (nativeFontFace) {
this.addNativeFontFace(nativeFontFace);
fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
}
Promise.all(fontLoadPromises).then(function () {
request.complete();
});
} else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
this.prepareFontLoadEvent(rules, fontsToLoad, request);
} else {
var rule = font.createFontFaceRule();
if (rule) {
this.insertRule(rule);
rules.push(rule);
fontsToLoad.push(font);
request.complete();
}
};
FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
function LoadLoader_completeRequest() {
(0, _util.assert)(!request.end, 'completeRequest() cannot be called twice');
request.end = Date.now();
while (context.requests.length > 0 && context.requests[0].end) {
var otherRequest = context.requests.shift();
setTimeout(otherRequest.callback, 0);
}
}
}
var request = this.queueLoadingCallback(callback);
if (isFontLoadingAPISupported) {
Promise.all(fontLoadPromises).then(function () {
var context = this.loadingContext;
var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
var request = {
id: requestId,
complete: LoadLoader_completeRequest,
callback: callback,
started: Date.now()
};
context.requests.push(request);
return request;
};
FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
function int32(data, offset) {
return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
}
function spliceString(s, offset, remove, insert) {
var chunk1 = s.substr(0, offset);
var chunk2 = s.substr(offset + remove);
return chunk1 + insert + chunk2;
}
var i, ii;
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
var ctx = canvas.getContext('2d');
var called = 0;
function isFontReady(name, callback) {
called++;
if (called > 30) {
(0, _util.warn)('Load test font never loaded.');
callback();
return;
}
ctx.font = '30px ' + name;
ctx.fillText('.', 0, 20);
var imageData = ctx.getImageData(0, 0, 1, 1);
if (imageData.data[3] > 0) {
callback();
return;
}
setTimeout(isFontReady.bind(null, name, callback));
}
var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
var data = this.loadTestFont;
var COMMENT_OFFSET = 976;
data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
var CFF_CHECKSUM_OFFSET = 16;
var XXXX_VALUE = 0x58585858;
var checksum = int32(data, CFF_CHECKSUM_OFFSET);
for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
}
if (i < loadTestFontId.length) {
checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
}
data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
this.insertRule(rule);
var names = [];
for (i = 0, ii = fonts.length; i < ii; i++) {
names.push(fonts[i].loadedName);
}
names.push(loadTestFontId);
var div = document.createElement('div');
div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
for (i = 0, ii = names.length; i < ii; ++i) {
var span = document.createElement('span');
span.textContent = 'Hi';
span.style.fontFamily = names[i];
div.appendChild(span);
}
document.body.appendChild(div);
isFontReady(loadTestFontId, function () {
document.body.removeChild(div);
request.complete();
});
} else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
this.prepareFontLoadEvent(rules, fontsToLoad, request);
} else {
request.complete();
}
};
FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
function LoadLoader_completeRequest() {
assert(!request.end, 'completeRequest() cannot be called twice');
request.end = Date.now();
while (context.requests.length > 0 && context.requests[0].end) {
var otherRequest = context.requests.shift();
setTimeout(otherRequest.callback, 0);
}
}
var context = this.loadingContext;
var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
var request = {
id: requestId,
complete: LoadLoader_completeRequest,
callback: callback,
started: Date.now()
};
context.requests.push(request);
return request;
};
FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
function int32(data, offset) {
return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
}
function spliceString(s, offset, remove, insert) {
var chunk1 = s.substr(0, offset);
var chunk2 = s.substr(offset + remove);
return chunk1 + insert + chunk2;
}
var i, ii;
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
var ctx = canvas.getContext('2d');
var called = 0;
function isFontReady(name, callback) {
called++;
if (called > 30) {
warn('Load test font never loaded.');
callback();
return;
}
{
FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
}
{
var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
if (typeof navigator === 'undefined') {
return true;
}
ctx.font = '30px ' + name;
ctx.fillText('.', 0, 20);
var imageData = ctx.getImageData(0, 0, 1, 1);
if (imageData.data[3] > 0) {
callback();
return;
var supported = false;
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
if (m && m[1] >= 14) {
supported = true;
}
setTimeout(isFontReady.bind(null, name, callback));
}
var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
var data = this.loadTestFont;
var COMMENT_OFFSET = 976;
data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
var CFF_CHECKSUM_OFFSET = 16;
var XXXX_VALUE = 0x58585858;
var checksum = int32(data, CFF_CHECKSUM_OFFSET);
for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
}
if (i < loadTestFontId.length) {
checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
}
data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
this.insertRule(rule);
var names = [];
for (i = 0, ii = fonts.length; i < ii; i++) {
names.push(fonts[i].loadedName);
}
names.push(loadTestFontId);
var div = document.createElement('div');
div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
for (i = 0, ii = names.length; i < ii; ++i) {
var span = document.createElement('span');
span.textContent = 'Hi';
span.style.fontFamily = names[i];
div.appendChild(span);
}
document.body.appendChild(div);
isFontReady(loadTestFontId, function () {
document.body.removeChild(div);
request.complete();
return supported;
};
Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
get: function get() {
return (0, _util.shadow)(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
},
enumerable: true,
configurable: true
});
};
FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
if (typeof navigator === 'undefined') {
return true;
}
var supported = false;
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
if (m && m[1] >= 14) {
supported = true;
}
return supported;
};
Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
get: function get() {
return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
},
enumerable: true,
configurable: true
});
}
var IsEvalSupportedCached = {
get value() {
return shadow(this, 'value', sharedUtil.isEvalSupported());
return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
}
};
var FontFaceObject = function FontFaceObjectClosure() {
@ -249,7 +256,7 @@ var FontFaceObject = function FontFaceObjectClosure() { @@ -249,7 +256,7 @@ var FontFaceObject = function FontFaceObjectClosure() {
this.disableFontFace = true;
return null;
}
var data = bytesToString(new Uint8Array(this.data));
var data = (0, _util.bytesToString)(new Uint8Array(this.data));
var fontName = this.loadedName;
var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';

164
lib/display/global.js

@ -14,66 +14,74 @@ @@ -14,66 +14,74 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var displayDOMUtils = require('./dom_utils.js');
var displayAPI = require('./api.js');
var displayAnnotationLayer = require('./annotation_layer.js');
var displayTextLayer = require('./text_layer.js');
var displayMetadata = require('./metadata.js');
var displaySVG = require('./svg.js');
var globalScope = sharedUtil.globalScope;
var deprecated = sharedUtil.deprecated;
var warn = sharedUtil.warn;
var LinkTarget = displayDOMUtils.LinkTarget;
var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFJS = exports.isWorker = exports.globalScope = undefined;
var _api = require('./api');
var _dom_utils = require('./dom_utils');
var _util = require('../shared/util');
var _annotation_layer = require('./annotation_layer');
var _metadata = require('./metadata');
var _text_layer = require('./text_layer');
var _svg = require('./svg');
var isWorker = typeof window === 'undefined';
if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
if (!_util.globalScope.PDFJS) {
_util.globalScope.PDFJS = {};
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.233';
PDFJS.build = '19321937';
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.213';
PDFJS.build = 'c6e8ca86';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
(0, _util.setVerbosityLevel)(PDFJS.verbosity);
}
delete PDFJS.verbosity;
Object.defineProperty(PDFJS, 'verbosity', {
get: function get() {
return sharedUtil.getVerbosityLevel();
return (0, _util.getVerbosityLevel)();
},
set: function set(level) {
sharedUtil.setVerbosityLevel(level);
(0, _util.setVerbosityLevel)(level);
},
enumerable: true,
configurable: true
});
PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
PDFJS.OPS = sharedUtil.OPS;
PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
PDFJS.shadow = sharedUtil.shadow;
PDFJS.createBlob = sharedUtil.createBlob;
PDFJS.VERBOSITY_LEVELS = _util.VERBOSITY_LEVELS;
PDFJS.OPS = _util.OPS;
PDFJS.UNSUPPORTED_FEATURES = _util.UNSUPPORTED_FEATURES;
PDFJS.isValidUrl = _dom_utils.isValidUrl;
PDFJS.shadow = _util.shadow;
PDFJS.createBlob = _util.createBlob;
PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
return (0, _util.createObjectURL)(data, contentType, PDFJS.disableCreateObjectURL);
};
Object.defineProperty(PDFJS, 'isLittleEndian', {
configurable: true,
get: function PDFJS_isLittleEndian() {
var value = sharedUtil.isLittleEndian();
return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
return (0, _util.shadow)(PDFJS, 'isLittleEndian', (0, _util.isLittleEndian)());
}
});
PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
PDFJS.PasswordException = sharedUtil.PasswordException;
PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
PDFJS.Util = sharedUtil.Util;
PDFJS.PageViewport = sharedUtil.PageViewport;
PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
PDFJS.removeNullCharacters = _util.removeNullCharacters;
PDFJS.PasswordResponses = _util.PasswordResponses;
PDFJS.PasswordException = _util.PasswordException;
PDFJS.UnknownErrorException = _util.UnknownErrorException;
PDFJS.InvalidPDFException = _util.InvalidPDFException;
PDFJS.MissingPDFException = _util.MissingPDFException;
PDFJS.UnexpectedResponseException = _util.UnexpectedResponseException;
PDFJS.Util = _util.Util;
PDFJS.PageViewport = _util.PageViewport;
PDFJS.createPromiseCapability = _util.createPromiseCapability;
PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
@ -89,46 +97,48 @@ PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug; @@ -89,46 +97,48 @@ PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? _dom_utils.LinkTarget.NONE : PDFJS.externalLinkTarget;
PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? _dom_utils.DEFAULT_LINK_REL : PDFJS.externalLinkRel;
PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext;
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
delete PDFJS.openExternalLinksInNewWindow;
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
get: function get() {
return PDFJS.externalLinkTarget === LinkTarget.BLANK;
},
set: function set(value) {
if (value) {
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
}
if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
warn('PDFJS.externalLinkTarget is already initialized');
return;
}
PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
},
enumerable: true,
configurable: true
});
if (savedOpenExternalLinksInNewWindow) {
PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
{
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
delete PDFJS.openExternalLinksInNewWindow;
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
get: function get() {
return PDFJS.externalLinkTarget === _dom_utils.LinkTarget.BLANK;
},
set: function set(value) {
if (value) {
(0, _util.deprecated)('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
}
if (PDFJS.externalLinkTarget !== _dom_utils.LinkTarget.NONE) {
(0, _util.warn)('PDFJS.externalLinkTarget is already initialized');
return;
}
PDFJS.externalLinkTarget = value ? _dom_utils.LinkTarget.BLANK : _dom_utils.LinkTarget.NONE;
},
enumerable: true,
configurable: true
});
if (savedOpenExternalLinksInNewWindow) {
PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
}
}
PDFJS.getDocument = displayAPI.getDocument;
PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
PDFJS.PDFWorker = displayAPI.PDFWorker;
PDFJS.getDocument = _api.getDocument;
PDFJS.PDFDataRangeTransport = _api.PDFDataRangeTransport;
PDFJS.PDFWorker = _api.PDFWorker;
PDFJS.hasCanvasTypedArrays = true;
PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
PDFJS.LinkTarget = LinkTarget;
PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
PDFJS.Metadata = displayMetadata.Metadata;
PDFJS.SVGGraphics = displaySVG.SVGGraphics;
PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
exports.globalScope = globalScope;
PDFJS.CustomStyle = _dom_utils.CustomStyle;
PDFJS.LinkTarget = _dom_utils.LinkTarget;
PDFJS.addLinkAttributes = _dom_utils.addLinkAttributes;
PDFJS.getFilenameFromUrl = _dom_utils.getFilenameFromUrl;
PDFJS.isExternalLinkTargetSet = _dom_utils.isExternalLinkTargetSet;
PDFJS.AnnotationLayer = _annotation_layer.AnnotationLayer;
PDFJS.renderTextLayer = _text_layer.renderTextLayer;
PDFJS.Metadata = _metadata.Metadata;
PDFJS.SVGGraphics = _svg.SVGGraphics;
PDFJS.UnsupportedManager = _api._UnsupportedManager;
exports.globalScope = _util.globalScope;
exports.isWorker = isWorker;
exports.PDFJS = globalScope.PDFJS;
exports.PDFJS = PDFJS;

11
lib/display/metadata.js

@ -14,8 +14,13 @@ @@ -14,8 +14,13 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var error = sharedUtil.error;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Metadata = undefined;
var _util = require('../shared/util');
function fixMetadata(meta) {
return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
@ -35,7 +40,7 @@ function Metadata(meta) { @@ -35,7 +40,7 @@ function Metadata(meta) {
var parser = new DOMParser();
meta = parser.parseFromString(meta, 'application/xml');
} else if (!(meta instanceof Document)) {
error('Metadata: Invalid metadata object');
(0, _util.error)('Metadata: Invalid metadata object');
}
this.metaDocument = meta;
this.metadata = Object.create(null);

44
lib/display/pattern_helper.js

@ -14,13 +14,15 @@ @@ -14,13 +14,15 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var displayWebGL = require('./webgl.js');
var Util = sharedUtil.Util;
var info = sharedUtil.info;
var isArray = sharedUtil.isArray;
var error = sharedUtil.error;
var WebGLUtils = displayWebGL.WebGLUtils;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TilingPattern = exports.getShadingPatternFromIR = undefined;
var _util = require('../shared/util');
var _webgl = require('./webgl');
var ShadingIRs = {};
ShadingIRs.RadialAxial = {
fromIR: function RadialAxial_fromIR(raw) {
@ -157,7 +159,7 @@ var createMeshCanvas = function createMeshCanvasClosure() { @@ -157,7 +159,7 @@ var createMeshCanvas = function createMeshCanvasClosure() {
}
break;
default:
error('illigal figure');
(0, _util.error)('illigal figure');
break;
}
}
@ -184,8 +186,8 @@ var createMeshCanvas = function createMeshCanvasClosure() { @@ -184,8 +186,8 @@ var createMeshCanvas = function createMeshCanvasClosure() {
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);
if (_webgl.WebGLUtils.isEnabled) {
canvas = _webgl.WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
canvas = tmpCanvas.canvas;
@ -231,11 +233,11 @@ ShadingIRs.Mesh = { @@ -231,11 +233,11 @@ ShadingIRs.Mesh = {
getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
var scale;
if (shadingFill) {
scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
} else {
scale = Util.singularValueDecompose2dScale(owner.baseTransform);
scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
if (matrix) {
var matrixScale = Util.singularValueDecompose2dScale(matrix);
var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
}
}
@ -266,7 +268,7 @@ ShadingIRs.Dummy = { @@ -266,7 +268,7 @@ ShadingIRs.Dummy = {
function getShadingPatternFromIR(raw) {
var shadingIR = ShadingIRs[raw[0]];
if (!shadingIR) {
error('Unknown IR type: ' + raw[0]);
(0, _util.error)('Unknown IR type: ' + raw[0]);
}
return shadingIR.fromIR(raw);
}
@ -279,7 +281,7 @@ var TilingPattern = function TilingPatternClosure() { @@ -279,7 +281,7 @@ var TilingPattern = function TilingPatternClosure() {
function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
this.operatorList = IR[2];
this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
this.bbox = Util.normalizeRect(IR[4]);
this.bbox = _util.Util.normalizeRect(IR[4]);
this.xstep = IR[5];
this.ystep = IR[6];
this.paintType = IR[7];
@ -300,7 +302,7 @@ var TilingPattern = function TilingPatternClosure() { @@ -300,7 +302,7 @@ var TilingPattern = function TilingPatternClosure() {
var tilingType = this.tilingType;
var color = this.color;
var canvasGraphicsFactory = this.canvasGraphicsFactory;
info('TilingType: ' + tilingType);
(0, _util.info)('TilingType: ' + tilingType);
var x0 = bbox[0],
y0 = bbox[1],
x1 = bbox[2],
@ -309,8 +311,8 @@ var TilingPattern = function TilingPatternClosure() { @@ -309,8 +311,8 @@ var TilingPattern = function TilingPatternClosure() {
var botRight = [x0 + xstep, y0 + ystep];
var width = botRight[0] - topLeft[0];
var height = botRight[1] - topLeft[1];
var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
@ -340,7 +342,7 @@ var TilingPattern = function TilingPatternClosure() { @@ -340,7 +342,7 @@ var TilingPattern = function TilingPatternClosure() {
this.ctx.scale(1 / scale[0], 1 / scale[1]);
},
clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
if (isArray(bbox) && bbox.length === 4) {
if ((0, _util.isArray)(bbox) && bbox.length === 4) {
var bboxWidth = x1 - x0;
var bboxHeight = y1 - y0;
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
@ -356,12 +358,12 @@ var TilingPattern = function TilingPatternClosure() { @@ -356,12 +358,12 @@ var TilingPattern = function TilingPatternClosure() {
context.strokeStyle = ctx.strokeStyle;
break;
case PaintType.UNCOLORED:
var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
context.fillStyle = cssColor;
context.strokeStyle = cssColor;
break;
default:
error('Unsupported paint type: ' + paintType);
(0, _util.error)('Unsupported paint type: ' + paintType);
}
},
getPattern: function TilingPattern_getPattern(ctx, owner) {

1844
lib/display/svg.js

File diff suppressed because it is too large Load Diff

31
lib/display/text_layer.js

@ -14,12 +14,15 @@ @@ -14,12 +14,15 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var displayDOMUtils = require('./dom_utils.js');
var Util = sharedUtil.Util;
var createPromiseCapability = sharedUtil.createPromiseCapability;
var CustomStyle = displayDOMUtils.CustomStyle;
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.renderTextLayer = undefined;
var _util = require('../shared/util');
var _dom_utils = require('./dom_utils');
var renderTextLayer = function renderTextLayerClosure() {
var MAX_TEXT_DIVS_TO_RENDER = 100000;
var NonWhitespaceRegexp = /\S/;
@ -47,7 +50,7 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -47,7 +50,7 @@ var renderTextLayer = function renderTextLayerClosure() {
task._textDivProperties.set(textDiv, textDivProperties);
return;
}
var tx = Util.transform(task._viewport.transform, geom.transform);
var tx = _util.Util.transform(task._viewport.transform, geom.transform);
var angle = Math.atan2(tx[1], tx[0]);
var style = styles[geom.fontName];
if (style.vertical) {
@ -76,7 +79,7 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -76,7 +79,7 @@ var renderTextLayer = function renderTextLayerClosure() {
textDivProperties.style = styleBuf.join('');
textDiv.setAttribute('style', textDivProperties.style);
textDiv.textContent = geom.str;
if (getDefaultSetting('pdfBug')) {
if ((0, _dom_utils.getDefaultSetting)('pdfBug')) {
textDiv.dataset.fontName = geom.fontName;
}
if (angle !== 0) {
@ -102,7 +105,7 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -102,7 +105,7 @@ var renderTextLayer = function renderTextLayerClosure() {
var m, b;
if (angle !== 0) {
m = [angleCos, angleSin, -angleSin, angleCos, left, top];
b = Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
} else {
b = [left, top, left + divWidth, top + divHeight];
}
@ -160,7 +163,7 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -160,7 +163,7 @@ var renderTextLayer = function renderTextLayerClosure() {
}
if (transform !== '') {
textDivProperties.originalTransform = transform;
CustomStyle.setProp('transform', textDiv, transform);
_dom_utils.CustomStyle.setProp('transform', textDiv, transform);
}
task._textDivProperties.set(textDiv, textDivProperties);
}
@ -190,7 +193,7 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -190,7 +193,7 @@ var renderTextLayer = function renderTextLayerClosure() {
var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
var ts = new Float64Array(64);
points.forEach(function (p, i) {
var t = Util.applyTransform(p, m);
var t = _util.Util.applyTransform(p, m);
ts[i + 0] = c && (e.left - t[0]) / c;
ts[i + 4] = s && (e.top - t[1]) / s;
ts[i + 8] = c && (e.right - t[0]) / c;
@ -400,7 +403,7 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -400,7 +403,7 @@ var renderTextLayer = function renderTextLayerClosure() {
this._textDivProperties = new WeakMap();
this._renderingDone = false;
this._canceled = false;
this._capability = createPromiseCapability();
this._capability = (0, _util.createPromiseCapability)();
this._renderTimer = null;
this._bounds = [];
this._enhanceTextSelection = !!enhanceTextSelection;
@ -474,11 +477,11 @@ var renderTextLayer = function renderTextLayerClosure() { @@ -474,11 +477,11 @@ var renderTextLayer = function renderTextLayerClosure() {
div.setAttribute('style', divProperties.style + padding);
}
if (transform !== '') {
CustomStyle.setProp('transform', div, transform);
_dom_utils.CustomStyle.setProp('transform', div, transform);
}
} else {
div.style.padding = 0;
CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
_dom_utils.CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
}
}
}

17
lib/display/webgl.js

@ -14,10 +14,15 @@ @@ -14,10 +14,15 @@
*/
'use strict';
var sharedUtil = require('../shared/util.js');
var displayDOMUtils = require('./dom_utils.js');
var shadow = sharedUtil.shadow;
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WebGLUtils = undefined;
var _dom_utils = require('./dom_utils');
var _util = require('../shared/util');
var WebGLUtils = function WebGLUtilsClosure() {
function loadShader(gl, code, shaderType) {
var shader = gl.createShader(shaderType);
@ -352,7 +357,7 @@ var WebGLUtils = function WebGLUtilsClosure() { @@ -352,7 +357,7 @@ var WebGLUtils = function WebGLUtilsClosure() {
}
return {
get isEnabled() {
if (getDefaultSetting('disableWebGL')) {
if ((0, _dom_utils.getDefaultSetting)('disableWebGL')) {
return false;
}
var enabled = false;
@ -360,7 +365,7 @@ var WebGLUtils = function WebGLUtilsClosure() { @@ -360,7 +365,7 @@ var WebGLUtils = function WebGLUtilsClosure() {
generateGL();
enabled = !!currentGL;
} catch (e) {}
return shadow(this, 'isEnabled', enabled);
return (0, _util.shadow)(this, 'isEnabled', enabled);
},
composeSMask: composeSMask,
drawFigures: drawFigures,

4
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.213';
var pdfjsBuild = 'c6e8ca86';
var pdfjsVersion = '1.8.233';
var pdfjsBuild = '19321937';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.213';
var pdfjsBuild = 'c6e8ca86';
var pdfjsVersion = '1.8.233';
var pdfjsBuild = '19321937';
var pdfjsCoreWorker = require('./core/worker.js');
{
require('./core/network.js');

5
lib/web/chromecom.js

@ -21,6 +21,8 @@ exports.ChromeCom = undefined; @@ -21,6 +21,8 @@ exports.ChromeCom = undefined;
var _app = require('./app');
var _download_manager = require('./download_manager');
var _overlay_manager = require('./overlay_manager');
var _pdfjs = require('./pdfjs');
@ -272,5 +274,8 @@ ChromeExternalServices.initPassiveLoading = function (callbacks) { @@ -272,5 +274,8 @@ ChromeExternalServices.initPassiveLoading = function (callbacks) {
callbacks.onOpenWithURL(url, length, originalURL);
});
};
ChromeExternalServices.createDownloadManager = function () {
return new _download_manager.DownloadManager();
};
_app.PDFViewerApplication.externalServices = ChromeExternalServices;
exports.ChromeCom = ChromeCom;

7
lib/web/download_manager.js

@ -21,8 +21,6 @@ exports.DownloadManager = undefined; @@ -21,8 +21,6 @@ exports.DownloadManager = undefined;
var _pdfjs = require('./pdfjs');
var _app = require('./app');
;
function download(blobUrl, filename) {
var a = document.createElement('a');
@ -73,9 +71,4 @@ DownloadManager.prototype = { @@ -73,9 +71,4 @@ DownloadManager.prototype = {
download(blobUrl, filename);
}
};
var GenericExternalServices = Object.create(_app.DefaultExternalServices);
GenericExternalServices.createDownloadManager = function () {
return new DownloadManager();
};
_app.PDFViewerApplication.externalServices = GenericExternalServices;
exports.DownloadManager = DownloadManager;

33
lib/web/genericcom.js

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
/* Copyright 2017 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GenericCom = undefined;
var _app = require('./app');
var _download_manager = require('./download_manager');
;
var GenericCom = {};
var GenericExternalServices = Object.create(_app.DefaultExternalServices);
GenericExternalServices.createDownloadManager = function () {
return new _download_manager.DownloadManager();
};
_app.PDFViewerApplication.externalServices = GenericExternalServices;
exports.GenericCom = GenericCom;

60
lib/web/password_prompt.js

@ -19,14 +19,22 @@ Object.defineProperty(exports, "__esModule", { @@ -19,14 +19,22 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PasswordPrompt = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _ui_utils = require('./ui_utils');
var _overlay_manager = require('./overlay_manager');
var _pdfjs = require('./pdfjs');
var PasswordPrompt = function PasswordPromptClosure() {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var PasswordPrompt = function () {
function PasswordPrompt(options) {
var _this = this;
_classCallCheck(this, PasswordPrompt);
this.overlayName = options.overlayName;
this.container = options.container;
this.label = options.label;
@ -39,41 +47,53 @@ var PasswordPrompt = function PasswordPromptClosure() { @@ -39,41 +47,53 @@ var PasswordPrompt = function PasswordPromptClosure() {
this.cancelButton.addEventListener('click', this.close.bind(this));
this.input.addEventListener('keydown', function (e) {
if (e.keyCode === 13) {
this.verify();
_this.verify();
}
}.bind(this));
});
_overlay_manager.OverlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
}
PasswordPrompt.prototype = {
open: function PasswordPrompt_open() {
_createClass(PasswordPrompt, [{
key: 'open',
value: function open() {
var _this2 = this;
_overlay_manager.OverlayManager.open(this.overlayName).then(function () {
this.input.type = 'password';
this.input.focus();
_this2.input.focus();
var promptString = _ui_utils.mozL10n.get('password_label', null, 'Enter the password to open this PDF file.');
if (this.reason === _pdfjs.PasswordResponses.INCORRECT_PASSWORD) {
if (_this2.reason === _pdfjs.PasswordResponses.INCORRECT_PASSWORD) {
promptString = _ui_utils.mozL10n.get('password_invalid', null, 'Invalid password. Please try again.');
}
this.label.textContent = promptString;
}.bind(this));
},
close: function PasswordPrompt_close() {
_this2.label.textContent = promptString;
});
}
}, {
key: 'close',
value: function close() {
var _this3 = this;
_overlay_manager.OverlayManager.close(this.overlayName).then(function () {
this.input.value = '';
this.input.type = '';
}.bind(this));
},
verify: function PasswordPrompt_verify() {
_this3.input.value = '';
});
}
}, {
key: 'verify',
value: function verify() {
var password = this.input.value;
if (password && password.length > 0) {
this.close();
return this.updateCallback(password);
}
},
setUpdateCallback: function PasswordPrompt_setUpdateCallback(updateCallback, reason) {
}
}, {
key: 'setUpdateCallback',
value: function setUpdateCallback(updateCallback, reason) {
this.updateCallback = updateCallback;
this.reason = reason;
}
};
}]);
return PasswordPrompt;
}();
exports.PasswordPrompt = PasswordPrompt;

102
lib/web/pdf_document_properties.js

@ -19,14 +19,22 @@ Object.defineProperty(exports, "__esModule", { @@ -19,14 +19,22 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PDFDocumentProperties = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _ui_utils = require('./ui_utils');
var _pdfjs = require('./pdfjs');
var _overlay_manager = require('./overlay_manager');
var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var PDFDocumentProperties = function () {
function PDFDocumentProperties(options) {
this.fields = options.fields;
_classCallCheck(this, PDFDocumentProperties);
this.overlayName = options.overlayName;
this.fields = options.fields;
this.container = options.container;
this.rawFileSize = 0;
this.url = null;
@ -34,67 +42,83 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -34,67 +42,83 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
if (options.closeButton) {
options.closeButton.addEventListener('click', this.close.bind(this));
}
this.dataAvailablePromise = new Promise(function (resolve) {
this.resolveDataAvailable = resolve;
}.bind(this));
this._dataAvailableCapability = (0, _pdfjs.createPromiseCapability)();
_overlay_manager.OverlayManager.register(this.overlayName, this.container, this.close.bind(this));
}
PDFDocumentProperties.prototype = {
open: function PDFDocumentProperties_open() {
Promise.all([_overlay_manager.OverlayManager.open(this.overlayName), this.dataAvailablePromise]).then(function () {
this._getProperties();
}.bind(this));
},
close: function PDFDocumentProperties_close() {
_createClass(PDFDocumentProperties, [{
key: 'open',
value: function open() {
var _this = this;
Promise.all([_overlay_manager.OverlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
_this._getProperties();
});
}
}, {
key: 'close',
value: function close() {
_overlay_manager.OverlayManager.close(this.overlayName);
},
setFileSize: function PDFDocumentProperties_setFileSize(fileSize) {
}
}, {
key: 'setFileSize',
value: function setFileSize(fileSize) {
if (fileSize > 0) {
this.rawFileSize = fileSize;
}
},
setDocumentAndUrl: function PDFDocumentProperties_setDocumentAndUrl(pdfDocument, url) {
}
}, {
key: 'setDocumentAndUrl',
value: function setDocumentAndUrl(pdfDocument, url) {
this.pdfDocument = pdfDocument;
this.url = url;
this.resolveDataAvailable();
},
_getProperties: function PDFDocumentProperties_getProperties() {
this._dataAvailableCapability.resolve();
}
}, {
key: '_getProperties',
value: function _getProperties() {
var _this2 = this;
if (!_overlay_manager.OverlayManager.active) {
return;
}
this.pdfDocument.getDownloadInfo().then(function (data) {
if (data.length === this.rawFileSize) {
if (data.length === _this2.rawFileSize) {
return;
}
this.setFileSize(data.length);
this._updateUI(this.fields['fileSize'], this._parseFileSize());
}.bind(this));
_this2.setFileSize(data.length);
_this2._updateUI(_this2.fields['fileSize'], _this2._parseFileSize());
});
this.pdfDocument.getMetadata().then(function (data) {
var content = {
'fileName': (0, _ui_utils.getPDFFileNameFromURL)(this.url),
'fileSize': this._parseFileSize(),
'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this2.url),
'fileSize': _this2._parseFileSize(),
'title': data.info.Title,
'author': data.info.Author,
'subject': data.info.Subject,
'keywords': data.info.Keywords,
'creationDate': this._parseDate(data.info.CreationDate),
'modificationDate': this._parseDate(data.info.ModDate),
'creationDate': _this2._parseDate(data.info.CreationDate),
'modificationDate': _this2._parseDate(data.info.ModDate),
'creator': data.info.Creator,
'producer': data.info.Producer,
'version': data.info.PDFFormatVersion,
'pageCount': this.pdfDocument.numPages
'pageCount': _this2.pdfDocument.numPages
};
for (var identifier in content) {
this._updateUI(this.fields[identifier], content[identifier]);
_this2._updateUI(_this2.fields[identifier], content[identifier]);
}
}.bind(this));
},
_updateUI: function PDFDocumentProperties_updateUI(field, content) {
});
}
}, {
key: '_updateUI',
value: function _updateUI(field, content) {
if (field && content !== undefined && content !== '') {
field.textContent = content;
}
},
_parseFileSize: function PDFDocumentProperties_parseFileSize() {
}
}, {
key: '_parseFileSize',
value: function _parseFileSize() {
var fileSize = this.rawFileSize,
kb = fileSize / 1024;
if (!kb) {
@ -109,8 +133,10 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -109,8 +133,10 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_mb}} MB ({{size_b}} bytes)');
},
_parseDate: function PDFDocumentProperties_parseDate(inputDate) {
}
}, {
key: '_parseDate',
value: function _parseDate(inputDate) {
var dateToParse = inputDate;
if (dateToParse === undefined) {
return '';
@ -142,7 +168,9 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -142,7 +168,9 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
time: timeString
}, '{{date}}, {{time}}');
}
};
}]);
return PDFDocumentProperties;
}();
exports.PDFDocumentProperties = PDFDocumentProperties;

85
lib/web/pdf_find_bar.js

@ -19,12 +19,20 @@ Object.defineProperty(exports, "__esModule", { @@ -19,12 +19,20 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PDFFindBar = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _pdf_find_controller = require('./pdf_find_controller');
var _ui_utils = require('./ui_utils');
var PDFFindBar = function PDFFindBarClosure() {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var PDFFindBar = function () {
function PDFFindBar(options) {
var _this = this;
_classCallCheck(this, PDFFindBar);
this.opened = false;
this.bar = options.bar || null;
this.toggleButton = options.toggleButton || null;
@ -41,44 +49,47 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -41,44 +49,47 @@ var PDFFindBar = function PDFFindBarClosure() {
if (this.findController === null) {
throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
}
var self = this;
this.toggleButton.addEventListener('click', function () {
self.toggle();
_this.toggle();
});
this.findField.addEventListener('input', function () {
self.dispatchEvent('');
_this.dispatchEvent('');
});
this.bar.addEventListener('keydown', function (evt) {
switch (evt.keyCode) {
this.bar.addEventListener('keydown', function (e) {
switch (e.keyCode) {
case 13:
if (evt.target === self.findField) {
self.dispatchEvent('again', evt.shiftKey);
if (e.target === _this.findField) {
_this.dispatchEvent('again', e.shiftKey);
}
break;
case 27:
self.close();
_this.close();
break;
}
});
this.findPreviousButton.addEventListener('click', function () {
self.dispatchEvent('again', true);
_this.dispatchEvent('again', true);
});
this.findNextButton.addEventListener('click', function () {
self.dispatchEvent('again', false);
_this.dispatchEvent('again', false);
});
this.highlightAll.addEventListener('click', function () {
self.dispatchEvent('highlightallchange');
_this.dispatchEvent('highlightallchange');
});
this.caseSensitive.addEventListener('click', function () {
self.dispatchEvent('casesensitivitychange');
_this.dispatchEvent('casesensitivitychange');
});
this.eventBus.on('resize', this._adjustWidth.bind(this));
}
PDFFindBar.prototype = {
reset: function PDFFindBar_reset() {
_createClass(PDFFindBar, [{
key: 'reset',
value: function reset() {
this.updateUIState();
},
dispatchEvent: function PDFFindBar_dispatchEvent(type, findPrev) {
}
}, {
key: 'dispatchEvent',
value: function dispatchEvent(type, findPrev) {
this.eventBus.dispatch('find', {
source: this,
type: type,
@ -88,8 +99,10 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -88,8 +99,10 @@ var PDFFindBar = function PDFFindBarClosure() {
highlightAll: this.highlightAll.checked,
findPrevious: findPrev
});
},
updateUIState: function PDFFindBar_updateUIState(state, previous, matchCount) {
}
}, {
key: 'updateUIState',
value: function updateUIState(state, previous, matchCount) {
var notFound = false;
var findMsg = '';
var status = '';
@ -120,8 +133,10 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -120,8 +133,10 @@ var PDFFindBar = function PDFFindBarClosure() {
this.findMsg.textContent = findMsg;
this.updateResultsCount(matchCount);
this._adjustWidth();
},
updateResultsCount: function updateResultsCount(matchCount) {
}
}, {
key: 'updateResultsCount',
value: function updateResultsCount(matchCount) {
if (!this.findResultsCount) {
return;
}
@ -131,8 +146,10 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -131,8 +146,10 @@ var PDFFindBar = function PDFFindBarClosure() {
}
this.findResultsCount.textContent = matchCount.toLocaleString();
this.findResultsCount.classList.remove('hidden');
},
open: function PDFFindBar_open() {
}
}, {
key: 'open',
value: function open() {
if (!this.opened) {
this.opened = true;
this.toggleButton.classList.add('toggled');
@ -141,8 +158,10 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -141,8 +158,10 @@ var PDFFindBar = function PDFFindBarClosure() {
this.findField.select();
this.findField.focus();
this._adjustWidth();
},
close: function PDFFindBar_close() {
}
}, {
key: 'close',
value: function close() {
if (!this.opened) {
return;
}
@ -150,15 +169,19 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -150,15 +169,19 @@ var PDFFindBar = function PDFFindBarClosure() {
this.toggleButton.classList.remove('toggled');
this.bar.classList.add('hidden');
this.findController.active = false;
},
toggle: function PDFFindBar_toggle() {
}
}, {
key: 'toggle',
value: function toggle() {
if (this.opened) {
this.close();
} else {
this.open();
}
},
_adjustWidth: function PDFFindBar_adjustWidth() {
}
}, {
key: '_adjustWidth',
value: function _adjustWidth() {
if (!this.opened) {
return;
}
@ -169,7 +192,9 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -169,7 +192,9 @@ var PDFFindBar = function PDFFindBarClosure() {
this.bar.classList.add('wrapContainers');
}
}
};
}]);
return PDFFindBar;
}();
exports.PDFFindBar = PDFFindBar;

10
lib/web/pdf_find_controller.js

@ -53,6 +53,8 @@ var PDFFindController = function PDFFindControllerClosure() { @@ -53,6 +53,8 @@ var PDFFindController = function PDFFindControllerClosure() {
}
PDFFindController.prototype = {
reset: function PDFFindController_reset() {
var _this = this;
this.startedTextExtraction = false;
this.extractTextPromises = [];
this.pendingFindMatches = Object.create(null);
@ -74,9 +76,9 @@ var PDFFindController = function PDFFindControllerClosure() { @@ -74,9 +76,9 @@ var PDFFindController = function PDFFindControllerClosure() {
this.state = null;
this.dirtyMatch = false;
this.findTimeout = null;
this.firstPagePromise = new Promise(function (resolve) {
this.resolveFirstPage = resolve;
}.bind(this));
this._firstPagePromise = new Promise(function (resolve) {
_this.resolveFirstPage = resolve;
});
},
normalize: function PDFFindController_normalize(text) {
return text.replace(this.normalizationRegex, function (ch) {
@ -223,7 +225,7 @@ var PDFFindController = function PDFFindControllerClosure() { @@ -223,7 +225,7 @@ var PDFFindController = function PDFFindControllerClosure() {
}
this.state = state;
this.updateUIState(FindStates.FIND_PENDING);
this.firstPagePromise.then(function () {
this._firstPagePromise.then(function () {
this.extractText();
clearTimeout(this.findTimeout);
if (cmd === 'find') {

2
lib/web/pdf_history.js

@ -23,7 +23,7 @@ var _dom_events = require('./dom_events'); @@ -23,7 +23,7 @@ var _dom_events = require('./dom_events');
function PDFHistory(options) {
this.linkService = options.linkService;
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
this.initialized = false;
this.initialDestination = null;
this.initialBookmark = null;

2
lib/web/pdf_link_service.js

@ -32,7 +32,7 @@ function isPageNumber(str) { @@ -32,7 +32,7 @@ function isPageNumber(str) {
var PDFLinkService = function PDFLinkServiceClosure() {
function PDFLinkService(options) {
options = options || {};
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
this.baseUrl = null;
this.pdfDocument = null;
this.pdfViewer = null;

14
lib/web/pdf_page_view.js

@ -49,7 +49,7 @@ var PDFPageView = function PDFPageViewClosure() { @@ -49,7 +49,7 @@ var PDFPageView = function PDFPageViewClosure() {
this.hasRestrictedScaling = false;
this.enhanceTextSelection = enhanceTextSelection;
this.renderInteractiveForms = renderInteractiveForms;
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
this.renderingQueue = renderingQueue;
this.textLayerFactory = textLayerFactory;
this.annotationLayerFactory = annotationLayerFactory;
@ -367,13 +367,9 @@ var PDFPageView = function PDFPageViewClosure() { @@ -367,13 +367,9 @@ var PDFPageView = function PDFPageViewClosure() {
return resultPromise;
},
paintOnCanvas: function paintOnCanvas(canvasWrapper) {
var resolveRenderPromise, rejectRenderPromise;
var promise = new Promise(function (resolve, reject) {
resolveRenderPromise = resolve;
rejectRenderPromise = reject;
});
var renderCapability = (0, _pdfjs.createPromiseCapability)();
var result = {
promise: promise,
promise: renderCapability.promise,
onRenderContinue: function onRenderContinue(cont) {
cont();
},
@ -441,10 +437,10 @@ var PDFPageView = function PDFPageViewClosure() { @@ -441,10 +437,10 @@ var PDFPageView = function PDFPageViewClosure() {
};
renderTask.promise.then(function pdfPageRenderCallback() {
showCanvas();
resolveRenderPromise(undefined);
renderCapability.resolve(undefined);
}, function pdfPageRenderError(error) {
showCanvas();
rejectRenderPromise(error);
renderCapability.reject(error);
});
return result;
},

18
lib/web/pdf_thumbnail_view.js

@ -19,10 +19,10 @@ Object.defineProperty(exports, "__esModule", { @@ -19,10 +19,10 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PDFThumbnailView = undefined;
var _ui_utils = require('./ui_utils');
var _pdfjs = require('./pdfjs');
var _ui_utils = require('./ui_utils');
var _pdf_rendering_queue = require('./pdf_rendering_queue');
var THUMBNAIL_WIDTH = 98;
@ -201,26 +201,22 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -201,26 +201,22 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
return Promise.resolve(undefined);
}
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
var resolveRenderPromise, rejectRenderPromise;
var promise = new Promise(function (resolve, reject) {
resolveRenderPromise = resolve;
rejectRenderPromise = reject;
});
var renderCapability = (0, _pdfjs.createPromiseCapability)();
var self = this;
function thumbnailDrawCallback(error) {
if (renderTask === self.renderTask) {
self.renderTask = null;
}
if (error === 'cancelled' || error instanceof _pdfjs.RenderingCancelledException) {
resolveRenderPromise(undefined);
renderCapability.resolve(undefined);
return;
}
self.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
self._convertCanvasToImage();
if (!error) {
resolveRenderPromise(undefined);
renderCapability.resolve(undefined);
} else {
rejectRenderPromise(error);
renderCapability.reject(error);
}
}
var ctx = this._getPageDrawContext();
@ -247,7 +243,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -247,7 +243,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
}, function pdfPageRenderError(error) {
thumbnailDrawCallback(error);
});
return promise;
return renderCapability.promise;
},
setImage: function PDFThumbnailView_setImage(pageView) {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {

123
lib/web/pdf_viewer.js

@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", { @@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PDFViewer = exports.PresentationModeState = undefined;
var _pdfjs = require('./pdfjs');
var _ui_utils = require('./ui_utils');
var _pdf_rendering_queue = require('./pdf_rendering_queue');
@ -27,8 +29,6 @@ var _annotation_layer_builder = require('./annotation_layer_builder'); @@ -27,8 +29,6 @@ var _annotation_layer_builder = require('./annotation_layer_builder');
var _dom_events = require('./dom_events');
var _pdfjs = require('./pdfjs');
var _pdf_page_view = require('./pdf_page_view');
var _pdf_link_service = require('./pdf_link_service');
@ -77,7 +77,7 @@ var PDFViewer = function pdfViewer() { @@ -77,7 +77,7 @@ var PDFViewer = function pdfViewer() {
function PDFViewer(options) {
this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild;
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
this.downloadManager = options.downloadManager || null;
this.removePageBorders = options.removePageBorders || false;
@ -204,6 +204,8 @@ var PDFViewer = function pdfViewer() { @@ -204,6 +204,8 @@ var PDFViewer = function pdfViewer() {
}
},
setDocument: function setDocument(pdfDocument) {
var _this = this;
if (this.pdfDocument) {
this._cancelRendering();
this._resetView();
@ -213,91 +215,82 @@ var PDFViewer = function pdfViewer() { @@ -213,91 +215,82 @@ var PDFViewer = function pdfViewer() {
return;
}
var pagesCount = pdfDocument.numPages;
var self = this;
var resolvePagesPromise;
var pagesPromise = new Promise(function (resolve) {
resolvePagesPromise = resolve;
});
this.pagesPromise = pagesPromise;
pagesPromise.then(function () {
self._pageViewsReady = true;
self.eventBus.dispatch('pagesloaded', {
source: self,
var pagesCapability = (0, _pdfjs.createPromiseCapability)();
this.pagesPromise = pagesCapability.promise;
pagesCapability.promise.then(function () {
_this._pageViewsReady = true;
_this.eventBus.dispatch('pagesloaded', {
source: _this,
pagesCount: pagesCount
});
});
var isOnePageRenderedResolved = false;
var resolveOnePageRendered = null;
var onePageRendered = new Promise(function (resolve) {
resolveOnePageRendered = resolve;
});
this.onePageRendered = onePageRendered;
var onePageRenderedCapability = (0, _pdfjs.createPromiseCapability)();
this.onePageRendered = onePageRenderedCapability.promise;
var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
pageView.onBeforeDraw = function pdfViewLoadOnBeforeDraw() {
self._buffer.push(this);
pageView.onBeforeDraw = function () {
_this._buffer.push(pageView);
};
pageView.onAfterDraw = function pdfViewLoadOnAfterDraw() {
pageView.onAfterDraw = function () {
if (!isOnePageRenderedResolved) {
isOnePageRenderedResolved = true;
resolveOnePageRendered();
onePageRenderedCapability.resolve();
}
};
};
var firstPagePromise = pdfDocument.getPage(1);
this.firstPagePromise = firstPagePromise;
return firstPagePromise.then(function (pdfPage) {
var scale = this.currentScale;
var scale = _this.currentScale;
var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var textLayerFactory = null;
if (!_pdfjs.PDFJS.disableTextLayer) {
textLayerFactory = this;
textLayerFactory = _this;
}
var pageView = new _pdf_page_view.PDFPageView({
container: this.viewer,
eventBus: this.eventBus,
container: _this.viewer,
eventBus: _this.eventBus,
id: pageNum,
scale: scale,
defaultViewport: viewport.clone(),
renderingQueue: this.renderingQueue,
renderingQueue: _this.renderingQueue,
textLayerFactory: textLayerFactory,
annotationLayerFactory: this,
enhanceTextSelection: this.enhanceTextSelection,
renderInteractiveForms: this.renderInteractiveForms,
renderer: this.renderer
annotationLayerFactory: _this,
enhanceTextSelection: _this.enhanceTextSelection,
renderInteractiveForms: _this.renderInteractiveForms,
renderer: _this.renderer
});
bindOnAfterAndBeforeDraw(pageView);
this._pages.push(pageView);
_this._pages.push(pageView);
}
var linkService = this.linkService;
onePageRendered.then(function () {
if (!_pdfjs.PDFJS.disableAutoFetch) {
var getPagesLeft = pagesCount;
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
var pageView = self._pages[pageNum - 1];
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
linkService.cachePageRef(pageNum, pdfPage.ref);
getPagesLeft--;
if (!getPagesLeft) {
resolvePagesPromise();
}
}.bind(null, pageNum));
}
} else {
resolvePagesPromise();
onePageRenderedCapability.promise.then(function () {
if (_pdfjs.PDFJS.disableAutoFetch) {
pagesCapability.resolve();
return;
}
var getPagesLeft = pagesCount;
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
var pageView = this._pages[pageNum - 1];
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
this.linkService.cachePageRef(pageNum, pdfPage.ref);
if (--getPagesLeft === 0) {
pagesCapability.resolve();
}
}.bind(_this, pageNum));
}
});
self.eventBus.dispatch('pagesinit', { source: self });
if (this.defaultRenderingQueue) {
this.update();
_this.eventBus.dispatch('pagesinit', { source: _this });
if (_this.defaultRenderingQueue) {
_this.update();
}
if (this.findController) {
this.findController.resolveFirstPage();
if (_this.findController) {
_this.findController.resolveFirstPage();
}
}.bind(this));
});
},
setPageLabels: function PDFViewer_setPageLabels(labels) {
if (!this.pdfDocument) {
@ -624,6 +617,8 @@ var PDFViewer = function pdfViewer() { @@ -624,6 +617,8 @@ var PDFViewer = function pdfViewer() {
}
},
_ensurePdfPageLoaded: function _ensurePdfPageLoaded(pageView) {
var _this2 = this;
if (pageView.pdfPage) {
return Promise.resolve(pageView.pdfPage);
}
@ -632,20 +627,24 @@ var PDFViewer = function pdfViewer() { @@ -632,20 +627,24 @@ var PDFViewer = function pdfViewer() {
return this._pagesRequests[pageNumber];
}
var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
pageView.setPdfPage(pdfPage);
this._pagesRequests[pageNumber] = null;
if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage);
}
_this2._pagesRequests[pageNumber] = null;
return pdfPage;
}.bind(this));
});
this._pagesRequests[pageNumber] = promise;
return promise;
},
forceRendering: function forceRendering(currentlyVisiblePages) {
var _this3 = this;
var visiblePages = currentlyVisiblePages || this._getVisiblePages();
var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
if (pageView) {
this._ensurePdfPageLoaded(pageView).then(function () {
this.renderingQueue.renderView(pageView);
}.bind(this));
_this3.renderingQueue.renderView(pageView);
});
return true;
}
return false;

2
lib/web/text_layer_builder.js

@ -27,7 +27,7 @@ var EXPAND_DIVS_TIMEOUT = 300; @@ -27,7 +27,7 @@ var EXPAND_DIVS_TIMEOUT = 300;
var TextLayerBuilder = function TextLayerBuilderClosure() {
function TextLayerBuilder(options) {
this.textLayerDiv = options.textLayerDiv;
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
this.textContent = null;
this.renderingDone = false;
this.pageIdx = options.pageIndex;

2
package.json

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

8440
web/pdf_viewer.js

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