Bug 1364136 - Update pdf.js to version 1.8.346. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2017-05-11 13:17:17 -04:00
Родитель fdae3f6561
Коммит 9669157cae
4 изменённых файлов: 312 добавлений и 309 удалений

Просмотреть файл

@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js This is the PDF.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.8.331 Current extension version is: 1.8.346
Taken from upstream commit: 0dbc68a6 Taken from upstream commit: 15425d5b

Просмотреть файл

@ -101,12 +101,17 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isInt = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.isArray = exports.info = exports.globalScope = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.error = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined; exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isInt = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.isArray = exports.info = exports.globalScope = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.error = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
__w_pdfjs_require__(14); __w_pdfjs_require__(14);
var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined; var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined;
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
const NativeImageDecoding = {
NONE: 'none',
DECODE: 'decode',
DISPLAY: 'display'
};
var TextRenderingMode = { var TextRenderingMode = {
FILL: 0, FILL: 0,
STROKE: 1, STROKE: 1,
@ -1125,6 +1130,7 @@ exports.InvalidPDFException = InvalidPDFException;
exports.MessageHandler = MessageHandler; exports.MessageHandler = MessageHandler;
exports.MissingDataException = MissingDataException; exports.MissingDataException = MissingDataException;
exports.MissingPDFException = MissingPDFException; exports.MissingPDFException = MissingPDFException;
exports.NativeImageDecoding = NativeImageDecoding;
exports.NotImplementedException = NotImplementedException; exports.NotImplementedException = NotImplementedException;
exports.PageViewport = PageViewport; exports.PageViewport = PageViewport;
exports.PasswordException = PasswordException; exports.PasswordException = PasswordException;
@ -2170,9 +2176,16 @@ function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallb
params[key] = source[key]; params[key] = source[key];
} }
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
params.ignoreErrors = params.stopAtErrors !== true; params.ignoreErrors = params.stopAtErrors !== true;
var CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory; var CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory;
if (params.disableNativeImageDecoder !== undefined) {
(0, _util.deprecated)('parameter disableNativeImageDecoder, ' + 'use nativeImageDecoderSupport instead');
}
params.nativeImageDecoderSupport = params.nativeImageDecoderSupport || (params.disableNativeImageDecoder === true ? _util.NativeImageDecoding.NONE : _util.NativeImageDecoding.DECODE);
if (params.nativeImageDecoderSupport !== _util.NativeImageDecoding.DECODE && params.nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && params.nativeImageDecoderSupport !== _util.NativeImageDecoding.DISPLAY) {
(0, _util.warn)('Invalid parameter nativeImageDecoderSupport: ' + 'need a state of enum {NativeImageDecoding}');
params.nativeImageDecoderSupport = _util.NativeImageDecoding.DECODE;
}
if (!worker) { if (!worker) {
var workerPort = (0, _dom_utils.getDefaultSetting)('workerPort'); var workerPort = (0, _dom_utils.getDefaultSetting)('workerPort');
worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker(); worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
@ -2215,7 +2228,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'), disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'),
postMessageTransfers: (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled, postMessageTransfers: (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled,
docBaseUrl: source.docBaseUrl, docBaseUrl: source.docBaseUrl,
disableNativeImageDecoder: source.disableNativeImageDecoder, nativeImageDecoderSupport: source.nativeImageDecoderSupport,
ignoreErrors: source.ignoreErrors ignoreErrors: source.ignoreErrors
}).then(function (workerId) { }).then(function (workerId) {
if (worker.destroyed) { if (worker.destroyed) {
@ -3392,8 +3405,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.331'; exports.version = version = '1.8.346';
exports.build = build = '0dbc68a6'; exports.build = build = '15425d5b';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -4395,8 +4408,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.331'; PDFJS.version = '1.8.346';
PDFJS.build = '0dbc68a6'; PDFJS.build = '15425d5b';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -6710,8 +6723,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.331'; var pdfjsVersion = '1.8.346';
var pdfjsBuild = '0dbc68a6'; var pdfjsBuild = '15425d5b';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(8); var pdfjsDisplayGlobal = __w_pdfjs_require__(8);
var pdfjsDisplayAPI = __w_pdfjs_require__(3); var pdfjsDisplayAPI = __w_pdfjs_require__(3);
@ -6734,6 +6747,7 @@ exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException; exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException; exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics; exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException; exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
exports.OPS = pdfjsSharedUtil.OPS; exports.OPS = pdfjsSharedUtil.OPS;
exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES; exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;

Просмотреть файл

@ -101,12 +101,17 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isInt = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.isArray = exports.info = exports.globalScope = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.error = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined; exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isInt = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.isArray = exports.info = exports.globalScope = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.error = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
__w_pdfjs_require__(36); __w_pdfjs_require__(36);
var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined; var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined;
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
const NativeImageDecoding = {
NONE: 'none',
DECODE: 'decode',
DISPLAY: 'display'
};
var TextRenderingMode = { var TextRenderingMode = {
FILL: 0, FILL: 0,
STROKE: 1, STROKE: 1,
@ -1125,6 +1130,7 @@ exports.InvalidPDFException = InvalidPDFException;
exports.MessageHandler = MessageHandler; exports.MessageHandler = MessageHandler;
exports.MissingDataException = MissingDataException; exports.MissingDataException = MissingDataException;
exports.MissingPDFException = MissingPDFException; exports.MissingPDFException = MissingPDFException;
exports.NativeImageDecoding = NativeImageDecoding;
exports.NotImplementedException = NotImplementedException; exports.NotImplementedException = NotImplementedException;
exports.PageViewport = PageViewport; exports.PageViewport = PageViewport;
exports.PasswordException = PasswordException; exports.PasswordException = PasswordException;
@ -16390,6 +16396,7 @@ var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES; var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
var ImageKind = sharedUtil.ImageKind; var ImageKind = sharedUtil.ImageKind;
var OPS = sharedUtil.OPS; var OPS = sharedUtil.OPS;
var NativeImageDecoding = sharedUtil.NativeImageDecoding;
var TextRenderingMode = sharedUtil.TextRenderingMode; var TextRenderingMode = sharedUtil.TextRenderingMode;
var CMapCompressionType = sharedUtil.CMapCompressionType; var CMapCompressionType = sharedUtil.CMapCompressionType;
var Util = sharedUtil.Util; var Util = sharedUtil.Util;
@ -16450,7 +16457,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
forceDataSchema: false, forceDataSchema: false,
maxImageSize: -1, maxImageSize: -1,
disableFontFace: false, disableFontFace: false,
disableNativeImageDecoder: false, nativeImageDecoderSupport: NativeImageDecoding.DECODE,
ignoreErrors: false ignoreErrors: false
}; };
function NativeImageDecoder(xref, resources, handler, forceDataSchema) { function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
@ -16724,17 +16731,17 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(OPS.paintInlineImageXObject, [imgData]); operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
return; return;
} }
var useNativeImageDecoder = !this.options.disableNativeImageDecoder; var nativeImageDecoderSupport = this.options.nativeImageDecoderSupport;
var objId = 'img_' + this.idFactory.createObjId(); var objId = 'img_' + this.idFactory.createObjId();
operatorList.addDependency(objId); operatorList.addDependency(objId);
args = [objId, w, h]; args = [objId, w, h];
if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) { if (nativeImageDecoderSupport !== NativeImageDecoding.NONE && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
operatorList.addOp(OPS.paintJpegXObject, args); operatorList.addOp(OPS.paintJpegXObject, args);
this.handler.send('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]); this.handler.send('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]);
return; return;
} }
var nativeImageDecoder = null; var nativeImageDecoder = null;
if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) { if (nativeImageDecoderSupport === NativeImageDecoding.DECODE && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
nativeImageDecoder = new NativeImageDecoder(this.xref, resources, this.handler, this.options.forceDataSchema); nativeImageDecoder = new NativeImageDecoder(this.xref, resources, this.handler, this.options.forceDataSchema);
} }
PDFImage.buildImage(this.handler, this.xref, resources, image, inline, nativeImageDecoder).then(imageObj => { PDFImage.buildImage(this.handler, this.xref, resources, image, inline, nativeImageDecoder).then(imageObj => {
@ -23864,7 +23871,7 @@ var WorkerMessageHandler = {
forceDataSchema: data.disableCreateObjectURL, forceDataSchema: data.disableCreateObjectURL,
maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize, maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
disableFontFace: data.disableFontFace, disableFontFace: data.disableFontFace,
disableNativeImageDecoder: data.disableNativeImageDecoder, nativeImageDecoderSupport: data.nativeImageDecoderSupport,
ignoreErrors: data.ignoreErrors ignoreErrors: data.ignoreErrors
}; };
getPdfManager(data, evaluatorOptions).then(function (newPdfManager) { getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
@ -36632,8 +36639,8 @@ exports.Type1Parser = Type1Parser;
"use strict"; "use strict";
var pdfjsVersion = '1.8.331'; var pdfjsVersion = '1.8.346';
var pdfjsBuild = '0dbc68a6'; var pdfjsBuild = '15425d5b';
var pdfjsCoreWorker = __w_pdfjs_require__(17); var pdfjsCoreWorker = __w_pdfjs_require__(17);
; ;
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

Просмотреть файл

@ -951,104 +951,103 @@ var PDFViewerApplication = {
})]).catch(function (reason) {}); })]).catch(function (reason) {});
}, },
_initializeViewerComponents() { _initializeViewerComponents() {
var self = this; let appConfig = this.appConfig;
var appConfig = this.appConfig;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(); let eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
this.eventBus = eventBus; this.eventBus = eventBus;
var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); let pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
pdfRenderingQueue.onIdle = self.cleanup.bind(self); pdfRenderingQueue.onIdle = this.cleanup.bind(this);
self.pdfRenderingQueue = pdfRenderingQueue; this.pdfRenderingQueue = pdfRenderingQueue;
var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus }); let pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus });
self.pdfLinkService = pdfLinkService; this.pdfLinkService = pdfLinkService;
var downloadManager = self.externalServices.createDownloadManager(); let downloadManager = this.externalServices.createDownloadManager();
self.downloadManager = downloadManager; this.downloadManager = downloadManager;
var container = appConfig.mainContainer; let container = appConfig.mainContainer;
var viewer = appConfig.viewerContainer; let viewer = appConfig.viewerContainer;
self.pdfViewer = new _pdf_viewer.PDFViewer({ this.pdfViewer = new _pdf_viewer.PDFViewer({
container, container,
viewer, viewer,
eventBus, eventBus,
renderingQueue: pdfRenderingQueue, renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService, linkService: pdfLinkService,
downloadManager, downloadManager,
renderer: self.viewerPrefs['renderer'], renderer: this.viewerPrefs['renderer'],
enhanceTextSelection: self.viewerPrefs['enhanceTextSelection'], enhanceTextSelection: this.viewerPrefs['enhanceTextSelection'],
renderInteractiveForms: self.viewerPrefs['renderInteractiveForms'], renderInteractiveForms: this.viewerPrefs['renderInteractiveForms'],
enablePrintAutoRotate: self.viewerPrefs['enablePrintAutoRotate'] enablePrintAutoRotate: this.viewerPrefs['enablePrintAutoRotate']
}); });
pdfRenderingQueue.setViewer(self.pdfViewer); pdfRenderingQueue.setViewer(this.pdfViewer);
pdfLinkService.setViewer(self.pdfViewer); pdfLinkService.setViewer(this.pdfViewer);
var thumbnailContainer = appConfig.sidebar.thumbnailView; let thumbnailContainer = appConfig.sidebar.thumbnailView;
self.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
container: thumbnailContainer, container: thumbnailContainer,
renderingQueue: pdfRenderingQueue, renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService linkService: pdfLinkService
}); });
pdfRenderingQueue.setThumbnailViewer(self.pdfThumbnailViewer); pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
self.pdfHistory = new _pdf_history.PDFHistory({ this.pdfHistory = new _pdf_history.PDFHistory({
linkService: pdfLinkService, linkService: pdfLinkService,
eventBus eventBus
}); });
pdfLinkService.setHistory(self.pdfHistory); pdfLinkService.setHistory(this.pdfHistory);
self.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: self.pdfViewer }); this.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: this.pdfViewer });
self.findController.onUpdateResultsCount = function (matchCount) { this.findController.onUpdateResultsCount = matchCount => {
if (self.supportsIntegratedFind) { if (this.supportsIntegratedFind) {
return; return;
} }
self.findBar.updateResultsCount(matchCount); this.findBar.updateResultsCount(matchCount);
}; };
self.findController.onUpdateState = function (state, previous, matchCount) { this.findController.onUpdateState = (state, previous, matchCount) => {
if (self.supportsIntegratedFind) { if (this.supportsIntegratedFind) {
self.externalServices.updateFindControlState({ this.externalServices.updateFindControlState({
result: state, result: state,
findPrevious: previous findPrevious: previous
}); });
} else { } else {
self.findBar.updateUIState(state, previous, matchCount); this.findBar.updateUIState(state, previous, matchCount);
} }
}; };
self.pdfViewer.setFindController(self.findController); this.pdfViewer.setFindController(this.findController);
var findBarConfig = Object.create(appConfig.findBar); let findBarConfig = Object.create(appConfig.findBar);
findBarConfig.findController = self.findController; findBarConfig.findController = this.findController;
findBarConfig.eventBus = eventBus; findBarConfig.eventBus = eventBus;
self.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig); this.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig);
self.overlayManager = _overlay_manager.OverlayManager; this.overlayManager = _overlay_manager.OverlayManager;
self.handTool = new _hand_tool.HandTool({ this.handTool = new _hand_tool.HandTool({
container, container,
eventBus, eventBus,
preferences: this.preferences preferences: this.preferences
}); });
self.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties); this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties);
self.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus); this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus);
self.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
if (self.supportsFullscreen) { if (this.supportsFullscreen) {
self.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
container, container,
viewer, viewer,
pdfViewer: self.pdfViewer, pdfViewer: this.pdfViewer,
eventBus, eventBus,
contextMenuItems: appConfig.fullscreen contextMenuItems: appConfig.fullscreen
}); });
} }
self.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay); this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay);
self.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
container: appConfig.sidebar.outlineView, container: appConfig.sidebar.outlineView,
eventBus, eventBus,
linkService: pdfLinkService linkService: pdfLinkService
}); });
self.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
container: appConfig.sidebar.attachmentsView, container: appConfig.sidebar.attachmentsView,
eventBus, eventBus,
downloadManager downloadManager
}); });
var sidebarConfig = Object.create(appConfig.sidebar); let sidebarConfig = Object.create(appConfig.sidebar);
sidebarConfig.pdfViewer = self.pdfViewer; sidebarConfig.pdfViewer = this.pdfViewer;
sidebarConfig.pdfThumbnailViewer = self.pdfThumbnailViewer; sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
sidebarConfig.pdfOutlineViewer = self.pdfOutlineViewer; sidebarConfig.pdfOutlineViewer = this.pdfOutlineViewer;
sidebarConfig.eventBus = eventBus; sidebarConfig.eventBus = eventBus;
self.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig); this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig);
self.pdfSidebar.onToggled = self.forceRendering.bind(self); this.pdfSidebar.onToggled = this.forceRendering.bind(this);
resolve(undefined); resolve(undefined);
}); });
}, },
@ -1193,14 +1192,14 @@ var PDFViewerApplication = {
} }
return promise; return promise;
}, },
open: function pdfViewOpen(file, args) { open(file, args) {
if (this.pdfLoadingTask) { if (this.pdfLoadingTask) {
return this.close().then(() => { return this.close().then(() => {
this.preferences.reload(); this.preferences.reload();
return this.open(file, args); return this.open(file, args);
}); });
} }
var parameters = Object.create(null), let parameters = Object.create(null),
scale; scale;
if (typeof file === 'string') { if (typeof file === 'string') {
this.setTitleUsingUrl(file); this.setTitleUsingUrl(file);
@ -1213,7 +1212,7 @@ var PDFViewerApplication = {
} }
parameters.docBaseUrl = this.baseUrl; parameters.docBaseUrl = this.baseUrl;
if (args) { if (args) {
for (var prop in args) { for (let prop in args) {
parameters[prop] = args[prop]; parameters[prop] = args[prop];
} }
if (args.scale) { if (args.scale) {
@ -1223,23 +1222,22 @@ var PDFViewerApplication = {
this.pdfDocumentProperties.setFileSize(args.length); this.pdfDocumentProperties.setFileSize(args.length);
} }
} }
var self = this; this.downloadComplete = false;
self.downloadComplete = false; let loadingTask = (0, _pdfjs.getDocument)(parameters);
var loadingTask = (0, _pdfjs.getDocument)(parameters);
this.pdfLoadingTask = loadingTask; this.pdfLoadingTask = loadingTask;
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) { loadingTask.onPassword = (updateCallback, reason) => {
self.passwordPrompt.setUpdateCallback(updateCallback, reason); this.passwordPrompt.setUpdateCallback(updateCallback, reason);
self.passwordPrompt.open(); this.passwordPrompt.open();
}; };
loadingTask.onProgress = function getDocumentProgress(progressData) { loadingTask.onProgress = ({ loaded, total }) => {
self.progress(progressData.loaded / progressData.total); this.progress(loaded / total);
}; };
loadingTask.onUnsupportedFeature = this.fallback.bind(this); loadingTask.onUnsupportedFeature = this.fallback.bind(this);
return loadingTask.promise.then(function getDocumentCallback(pdfDocument) { return loadingTask.promise.then(pdfDocument => {
self.load(pdfDocument, scale); this.load(pdfDocument, scale);
}, function getDocumentError(exception) { }, exception => {
var message = exception && exception.message; let message = exception && exception.message;
var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'); let loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
if (exception instanceof _pdfjs.InvalidPDFException) { if (exception instanceof _pdfjs.InvalidPDFException) {
loadingErrorMessage = _ui_utils.mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.'); loadingErrorMessage = _ui_utils.mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
} else if (exception instanceof _pdfjs.MissingPDFException) { } else if (exception instanceof _pdfjs.MissingPDFException) {
@ -1247,8 +1245,7 @@ var PDFViewerApplication = {
} else if (exception instanceof _pdfjs.UnexpectedResponseException) { } else if (exception instanceof _pdfjs.UnexpectedResponseException) {
loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.'); loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.');
} }
var moreInfo = { message }; this.error(loadingErrorMessage, { message });
self.error(loadingErrorMessage, moreInfo);
throw new Error(loadingErrorMessage); throw new Error(loadingErrorMessage);
}); });
}, },
@ -1328,54 +1325,53 @@ var PDFViewerApplication = {
} }
} }
}, },
load: function pdfViewLoad(pdfDocument, scale) { load(pdfDocument, scale) {
var self = this;
scale = scale || _ui_utils.UNKNOWN_SCALE; scale = scale || _ui_utils.UNKNOWN_SCALE;
this.pdfDocument = pdfDocument; this.pdfDocument = pdfDocument;
var downloadedPromise = pdfDocument.getDownloadInfo().then(function () { pdfDocument.getDownloadInfo().then(() => {
self.downloadComplete = true; this.downloadComplete = true;
self.loadingBar.hide(); this.loadingBar.hide();
firstPagePromise.then(() => {
this.eventBus.dispatch('documentload', { source: this });
});
}); });
this.toolbar.setPagesCount(pdfDocument.numPages, false); this.toolbar.setPagesCount(pdfDocument.numPages, false);
this.secondaryToolbar.setPagesCount(pdfDocument.numPages); this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
var id = this.documentFingerprint = pdfDocument.fingerprint; let id = this.documentFingerprint = pdfDocument.fingerprint;
var store = this.store = new _view_history.ViewHistory(id); let store = this.store = new _view_history.ViewHistory(id);
var baseDocumentUrl; let baseDocumentUrl;
baseDocumentUrl = this.baseUrl; baseDocumentUrl = this.baseUrl;
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl); this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
this.pdfDocumentProperties.setDocument(pdfDocument, this.url); this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
var pdfViewer = this.pdfViewer; let pdfViewer = this.pdfViewer;
pdfViewer.currentScale = scale; pdfViewer.currentScale = scale;
pdfViewer.setDocument(pdfDocument); pdfViewer.setDocument(pdfDocument);
var firstPagePromise = pdfViewer.firstPagePromise; let firstPagePromise = pdfViewer.firstPagePromise;
var pagesPromise = pdfViewer.pagesPromise; let pagesPromise = pdfViewer.pagesPromise;
var onePageRendered = pdfViewer.onePageRendered; let onePageRendered = pdfViewer.onePageRendered;
this.pageRotation = 0; this.pageRotation = 0;
var pdfThumbnailViewer = this.pdfThumbnailViewer; let pdfThumbnailViewer = this.pdfThumbnailViewer;
pdfThumbnailViewer.setDocument(pdfDocument); pdfThumbnailViewer.setDocument(pdfDocument);
firstPagePromise.then(pdfPage => { firstPagePromise.then(pdfPage => {
downloadedPromise.then(function () { this.loadingBar.setWidth(this.appConfig.viewerContainer);
self.eventBus.dispatch('documentload', { source: self }); if (!_pdfjs.PDFJS.disableHistory && !this.isViewerEmbedded) {
}); if (!this.viewerPrefs['showPreviousViewOnLoad']) {
self.loadingBar.setWidth(self.appConfig.viewerContainer); this.pdfHistory.clearHistoryState();
if (!_pdfjs.PDFJS.disableHistory && !self.isViewerEmbedded) {
if (!self.viewerPrefs['showPreviousViewOnLoad']) {
self.pdfHistory.clearHistoryState();
} }
self.pdfHistory.initialize(self.documentFingerprint); this.pdfHistory.initialize(this.documentFingerprint);
if (self.pdfHistory.initialDestination) { if (this.pdfHistory.initialDestination) {
self.initialDestination = self.pdfHistory.initialDestination; this.initialDestination = this.pdfHistory.initialDestination;
} else if (self.pdfHistory.initialBookmark) { } else if (this.pdfHistory.initialBookmark) {
self.initialBookmark = self.pdfHistory.initialBookmark; this.initialBookmark = this.pdfHistory.initialBookmark;
} }
} }
var initialParams = { let initialParams = {
destination: this.initialDestination, destination: this.initialDestination,
bookmark: this.initialBookmark, bookmark: this.initialBookmark,
hash: null hash: null
}; };
var storedHash = this.viewerPrefs['defaultZoomValue'] ? 'zoom=' + this.viewerPrefs['defaultZoomValue'] : null; let storedHash = this.viewerPrefs['defaultZoomValue'] ? 'zoom=' + this.viewerPrefs['defaultZoomValue'] : null;
var sidebarView = this.viewerPrefs['sidebarViewOnLoad']; let sidebarView = this.viewerPrefs['sidebarViewOnLoad'];
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
if (!this.viewerPrefs['showPreviousViewOnLoad']) { if (!this.viewerPrefs['showPreviousViewOnLoad']) {
resolve(); resolve();
@ -1422,13 +1418,13 @@ var PDFViewerApplication = {
this.setInitialView(initialParams.hash); this.setInitialView(initialParams.hash);
}); });
}); });
pdfDocument.getPageLabels().then(function (labels) { pdfDocument.getPageLabels().then(labels => {
if (!labels || self.viewerPrefs['disablePageLabels']) { if (!labels || this.viewerPrefs['disablePageLabels']) {
return; return;
} }
var i = 0, let i = 0,
numLabels = labels.length; numLabels = labels.length;
if (numLabels !== self.pagesCount) { if (numLabels !== this.pagesCount) {
console.error('The number of Page Labels does not match ' + 'the number of pages in the document.'); console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
return; return;
} }
@ -1440,46 +1436,45 @@ var PDFViewerApplication = {
} }
pdfViewer.setPageLabels(labels); pdfViewer.setPageLabels(labels);
pdfThumbnailViewer.setPageLabels(labels); pdfThumbnailViewer.setPageLabels(labels);
self.toolbar.setPagesCount(pdfDocument.numPages, true); this.toolbar.setPagesCount(pdfDocument.numPages, true);
self.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); this.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
}); });
pagesPromise.then(function () { pagesPromise.then(() => {
if (self.supportsPrinting) { if (!this.supportsPrinting) {
pdfDocument.getJavaScript().then(function (javaScript) { return;
if (javaScript.length) {
console.warn('Warning: JavaScript is not supported');
self.fallback(_pdfjs.UNSUPPORTED_FEATURES.javaScript);
}
var regex = /\bprint\s*\(/;
for (var i = 0, ii = javaScript.length; i < ii; i++) {
var js = javaScript[i];
if (js && regex.test(js)) {
setTimeout(function () {
window.print();
});
return;
}
}
});
} }
}); pdfDocument.getJavaScript().then(javaScript => {
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () { if (javaScript.length) {
pdfDocument.getOutline().then(function (outline) { console.warn('Warning: JavaScript is not supported');
self.pdfOutlineViewer.render({ outline }); this.fallback(_pdfjs.UNSUPPORTED_FEATURES.javaScript);
}); }
pdfDocument.getAttachments().then(function (attachments) { let regex = /\bprint\s*\(/;
self.pdfAttachmentViewer.render({ attachments }); for (let i = 0, ii = javaScript.length; i < ii; i++) {
let js = javaScript[i];
if (js && regex.test(js)) {
setTimeout(function () {
window.print();
});
return;
}
}
}); });
}); });
pdfDocument.getMetadata().then(function (data) { Promise.all([onePageRendered, _ui_utils.animationStarted]).then(() => {
var info = data.info, pdfDocument.getOutline().then(outline => {
metadata = data.metadata; this.pdfOutlineViewer.render({ outline });
self.documentInfo = info; });
self.metadata = metadata; pdfDocument.getAttachments().then(attachments => {
this.pdfAttachmentViewer.render({ attachments });
});
});
pdfDocument.getMetadata().then(({ info, metadata }) => {
this.documentInfo = info;
this.metadata = metadata;
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjs.version || '-') + (!_pdfjs.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjs.version || '-') + (!_pdfjs.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
var pdfTitle; let pdfTitle;
if (metadata && metadata.has('dc:title')) { if (metadata && metadata.has('dc:title')) {
var title = metadata.get('dc:title'); let title = metadata.get('dc:title');
if (title !== 'Untitled') { if (title !== 'Untitled') {
pdfTitle = title; pdfTitle = title;
} }
@ -1488,15 +1483,15 @@ var PDFViewerApplication = {
pdfTitle = info['Title']; pdfTitle = info['Title'];
} }
if (pdfTitle) { if (pdfTitle) {
self.setTitle(pdfTitle + ' - ' + document.title); this.setTitle(pdfTitle + ' - ' + document.title);
} }
if (info.IsAcroFormPresent) { if (info.IsAcroFormPresent) {
console.warn('Warning: AcroForm/XFA is not supported'); console.warn('Warning: AcroForm/XFA is not supported');
self.fallback(_pdfjs.UNSUPPORTED_FEATURES.forms); this.fallback(_pdfjs.UNSUPPORTED_FEATURES.forms);
} }
var versionId = String(info.PDFFormatVersion).slice(-1) | 0; let versionId = String(info.PDFFormatVersion).slice(-1) | 0;
var generatorId = 0; let generatorId = 0;
var KNOWN_GENERATORS = ['acrobat distiller', 'acrobat pdfwriter', 'adobe livecycle', 'adobe pdf library', 'adobe photoshop', 'ghostscript', 'tcpdf', 'cairo', 'dvipdfm', 'dvips', 'pdftex', 'pdfkit', 'itext', 'prince', 'quarkxpress', 'mac os x', 'microsoft', 'openoffice', 'oracle', 'luradocument', 'pdf-xchange', 'antenna house', 'aspose.cells', 'fpdf']; const KNOWN_GENERATORS = ['acrobat distiller', 'acrobat pdfwriter', 'adobe livecycle', 'adobe pdf library', 'adobe photoshop', 'ghostscript', 'tcpdf', 'cairo', 'dvipdfm', 'dvips', 'pdftex', 'pdfkit', 'itext', 'prince', 'quarkxpress', 'mac os x', 'microsoft', 'openoffice', 'oracle', 'luradocument', 'pdf-xchange', 'antenna house', 'aspose.cells', 'fpdf'];
if (info.Producer) { if (info.Producer) {
KNOWN_GENERATORS.some(function (generator, s, i) { KNOWN_GENERATORS.some(function (generator, s, i) {
if (generator.indexOf(s) < 0) { if (generator.indexOf(s) < 0) {
@ -1506,8 +1501,8 @@ var PDFViewerApplication = {
return true; return true;
}.bind(null, info.Producer.toLowerCase())); }.bind(null, info.Producer.toLowerCase()));
} }
var formType = !info.IsAcroFormPresent ? null : info.IsXFAPresent ? 'xfa' : 'acroform'; let formType = !info.IsAcroFormPresent ? null : info.IsXFAPresent ? 'xfa' : 'acroform';
self.externalServices.reportTelemetry({ this.externalServices.reportTelemetry({
type: 'documentInfo', type: 'documentInfo',
version: versionId, version: versionId,
generator: generatorId, generator: generatorId,
@ -2702,6 +2697,8 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.PDFFindController = exports.FindStates = undefined; exports.PDFFindController = exports.FindStates = undefined;
var _pdfjs = __webpack_require__(1);
var _ui_utils = __webpack_require__(0); var _ui_utils = __webpack_require__(0);
var FindStates = { var FindStates = {
@ -2870,35 +2867,28 @@ var PDFFindController = function PDFFindControllerClosure() {
this.updateUIResultsCount(); this.updateUIResultsCount();
} }
}, },
extractText: function PDFFindController_extractText() { extractText() {
if (this.startedTextExtraction) { if (this.startedTextExtraction) {
return; return;
} }
this.startedTextExtraction = true; this.startedTextExtraction = true;
this.pageContents = []; this.pageContents.length = 0;
var extractTextPromisesResolves = []; let promise = Promise.resolve();
var numPages = this.pdfViewer.pagesCount; for (let i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
for (var i = 0; i < numPages; i++) { let extractTextCapability = (0, _pdfjs.createPromiseCapability)();
this.extractTextPromises.push(new Promise(function (resolve) { this.extractTextPromises[i] = extractTextCapability.promise;
extractTextPromisesResolves.push(resolve); promise = promise.then(() => {
})); return this.pdfViewer.getPageTextContent(i).then(textContent => {
} let textItems = textContent.items;
var self = this; let strBuf = [];
function extractPageText(pageIndex) { for (let j = 0, jj = textItems.length; j < jj; j++) {
self.pdfViewer.getPageTextContent(pageIndex).then(function textContentResolved(textContent) { strBuf.push(textItems[j].str);
var textItems = textContent.items; }
var str = []; this.pageContents[i] = strBuf.join('');
for (var i = 0, len = textItems.length; i < len; i++) { extractTextCapability.resolve(i);
str.push(textItems[i].str); });
}
self.pageContents.push(str.join(''));
extractTextPromisesResolves[pageIndex](pageIndex);
if (pageIndex + 1 < self.pdfViewer.pagesCount) {
extractPageText(pageIndex + 1);
}
}); });
} }
extractPageText(0);
}, },
executeCommand: function PDFFindController_executeCommand(cmd, state) { executeCommand: function PDFFindController_executeCommand(cmd, state) {
if (this.state === null || cmd !== 'findagain') { if (this.state === null || cmd !== 'findagain') {
@ -2940,14 +2930,13 @@ var PDFFindController = function PDFFindControllerClosure() {
this.pageMatches = []; this.pageMatches = [];
this.matchCount = 0; this.matchCount = 0;
this.pageMatchesLength = null; this.pageMatchesLength = null;
var self = this; for (let i = 0; i < numPages; i++) {
for (var i = 0; i < numPages; i++) {
this.updatePage(i); this.updatePage(i);
if (!(i in this.pendingFindMatches)) { if (!(i in this.pendingFindMatches)) {
this.pendingFindMatches[i] = true; this.pendingFindMatches[i] = true;
this.extractTextPromises[i].then(function (pageIdx) { this.extractTextPromises[i].then(pageIdx => {
delete self.pendingFindMatches[pageIdx]; delete this.pendingFindMatches[pageIdx];
self.calcFindMatch(pageIdx); this.calcFindMatch(pageIdx);
}); });
} }
} }
@ -3602,11 +3591,10 @@ var _grab_to_pan = __webpack_require__(11);
var _ui_utils = __webpack_require__(0); var _ui_utils = __webpack_require__(0);
var HandTool = function HandToolClosure() { class HandTool {
function HandTool(options) { constructor({ container, eventBus, preferences }) {
this.container = options.container; this.container = container;
this.eventBus = options.eventBus; this.eventBus = eventBus;
var preferences = options.preferences;
this.wasActive = false; this.wasActive = false;
this.handTool = new _grab_to_pan.GrabToPan({ this.handTool = new _grab_to_pan.GrabToPan({
element: this.container, element: this.container,
@ -3615,11 +3603,12 @@ var HandTool = function HandToolClosure() {
} }
}); });
this.eventBus.on('togglehandtool', this.toggle.bind(this)); this.eventBus.on('togglehandtool', this.toggle.bind(this));
Promise.all([_ui_utils.localized, preferences.get('enableHandToolOnLoad')]).then(values => { let enableOnLoad = preferences.get('enableHandToolOnLoad');
Promise.all([_ui_utils.localized, enableOnLoad]).then(values => {
if (values[1] === true) { if (values[1] === true) {
this.handTool.activate(); this.handTool.activate();
} }
}).catch(function rejected(reason) {}); }).catch(function (reason) {});
this.eventBus.on('presentationmodechanged', evt => { this.eventBus.on('presentationmodechanged', evt => {
if (evt.switchInProgress) { if (evt.switchInProgress) {
return; return;
@ -3631,28 +3620,25 @@ var HandTool = function HandToolClosure() {
} }
}); });
} }
HandTool.prototype = { get isActive() {
get isActive() { return !!this.handTool.active;
return !!this.handTool.active; }
}, toggle() {
toggle: function HandTool_toggle() { this.handTool.toggle();
this.handTool.toggle(); }
}, enterPresentationMode() {
enterPresentationMode: function HandTool_enterPresentationMode() { if (this.isActive) {
if (this.isActive) { this.wasActive = true;
this.wasActive = true; this.handTool.deactivate();
this.handTool.deactivate();
}
},
exitPresentationMode: function HandTool_exitPresentationMode() {
if (this.wasActive) {
this.wasActive = false;
this.handTool.activate();
}
} }
}; }
return HandTool; exitPresentationMode() {
}(); if (this.wasActive) {
this.wasActive = false;
this.handTool.activate();
}
}
}
exports.HandTool = HandTool; exports.HandTool = HandTool;
/***/ }), /***/ }),
@ -6948,8 +6934,8 @@ exports.SecondaryToolbar = undefined;
var _ui_utils = __webpack_require__(0); var _ui_utils = __webpack_require__(0);
var SecondaryToolbar = function SecondaryToolbarClosure() { class SecondaryToolbar {
function SecondaryToolbar(options, mainContainer, eventBus) { constructor(options, mainContainer, eventBus) {
this.toolbar = options.toolbar; this.toolbar = options.toolbar;
this.toggleButton = options.toggleButton; this.toggleButton = options.toggleButton;
this.toolbarButtonContainer = options.toolbarButtonContainer; this.toolbarButtonContainer = options.toolbarButtonContainer;
@ -7014,98 +7000,94 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
this._bindHandToolListener(options.toggleHandToolButton); this._bindHandToolListener(options.toggleHandToolButton);
this.eventBus.on('resize', this._setMaxHeight.bind(this)); this.eventBus.on('resize', this._setMaxHeight.bind(this));
} }
SecondaryToolbar.prototype = { get isOpen() {
get isOpen() { return this.opened;
return this.opened; }
}, setPageNumber(pageNumber) {
setPageNumber: function SecondaryToolbar_setPageNumber(pageNumber) { this.pageNumber = pageNumber;
this.pageNumber = pageNumber; this._updateUIState();
this._updateUIState(); }
}, setPagesCount(pagesCount) {
setPagesCount: function SecondaryToolbar_setPagesCount(pagesCount) { this.pagesCount = pagesCount;
this.pagesCount = pagesCount; this._updateUIState();
this._updateUIState(); }
}, reset() {
reset: function SecondaryToolbar_reset() { this.pageNumber = 0;
this.pageNumber = 0; this.pagesCount = 0;
this.pagesCount = 0; this._updateUIState();
this._updateUIState(); }
}, _updateUIState() {
_updateUIState: function SecondaryToolbar_updateUIState() { this.items.firstPage.disabled = this.pageNumber <= 1;
var items = this.items; this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
items.firstPage.disabled = this.pageNumber <= 1; this.items.pageRotateCw.disabled = this.pagesCount === 0;
items.lastPage.disabled = this.pageNumber >= this.pagesCount; this.items.pageRotateCcw.disabled = this.pagesCount === 0;
items.pageRotateCw.disabled = this.pagesCount === 0; }
items.pageRotateCcw.disabled = this.pagesCount === 0; _bindClickListeners() {
}, this.toggleButton.addEventListener('click', this.toggle.bind(this));
_bindClickListeners: function SecondaryToolbar_bindClickListeners() { for (let button in this.buttons) {
this.toggleButton.addEventListener('click', this.toggle.bind(this)); let { element, eventName, close } = this.buttons[button];
for (let button in this.buttons) { element.addEventListener('click', evt => {
let { element, eventName, close } = this.buttons[button]; if (eventName !== null) {
element.addEventListener('click', evt => { this.eventBus.dispatch(eventName, { source: this });
if (eventName !== null) {
this.eventBus.dispatch(eventName, { source: this });
}
if (close) {
this.close();
}
});
}
},
_bindHandToolListener: function SecondaryToolbar_bindHandToolListener(toggleHandToolButton) {
var isHandToolActive = false;
this.eventBus.on('handtoolchanged', function (e) {
if (isHandToolActive === e.isActive) {
return;
} }
isHandToolActive = e.isActive; if (close) {
if (isHandToolActive) { this.close();
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
} else {
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
} }
}); });
},
open: function SecondaryToolbar_open() {
if (this.opened) {
return;
}
this.opened = true;
this._setMaxHeight();
this.toggleButton.classList.add('toggled');
this.toolbar.classList.remove('hidden');
},
close: function SecondaryToolbar_close() {
if (!this.opened) {
return;
}
this.opened = false;
this.toolbar.classList.add('hidden');
this.toggleButton.classList.remove('toggled');
},
toggle: function SecondaryToolbar_toggle() {
if (this.opened) {
this.close();
} else {
this.open();
}
},
_setMaxHeight: function SecondaryToolbar_setMaxHeight() {
if (!this.opened) {
return;
}
this.containerHeight = this.mainContainer.clientHeight;
if (this.containerHeight === this.previousContainerHeight) {
return;
}
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
this.previousContainerHeight = this.containerHeight;
} }
}; }
return SecondaryToolbar; _bindHandToolListener(toggleHandToolButton) {
}(); let isHandToolActive = false;
this.eventBus.on('handtoolchanged', function (evt) {
if (isHandToolActive === evt.isActive) {
return;
}
isHandToolActive = evt.isActive;
if (isHandToolActive) {
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
} else {
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
}
});
}
open() {
if (this.opened) {
return;
}
this.opened = true;
this._setMaxHeight();
this.toggleButton.classList.add('toggled');
this.toolbar.classList.remove('hidden');
}
close() {
if (!this.opened) {
return;
}
this.opened = false;
this.toolbar.classList.add('hidden');
this.toggleButton.classList.remove('toggled');
}
toggle() {
if (this.opened) {
this.close();
} else {
this.open();
}
}
_setMaxHeight() {
if (!this.opened) {
return;
}
this.containerHeight = this.mainContainer.clientHeight;
if (this.containerHeight === this.previousContainerHeight) {
return;
}
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
this.previousContainerHeight = this.containerHeight;
}
}
exports.SecondaryToolbar = SecondaryToolbar; exports.SecondaryToolbar = SecondaryToolbar;
/***/ }), /***/ }),