TagSpaces is an offline, open source, document manager with tagging support
exchanging the pdf.js lib with a newer version
uggrock0db67a4c69cf
diff --git a/data/libs/pdfjs/build/pdf.js b/data/libs/pdfjs/build/pdf.jsindex d3a30084d..e353b5ef1 100644--- a/data/libs/pdfjs/build/pdf.js+++ b/data/libs/pdfjs/build/pdf.js@@ -22,33 +22,14 @@ if (typeof PDFJS === 'undefined') {(typeof window !== 'undefined' ? window : this).PDFJS = {};}-PDFJS.version = '1.1.1';-PDFJS.build = 'a1e0859';+PDFJS.version = '1.1.366';+PDFJS.build = '9e9df56';(function pdfjsWrapper() {// Use strict in our context only - users might not want it'use strict';-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */-/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */-/* Copyright 2012 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.- */-/* globals Cmd, ColorSpace, Dict, MozBlobBuilder, Name, PDFJS, Ref, URL,- Promise */-'use strict';var globalScope = (typeof window === 'undefined') ? this : window;@@ -81,6 +62,14 @@ var AnnotationType = {LINK: 3};+var AnnotationBorderStyleType = {+ SOLID: 1,+ DASHED: 2,+ BEVELED: 3,+ INSET: 4,+ UNDERLINE: 5+};+var StreamType = {UNKNOWN: 0,FLATE: 1,@@ -239,17 +228,10 @@ function warn(msg) {// Fatal errors that should trigger the fallback UI and halt execution by// throwing an exception.function error(msg) {- // If multiple arguments were passed, pass them all to the log function.- if (arguments.length > 1) {- var logArguments = ['Error:'];- logArguments.push.apply(logArguments, arguments);- console.log.apply(console, logArguments);- // Join the arguments into a single string for the lines below.- msg = [].join.call(arguments, ' ');- } else {+ if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {console.log('Error: ' + msg);+ console.log(backtrace());}- console.log(backtrace());UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);throw new Error(msg);}@@ -541,7 +523,7 @@ Object.defineProperty(PDFJS, 'isLittleEndian', {}});- // Lazy test if the userAgant support CanvasTypedArrays+ // Lazy test if the userAgent support CanvasTypedArraysfunction hasCanvasTypedArrays() {var canvas = document.createElement('canvas');canvas.width = canvas.height = 1;@@ -980,6 +962,10 @@ function stringToUTF8String(str) {return decodeURIComponent(escape(str));}+function utf8StringToString(str) {+ return unescape(encodeURIComponent(str));+}+function isEmptyObj(obj) {for (var key in obj) {return false;@@ -2276,13 +2262,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {* annotation objects.*/getAnnotations: function PDFPageProxy_getAnnotations() {- if (this.annotationsPromise) {- return this.annotationsPromise;+ if (!this.annotationsPromise) {+ this.annotationsPromise = this.transport.getAnnotations(this.pageIndex);}-- var promise = this.transport.getAnnotations(this.pageIndex);- this.annotationsPromise = promise;- return promise;+ return this.annotationsPromise;},/*** Begins the process of rendering a page to the desired context.@@ -2328,6 +2311,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {this.commonObjs,intentState.operatorList,this.pageNumber);+ internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';if (!intentState.renderTasks) {intentState.renderTasks = [];}@@ -3133,6 +3117,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {this.running = false;this.graphicsReadyCallback = null;this.graphicsReady = false;+ this.useRequestAnimationFrame = false;this.cancelled = false;this.capability = createPromiseCapability();this.task = new RenderTask(this);@@ -3206,7 +3191,11 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {},_scheduleNext: function InternalRenderTask__scheduleNext() {- window.requestAnimationFrame(this._nextBound);+ if (this.useRequestAnimationFrame) {+ window.requestAnimationFrame(this._nextBound);+ } else {+ Promise.resolve(undefined).then(this._nextBound);+ }},_next: function InternalRenderTask__next() {@@ -3338,11 +3327,8 @@ function createScratchCanvas(width, height) {}function addContextCurrentTransform(ctx) {- // If the context doesn't expose a `mozCurrentTransform`, add a JS based on.+ // If the context doesn't expose a `mozCurrentTransform`, add a JS based one.if (!ctx.mozCurrentTransform) {- // Store the original context- ctx._scaleX = ctx._scaleX || 1.0;- ctx._scaleY = ctx._scaleY || 1.0;ctx._originalSave = ctx.save;ctx._originalRestore = ctx.restore;ctx._originalRotate = ctx.rotate;@@ -3351,7 +3337,7 @@ function addContextCurrentTransform(ctx) {ctx._originalTransform = ctx.transform;ctx._originalSetTransform = ctx.setTransform;- ctx._transformMatrix = [ctx._scaleX, 0, 0, ctx._scaleY, 0, 0];+ ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];ctx._transformStack = [];Object.defineProperty(ctx, 'mozCurrentTransform', {@@ -3727,6 +3713,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {this.smaskCounter = 0;this.tempSMask = null;if (canvasCtx) {+ // NOTE: if mozCurrentTransform is polyfilled, then the current state of+ // the transformation must already be set in canvasCtx._transformMatrix.addContextCurrentTransform(canvasCtx);}this.cachedGetSinglePixelWidth = null;@@ -4518,7 +4506,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {}var name = fontObj.loadedName || 'sans-serif';- var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') :+ var bold = fontObj.black ? (fontObj.bold ? '900' : 'bold') :(fontObj.bold ? 'bold' : 'normal');var italic = fontObj.italic ? 'italic' : 'normal';@@ -4778,6 +4766,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {if (isTextInvisible || fontSize === 0) {return;}+ this.cachedGetSinglePixelWidth = null;ctx.save();ctx.transform.apply(ctx, current.textMatrix);@@ -6364,6 +6353,13 @@ var FontLoader = {var rules = [];var fontsToLoad = [];var fontLoadPromises = [];+ var getNativeFontPromise = function(nativeFontFace) {+ // Return a promise that is always fulfilled, even when the font fails to+ // load.+ return nativeFontFace.loaded.catch(function(e) {+ warn('Failed to load font "' + nativeFontFace.family + '": ' + e);+ });+ };for (var i = 0, ii = fonts.length; i < ii; i++) {var font = fonts[i];@@ -6377,7 +6373,7 @@ var FontLoader = {if (this.isFontLoadingAPISupported) {var nativeFontFace = font.createNativeFontFace();if (nativeFontFace) {- fontLoadPromises.push(nativeFontFace.loaded);+ fontLoadPromises.push(getNativeFontPromise(nativeFontFace));}} else {var rule = font.bindDOM();@@ -6390,7 +6386,7 @@ var FontLoader = {var request = FontLoader.queueLoadingCallback(callback);if (this.isFontLoadingAPISupported) {- Promise.all(fontsToLoad).then(function() {+ Promise.all(fontLoadPromises).then(function() {request.complete();});} else if (rules.length > 0 && !this.isSyncFontLoadingSupported) {@@ -6628,25 +6624,70 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {style.fontFamily = fontFamily + fallbackName;}- function initContainer(item, drawBorder) {+ function initContainer(item) {var container = document.createElement('section');var cstyle = container.style;var width = item.rect[2] - item.rect[0];var height = item.rect[3] - item.rect[1];- var bWidth = item.borderWidth || 0;- if (bWidth) {- width = width - 2 * bWidth;- height = height - 2 * bWidth;- cstyle.borderWidth = bWidth + 'px';- var color = item.color;- if (drawBorder && color) {- cstyle.borderStyle = 'solid';- cstyle.borderColor = Util.makeCssRgb(Math.round(color[0] * 255),- Math.round(color[1] * 255),- Math.round(color[2] * 255));+ // Border+ if (item.borderStyle.width > 0) {+ // Border width+ container.style.borderWidth = item.borderStyle.width + 'px';+ if (item.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {+ // Underline styles only have a bottom border, so we do not need+ // to adjust for all borders. This yields a similar result as+ // Adobe Acrobat/Reader.+ width = width - 2 * item.borderStyle.width;+ height = height - 2 * item.borderStyle.width;+ }++ // Horizontal and vertical border radius+ var horizontalRadius = item.borderStyle.horizontalCornerRadius;+ var verticalRadius = item.borderStyle.verticalCornerRadius;+ if (horizontalRadius > 0 || verticalRadius > 0) {+ var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';+ CustomStyle.setProp('borderRadius', container, radius);+ }++ // Border style+ switch (item.borderStyle.style) {+ case AnnotationBorderStyleType.SOLID:+ container.style.borderStyle = 'solid';+ break;++ case AnnotationBorderStyleType.DASHED:+ container.style.borderStyle = 'dashed';+ break;++ case AnnotationBorderStyleType.BEVELED:+ warn('Unimplemented border style: beveled');+ break;++ case AnnotationBorderStyleType.INSET:+ warn('Unimplemented border style: inset');+ break;++ case AnnotationBorderStyleType.UNDERLINE:+ container.style.borderBottomStyle = 'solid';+ break;++ default:+ break;+ }++ // Border color+ if (item.color) {+ container.style.borderColor =+ Util.makeCssRgb(item.color[0] | 0,+ item.color[1] | 0,+ item.color[2] | 0);+ } else {+ // Transparent (invisible) border, so do not draw it at all.+ container.style.borderWidth = 0;}}+cstyle.width = width + 'px';cstyle.height = height + 'px';return container;@@ -6687,7 +6728,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {rect[2] = rect[0] + (rect[3] - rect[1]); // make it square}- var container = initContainer(item, false);+ var container = initContainer(item);container.className = 'annotText';var image = document.createElement('img');@@ -6710,17 +6751,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {content.setAttribute('hidden', true);var i, ii;- if (item.hasBgColor) {+ if (item.hasBgColor && item.color) {var color = item.color;// Enlighten the color (70%)var BACKGROUND_ENLIGHT = 0.7;- var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];- var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];- var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];- content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,- (g * 255) | 0,- (b * 255) | 0);+ 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];+ content.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);}var title = document.createElement('h1');@@ -6796,7 +6835,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {}function getHtmlElementForLinkAnnotation(item) {- var container = initContainer(item, true);+ var container = initContainer(item);container.className = 'annotLink';var link = document.createElement('a');diff --git a/data/libs/pdfjs/build/pdf.worker.js b/data/libs/pdfjs/build/pdf.worker.jsindex be9a21c3c..2c32874d1 100644--- a/data/libs/pdfjs/build/pdf.worker.js+++ b/data/libs/pdfjs/build/pdf.worker.js@@ -22,33 +22,14 @@ if (typeof PDFJS === 'undefined') {(typeof window !== 'undefined' ? window : this).PDFJS = {};}-PDFJS.version = '1.1.1';-PDFJS.build = 'a1e0859';+PDFJS.version = '1.1.366';+PDFJS.build = '9e9df56';(function pdfjsWrapper() {// Use strict in our context only - users might not want it'use strict';-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */-/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */-/* Copyright 2012 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.- */-/* globals Cmd, ColorSpace, Dict, MozBlobBuilder, Name, PDFJS, Ref, URL,- Promise */-'use strict';var globalScope = (typeof window === 'undefined') ? this : window;@@ -81,6 +62,14 @@ var AnnotationType = {LINK: 3};+var AnnotationBorderStyleType = {+ SOLID: 1,+ DASHED: 2,+ BEVELED: 3,+ INSET: 4,+ UNDERLINE: 5+};+var StreamType = {UNKNOWN: 0,FLATE: 1,@@ -239,17 +228,10 @@ function warn(msg) {// Fatal errors that should trigger the fallback UI and halt execution by// throwing an exception.function error(msg) {- // If multiple arguments were passed, pass them all to the log function.- if (arguments.length > 1) {- var logArguments = ['Error:'];- logArguments.push.apply(logArguments, arguments);- console.log.apply(console, logArguments);- // Join the arguments into a single string for the lines below.- msg = [].join.call(arguments, ' ');- } else {+ if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {console.log('Error: ' + msg);+ console.log(backtrace());}- console.log(backtrace());UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);throw new Error(msg);}@@ -541,7 +523,7 @@ Object.defineProperty(PDFJS, 'isLittleEndian', {}});- // Lazy test if the userAgant support CanvasTypedArrays+ // Lazy test if the userAgent support CanvasTypedArraysfunction hasCanvasTypedArrays() {var canvas = document.createElement('canvas');canvas.width = canvas.height = 1;@@ -980,6 +962,10 @@ function stringToUTF8String(str) {return decodeURIComponent(escape(str));}+function utf8StringToString(str) {+ return unescape(encodeURIComponent(str));+}+function isEmptyObj(obj) {for (var key in obj) {return false;@@ -1647,6 +1633,26 @@ var NetworkManager = (function NetworkManagerClosure() {return array.buffer;}+ var supportsMozChunked = (function supportsMozChunkedClosure() {+ var x = new XMLHttpRequest();+ try {+ // Firefox 37- required .open() to be called before setting responseType.+ // https://bugzilla.mozilla.org/show_bug.cgi?id=707484+ x.open('GET', 'https://example.com');+ } catch (e) {+ // Even though the URL is not visited, .open() could fail if the URL is+ // blocked, e.g. via the connect-src CSP directive or the NoScript addon.+ // When this error occurs, this feature detection method will mistakenly+ // report that moz-chunked-arraybuffer is not supported in Firefox 37-.+ }+ try {+ x.responseType = 'moz-chunked-arraybuffer';+ return x.responseType === 'moz-chunked-arraybuffer';+ } catch (e) {+ return false;+ }+ })();+NetworkManager.prototype = {requestRange: function NetworkManager_requestRange(begin, end, listeners) {var args = {@@ -1687,17 +1693,11 @@ var NetworkManager = (function NetworkManagerClosure() {pendingRequest.expectedStatus = 200;}- if (args.onProgressiveData) {- // Some legacy browsers might throw an exception.- try {- xhr.responseType = 'moz-chunked-arraybuffer';- } catch(e) {}- if (xhr.responseType === 'moz-chunked-arraybuffer') {- pendingRequest.onProgressiveData = args.onProgressiveData;- pendingRequest.mozChunked = true;- } else {- xhr.responseType = 'arraybuffer';- }+ var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;+ if (useMozChunkedLoading) {+ xhr.responseType = 'moz-chunked-arraybuffer';+ pendingRequest.onProgressiveData = args.onProgressiveData;+ pendingRequest.mozChunked = true;} else {xhr.responseType = 'arraybuffer';}@@ -1960,14 +1960,9 @@ var ChunkedStream = (function ChunkedStreamClosure() {},nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {- var chunk, n;- for (chunk = beginChunk, n = this.numChunks; chunk < n; ++chunk) {- if (!this.loadedChunks[chunk]) {- return chunk;- }- }- // Wrap around to beginning- for (chunk = 0; chunk < beginChunk; ++chunk) {+ var chunk, numChunks = this.numChunks;+ for (var i = 0; i < numChunks; ++i) {+ chunk = (beginChunk + i) % numChunks; // Wrap around to beginningif (!this.loadedChunks[chunk]) {return chunk;}@@ -2244,7 +2239,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {this.requestChunks(chunksToRequest, callback);},- // Groups a sorted array of chunks into as few continguous larger+ // Groups a sorted array of chunks into as few contiguous larger// chunks as possiblegroupChunks: function ChunkedStreamManager_groupChunks(chunks) {var groupedChunks = [];@@ -2369,15 +2364,6 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {},getEndChunk: function ChunkedStreamManager_getEndChunk(end) {- if (end % this.chunkSize === 0) {- return end / this.chunkSize;- }-- // 0 -> 0- // 1 -> 1- // 99 -> 1- // 100 -> 1- // 101 -> 2var chunk = Math.floor((end - 1) / this.chunkSize) + 1;return chunk;}@@ -2614,17 +2600,33 @@ var Page = (function PageClosure() {return this.pageDict.get(key);},- getInheritedPageProp: function Page_inheritPageProp(key) {- var dict = this.pageDict;- var value = dict.get(key);- while (value === undefined) {- dict = dict.get('Parent');- if (!dict) {+ getInheritedPageProp: function Page_getInheritedPageProp(key) {+ var dict = this.pageDict, valueArray = null, loopCount = 0;+ var MAX_LOOP_COUNT = 100;+ // Always walk up the entire parent chain, to be able to find+ // e.g. \Resources placed on multiple levels of the tree.+ while (dict) {+ var value = dict.get(key);+ if (value) {+ if (!valueArray) {+ valueArray = [];+ }+ valueArray.push(value);+ }+ if (++loopCount > MAX_LOOP_COUNT) {+ warn('Page_getInheritedPageProp: maximum loop count exceeded.');break;}- value = dict.get(key);+ dict = dict.get('Parent');}- return value;+ if (!valueArray) {+ return Dict.empty;+ }+ if (valueArray.length === 1 || !isDict(valueArray[0]) ||+ loopCount > MAX_LOOP_COUNT) {+ return valueArray[0];+ }+ return Dict.merge(this.xref, valueArray);},get content() {@@ -2632,14 +2634,10 @@ var Page = (function PageClosure() {},get resources() {- var value = this.getInheritedPageProp('Resources');// For robustness: The spec states that a \Resources entry has to be- // present, but can be empty. Some document omit it still. In this case- // return an empty dictionary:- if (value === undefined) {- value = Dict.empty;- }- return shadow(this, 'resources', value);+ // present, but can be empty. Some document omit it still, in this case+ // we return an empty dictionary.+ return shadow(this, 'resources', this.getInheritedPageProp('Resources'));},get mediaBox() {@@ -2669,11 +2667,6 @@ var Page = (function PageClosure() {return shadow(this, 'view', cropBox);},- get annotationRefs() {- return shadow(this, 'annotationRefs',- this.getInheritedPageProp('Annots'));- },-get rotate() {var rotate = this.getInheritedPageProp('Rotate') || 0;// Normalize rotation so it's a multiple of 90 and between 0 and 270@@ -2819,18 +2812,20 @@ var Page = (function PageClosure() {var annotations = this.annotations;var annotationsData = [];for (var i = 0, n = annotations.length; i < n; ++i) {- annotationsData.push(annotations[i].getData());+ annotationsData.push(annotations[i].data);}return annotationsData;},get annotations() {var annotations = [];- var annotationRefs = (this.annotationRefs || []);+ var annotationRefs = this.getInheritedPageProp('Annots') || [];+ var annotationFactory = new AnnotationFactory();for (var i = 0, n = annotationRefs.length; i < n; ++i) {var annotationRef = annotationRefs[i];- var annotation = Annotation.fromRef(this.xref, annotationRef);- if (annotation) {+ var annotation = annotationFactory.create(this.xref, annotationRef);+ if (annotation &&+ (annotation.isViewable() || annotation.isPrintable())) {annotations.push(annotation);}}@@ -2912,6 +2907,10 @@ var PDFDocument = (function PDFDocumentClosure() {PDFDocument.prototype = {parse: function PDFDocument_parse(recoveryMode) {this.setup(recoveryMode);+ var version = this.catalog.catDict.get('Version');+ if (isName(version)) {+ this.pdfFormatVersion = version.name;+ }try {// checking if AcroForm is presentthis.acroForm = this.catalog.catDict.get('AcroForm');@@ -3013,8 +3012,10 @@ var PDFDocument = (function PDFDocumentClosure() {}version += String.fromCharCode(ch);}- // removing "%PDF-"-prefix- this.pdfFormatVersion = version.substring(5);+ if (!this.pdfFormatVersion) {+ // removing "%PDF-"-prefix+ this.pdfFormatVersion = version.substring(5);+ }return;}// May not be a PDF file, continue anyway.@@ -3270,6 +3271,10 @@ var Dict = (function DictClosure() {return all;},+ getKeys: function Dict_getKeys() {+ return Object.keys(this.map);+ },+set: function Dict_set(key, value) {this.map[key] = value;},@@ -3287,6 +3292,24 @@ var Dict = (function DictClosure() {Dict.empty = new Dict(null);+ Dict.merge = function Dict_merge(xref, dictArray) {+ var mergedDict = new Dict(xref);++ for (var i = 0, ii = dictArray.length; i < ii; i++) {+ var dict = dictArray[i];+ if (!isDict(dict)) {+ continue;+ }+ for (var keyName in dict.map) {+ if (mergedDict.map[keyName]) {+ continue;+ }+ mergedDict.map[keyName] = dict.map[keyName];+ }+ }+ return mergedDict;+ };+return Dict;})();@@ -3541,7 +3564,7 @@ var Catalog = (function CatalogClosure() {}var xref = this.xref;- var dest, nameTreeRef, nameDictionaryRef;+ var dest = null, nameTreeRef, nameDictionaryRef;var obj = this.catDict.get('Names');if (obj && obj.has('Dests')) {nameTreeRef = obj.getRaw('Dests');@@ -3549,17 +3572,11 @@ var Catalog = (function CatalogClosure() {nameDictionaryRef = this.catDict.get('Dests');}- if (nameDictionaryRef) {- // reading simple destination dictionary- obj = nameDictionaryRef;- obj.forEach(function catalogForEach(key, value) {- if (!value) {- return;- }- if (key === destinationId) {- dest = fetchDestination(value);- }- });+ if (nameDictionaryRef) { // Simple destination dictionary.+ var value = nameDictionaryRef.get(destinationId);+ if (value) {+ dest = fetchDestination(value);+ }}if (nameTreeRef) {var nameTree = new NameTree(nameTreeRef, xref);@@ -3596,6 +3613,19 @@ var Catalog = (function CatalogClosure() {var obj = this.catDict.get('Names');var javaScript = [];+ function appendIfJavaScriptDict(jsDict) {+ var type = jsDict.get('S');+ if (!isName(type) || type.name !== 'JavaScript') {+ return;+ }+ var js = jsDict.get('JS');+ if (isStream(js)) {+ js = bytesToString(js.getBytes());+ } else if (!isString(js)) {+ return;+ }+ javaScript.push(stringToPDFString(js));+ }if (obj && obj.has('JavaScript')) {var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);var names = nameTree.getAll();@@ -3606,36 +3636,25 @@ var Catalog = (function CatalogClosure() {// We don't really use the JavaScript right now. This code is// defensive so we don't cause errors on document load.var jsDict = names[name];- if (!isDict(jsDict)) {- continue;+ if (isDict(jsDict)) {+ appendIfJavaScriptDict(jsDict);}- var type = jsDict.get('S');- if (!isName(type) || type.name !== 'JavaScript') {- continue;- }- var js = jsDict.get('JS');- if (!isString(js) && !isStream(js)) {- continue;- }- if (isStream(js)) {- js = bytesToString(js.getBytes());- }- javaScript.push(stringToPDFString(js));}}// Append OpenAction actions to javaScript arrayvar openactionDict = this.catDict.get('OpenAction');- if (isDict(openactionDict)) {- var objType = openactionDict.get('Type');+ if (isDict(openactionDict, 'Action')) {var actionType = openactionDict.get('S');- var action = openactionDict.get('N');- var isPrintAction = (isName(objType) && objType.name === 'Action' &&- isName(actionType) && actionType.name === 'Named' &&- isName(action) && action.name === 'Print');-- if (isPrintAction) {- javaScript.push('print(true);');+ if (isName(actionType) && actionType.name === 'Named') {+ // The named Print action is not a part of the PDF 1.7 specification,+ // but is supported by many PDF readers/writers (including Adobe's).+ var action = openactionDict.get('N');+ if (isName(action) && action.name === 'Print') {+ javaScript.push('print({});');+ }+ } else {+ appendIfJavaScriptDict(openactionDict);}}@@ -3675,6 +3694,7 @@ var Catalog = (function CatalogClosure() {var nodesToVisit = [this.catDict.getRaw('Pages')];var currentPageIndex = 0;var xref = this.xref;+ var checkAllKids = false;function next() {while (nodesToVisit.length) {@@ -3682,7 +3702,7 @@ var Catalog = (function CatalogClosure() {if (isRef(currentNode)) {xref.fetchAsync(currentNode).then(function (obj) {- if ((isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids')))) {+ if (isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids'))) {if (pageIndex === currentPageIndex) {capability.resolve([obj, currentNode]);} else {@@ -3697,12 +3717,17 @@ var Catalog = (function CatalogClosure() {return;}- // must be a child page dictionary+ // Must be a child page dictionary.assert(isDict(currentNode),'page dictionary kid reference points to wrong type of object');var count = currentNode.get('Count');+ // If the current node doesn't have any children, avoid getting stuck+ // in an empty node further down in the tree (see issue5644.pdf).+ if (count === 0) {+ checkAllKids = true;+ }// Skip nodes where the page can't be.if (currentPageIndex + count <= pageIndex) {currentPageIndex += count;@@ -3711,7 +3736,7 @@ var Catalog = (function CatalogClosure() {var kids = currentNode.get('Kids');assert(isArray(kids), 'page dictionary kids object is not an array');- if (count === kids.length) {+ if (!checkAllKids && count === kids.length) {// Nodes that don't have the page have been skipped and this is the// bottom of the tree which means the page requested must be a// descendant of this pages node. Ideally we would just resolve the@@ -4129,12 +4154,13 @@ var XRef = (function XRefClosure() {trailers.push(position);position += skipUntil(buffer, position, startxrefBytes);} else if ((m = /^(\d+)\s+(\d+)\s+obj\b/.exec(token))) {- this.entries[m[1]] = {- offset: position,- gen: m[2] | 0,- uncompressed: true- };-+ if (typeof this.entries[m[1]] === 'undefined') {+ this.entries[m[1]] = {+ offset: position - stream.start,+ gen: m[2] | 0,+ uncompressed: true+ };+ }var contentLength = skipUntil(buffer, position, endobjBytes) + 7;var content = buffer.subarray(position, position + contentLength);@@ -4143,8 +4169,8 @@ var XRef = (function XRefClosure() {var xrefTagOffset = skipUntil(content, 0, xrefBytes);if (xrefTagOffset < contentLength &&content[xrefTagOffset + 5] < 64) {- xrefStms.push(position);- this.xrefstms[position] = 1; // don't read it recursively+ xrefStms.push(position - stream.start);+ this.xrefstms[position - stream.start] = 1; // Avoid recursion}position += contentLength;@@ -4463,7 +4489,7 @@ var NameTree = (function NameTreeClosure() {var names = obj.get('Names');if (names) {for (i = 0, n = names.length; i < n; i += 2) {- dict[names[i]] = xref.fetchIfRef(names[i + 1]);+ dict[xref.fetchIfRef(names[i])] = xref.fetchIfRef(names[i + 1]);}}}@@ -4502,9 +4528,9 @@ var NameTree = (function NameTreeClosure() {var kid = xref.fetchIfRef(kids[m]);var limits = kid.get('Limits');- if (destinationId < limits[0]) {+ if (destinationId < xref.fetchIfRef(limits[0])) {r = m - 1;- } else if (destinationId > limits[1]) {+ } else if (destinationId > xref.fetchIfRef(limits[1])) {l = m + 1;} else {kidsOrNames = xref.fetchIfRef(kids[m]);@@ -4528,9 +4554,9 @@ var NameTree = (function NameTreeClosure() {// Check only even indices (0, 2, 4, ...) because the// odd indices contain the actual D array.m = (l + r) & ~1;- if (destinationId < names[m]) {+ if (destinationId < xref.fetchIfRef(names[m])) {r = m - 2;- } else if (destinationId > names[m]) {+ } else if (destinationId > xref.fetchIfRef(names[m])) {l = m + 2;} else {return xref.fetchIfRef(names[m + 1]);@@ -4878,7 +4904,54 @@ var ExpertSubsetCharset = [var DEFAULT_ICON_SIZE = 22; // px-var SUPPORTED_TYPES = ['Link', 'Text', 'Widget'];++/**+ * @constructor+ */+function AnnotationFactory() {}+AnnotationFactory.prototype = {+ /**+ * @param {XRef} xref+ * @param {Object} ref+ * @returns {Annotation}+ */+ create: function AnnotationFactory_create(xref, ref) {+ var dict = xref.fetchIfRef(ref);+ if (!isDict(dict)) {+ return;+ }++ // Determine the annotation's subtype.+ var subtype = dict.get('Subtype');+ subtype = isName(subtype) ? subtype.name : '';++ // Return the right annotation object based on the subtype and field type.+ var parameters = {+ dict: dict,+ ref: ref+ };++ switch (subtype) {+ case 'Link':+ return new LinkAnnotation(parameters);++ case 'Text':+ return new TextAnnotation(parameters);++ case 'Widget':+ var fieldType = Util.getInheritableProperty(dict, 'FT');+ if (isName(fieldType) && fieldType.name === 'Tx') {+ return new TextWidgetAnnotation(parameters);+ }+ return new WidgetAnnotation(parameters);++ default:+ warn('Unimplemented annotation type "' + subtype + '", ' ++ 'falling back to base annotation');+ return new Annotation(parameters);+ }+ }+};var Annotation = (function AnnotationClosure() {// 12.5.5: Algorithm: Appearance streams@@ -4931,93 +5004,127 @@ var Annotation = (function AnnotationClosure() {var data = this.data = {};data.subtype = dict.get('Subtype').name;- var rect = dict.get('Rect') || [0, 0, 0, 0];- data.rect = Util.normalizeRect(rect);data.annotationFlags = dict.get('F');- var color = dict.get('C');- if (!color) {- // The PDF spec does not mention how a missing color array is interpreted.- // Adobe Reader seems to default to black in this case.- data.color = [0, 0, 0];- } else if (isArray(color)) {+ this.setRectangle(dict.get('Rect'));+ data.rect = this.rectangle;++ this.setColor(dict.get('C'));+ data.color = this.color;++ this.borderStyle = data.borderStyle = new AnnotationBorderStyle();+ this.setBorderStyle(dict);++ this.appearance = getDefaultAppearance(dict);+ data.hasAppearance = !!this.appearance;+ data.id = params.ref.num;+ }++ Annotation.prototype = {+ /**+ * Set the rectangle.+ *+ * @public+ * @memberof Annotation+ * @param {Array} rectangle - The rectangle array with exactly four entries+ */+ setRectangle: function Annotation_setRectangle(rectangle) {+ if (isArray(rectangle) && rectangle.length === 4) {+ this.rectangle = Util.normalizeRect(rectangle);+ } else {+ this.rectangle = [0, 0, 0, 0];+ }+ },++ /**+ * Set the color and take care of color space conversion.+ *+ * @public+ * @memberof Annotation+ * @param {Array} color - The color array containing either 0+ * (transparent), 1 (grayscale), 3 (RGB) or+ * 4 (CMYK) elements+ */+ setColor: function Annotation_setColor(color) {+ var rgbColor = new Uint8Array(3); // Black in RGB color space (default)+ if (!isArray(color)) {+ this.color = rgbColor;+ return;+ }+switch (color.length) {- case 0:- // Empty array denotes transparent border.- data.color = null;+ case 0: // Transparent, which we indicate with a null value+ this.color = null;break;- case 1:- // TODO: implement DeviceGray++ case 1: // Convert grayscale to RGB+ ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);+ this.color = rgbColor;break;- case 3:- data.color = color;++ case 3: // Convert RGB percentages to RGB+ ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);+ this.color = rgbColor;break;- case 4:- // TODO: implement DeviceCMYK++ case 4: // Convert CMYK to RGB+ ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);+ this.color = rgbColor;break;- }- }- // Some types of annotations have border style dict which has more- // info than the border array- if (dict.has('BS')) {- var borderStyle = dict.get('BS');- data.borderWidth = borderStyle.has('W') ? borderStyle.get('W') : 1;- } else {- var borderArray = dict.get('Border') || [0, 0, 1];- data.borderWidth = borderArray[2] || 0;-- // TODO: implement proper support for annotations with line dash patterns.- var dashArray = borderArray[3];- if (data.borderWidth > 0 && dashArray) {- if (!isArray(dashArray)) {- // Ignore the border if dashArray is not actually an array,- // this is consistent with the behaviour in Adobe Reader.- data.borderWidth = 0;- } else {- var dashArrayLength = dashArray.length;- if (dashArrayLength > 0) {- // According to the PDF specification: the elements in a dashArray- // shall be numbers that are nonnegative and not all equal to zero.- var isInvalid = false;- var numPositive = 0;- for (var i = 0; i < dashArrayLength; i++) {- var validNumber = (+dashArray[i] >= 0);- if (!validNumber) {- isInvalid = true;- break;- } else if (dashArray[i] > 0) {- numPositive++;- }- }- if (isInvalid || numPositive === 0) {- data.borderWidth = 0;- }- }- }+ default:+ this.color = rgbColor;+ break;}- }+ },- this.appearance = getDefaultAppearance(dict);- data.hasAppearance = !!this.appearance;- data.id = params.ref.num;- }+ /**+ * Set the border style (as AnnotationBorderStyle object).+ *+ * @public+ * @memberof Annotation+ * @param {Dict} borderStyle - The border style dictionary+ */+ setBorderStyle: function Annotation_setBorderStyle(borderStyle) {+ if (!isDict(borderStyle)) {+ return;+ }+ if (borderStyle.has('BS')) {+ var dict = borderStyle.get('BS');+ var dictType;- Annotation.prototype = {+ if (!dict.has('Type') || (isName(dictType = dict.get('Type')) &&+ dictType.name === 'Border')) {+ this.borderStyle.setWidth(dict.get('W'));+ this.borderStyle.setStyle(dict.get('S'));+ this.borderStyle.setDashArray(dict.get('D'));+ }+ } else if (borderStyle.has('Border')) {+ var array = borderStyle.get('Border');+ if (isArray(array) && array.length >= 3) {+ this.borderStyle.setHorizontalCornerRadius(array[0]);+ this.borderStyle.setVerticalCornerRadius(array[1]);+ this.borderStyle.setWidth(array[2]);- getData: function Annotation_getData() {- return this.data;+ if (array.length === 4) { // Dash array available+ this.borderStyle.setDashArray(array[3]);+ }+ }+ } else {+ // There are no border entries in the dictionary. According to the+ // specification, we should draw a solid border of width 1 in that+ // case, but Adobe Reader did not implement that part of the+ // specification and instead draws no border at all, so we do the same.+ // See also https://github.com/mozilla/pdf.js/issues/6179.+ this.borderStyle.setWidth(0);+ }},isInvisible: function Annotation_isInvisible() {var data = this.data;- if (data && SUPPORTED_TYPES.indexOf(data.subtype) !== -1) {- return false;- } else {- return !!(data &&- data.annotationFlags && // Default: not invisible- data.annotationFlags & 0x1); // Invisible- }+ return !!(data &&+ data.annotationFlags && // Default: not invisible+ data.annotationFlags & 0x1); // Invisible},isViewable: function Annotation_isViewable() {@@ -5093,70 +5200,6 @@ var Annotation = (function AnnotationClosure() {}};- Annotation.getConstructor =- function Annotation_getConstructor(subtype, fieldType) {-- if (!subtype) {- return;- }-- // TODO(mack): Implement FreeText annotations- if (subtype === 'Link') {- return LinkAnnotation;- } else if (subtype === 'Text') {- return TextAnnotation;- } else if (subtype === 'Widget') {- if (!fieldType) {- return;- }-- if (fieldType === 'Tx') {- return TextWidgetAnnotation;- } else {- return WidgetAnnotation;- }- } else {- return Annotation;- }- };-- Annotation.fromRef = function Annotation_fromRef(xref, ref) {-- var dict = xref.fetchIfRef(ref);- if (!isDict(dict)) {- return;- }-- var subtype = dict.get('Subtype');- subtype = isName(subtype) ? subtype.name : '';- if (!subtype) {- return;- }-- var fieldType = Util.getInheritableProperty(dict, 'FT');- fieldType = isName(fieldType) ? fieldType.name : '';-- var Constructor = Annotation.getConstructor(subtype, fieldType);- if (!Constructor) {- return;- }-- var params = {- dict: dict,- ref: ref,- };-- var annotation = new Constructor(params);-- if (annotation.isViewable() || annotation.isPrintable()) {- return annotation;- } else {- if (SUPPORTED_TYPES.indexOf(subtype) === -1) {- warn('unimplemented annotation type: ' + subtype);- }- }- };-Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, pdfManager, partialEvaluator, intent) {@@ -5190,6 +5233,144 @@ var Annotation = (function AnnotationClosure() {return Annotation;})();+/**+ * Contains all data regarding an annotation's border style.+ *+ * @class+ */+var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {+ /**+ * @constructor+ * @private+ */+ function AnnotationBorderStyle() {+ this.width = 1;+ this.style = AnnotationBorderStyleType.SOLID;+ this.dashArray = [3];+ this.horizontalCornerRadius = 0;+ this.verticalCornerRadius = 0;+ }++ AnnotationBorderStyle.prototype = {+ /**+ * Set the width.+ *+ * @public+ * @memberof AnnotationBorderStyle+ * @param {integer} width - The width+ */+ setWidth: function AnnotationBorderStyle_setWidth(width) {+ if (width === (width | 0)) {+ this.width = width;+ }+ },++ /**+ * Set the style.+ *+ * @public+ * @memberof AnnotationBorderStyle+ * @param {Object} style - The style object+ * @see {@link shared/util.js}+ */+ setStyle: function AnnotationBorderStyle_setStyle(style) {+ if (!style) {+ return;+ }+ switch (style.name) {+ case 'S':+ this.style = AnnotationBorderStyleType.SOLID;+ break;++ case 'D':+ this.style = AnnotationBorderStyleType.DASHED;+ break;++ case 'B':+ this.style = AnnotationBorderStyleType.BEVELED;+ break;++ case 'I':+ this.style = AnnotationBorderStyleType.INSET;+ break;++ case 'U':+ this.style = AnnotationBorderStyleType.UNDERLINE;+ break;++ default:+ break;+ }+ },++ /**+ * Set the dash array.+ *+ * @public+ * @memberof AnnotationBorderStyle+ * @param {Array} dashArray - The dash array with at least one element+ */+ setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {+ // We validate the dash array, but we do not use it because CSS does not+ // allow us to change spacing of dashes. For more information, visit+ // http://www.w3.org/TR/css3-background/#the-border-style.+ if (isArray(dashArray) && dashArray.length > 0) {+ // According to the PDF specification: the elements in a dashArray+ // shall be numbers that are nonnegative and not all equal to zero.+ var isValid = true;+ var allZeros = true;+ for (var i = 0, len = dashArray.length; i < len; i++) {+ var element = dashArray[i];+ var validNumber = (+element >= 0);+ if (!validNumber) {+ isValid = false;+ break;+ } else if (element > 0) {+ allZeros = false;+ }+ }+ if (isValid && !allZeros) {+ this.dashArray = dashArray;+ } else {+ this.width = 0; // Adobe behavior when the array is invalid.+ }+ } else if (dashArray) {+ this.width = 0; // Adobe behavior when the array is invalid.+ }+ },++ /**+ * Set the horizontal corner radius (from a Border dictionary).+ *+ * @public+ * @memberof AnnotationBorderStyle+ * @param {integer} radius - The horizontal corner radius+ */+ setHorizontalCornerRadius:+ function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {+ if (radius === (radius | 0)) {+ this.horizontalCornerRadius = radius;+ }+ },++ /**+ * Set the vertical corner radius (from a Border dictionary).+ *+ * @public+ * @memberof AnnotationBorderStyle+ * @param {integer} radius - The vertical corner radius+ */+ setVerticalCornerRadius:+ function AnnotationBorderStyle_setVerticalCornerRadius(radius) {+ if (radius === (radius | 0)) {+ this.verticalCornerRadius = radius;+ }+ }+ };++ return AnnotationBorderStyle;+})();+var WidgetAnnotation = (function WidgetAnnotationClosure() {function WidgetAnnotation(params) {@@ -5290,21 +5471,9 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {return TextWidgetAnnotation;})();-var InteractiveAnnotation = (function InteractiveAnnotationClosure() {- function InteractiveAnnotation(params) {- Annotation.call(this, params);-- this.data.hasHtml = true;- }-- Util.inherit(InteractiveAnnotation, Annotation, { });-- return InteractiveAnnotation;-})();-var TextAnnotation = (function TextAnnotationClosure() {function TextAnnotation(params) {- InteractiveAnnotation.call(this, params);+ Annotation.call(this, params);var dict = params.dict;var data = this.data;@@ -5314,6 +5483,7 @@ var TextAnnotation = (function TextAnnotationClosure() {data.annotationType = AnnotationType.TEXT;data.content = stringToPDFString(content || '');data.title = stringToPDFString(title || '');+ data.hasHtml = true;if (data.hasAppearance) {data.name = 'NoIcon';@@ -5328,18 +5498,19 @@ var TextAnnotation = (function TextAnnotationClosure() {}}- Util.inherit(TextAnnotation, InteractiveAnnotation, { });+ Util.inherit(TextAnnotation, Annotation, { });return TextAnnotation;})();var LinkAnnotation = (function LinkAnnotationClosure() {function LinkAnnotation(params) {- InteractiveAnnotation.call(this, params);+ Annotation.call(this, params);var dict = params.dict;var data = this.data;data.annotationType = AnnotationType.LINK;+ data.hasHtml = true;var action = dict.get('A');if (action && isDict(action)) {@@ -5357,7 +5528,15 @@ var LinkAnnotation = (function LinkAnnotationClosure() {if (!isValidUrl(url, false)) {url = '';}- data.url = url;+ // According to ISO 32000-1:2008, section 12.6.4.7,+ // URI should to be encoded in 7-bit ASCII.+ // Some bad PDFs may have URIs in UTF-8 encoding, see Bugzilla 1122280.+ try {+ data.url = stringToUTF8String(url);+ } catch (e) {+ // Fall back to a simple copy.+ data.url = url;+ }} else if (linkType === 'GoTo') {data.dest = action.get('D');} else if (linkType === 'GoToR') {@@ -5395,7 +5574,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {return url;}- Util.inherit(LinkAnnotation, InteractiveAnnotation, { });+ Util.inherit(LinkAnnotation, Annotation, { });return LinkAnnotation;})();@@ -5746,7 +5925,10 @@ var PDFFunction = (function PDFFunctionClosure() {var rmin = encode[2 * i];var rmax = encode[2 * i + 1];- tmpBuf[0] = rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);+ // Prevent the value from becoming NaN as a result+ // of division by zero (fixes issue6113.pdf).+ tmpBuf[0] = dmin === dmax ? rmin :+ rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);// call the appropriate functionfns[i](tmpBuf, 0, dest, destOffset);@@ -6755,9 +6937,9 @@ var ColorSpace = (function ColorSpaceClosure() {error('unrecognized colorspace ' + mode);}} else if (isArray(cs)) {- mode = cs[0].name;+ mode = xref.fetchIfRef(cs[0]).name;this.mode = mode;- var numComps, params;+ var numComps, params, alt;switch (mode) {case 'DeviceGray':@@ -6779,6 +6961,17 @@ var ColorSpace = (function ColorSpaceClosure() {var stream = xref.fetchIfRef(cs[1]);var dict = stream.dict;numComps = dict.get('N');+ alt = dict.get('Alternate');+ if (alt) {+ var altIR = ColorSpace.parseToIR(alt, xref, res);+ // Parse the /Alternate CS to ensure that the number of components+ // are correct, and also (indirectly) that it is not a PatternCS.+ var altCS = ColorSpace.fromIR(altIR);+ if (altCS.numComps === numComps) {+ return altIR;+ }+ warn('ICCBased color space: Ignoring incorrect /Alternate entry.');+ }if (numComps === 1) {return 'DeviceGrayCS';} else if (numComps === 3) {@@ -6788,7 +6981,7 @@ var ColorSpace = (function ColorSpaceClosure() {}break;case 'Pattern':- var basePatternCS = cs[1];+ var basePatternCS = cs[1] || null;if (basePatternCS) {basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);}@@ -6796,7 +6989,7 @@ var ColorSpace = (function ColorSpaceClosure() {case 'Indexed':case 'I':var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);- var hiVal = cs[2] + 1;+ var hiVal = xref.fetchIfRef(cs[2]) + 1;var lookup = xref.fetchIfRef(cs[3]);if (isStream(lookup)) {lookup = lookup.getBytes();@@ -6804,18 +6997,18 @@ var ColorSpace = (function ColorSpaceClosure() {return ['IndexedCS', baseIndexedCS, hiVal, lookup];case 'Separation':case 'DeviceN':- var name = cs[1];+ var name = xref.fetchIfRef(cs[1]);numComps = 1;if (isName(name)) {numComps = 1;} else if (isArray(name)) {numComps = name.length;}- var alt = ColorSpace.parseToIR(cs[2], xref, res);+ alt = ColorSpace.parseToIR(cs[2], xref, res);var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));return ['AlternateCS', numComps, alt, tintFnIR];case 'Lab':- params = cs[1].getAll();+ params = xref.fetchIfRef(cs[1]).getAll();return ['LabCS', params];default:error('unimplemented color space object "' + mode + '"');@@ -6835,7 +7028,7 @@ var ColorSpace = (function ColorSpaceClosure() {* @param {Number} n Number of components the color space has.*/ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {- if (!decode) {+ if (!isArray(decode)) {return true;}@@ -9640,6 +9833,14 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {var fileIdBytes = stringToBytes(fileId);var passwordBytes;if (password) {+ if (revision === 6) {+ try {+ password = utf8StringToString(password);+ } catch (ex) {+ warn('CipherTransformFactory: ' ++ 'Unable to convert UTF8 encoded password.');+ }+ }passwordBytes = stringToBytes(password);}@@ -9689,7 +9890,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {this.cf = dict.get('CF');this.stmf = dict.get('StmF') || identityName;this.strf = dict.get('StrF') || identityName;- this.eff = dict.get('EFF') || this.strf;+ this.eff = dict.get('EFF') || this.stmf;}}@@ -9744,7 +9945,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {CipherTransformFactory.prototype = {createCipherTransform:- function CipherTransformFactory_createCipherTransform(num, gen) {+ function CipherTransformFactory_createCipherTransform(num, gen) {if (this.algorithm === 4 || this.algorithm === 5) {return new CipherTransform(buildCipherConstructor(this.cf, this.stmf,@@ -9764,7 +9965,8 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {return CipherTransformFactory;})();-var PatternType = {++var ShadingType = {FUNCTION_BASED: 1,AXIAL: 2,RADIAL: 3,@@ -9796,17 +9998,17 @@ var Pattern = (function PatternClosure() {try {switch (type) {- case PatternType.AXIAL:- case PatternType.RADIAL:+ case ShadingType.AXIAL:+ case ShadingType.RADIAL:// Both radial and axial shadings are handled by RadialAxial shading.return new Shadings.RadialAxial(dict, matrix, xref, res);- case PatternType.FREE_FORM_MESH:- case PatternType.LATTICE_FORM_MESH:- case PatternType.COONS_PATCH_MESH:- case PatternType.TENSOR_PATCH_MESH:+ case ShadingType.FREE_FORM_MESH:+ case ShadingType.LATTICE_FORM_MESH:+ case ShadingType.COONS_PATCH_MESH:+ case ShadingType.TENSOR_PATCH_MESH:return new Shadings.Mesh(shading, matrix, xref, res);default:- throw new Error('Unknown PatternType: ' + type);+ throw new Error('Unsupported ShadingType: ' + type);}} catch (ex) {if (ex instanceof MissingDataException) {@@ -9854,7 +10056,7 @@ Shadings.RadialAxial = (function RadialAxialClosure() {extendEnd = extendArr[1];}- if (this.shadingType === PatternType.RADIAL &&+ if (this.shadingType === ShadingType.RADIAL &&(!extendStart || !extendEnd)) {// Radial gradient only currently works if either circle is fully within// the other circle.@@ -9929,13 +10131,13 @@ Shadings.RadialAxial = (function RadialAxialClosure() {var coordsArr = this.coordsArr;var shadingType = this.shadingType;var type, p0, p1, r0, r1;- if (shadingType === PatternType.AXIAL) {+ if (shadingType === ShadingType.AXIAL) {p0 = [coordsArr[0], coordsArr[1]];p1 = [coordsArr[2], coordsArr[3]];r0 = null;r1 = null;type = 'axial';- } else if (shadingType === PatternType.RADIAL) {+ } else if (shadingType === ShadingType.RADIAL) {p0 = [coordsArr[0], coordsArr[1]];p1 = [coordsArr[3], coordsArr[4]];r0 = coordsArr[2];@@ -9969,7 +10171,7 @@ Shadings.Mesh = (function MeshClosure() {var numComps = context.numComps;this.tmpCompsBuf = new Float32Array(numComps);- var csNumComps = context.colorSpace;+ var csNumComps = context.colorSpace.numComps;this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) :this.tmpCompsBuf;}@@ -10089,13 +10291,10 @@ Shadings.Mesh = (function MeshClosure() {reader.align();}-- var psPacked = new Int32Array(ps);-mesh.figures.push({type: 'triangles',- coords: psPacked,- colors: psPacked+ coords: new Int32Array(ps),+ colors: new Int32Array(ps),});}@@ -10110,13 +10309,10 @@ Shadings.Mesh = (function MeshClosure() {coords.push(coord);colors.push(color);}-- var psPacked = new Int32Array(ps);-mesh.figures.push({type: 'lattice',- coords: psPacked,- colors: psPacked,+ coords: new Int32Array(ps),+ colors: new Int32Array(ps),verticesPerRow: verticesPerRow});}@@ -10258,29 +10454,32 @@ Shadings.Mesh = (function MeshClosure() {break;case 1:tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];- ps[12] = pi + 5; ps[13] = pi + 4; ps[14] = pi + 3; ps[15] = pi + 2;- ps[ 8] = pi + 6; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 1;- ps[ 4] = pi + 7; /* calculated below */ ps[ 7] = pi;- ps[ 0] = tmp1; ps[ 1] = tmp2; ps[ 2] = tmp3; ps[ 3] = tmp4;+ ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;+ ps[ 8] = tmp3; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;+ ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;+ ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;tmp1 = cs[2]; tmp2 = cs[3];- cs[2] = ci + 1; cs[3] = ci;- cs[0] = tmp1; cs[1] = tmp2;+ cs[2] = tmp2; cs[3] = ci;+ cs[0] = tmp1; cs[1] = ci + 1;break;case 2:- ps[12] = ps[15]; ps[13] = pi + 7; ps[14] = pi + 6; ps[15] = pi + 5;- ps[ 8] = ps[11]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 4;- ps[ 4] = ps[7]; /* calculated below */ ps[ 7] = pi + 3;- ps[ 0] = ps[3]; ps[ 1] = pi; ps[ 2] = pi + 1; ps[ 3] = pi + 2;- cs[2] = cs[3]; cs[3] = ci + 1;- cs[0] = cs[1]; cs[1] = ci;+ tmp1 = ps[15];+ tmp2 = ps[11];+ ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;+ ps[ 8] = ps[7]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;+ ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;+ ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;+ tmp1 = cs[3];+ cs[2] = cs[1]; cs[3] = ci;+ cs[0] = tmp1; cs[1] = ci + 1;break;case 3:- ps[12] = ps[0]; ps[13] = ps[1]; ps[14] = ps[2]; ps[15] = ps[3];- ps[ 8] = pi; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 7;- ps[ 4] = pi + 1; /* calculated below */ ps[ 7] = pi + 6;- ps[ 0] = pi + 2; ps[ 1] = pi + 3; ps[ 2] = pi + 4; ps[ 3] = pi + 5;- cs[2] = cs[0]; cs[3] = cs[1];- cs[0] = ci; cs[1] = ci + 1;+ ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;+ ps[ 8] = ps[1]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;+ ps[ 4] = ps[2]; /* calculated below */ ps[ 7] = pi + 4;+ ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;+ cs[2] = cs[0]; cs[3] = ci;+ cs[0] = cs[1]; cs[1] = ci + 1;break;}// set p11, p12, p21, p22@@ -10365,29 +10564,32 @@ Shadings.Mesh = (function MeshClosure() {break;case 1:tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];- ps[12] = pi + 5; ps[13] = pi + 4; ps[14] = pi + 3; ps[15] = pi + 2;- ps[ 8] = pi + 6; ps[ 9] = pi + 11; ps[10] = pi + 10; ps[11] = pi + 1;- ps[ 4] = pi + 7; ps[ 5] = pi + 8; ps[ 6] = pi + 9; ps[ 7] = pi;- ps[ 0] = tmp1; ps[ 1] = tmp2; ps[ 2] = tmp3; ps[ 3] = tmp4;+ ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;+ ps[ 8] = tmp3; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;+ ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;+ ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;tmp1 = cs[2]; tmp2 = cs[3];- cs[2] = ci + 1; cs[3] = ci;- cs[0] = tmp1; cs[1] = tmp2;+ cs[2] = tmp2; cs[3] = ci;+ cs[0] = tmp1; cs[1] = ci + 1;break;case 2:- ps[12] = ps[15]; ps[13] = pi + 7; ps[14] = pi + 6; ps[15] = pi + 5;- ps[ 8] = ps[11]; ps[ 9] = pi + 8; ps[10] = pi + 11; ps[11] = pi + 4;- ps[ 4] = ps[7]; ps[ 5] = pi + 9; ps[ 6] = pi + 10; ps[ 7] = pi + 3;- ps[ 0] = ps[3]; ps[ 1] = pi; ps[ 2] = pi + 1; ps[ 3] = pi + 2;- cs[2] = cs[3]; cs[3] = ci + 1;- cs[0] = cs[1]; cs[1] = ci;+ tmp1 = ps[15];+ tmp2 = ps[11];+ ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;+ ps[ 8] = ps[7]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;+ ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;+ ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;+ tmp1 = cs[3];+ cs[2] = cs[1]; cs[3] = ci;+ cs[0] = tmp1; cs[1] = ci + 1;break;case 3:- ps[12] = ps[0]; ps[13] = ps[1]; ps[14] = ps[2]; ps[15] = ps[3];- ps[ 8] = pi; ps[ 9] = pi + 9; ps[10] = pi + 8; ps[11] = pi + 7;- ps[ 4] = pi + 1; ps[ 5] = pi + 10; ps[ 6] = pi + 11; ps[ 7] = pi + 6;- ps[ 0] = pi + 2; ps[ 1] = pi + 3; ps[ 2] = pi + 4; ps[ 3] = pi + 5;- cs[2] = cs[0]; cs[3] = cs[1];- cs[0] = ci; cs[1] = ci + 1;+ ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;+ ps[ 8] = ps[1]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;+ ps[ 4] = ps[2]; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;+ ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;+ cs[2] = cs[0]; cs[3] = ci;+ cs[0] = cs[1]; cs[1] = ci + 1;break;}mesh.figures.push({@@ -10476,19 +10678,19 @@ Shadings.Mesh = (function MeshClosure() {var patchMesh = false;switch (this.shadingType) {- case PatternType.FREE_FORM_MESH:+ case ShadingType.FREE_FORM_MESH:decodeType4Shading(this, reader);break;- case PatternType.LATTICE_FORM_MESH:+ case ShadingType.LATTICE_FORM_MESH:var verticesPerRow = dict.get('VerticesPerRow') | 0;assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');decodeType5Shading(this, reader, verticesPerRow);break;- case PatternType.COONS_PATCH_MESH:+ case ShadingType.COONS_PATCH_MESH:decodeType6Shading(this, reader);patchMesh = true;break;- case PatternType.TENSOR_PATCH_MESH:+ case ShadingType.TENSOR_PATCH_MESH:decodeType7Shading(this, reader);patchMesh = true;break;@@ -11179,6 +11381,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {}// eagerly compile XForm objectsvar name = args[0].name;+ if (!name) {+ warn('XObject must be referred to by name.');+ continue;+ }if (imageCache[name] !== undefined) {operatorList.addOp(imageCache[name].fn, imageCache[name].args);args = null;@@ -11477,6 +11683,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {var tsm = [textState.fontSize * textState.textHScale, 0,0, textState.fontSize,0, textState.textRise];++ if (font.isType3Font &&+ textState.fontMatrix !== FONT_IDENTITY_MATRIX &&+ textState.fontSize === 1) {+ var glyphHeight = font.bbox[3] - font.bbox[1];+ if (glyphHeight > 0) {+ glyphHeight = glyphHeight * textState.fontMatrix[3];+ tsm[3] *= glyphHeight;+ }+ }+var trm = textChunk.transform = Util.transform(textState.ctm,Util.transform(textState.textMatrix, tsm));if (!font.vertical) {@@ -11530,16 +11747,23 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {// var x = pt[0];// var y = pt[1];+ var charSpacing = 0;+ if (textChunk.str.length > 0) {+ // Apply char spacing only when there are chars.+ // As a result there is only spacing between glyphs.+ charSpacing = textState.charSpacing;+ }+var tx = 0;var ty = 0;if (!font.vertical) {var w0 = glyphWidth * textState.fontMatrix[0];- tx = (w0 * textState.fontSize + textState.charSpacing) *+ tx = (w0 * textState.fontSize + charSpacing) *textState.textHScale;width += tx;} else {var w1 = glyphWidth * textState.fontMatrix[0];- ty = w1 * textState.fontSize + textState.charSpacing;+ ty = w1 * textState.fontSize + charSpacing;height += ty;}textState.translateTextMatrix(tx, ty);@@ -11805,8 +12029,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {var data = diffEncoding[j];if (isNum(data)) {index = data;- } else {+ } else if (isName(data)) {differences[index++] = data.name;+ } else if (isRef(data)) {+ diffEncoding[j--] = xref.fetch(data);+ continue;+ } else {+ error('Invalid entry in \'Differences\' array: ' + data);}}}@@ -11853,11 +12082,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {var cmap, cmapObj = toUnicode;if (isName(cmapObj)) {cmap = CMapFactory.create(cmapObj,- { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).getMap();- return new ToUnicodeMap(cmap);+ { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);+ if (cmap instanceof IdentityCMap) {+ return new IdentityToUnicodeMap(0, 0xFFFF);+ }+ return new ToUnicodeMap(cmap.getMap());} else if (isStream(cmapObj)) {cmap = CMapFactory.create(cmapObj,- { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).getMap();+ { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);+ if (cmap instanceof IdentityCMap) {+ return new IdentityToUnicodeMap(0, 0xFFFF);+ }+ cmap = cmap.getMap();// Convert UTF-16BE// NOTE: cmap can be a sparse array, so use forEach instead of for(;;)// to iterate over all keys.@@ -12085,6 +12321,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {hash.update(encoding.name);} else if (isRef(encoding)) {hash.update(encoding.num + '_' + encoding.gen);+ } else if (isDict(encoding)) {+ var keys = encoding.getKeys();+ for (var i = 0, ii = keys.length; i < ii; i++) {+ var entry = encoding.getRaw(keys[i]);+ if (isName(entry)) {+ hash.update(entry.name);+ } else if (isRef(entry)) {+ hash.update(entry.num + '_' + entry.gen);+ } else if (isArray(entry)) { // 'Differences' entry.+ // Ideally we should check the contents of the array, but to avoid+ // parsing it here and then again in |extractDataStructures|,+ // we only use the array length for now (fixes bug1157493.pdf).+ hash.update(entry.length.toString());+ }+ }}var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');@@ -12133,6 +12384,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {// is a tagged pdf. Create a barbebones one to get by.descriptor = new Dict(null);descriptor.set('FontName', Name.get(type));+ descriptor.set('FontBBox', dict.get('FontBBox'));} else {// Before PDF 1.5 if the font was one of the base 14 fonts, having a// FontDescriptor was not required.@@ -13352,6 +13604,7 @@ var CMap = (function CMapClosure() {// - bf chars are variable-length byte sequences, stored as strings, with// one byte per character.this._map = [];+ this.name = '';this.vertical = false;this.useCMap = null;this.builtInCMap = builtInCMap;@@ -13451,13 +13704,28 @@ var CMap = (function CMapClosure() {}out.charcode = 0;out.length = 1;+ },++ get isIdentityCMap() {+ if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {+ return false;+ }+ if (this._map.length !== 0x10000) {+ return false;+ }+ for (var i = 0; i < 0x10000; i++) {+ if (this._map[i] !== i) {+ return false;+ }+ }+ return true;}};return CMap;})();// A special case of CMap, where the _map array implicitly has a length of-// 65535 and each element is equal to its index.+// 65536 and each element is equal to its index.var IdentityCMap = (function IdentityCMapClosure() {function IdentityCMap(vertical, n) {CMap.call(this);@@ -13512,7 +13780,11 @@ var IdentityCMap = (function IdentityCMapClosure() {return map;},- readCharCode: CMap.prototype.readCharCode+ readCharCode: CMap.prototype.readCharCode,++ get isIdentityCMap() {+ error('should not access .isIdentityCMap');+ }};return IdentityCMap;@@ -13977,6 +14249,13 @@ var CMapFactory = (function CMapFactoryClosure() {}}+ function parseCMapName(cMap, lexer) {+ var obj = lexer.getObj();+ if (isName(obj) && isString(obj.name)) {+ cMap.name = obj.name;+ }+ }+function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {var previous;var embededUseCMap;@@ -13987,6 +14266,8 @@ var CMapFactory = (function CMapFactoryClosure() {} else if (isName(obj)) {if (obj.name === 'WMode') {parseWMode(cMap, lexer);+ } else if (obj.name === 'CMapName') {+ parseCMapName(cMap, lexer);}previous = obj;} else if (isCmd(obj)) {@@ -14096,6 +14377,9 @@ var CMapFactory = (function CMapFactoryClosure() {} catch (e) {warn('Invalid CMap data. ' + e);}+ if (cMap.isIdentityCMap) {+ return createBuiltInCMap(cMap.name, builtInCMapParams);+ }return cMap;}error('Encoding required.');@@ -14590,6 +14874,13 @@ var GlyphMapForStandardFonts = {'3316': 578, '3379': 42785, '3393': 1159, '3416': 8377};+// The glyph map for ArialBlack differs slightly from the glyph map used for+// other well-known standard fonts. Hence we use this (incomplete) CID to GID+// mapping to adjust the glyph map for non-embedded ArialBlack fonts.+var SupplementalGlyphMapForArialBlack = {+ '227': 322, '264': 261, '291': 346,+};+// Some characters, e.g. copyrightserif, are mapped to the private use area and// might not be displayed using standard fonts. Mapping/hacking well-known chars// to the similar equivalents in the normal characters range.@@ -16309,7 +16600,7 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {IdentityToUnicodeMap.prototype = {get length() {- error('should not access .length');+ return (this.lastChar + 1) - this.firstChar;},forEach: function (callback) {@@ -16478,6 +16769,32 @@ var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() {return OpenTypeFileBuilder;})();+// Problematic Unicode characters in the fonts that needs to be moved to avoid+// issues when they are painted on the canvas, e.g. complex-script shaping or+// control/whitespace characters. The ranges are listed in pairs: the first item+// is a code of the first problematic code, the second one is the next+// non-problematic code. The ranges must be in sorted order.+var ProblematicCharRanges = new Int32Array([+ // Control characters.+ 0x0000, 0x0020,+ 0x007F, 0x00A1,+ 0x00AD, 0x00AE,+ // Chars that is used in complex-script shaping.+ 0x0600, 0x0780,+ 0x08A0, 0x10A0,+ 0x1780, 0x1800,+ // General punctuation chars.+ 0x2000, 0x2010,+ 0x2011, 0x2012,+ 0x2028, 0x2030,+ 0x205F, 0x2070,+ 0x25CC, 0x25CD,+ // Chars that is used in complex-script shaping.+ 0xAA60, 0xAA80,+ // Specials Unicode block.+ 0xFFF0, 0x10000+]);+/*** 'Font' is the class the outside world should use, it encapsulate all the font* decoding logics whatever type it is (assuming the font type is supported).@@ -16520,6 +16837,7 @@ var Font = (function FontClosure() {this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;this.fontMatrix = properties.fontMatrix;+ this.bbox = properties.bbox;this.toUnicode = properties.toUnicode = this.buildToUnicode(properties);@@ -16571,8 +16889,13 @@ var Font = (function FontClosure() {// Standard fonts might be embedded as CID font without glyph mapping.// Building one based on GlyphMapForStandardFonts.var map = [];- for (var code in GlyphMapForStandardFonts) {- map[+code] = GlyphMapForStandardFonts[code];+ for (charCode in GlyphMapForStandardFonts) {+ map[+charCode] = GlyphMapForStandardFonts[charCode];+ }+ if (/ArialBlack/i.test(name)) {+ for (charCode in SupplementalGlyphMapForArialBlack) {+ map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];+ }}var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;if (!isIdentityUnicode) {@@ -16657,6 +16980,10 @@ var Font = (function FontClosure() {if (subtype === 'OpenType') {type = 'OpenType';}+ // Some CIDFontType0C fonts by mistake claim CIDFontType0.+ if (type === 'CIDFontType0') {+ subtype = isType1File(file) ? 'CIDFontType0' : 'CIDFontType0C';+ }var data;switch (type) {@@ -16737,6 +17064,39 @@ var Font = (function FontClosure() {return readUint32(header, 0) === 0x00010000;}+ function isType1File(file) {+ var header = file.peekBytes(2);+ // All Type1 font programs must begin with the comment '%!' (0x25 + 0x21).+ if (header[0] === 0x25 && header[1] === 0x21) {+ return true;+ }+ // ... obviously some fonts violate that part of the specification,+ // please refer to the comment in |Type1Font| below.+ if (header[0] === 0x80 && header[1] === 0x01) { // pfb file header.+ return true;+ }+ return false;+ }++ /**+ * Helper function for |adjustMapping|.+ * @return {boolean}+ */+ function isProblematicUnicodeLocation(code) {+ // Using binary search to find a range start.+ var i = 0, j = ProblematicCharRanges.length - 1;+ while (i < j) {+ var c = (i + j + 1) >> 1;+ if (code < ProblematicCharRanges[c]) {+ j = c - 1;+ } else {+ i = c;+ }+ }+ // Even index means code in problematic range.+ return !(i & 1);+ }+/*** Rebuilds the char code to glyph ID map by trying to replace the char codes* with their unicode value. It also moves char codes that are in known@@ -16776,13 +17136,7 @@ var Font = (function FontClosure() {// characters probably aren't in the correct position (fixes an issue// with firefox and thuluthfont).if ((usedFontCharCodes[fontCharCode] !== undefined ||- fontCharCode <= 0x1f || // Control chars- fontCharCode === 0x7F || // Control char- fontCharCode === 0xAD || // Soft hyphen- fontCharCode === 0xA0 || // Non breaking space- (fontCharCode >= 0x80 && fontCharCode <= 0x9F) || // Control chars- // Prevent drawing characters in the specials unicode block.- (fontCharCode >= 0xFFF0 && fontCharCode <= 0xFFFF) ||+ isProblematicUnicodeLocation(fontCharCode) ||(isSymbolic && isIdentityUnicode)) &&nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left.// Loop to try and find a free spot in the private use area.@@ -17287,7 +17641,10 @@ var Font = (function FontClosure() {}}- if (!potentialTable) {+ if (potentialTable) {+ font.pos = start + potentialTable.offset;+ }+ if (!potentialTable || font.peekByte() === -1) {warn('Could not find a preferred cmap table.');return {platformId: -1,@@ -17297,7 +17654,6 @@ var Font = (function FontClosure() {};}- font.pos = start + potentialTable.offset;var format = font.getUint16();var length = font.getUint16();var language = font.getUint16();@@ -17732,6 +18088,9 @@ var Font = (function FontClosure() {default:warn('Unknown/unsupported post table version ' + version);valid = false;+ if (properties.defaultEncoding) {+ glyphNames = properties.defaultEncoding;+ }break;}properties.glyphNames = glyphNames;@@ -18060,7 +18419,7 @@ var Font = (function FontClosure() {var isTrueType = !tables['CFF '];if (!isTrueType) {// OpenType font- if (header.version === 'OTTO' ||+ if ((header.version === 'OTTO' && properties.type !== 'CIDFontType2') ||!tables.head || !tables.hhea || !tables.maxp || !tables.post) {// no major tables: throwing everything at CFFFontcffFile = new Stream(tables['CFF '].data);@@ -18158,13 +18517,22 @@ var Font = (function FontClosure() {}}- var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode;+ var charCodeToGlyphId = [], charCode;+ var toUnicode = properties.toUnicode, widths = properties.widths;+ var skipToUnicode = (toUnicode instanceof IdentityToUnicodeMap ||+ toUnicode.length === 0x10000);- function hasGlyph(glyphId, charCode) {+ // Helper function to try to skip mapping of empty glyphs.+ // Note: In some cases, just relying on the glyph data doesn't work,+ // hence we also use a few heuristics to fix various PDF files.+ function hasGlyph(glyphId, charCode, widthCode) {if (!missingGlyphs[glyphId]) {return true;}- if (charCode >= 0 && toUnicode.has(charCode)) {+ if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {+ return true;+ }+ if (widths && widthCode >= 0 && isNum(widths[widthCode])) {return true;}return false;@@ -18184,7 +18552,7 @@ var Font = (function FontClosure() {}if (glyphId >= 0 && glyphId < numGlyphs &&- hasGlyph(glyphId, charCode)) {+ hasGlyph(glyphId, charCode, cid)) {charCodeToGlyphId[charCode] = glyphId;}});@@ -18245,18 +18613,19 @@ var Font = (function FontClosure() {var found = false;for (i = 0; i < cmapMappingsLength; ++i) {if (cmapMappings[i].charCode === unicodeOrCharCode &&- hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) {+ hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode, -1)) {charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;found = true;break;}}if (!found && properties.glyphNames) {- // Try to map using the post table. There are currently no known- // pdfs that this fixes.+ // Try to map using the post table.var glyphId = properties.glyphNames.indexOf(glyphName);- if (glyphId > 0 && hasGlyph(glyphId, -1)) {+ if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {charCodeToGlyphId[charCode] = glyphId;+ } else {+ charCodeToGlyphId[charCode] = 0; // notdef}}}@@ -30067,6 +30436,16 @@ var Parser = (function ParserClosure() {this.buf2 = this.lexer.getObj();}},+ tryShift: function Parser_tryShift() {+ try {+ this.shift();+ return true;+ } catch (e) {+ // Upon failure, the caller should reset this.lexer.pos to a known good+ // state and call this.shift() twice to reset the buffers.+ return false;+ }+ },getObj: function Parser_getObj(cipherTransform) {var buf1 = this.buf1;this.shift();@@ -30440,9 +30819,10 @@ var Parser = (function ParserClosure() {stream.pos = pos + length;lexer.nextChar();- this.shift(); // '>>'- this.shift(); // 'stream'- if (!isCmd(this.buf1, 'endstream')) {+ // Shift '>>' and check whether the new object marks the end of the stream+ if (this.tryShift() && isCmd(this.buf2, 'endstream')) {+ this.shift(); // 'stream'+ } else {// bad stream length, scanning for endstreamstream.pos = pos;var SCAN_BLOCK_SIZE = 2048;@@ -30674,6 +31054,11 @@ var Lexer = (function LexerClosure() {if (ch === 0x2D) { // '-'sign = -1;ch = this.nextChar();++ if (ch === 0x2D) { // '-'+ // Ignore double negative (this is consistent with Adobe Reader).+ ch = this.nextChar();+ }} else if (ch === 0x2B) { // '+'ch = this.nextChar();}@@ -30852,9 +31237,8 @@ var Lexer = (function LexerClosure() {strBuf.push(String.fromCharCode(ch));}}- if (strBuf.length > 128) {- error('Warning: name token is longer than allowed by the spec: ' +- strBuf.length);+ if (strBuf.length > 127) {+ warn('name token is longer than allowed by the spec: ' + strBuf.length);}return Name.get(strBuf.join(''));},@@ -31539,25 +31923,25 @@ var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {})();var FlateStream = (function FlateStreamClosure() {- var codeLenCodeMap = new Uint32Array([+ var codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);- var lengthDecode = new Uint32Array([+ var lengthDecode = new Int32Array([0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a,0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f,0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073,0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102]);- var distDecode = new Uint32Array([+ var distDecode = new Int32Array([0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d,0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1,0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01,0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001]);- var fixedLitCodeTab = [new Uint32Array([+ var fixedLitCodeTab = [new Int32Array([0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0,0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0,0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0,@@ -31624,7 +32008,7 @@ var FlateStream = (function FlateStreamClosure() {0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff]), 9];- var fixedDistCodeTab = [new Uint32Array([+ var fixedDistCodeTab = [new Int32Array([0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c,0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000,0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d,@@ -31721,7 +32105,7 @@ var FlateStream = (function FlateStreamClosure() {// build the tablevar size = 1 << maxLen;- var codes = new Uint32Array(size);+ var codes = new Int32Array(size);for (var len = 1, code = 0, skip = 2;len <= maxLen;++len, code <<= 1, skip <<= 1) {@@ -32189,7 +32573,8 @@ var JpegStream = (function JpegStreamClosure() {JpegStream.prototype.isNativelySupported =function JpegStream_isNativelySupported(xref, res) {var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);- return cs.name === 'DeviceGray' || cs.name === 'DeviceRGB';+ return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') &&+ cs.isDefaultDecode(this.dict.get('Decode', 'D'));};/*** Checks if the image can be decoded by the browser.@@ -32197,8 +32582,8 @@ var JpegStream = (function JpegStreamClosure() {JpegStream.prototype.isNativelyDecodable =function JpegStream_isNativelyDecodable(xref, res) {var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);- var numComps = cs.numComps;- return numComps === 1 || numComps === 3;+ return (cs.numComps === 1 || cs.numComps === 3) &&+ cs.isDefaultDecode(this.dict.get('Decode', 'D'));};return JpegStream;@@ -33798,20 +34183,6 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {var length = fullRequestXhr.getResponseHeader('Content-Length');length = parseInt(length, 10);- if (fullRequestXhr.status === 206) {- // Since Chrome 39, there exists a bug where cached responses are- // served with status code 206 for non-range requests.- // Content-Length does not specify the total size of the resource- // when the status code is 206 (see RFC 2616, section 14.16).- // In this case, extract the file size from the Content-Range- // header, which is defined to be "bytes start-end/length" for- // byte range requests.- // See https://github.com/mozilla/pdf.js/issues/5512 and- // https://code.google.com/p/chromium/issues/detail?id=442318- length = fullRequestXhr.getResponseHeader('Content-Range');- length = length && /bytes \d+-\d+\/(\d+)/.exec(length);- length = length && parseInt(length[1], 10);- }if (!isInt(length)) {return;}@@ -39051,30 +39422,6 @@ var bidi = PDFJS.bidi = (function bidiClosure() {return bidi;})();-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */-/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */--/* Copyright 2014 Opera Software ASA- *- * 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.- *- *- * Based on https://code.google.com/p/smhasher/wiki/MurmurHash3.- * Hashes roughly 100 KB per millisecond on i7 3.4 GHz.- */-/* globals Uint32ArrayView */--'use strict';var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {// Workaround for missing math precison in JS.diff --git a/data/libs/pdfjs/web/compatibility.js b/data/libs/pdfjs/web/compatibility.jsindex 00429dded..06f54bff0 100644--- a/data/libs/pdfjs/web/compatibility.js+++ b/data/libs/pdfjs/web/compatibility.js@@ -469,7 +469,10 @@ if (typeof PDFJS === 'undefined') {var regex = /Android\s[0-2][^\d]/;var isOldAndroid = regex.test(navigator.userAgent);- if (isSafari || isOldAndroid) {+ // Range requests are broken in Chrome 39 and 40, https://crbug.com/442318+ var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent);++ if (isSafari || isOldAndroid || isChromeWithRangeBug) {PDFJS.disableRange = true;PDFJS.disableStream = true;}diff --git a/data/libs/pdfjs/web/locale/ach/viewer.properties b/data/libs/pdfjs/web/locale/ach/viewer.propertiesindex 04cb71ae8..89b8180ba 100644--- a/data/libs/pdfjs/web/locale/ach/viewer.properties+++ b/data/libs/pdfjs/web/locale/ach/viewer.properties@@ -149,7 +149,7 @@ loading_error_indicator=Balloading_error=Bal otime kun cano PDF.invalid_file_error=Pwail me PDF ma pe atir onyo obale woko.missing_file_error=Pwail me PDF tye ka rem.-unexpected_response_error=Lagam mape kigeno pa lapok tic+unexpected_response_error=Lagam mape kigeno pa lapok tic.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined indiff --git a/data/libs/pdfjs/web/locale/ast/viewer.properties b/data/libs/pdfjs/web/locale/ast/viewer.propertiesindex daa5cbf0c..2346c54ba 100644--- a/data/libs/pdfjs/web/locale/ast/viewer.properties+++ b/data/libs/pdfjs/web/locale/ast/viewer.properties@@ -108,3 +108,4 @@ document_properties.title = Propiedaes del documentu…attachments_label = Axuntosattachments.title = Amosar axuntosunexpected_response_error = Rempuesta inesperada del sirvidor.+page_scale_percent = {{scale}}%diff --git a/data/libs/pdfjs/web/locale/bg/viewer.properties b/data/libs/pdfjs/web/locale/bg/viewer.propertiesindex 7b3cd53b0..80059f562 100644--- a/data/libs/pdfjs/web/locale/bg/viewer.properties+++ b/data/libs/pdfjs/web/locale/bg/viewer.properties@@ -57,18 +57,18 @@ page_rotate_ccw.title=Превъртане обратно на часовникpage_rotate_ccw.label=Превъртане обратно на часовниковата стрелкаpage_rotate_ccw_label=Превъртане обратно на часовниковата стрелка-hand_tool_enable.title=Активиране на инструмента ръка-hand_tool_enable_label=Активиране на инструмента ръка-hand_tool_disable.title=Деактивиране на инструмента ръка-hand_tool_disable_label=Деактивиране на инструмента ръка+hand_tool_enable.title=Включване на инструмента ръка+hand_tool_enable_label=Включване на инструмента ръка+hand_tool_disable.title=Изключване на инструмента ръка+hand_tool_disable_label=Изключване на инструмента ръка# Document properties dialog boxdocument_properties.title=Свойства на документа…document_properties_label=Свойства на документа…document_properties_file_name=Име на файл:document_properties_file_size=Големина на файл:-document_properties_kb={{size_kb}} KiB ({{size_b}} bytes)-document_properties_mb={{size_mb}} MiB ({{size_b}} bytes)+document_properties_kb={{size_kb}} КБ ({{size_b}} байта)+document_properties_mb={{size_mb}} МБ ({{size_b}} байта)document_properties_title=Заглавие:document_properties_author=Автор:document_properties_subject=Тема:@@ -112,8 +112,8 @@ find_next.title=Намиране на следващото споменаванfind_next_label=Следващаfind_highlight=Маркирай всичкиfind_match_case_label=Точно съвпадения-find_reached_top=Достигнато е началото на документа. Търсенето ще продължи до края му.-find_reached_bottom=Достигнат е края на документа. Търсенето ще продължи от началото му.+find_reached_top=Достигнато е началото на документа, продължаване от края+find_reached_bottom=Достигнат е краят на документа, продължаване от началотоfind_not_found=Фразата не е намерена# Error panel labels@@ -142,12 +142,14 @@ page_scale_auto=Автоматично мащабиранеpage_scale_actual=Действителен размер# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=Грешкаloading_error=Получи се грешка при зареждане на PDF-а.invalid_file_error=Невалиден или повреден PDF файлmissing_file_error=Липсващ PDF файл.+unexpected_response_error=Неочакван отговор от сървъра.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined in@@ -162,4 +164,4 @@ password_cancel=Отказprinting_not_supported=Внимание: Този браузър няма пълна поддръжка на отпечатване.printing_not_ready=Внимание: Този PDF файл не е напълно зареден за печат.web_fonts_disabled=Уеб-шрифтовете са забранени: разрешаване на използването на вградените PDF шрифтове.-document_colors_disabled=На PDF-документите не е разрешено да използват собствени цветове: „Разрешаване на страниците да избират собствени цветове“ е деактивирано в браузъра.+document_colors_disabled=На PDF-документите не е разрешено да използват собствени цветове: „Разрешаване на страниците да избират собствени цветове“ е изключено в браузъра.diff --git a/data/libs/pdfjs/web/locale/bn-BD/viewer.properties b/data/libs/pdfjs/web/locale/bn-BD/viewer.propertiesindex 6577a3660..ab9daf21f 100644--- a/data/libs/pdfjs/web/locale/bn-BD/viewer.properties+++ b/data/libs/pdfjs/web/locale/bn-BD/viewer.properties@@ -57,6 +57,9 @@ page_rotate_ccw.title=ঘড়ির কাঁটার বিপরীতেpage_rotate_ccw.label=ঘড়ির কাঁটার বিপরীতে ঘোরাওpage_rotate_ccw_label=ঘড়ির কাঁটার বিপরীতে ঘোরাও+hand_tool_enable.title=হ্যান্ড টুল সক্রিয় করুন+hand_tool_enable_label=হ্যান্ড টুল সক্রিয় করুন+hand_tool_disable.title=হ্যান্ড টুল নিস্ক্রিয় করুন# Document properties dialog boxdocument_properties_title=শিরোনাম:@@ -116,6 +119,8 @@ page_scale_width=পৃষ্ঠার প্রস্থpage_scale_fit=পৃষ্ঠা ফিট করুনpage_scale_auto=স্বয়ংক্রিয় জুমpage_scale_actual=প্রকৃত আকার+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.# Loading indicator messagesloading_error_indicator=ত্রুটিdiff --git a/data/libs/pdfjs/web/locale/bs/viewer.properties b/data/libs/pdfjs/web/locale/bs/viewer.propertiesindex a89bf7afd..c0f5cda6c 100644--- a/data/libs/pdfjs/web/locale/bs/viewer.properties+++ b/data/libs/pdfjs/web/locale/bs/viewer.properties@@ -30,17 +30,58 @@ zoom_out_label=Umanjizoom_in.title=Uvećajzoom_in_label=Uvećajzoom.title=Uvećanje-print.title=Štampaj-print_label=Štampajpresentation_mode.title=Prebaci se u prezentacijski režimpresentation_mode_label=Prezentacijski režimopen_file.title=Otvori fajlopen_file_label=Otvori+print.title=Štampaj+print_label=Štampajdownload.title=Preuzmidownload_label=Preuzmibookmark.title=Trenutni prikaz (kopiraj ili otvori u novom prozoru)bookmark_label=Trenutni prikaz+# Secondary toolbar and context menu+tools.title=Alati+tools_label=Alati+first_page.title=Idi na prvu stranu+first_page.label=Idi na prvu stranu+first_page_label=Idi na prvu stranu+last_page.title=Idi na zadnju stranu+last_page.label=Idi na zadnju stranu+last_page_label=Idi na zadnju stranu+page_rotate_cw.title=Rotiraj u smjeru kazaljke na satu+page_rotate_cw.label=Rotiraj u smjeru kazaljke na satu+page_rotate_cw_label=Rotiraj u smjeru kazaljke na satu+page_rotate_ccw.title=Rotiraj suprotno smjeru kazaljke na satu+page_rotate_ccw.label=Rotiraj suprotno smjeru kazaljke na satu+page_rotate_ccw_label=Rotiraj suprotno smjeru kazaljke na satu++hand_tool_enable.title=Omogući ručni alat+hand_tool_enable_label=Omogući ručni alat+hand_tool_disable.title=Onemogući ručni alat+hand_tool_disable_label=Onemogući ručni alat++# Document properties dialog box+document_properties.title=Svojstva dokumenta...+document_properties_label=Svojstva dokumenta...+document_properties_file_name=Naziv fajla:+document_properties_file_size=Veličina fajla:+document_properties_kb={{size_kb}} KB ({{size_b}} bajta)+document_properties_mb={{size_mb}} MB ({{size_b}} bajta)+document_properties_title=Naslov:+document_properties_author=Autor:+document_properties_subject=Predmet:+document_properties_keywords=Ključne riječi:+document_properties_creation_date=Datum kreiranja:+document_properties_modification_date=Datum promjene:+document_properties_date_string={{date}}, {{time}}+document_properties_creator=Kreator:+document_properties_producer=PDF stvaratelj:+document_properties_version=PDF verzija:+document_properties_page_count=Broj stranica:+document_properties_close=Zatvori+# Tooltips and alt text for side panel toolbar buttons# (the _label strings are alt text for the buttons, the .title strings are# tooltips)@@ -48,6 +89,8 @@ toggle_sidebar.title=Uključi/isključi bočnu trakutoggle_sidebar_label=Uključi/isključi bočnu trakuoutline.title=Prikaži konture dokumentaoutline_label=Konture dokumenta+attachments.title=Prikaži priloge+attachments_label=Prilozithumbs.title=Prikaži thumbnailovethumbs_label=Thumbnailovifindbar.title=Pronađi u dokumentu@@ -61,12 +104,6 @@ thumb_page_title=Strana {{page}}# number.thumb_page_canvas=Thumbnail strane {{page}}-# Context menu-first_page.label=Idi na prvu stranu-last_page.label=Idi na zadnju stranu-page_rotate_cw.label=Rotiraj u smjeru kazaljke na satu-page_rotate_ccw.label=Rotiraj suprotno smjeru kazaljke na satu-# Find panel button title and messagesfind_label=Pronađi:find_previous.title=Pronađi prethodno pojavljivanje fraze@@ -103,23 +140,28 @@ page_scale_width=Širina stranepage_scale_fit=Uklopi stranupage_scale_auto=Automatsko uvećanjepage_scale_actual=Stvarna veličina+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messages-# LOCALIZATION NOTE (error_line): "{{[percent}}" will be replaced with a percentageloading_error_indicator=Greškaloading_error=Došlo je do greške prilikom učitavanja PDF-a.invalid_file_error=Neispravan ili oštećen PDF fajl.missing_file_error=Nedostaje PDF fajl.+unexpected_response_error=Neočekivani odgovor servera.-# LOCALIZATION NOTE (text_annotation_type): This is used as a tooltip.-# "{{[type}}" will be replaced with an annotation type from a list defined in+# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.+# "{{type}}" will be replaced with an annotation type from a list defined in# the PDF spec (32000-1:2008 Table 169 – Annotation types).# Some common types are e.g.: "Check", "Text", "Comment", "Note"text_annotation_type.alt=[{{type}} pribilješka]-request_password=PDF je zaštićen lozinkom:-invalid_password=Pogrešna lozinka.+password_label=Upišite lozinku da biste otvorili ovaj PDF fajl.+password_invalid=Pogrešna lozinka. Pokušajte ponovo.+password_ok=OK+password_cancel=Otkažiprinting_not_supported=Upozorenje: Štampanje nije u potpunosti podržano u ovom browseru.printing_not_ready=Upozorenje: PDF nije u potpunosti učitan za štampanje.web_fonts_disabled=Web fontovi su onemogućeni: nemoguće koristiti ubačene PDF fontove.-document_colors_disabled=PDF dokumentima nije dozvoljeno da koriste vlastite boje: \'Dozvoli stranicama da izaberu vlastite boje\' je deaktivirano u browseru.+document_colors_disabled=PDF dokumentima nije dozvoljeno da koriste vlastite boje: 'Dozvoli stranicama da izaberu vlastite boje' je deaktivirano u browseru.diff --git a/data/libs/pdfjs/web/locale/ca/viewer.properties b/data/libs/pdfjs/web/locale/ca/viewer.propertiesindex 94229be66..93b3b7697 100644--- a/data/libs/pdfjs/web/locale/ca/viewer.properties+++ b/data/libs/pdfjs/web/locale/ca/viewer.properties@@ -133,7 +133,7 @@ error_stack=Pila: {{stack}}error_file=Fitxer: {{file}}# LOCALIZATION NOTE (error_line): "{{line}}" will be replaced with a line numbererror_line=Línia: {{line}}-rendering_error=S'ha produït un error mentre es renderitzava la pàgina+rendering_error=S'ha produït un error mentre es renderitzava la pàgina.# Predefined zoom valuespage_scale_width=Amplària de la pàginadiff --git a/data/libs/pdfjs/web/locale/el/viewer.properties b/data/libs/pdfjs/web/locale/el/viewer.propertiesindex 36723c22b..a5d3d1216 100644--- a/data/libs/pdfjs/web/locale/el/viewer.properties+++ b/data/libs/pdfjs/web/locale/el/viewer.properties@@ -1,6 +1,16 @@-# This Source Code Form is subject to the terms of the Mozilla Public-# License, v. 2.0. If a copy of the MPL was not distributed with this-# file, You can obtain one at http://mozilla.org/MPL/2.0/.+# Copyright 2012 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.# Main toolbar buttons (tooltips and alt text for images)previous.title=Προηγούμενη σελίδα@@ -20,24 +30,71 @@ zoom_out_label=Σμίκρυνσηzoom_in.title=Μεγέθυνσηzoom_in_label=Μεγέθυνσηzoom.title=Μεγέθυνση-print.title=Εκτύπωση-print_label=Εκτύπωση+presentation_mode.title=Μετάβαση σε λειτουργία παρουσίασης+presentation_mode_label=Λειτουργία παρουσίασηςopen_file.title=Άνοιγμα αρχείουopen_file_label=Άνοιγμα+print.title=Εκτύπωση+print_label=Εκτύπωσηdownload.title=Λήψηdownload_label=Λήψηbookmark.title=Τρέχουσα προβολή (αντίγραφο ή άνοιγμα σε νέο παράθυρο)bookmark_label=Τρέχουσα προβολή+# Secondary toolbar and context menu+tools.title=Tools+tools_label=Tools+first_page.title=Go to First Page+first_page.label=Μετάβαση στην πρώτη σελίδα+first_page_label=Go to First Page+last_page.title=Go to Last Page+last_page.label=Μετάβαση στη τελευταία σελίδα+last_page_label=Go to Last Page+page_rotate_cw.title=Rotate Clockwise+page_rotate_cw.label=Δεξιόστροφη περιστροφή+page_rotate_cw_label=Rotate Clockwise+page_rotate_ccw.title=Rotate Counterclockwise+page_rotate_ccw.label=Αριστερόστροφη περιστροφή+page_rotate_ccw_label=Rotate Counterclockwise++hand_tool_enable.title=Enable hand tool+hand_tool_enable_label=Enable hand tool+hand_tool_disable.title=Disable hand tool+hand_tool_disable_label=Disable hand tool++# Document properties dialog box+document_properties.title=Document Properties…+document_properties_label=Document Properties…+document_properties_file_name=File name:+document_properties_file_size=File size:+document_properties_kb={{size_kb}} KB ({{size_b}} bytes)+document_properties_mb={{size_mb}} MB ({{size_b}} bytes)+document_properties_title=Title:+document_properties_author=Author:+document_properties_subject=Subject:+document_properties_keywords=Keywords:+document_properties_creation_date=Creation Date:+document_properties_modification_date=Modification Date:+document_properties_date_string={{date}}, {{time}}+document_properties_creator=Creator:+document_properties_producer=PDF Producer:+document_properties_version=PDF Version:+document_properties_page_count=Page Count:+document_properties_close=Close+# Tooltips and alt text for side panel toolbar buttons# (the _label strings are alt text for the buttons, the .title strings are# tooltips)+toggle_sidebar.title=Εναλλαγή προβολής πλευρικής στήλης+toggle_sidebar_label=Εναλλαγή προβολής πλευρικής στήληςoutline.title=Προβολή διάρθρωσης κειμένουoutline_label=Διάρθρωση κειμένου+attachments.title=Show Attachments+attachments_label=Attachmentsthumbs.title=Προβολή μικρογραφιώνthumbs_label=Μικρογραφίες--+findbar.title=Εύρεση στο έγγραφο+findbar_label=Εύρεση# Thumbnails panel item (tooltip and alt text for images)# LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page@@ -47,12 +104,25 @@ thumb_page_title=Σελίδα {{page}}# number.thumb_page_canvas=Μικρογραφία της σελίδας {{page}}-first_page.label=Μετάβαση στην πρώτη σελίδα+# Find panel button title and messages+find_label=Εύρεση:+find_previous.title=Εύρεση της προηγούμενης εμφάνισης της φράσης+find_previous_label=Προηγούμενο+find_next.title=Εύρεση της επόμενης εμφάνισης της φράσης+find_next_label=Επόμενο+find_highlight=Επισήμανση όλων+find_match_case_label=Ταίριασμα χαρακτήρα+find_reached_top=Έλευση στην αρχή του εγγράφου, συνέχεια από το τέλος+find_reached_bottom=Έλευση στο τέλος του εγγράφου, συνέχεια από την αρχή+find_not_found=Η φράση δεν βρέθηκε# Error panel labelserror_more_info=Περισσότερες πληροφορίεςerror_less_info=Λιγότερες πληροφορίεςerror_close=Κλείσιμο+# LOCALIZATION NOTE (error_version_info): "{{version}}" and "{{build}}" will be+# replaced by the PDF.JS version and build ID.+error_version_info=PDF.js v{{version}} (build: {{build}})# LOCALIZATION NOTE (error_message): "{{message}}" will be replaced by an# english string describing the error.error_message=Μήνυμα: {{message}}@@ -70,62 +140,28 @@ page_scale_width=Πλάτος σελίδαςpage_scale_fit=Μέγεθος σελίδαςpage_scale_auto=Αυτόματη μεγέθυνσηpage_scale_actual=Πραγματικό μέγεθος---# Context menu-page_rotate_cw.label=Δεξιόστροφη περιστροφή-page_rotate_ccw.label=Αριστερόστροφη περιστροφή--presentation_mode.title=Μετάβαση σε λειτουργία παρουσίασης-presentation_mode_label=Λειτουργία παρουσίασης+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messages-# LOCALIZATION NOTE (error_line): "{{[percent}}" will be replaced with a percentage-loading_error_indicator=Σφάλμαloading_error=Προέκυψε ένα σφάλμα κατά τη φόρτωση του PDF.--request_password=Το PDF προστατεύεται από κωδικό:--printing_not_supported=Προειδοποίηση: Η εκτύπωση δεν υποστηρίζεται πλήρως από αυτόν τον περιηγητή.----findbar.title=Εύρεση στο έγγραφο-findbar_label=Εύρεση---# Find panel button title and messages-find_label=Εύρεση:-find_previous.title=Εύρεση της προηγούμενης εμφάνισης της φράσης-find_previous_label=Προηγούμενο-find_next.title=Εύρεση της επόμενης εμφάνισης της φράσης-find_next_label=Επόμενο-find_highlight=Επισήμανση όλων-find_match_case_label=Ταίριασμα χαρακτήρα-find_reached_top=Έλευση στην αρχή του εγγράφου, συνέχεια από το τέλος-find_reached_bottom=Έλευση στο τέλος του εγγράφου, συνέχεια από την αρχή-find_not_found=Η φράση δεν βρέθηκε-invalid_file_error=Μη έγκυρο ή κατεστραμμένο αρχείο PDF.-last_page.label=Μετάβαση στη τελευταία σελίδα--# LOCALIZATION NOTE (error_version_info): "{{version}}" and "{{build}}" will be-# replaced by the PDF.JS version and build ID.-error_version_info=PDF.js v{{version}} (build: {{build}})-missing_file_error=Λείπει αρχείο PDF.+unexpected_response_error=Unexpected server response.+# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.+# "{{type}}" will be replaced with an annotation type from a list defined in+# the PDF spec (32000-1:2008 Table 169 – Annotation types).+# Some common types are e.g.: "Check", "Text", "Comment", "Note"+text_annotation_type.alt=[{{type}} Annotation]+password_label=Enter the password to open this PDF file.+password_invalid=Invalid password. Please try again.+password_ok=OK+password_cancel=Cancel-toggle_sidebar.title=Εναλλαγή προβολής πλευρικής στήλης-toggle_sidebar_label=Εναλλαγή προβολής πλευρικής στήλης--web_fonts_disabled=Οι γραμματοσειρές Web απενεργοποιημένες: αδυναμία χρήσης των ενσωματωμένων γραμματοσειρών PDF.-+printing_not_supported=Προειδοποίηση: Η εκτύπωση δεν υποστηρίζεται πλήρως από αυτόν τον περιηγητή.printing_not_ready=Προειδοποίηση: Το PDF δεν φορτώθηκε πλήρως για εκτύπωση.-+web_fonts_disabled=Οι γραμματοσειρές Web απενεργοποιημένες: αδυναμία χρήσης των ενσωματωμένων γραμματοσειρών PDF.document_colors_disabled=Δεν επιτρέπεται στα έγγραφα PDF να χρησιμοποιούν τα δικά τους χρώματα: Η επιλογή \'Να επιτρέπεται η χρήση χρωμάτων της σελίδας\' δεν είναι ενεργή στην εφαρμογή.--invalid_password=Μη έγκυρος κωδικός.-text_annotation_type.alt=[{{type}} Annotation]-diff --git a/data/libs/pdfjs/web/locale/eo/viewer.properties b/data/libs/pdfjs/web/locale/eo/viewer.propertiesindex 65bb15f6f..4350e1d3b 100644--- a/data/libs/pdfjs/web/locale/eo/viewer.properties+++ b/data/libs/pdfjs/web/locale/eo/viewer.properties@@ -161,7 +161,7 @@ password_invalid=Nevalida pasvorto. Bonvolu provi denove.password_ok=Akceptipassword_cancel=Nuligi-printing_not_supported=Averto: tiu ĉi retesplorilo ne plene subtenas presadon.-printing_not_ready=Warning: La PDF dosiero ne estas plene ŝargita por presado.+printing_not_supported=Averto: tiu ĉi retumilo ne plene subtenas presadon.+printing_not_ready=Averto: La PDF dosiero ne estas plene ŝargita por presado.web_fonts_disabled=Neaktivaj teksaĵaj tiparoj: ne elbas uzi enmetitajn tiparojn de PDF.-document_colors_disabled=Dokumentoj PDF ne rajtas havi siajn proprajn kolorojn: \'Permesi al paĝoj elekti siajn proprajn kolorojn\' estas malaktiva en la retesplorilo.+document_colors_disabled=Dokumentoj PDF ne rajtas havi siajn proprajn kolorojn: \'Permesi al paĝoj elekti siajn proprajn kolorojn\' estas malaktiva en la retumilo.diff --git a/data/libs/pdfjs/web/locale/es-ES/viewer.properties b/data/libs/pdfjs/web/locale/es-ES/viewer.propertiesindex ee53ab177..b9c2fccde 100644--- a/data/libs/pdfjs/web/locale/es-ES/viewer.properties+++ b/data/libs/pdfjs/web/locale/es-ES/viewer.properties@@ -93,7 +93,7 @@ rendering_error = Ocurrió un error al renderizar la página.page_scale_width = Anchura de la páginapage_scale_fit = Ajuste de la páginapage_scale_auto = Tamaño automático-page_scale_actual = Tamaño actual+page_scale_actual = Tamaño realpage_scale_percent = {{scale}}%loading_error_indicator = Errorloading_error = Ocurrió un error al cargar el PDF.diff --git a/data/libs/pdfjs/web/locale/es-MX/viewer.properties b/data/libs/pdfjs/web/locale/es-MX/viewer.propertiesindex 1372a7616..f0b3e7a03 100644--- a/data/libs/pdfjs/web/locale/es-MX/viewer.properties+++ b/data/libs/pdfjs/web/locale/es-MX/viewer.properties@@ -142,7 +142,7 @@ page_scale_auto=Zoom automáticopage_scale_actual=Tamaño real# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.-page_scale_percent={{escala}}%+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=Errordiff --git a/data/libs/pdfjs/web/locale/fa/viewer.properties b/data/libs/pdfjs/web/locale/fa/viewer.propertiesindex 51bda1b4f..0894cfd7f 100644--- a/data/libs/pdfjs/web/locale/fa/viewer.properties+++ b/data/libs/pdfjs/web/locale/fa/viewer.properties@@ -142,10 +142,11 @@ page_scale_auto=بزرگنمایی خودکارpage_scale_actual=اندازه واقعی# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=خطا-loading_error=هنگام بارگیری پرونده (PDF) خطایی رخ داد.+loading_error=هنگام بارگیری پرونده PDF خطایی رخ داد.invalid_file_error=پرونده PDF نامعتبر یامعیوب میباشد.missing_file_error=پرونده PDF یافت نشد.unexpected_response_error=پاسخ پیش بینی نشده سرورdiff --git a/data/libs/pdfjs/web/locale/hi-IN/viewer.properties b/data/libs/pdfjs/web/locale/hi-IN/viewer.propertiesindex 0c476c921..7b8db3ed8 100644--- a/data/libs/pdfjs/web/locale/hi-IN/viewer.properties+++ b/data/libs/pdfjs/web/locale/hi-IN/viewer.properties@@ -140,12 +140,15 @@ page_scale_width=पृष्ठ चौड़ाईpage_scale_fit=पृष्ठ फिटpage_scale_auto=स्वचालित जूमpage_scale_actual=वास्तविक आकार+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.# Loading indicator messagesloading_error_indicator=त्रुटिloading_error=पीडीएफ लोड करते समय एक त्रुटि हुई.invalid_file_error=अमान्य या भ्रष्ट PDF फ़ाइल.missing_file_error=अनुपस्थित PDF फ़ाइल.+unexpected_response_error=अप्रत्याशित सर्वर प्रतिक्रिया.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined indiff --git a/data/libs/pdfjs/web/locale/hu/viewer.properties b/data/libs/pdfjs/web/locale/hu/viewer.propertiesindex dc261b2db..eda1c88bc 100644--- a/data/libs/pdfjs/web/locale/hu/viewer.properties+++ b/data/libs/pdfjs/web/locale/hu/viewer.properties@@ -117,7 +117,7 @@ find_reached_bottom=A dokumentum vége elérve, folytatás az elejétőlfind_not_found=A kifejezés nem található# Error panel labels-error_more_info=További információ+error_more_info=További tudnivalókerror_less_info=Kevesebb információerror_close=Bezárás# LOCALIZATION NOTE (error_version_info): "{{version}}" and "{{build}}" will bediff --git a/data/libs/pdfjs/web/locale/id/viewer.properties b/data/libs/pdfjs/web/locale/id/viewer.propertiesindex b9cfc74c3..598408335 100644--- a/data/libs/pdfjs/web/locale/id/viewer.properties+++ b/data/libs/pdfjs/web/locale/id/viewer.properties@@ -110,7 +110,7 @@ find_previous.title=Temukan kata sebelumnyafind_previous_label=Sebelumnyafind_next.title=Temukan lebih lanjutfind_next_label=Selanjutnya-find_highlight=Sorot semu&anya+find_highlight=Sorot semuanyafind_match_case_label=Cocokkan BESAR/kecilfind_reached_top=Sampai di awal dokumen, dilanjutkan dari bawahfind_reached_bottom=Sampai di akhir dokumen, dilanjutkan dari atasdiff --git a/data/libs/pdfjs/web/locale/it/viewer.properties b/data/libs/pdfjs/web/locale/it/viewer.propertiesindex 4453b7bc6..91918e652 100644--- a/data/libs/pdfjs/web/locale/it/viewer.properties+++ b/data/libs/pdfjs/web/locale/it/viewer.properties@@ -46,7 +46,7 @@ document_properties_label = Proprietà del documento…document_properties_file_name = Nome file:document_properties_file_size = Dimensione file:document_properties_kb = {{size_kb}} kB ({{size_b}} byte)-document_properties_mb = {{size_kb}} MB ({{size_b}} byte)+document_properties_mb = {{size_mb}} MB ({{size_b}} byte)document_properties_title = Titolo:document_properties_author = Autore:document_properties_subject = Oggetto:diff --git a/data/libs/pdfjs/web/locale/ja/viewer.properties b/data/libs/pdfjs/web/locale/ja/viewer.propertiesindex 04a6a0b3f..10a21d941 100644--- a/data/libs/pdfjs/web/locale/ja/viewer.properties+++ b/data/libs/pdfjs/web/locale/ja/viewer.properties@@ -13,9 +13,9 @@# limitations under the License.# Main toolbar buttons (tooltips and alt text for images)-previous.title=前のページ+previous.title=前のページへ戻りますprevious_label=前へ-next.title=次のページ+next.title=次のページへ進みますnext_label=次へ# LOCALIZATION NOTE (page_label, page_of):@@ -25,41 +25,41 @@ next_label=次へpage_label=ページ:page_of=/ {{pageCount}}-zoom_out.title=縮小+zoom_out.title=表示を縮小しますzoom_out_label=縮小-zoom_in.title=拡大+zoom_in.title=表示を拡大しますzoom_in_label=拡大zoom.title=拡大/縮小presentation_mode.title=プレゼンテーションモードに切り替えますpresentation_mode_label=プレゼンテーションモード-open_file.title=ファイルを開く+open_file.title=ファイルを指定して開きますopen_file_label=開く-print.title=印刷+print.title=印刷しますprint_label=印刷-download.title=ダウンロード+download.title=ダウンロードしますdownload_label=ダウンロード-bookmark.title=現在のビューをブックマーク-bookmark_label=現在のビューをブックマーク+bookmark.title=現在のビューの URL です (コピーまたは新しいウィンドウに開く)+bookmark_label=現在のビュー# Secondary toolbar and context menutools.title=ツールtools_label=ツール-first_page.title=最初のページへ移動+first_page.title=最初のページへ移動しますfirst_page.label=最初のページへ移動first_page_label=最初のページへ移動-last_page.title=最後のページへ移動+last_page.title=最後のページへ移動しますlast_page.label=最後のページへ移動last_page_label=最後のページへ移動-page_rotate_cw.title=右回転+page_rotate_cw.title=ページを右へ回転しますpage_rotate_cw.label=右回転page_rotate_cw_label=右回転-page_rotate_ccw.title=左回転+page_rotate_ccw.title=ページを左へ回転しますpage_rotate_ccw.label=左回転page_rotate_ccw_label=左回転-hand_tool_enable.title=手のひらツールを有効にする+hand_tool_enable.title=手のひらツールを有効にしますhand_tool_enable_label=手のひらツールを有効にする-hand_tool_disable.title=手のひらツールを無効にする+hand_tool_disable.title=手のひらツールを無効にしますhand_tool_disable_label=手のひらツールを無効にする# Document properties dialog box@@ -77,7 +77,7 @@ document_properties_creation_date=作成日:document_properties_modification_date=更新日:document_properties_date_string={{date}}, {{time}}document_properties_creator=アプリケーション:-document_properties_producer=PDF 変換:+document_properties_producer=PDF 作成:document_properties_version=PDF のバージョン:document_properties_page_count=ページ数:document_properties_close=閉じる@@ -85,15 +85,15 @@ document_properties_close=閉じる# Tooltips and alt text for side panel toolbar buttons# (the _label strings are alt text for the buttons, the .title strings are# tooltips)-toggle_sidebar.title=サイドバーの切り替え+toggle_sidebar.title=サイドバー表示を切り替えますtoggle_sidebar_label=サイドバーの切り替え-outline.title=文書の目次+outline.title=文書の目次を表示しますoutline_label=文書の目次-attachments.title=添付ファイル+attachments.title=添付ファイルを表示しますattachments_label=添付ファイル-thumbs.title=縮小版+thumbs.title=縮小版を表示しますthumbs_label=縮小版-findbar.title=検索+findbar.title=文書内を検索しますfindbar_label=検索# Thumbnails panel item (tooltip and alt text for images)diff --git a/data/libs/pdfjs/web/locale/mai/viewer.properties b/data/libs/pdfjs/web/locale/mai/viewer.propertiesindex 564822fe2..cebcd75e3 100644--- a/data/libs/pdfjs/web/locale/mai/viewer.properties+++ b/data/libs/pdfjs/web/locale/mai/viewer.properties@@ -75,7 +75,7 @@ document_properties_subject=विषयdocument_properties_keywords=बीजशब्दdocument_properties_creation_date=निर्माण तिथि:document_properties_modification_date=संशोधन दिनांक:-document_properties_date_string=तिथि/समय+document_properties_date_string={{date}}, {{time}}document_properties_creator=सृजक:document_properties_producer=PDF उत्पादक:document_properties_version=PDF संस्करण:@@ -142,12 +142,14 @@ page_scale_auto=स्वचालित जूमpage_scale_actual=सही आकार# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=त्रुटिloading_error=पीडीएफ लोड करैत समय एकटा त्रुटि भेल.invalid_file_error=अमान्य अथवा भ्रष्ट PDF फाइल.missing_file_error=अनुपस्थित PDF फाइल.+unexpected_response_error=अप्रत्याशित सर्वर अनुक्रिया.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined indiff --git a/data/libs/pdfjs/web/locale/ml/viewer.properties b/data/libs/pdfjs/web/locale/ml/viewer.propertiesindex ecacc7c68..1e17a8a84 100644--- a/data/libs/pdfjs/web/locale/ml/viewer.properties+++ b/data/libs/pdfjs/web/locale/ml/viewer.properties@@ -140,12 +140,16 @@ page_scale_width=താളിന്റെ വീതിpage_scale_fit=താള് പാകത്തിനാക്കുകpage_scale_auto=സ്വയമായി വലുതാക്കുകpage_scale_actual=യഥാര്ത്ഥ വ്യാപ്തി+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=പിശക്loading_error=പിഡിഎഫ് ലഭ്യമാക്കുമ്പോള് പിശക് ഉണ്ടായിരിയ്ക്കുന്നു.invalid_file_error=തെറ്റായ അല്ലെങ്കില് തകരാറുള്ള പിഡിഎഫ് ഫയല്.missing_file_error=പിഡിഎഫ് ഫയല് ലഭ്യമല്ല.+unexpected_response_error=പ്രതീക്ഷിക്കാത്ത സെര്വര് മറുപടി.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined indiff --git a/data/libs/pdfjs/web/locale/mr/viewer.properties b/data/libs/pdfjs/web/locale/mr/viewer.propertiesindex 0e6f72ff6..a37456b0f 100644--- a/data/libs/pdfjs/web/locale/mr/viewer.properties+++ b/data/libs/pdfjs/web/locale/mr/viewer.properties@@ -142,12 +142,14 @@ page_scale_auto=स्वयं लाहन किंवा मोठे करpage_scale_actual=प्रत्यक्ष आकार# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=त्रुटीloading_error=PDF लोड करतेवेळी त्रुटी आढळली.invalid_file_error=अवैध किंवा दोषीत PDF फाइल.missing_file_error=न आढळणारी PDF फाइल.+unexpected_response_error=अनपेक्षित सर्व्हर प्रतिसाद.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined indiff --git a/data/libs/pdfjs/web/locale/nl/viewer.properties b/data/libs/pdfjs/web/locale/nl/viewer.propertiesindex e3b518305..50e4d1387 100644--- a/data/libs/pdfjs/web/locale/nl/viewer.properties+++ b/data/libs/pdfjs/web/locale/nl/viewer.properties@@ -162,6 +162,6 @@ password_ok=OKpassword_cancel=Annulerenprinting_not_supported=Waarschuwing: afdrukken wordt niet volledig ondersteund door deze browser.-printing_not_ready=Warning: PDF is niet volledig geladen om af te drukken.+printing_not_ready=Waarschuwing: de PDF is niet volledig geladen voor afdrukken.web_fonts_disabled=Weblettertypen zijn uitgeschakeld: gebruik van ingebedde PDF-lettertypen is niet mogelijk.document_colors_disabled=PDF-documenten mogen hun eigen kleuren niet gebruiken: ‘Pagina’s toestaan om hun eigen kleuren te kiezen’ is uitgeschakeld in de browser.diff --git a/data/libs/pdfjs/web/locale/nn-NO/viewer.properties b/data/libs/pdfjs/web/locale/nn-NO/viewer.propertiesindex fc955bb5d..098e8228b 100644--- a/data/libs/pdfjs/web/locale/nn-NO/viewer.properties+++ b/data/libs/pdfjs/web/locale/nn-NO/viewer.properties@@ -44,9 +44,9 @@ bookmark_label=Gjeldande vising# Secondary toolbar and context menutools.title=Verktøytools_label=Verktøy-first_page.title=Gå til første side-first_page.label=Gå til første side-first_page_label=Gå til første side+first_page.title=Gå til fyrstesida+first_page.label=Gå til fyrstesida+first_page_label=Gå til fyrstesidalast_page.title=Gå til siste sidelast_page.label=Gå til siste sidelast_page_label=Gå til siste side@@ -140,11 +140,14 @@ page_scale_width=Sidebreiddepage_scale_fit=Tilpass til sidapage_scale_auto=Automatisk skaleringpage_scale_actual=Verkeleg storleik+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=Feilloading_error=Ein feil oppstod ved lasting av PDF.-invalid_file_error=Ugyldig eller korrupt PDF fil.+invalid_file_error=Ugyldig eller korrupt PDF-fil.missing_file_error=Manglande PDF-fil.unexpected_response_error=Uventa tenarrespons.@@ -160,5 +163,5 @@ password_cancel=Avbrytprinting_not_supported=Åtvaring: Utskrift er ikkje fullstendig støtta av denne nettlesaren.printing_not_ready=Åtvaring: PDF ikkje fullstendig innlasta for utskrift.-web_fonts_disabled=Vev-fontar er slått av: Kan ikkje bruka innbundne PDF-fontar.+web_fonts_disabled=Vev-skrifter er slått av: Kan ikkje bruka innbundne PDF-skrifter.document_colors_disabled=PDF-dokument har ikkje løyve til å bruka eigne fargar: 'Tillat sider å velja eigne fargar' er slått av i nettlesaren.diff --git a/data/libs/pdfjs/web/locale/pt-BR/viewer.properties b/data/libs/pdfjs/web/locale/pt-BR/viewer.propertiesindex dbd826c5d..b295275f0 100644--- a/data/libs/pdfjs/web/locale/pt-BR/viewer.properties+++ b/data/libs/pdfjs/web/locale/pt-BR/viewer.properties@@ -38,7 +38,7 @@ print.title=Imprimirprint_label=Imprimirdownload.title=Downloaddownload_label=Download-bookmark.title=Visualização atual (copie ou abra em nova janela)+bookmark.title=Visualização atual (copie ou abra em uma nova janela)bookmark_label=Visualização atual# Secondary toolbar and context menu@@ -142,6 +142,7 @@ page_scale_auto=Zoom automáticopage_scale_actual=Tamanho real# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=Errodiff --git a/data/libs/pdfjs/web/locale/pt-PT/viewer.properties b/data/libs/pdfjs/web/locale/pt-PT/viewer.propertiesindex 7a83edfac..9b29039c9 100644--- a/data/libs/pdfjs/web/locale/pt-PT/viewer.properties+++ b/data/libs/pdfjs/web/locale/pt-PT/viewer.properties@@ -36,10 +36,10 @@ open_file.title=Abrir ficheiroopen_file_label=Abrirprint.title=Imprimirprint_label=Imprimir-download.title=Transferir-download_label=Transferir-bookmark.title=Vista atual (copiar ou abrir em nova janela)-bookmark_label=Vista atual+download.title=Descarregar+download_label=Descarregar+bookmark.title=Visão atual (copiar ou abrir numa nova janela)+bookmark_label=Visão atual# Secondary toolbar and context menutools.title=Ferramentas@@ -63,8 +63,8 @@ hand_tool_disable.title=Desativar ferramenta de mãohand_tool_disable_label=Desativar ferramenta de mão# Document properties dialog box-document_properties.title=Propriedades do documento...-document_properties_label=Propriedades do documento...+document_properties.title=Propriedades do documento…+document_properties_label=Propriedades do documento…document_properties_file_name=Nome do ficheiro:document_properties_file_size=Tamanho do ficheiro:document_properties_kb={{size_kb}} KB ({{size_b}} bytes)@@ -106,9 +106,9 @@ thumb_page_canvas=Miniatura da página {{page}}# Find panel button title and messagesfind_label=Localizar:-find_previous.title=Localizar a ocorrência anterior+find_previous.title=Localizar ocorrência anterior da frasefind_previous_label=Anterior-find_next.title=Localizar a ocorrência seguinte+find_next.title=Localizar ocorrência seguinte da frasefind_next_label=Seguintefind_highlight=Destacar tudofind_match_case_label=Correspondência@@ -156,12 +156,12 @@ unexpected_response_error=Resposta inesperada do servidor.# the PDF spec (32000-1:2008 Table 169 – Annotation types).# Some common types are e.g.: "Check", "Text", "Comment", "Note"text_annotation_type.alt=[Anotação {{type}}]-password_label=Introduza a senha para abrir este PDF.-password_invalid=Senha inválida. Tente novamente.+password_label=Digite a palavra-passe para abrir este PDF.+password_invalid=Palavra-passe inválida. Por favor, tente novamente.password_ok=OKpassword_cancel=Cancelarprinting_not_supported=Aviso: a impressão não é totalmente suportada por este navegador.printing_not_ready=Aviso: o PDF ainda não está totalmente carregado.web_fonts_disabled=Os tipos de letra web estão desativados: não é possível utilizar os tipos de letra PDF incorporados.-document_colors_disabled=Os documentos PDF não permitem a utilização das suas próprias cores: Autorizar as páginas a escolher as suas próprias cores está desativado no navegador.+document_colors_disabled=Os documentos PDF não permitem a utilização das suas próprias cores: 'Autorizar as páginas a escolher as suas próprias cores' está desativada no navegador.diff --git a/data/libs/pdfjs/web/locale/ro/viewer.properties b/data/libs/pdfjs/web/locale/ro/viewer.propertiesindex 412ca731d..e93cc4910 100644--- a/data/libs/pdfjs/web/locale/ro/viewer.properties+++ b/data/libs/pdfjs/web/locale/ro/viewer.properties@@ -25,11 +25,11 @@ next_label=Înaintepage_label=Pagină:page_of=din {{pageCount}}-zoom_out.title=Depărtează-zoom_out_label=Depărtează-zoom_in.title=Apropie-zoom_in_label=Apropie-zoom.title=Panoramează+zoom_out.title=Micșorează+zoom_out_label=Micșorează+zoom_in.title=Mărește+zoom_in_label=Mărește+zoom.title=Scalarepresentation_mode.title=Schimbă la modul de prezentarepresentation_mode_label=Mod de prezentareopen_file.title=Deschide un fișier@@ -80,7 +80,7 @@ document_properties_creator=Autor:document_properties_producer=Producător PDF:document_properties_version=Versiune PDF:document_properties_page_count=Număr de pagini:-document_properties_close=Închidere+document_properties_close=Închide# Tooltips and alt text for side panel toolbar buttons# (the _label strings are alt text for the buttons, the .title strings are@@ -156,12 +156,12 @@ unexpected_response_error=Răspuns neașteptat de la server.# the PDF spec (32000-1:2008 Table 169 – Annotation types).# Some common types are e.g.: "Check", "Text", "Comment", "Note"text_annotation_type.alt=[{{type}} Adnotare]-password_label=Introduceți parola pentru a deschide acest fişier PDF.+password_label=Introduceți parola pentru a deschide acest fișier PDF.password_invalid=Parolă greșită. Vă rugăm încercați din nou.password_ok=Okpassword_cancel=Renunțăprinting_not_supported=Atenție: Tipărirea nu este suportată în totalitate de acest navigator.-printing_not_ready=Avertisment: Fișierul PDF nu este încărcat complet pentru tipărire.+printing_not_ready=Atenție: Fișierul PDF nu este încărcat complet pentru tipărire.web_fonts_disabled=Fonturile web sunt dezactivate: nu pot utiliza fonturile PDF încorporate.document_colors_disabled=Documentele PDF nu sunt autorizate să folosească propriile culori: 'Permite paginilor să aleagă propriile culori' este dezactivată în navigator.diff --git a/data/libs/pdfjs/web/locale/rw/viewer.properties b/data/libs/pdfjs/web/locale/rw/viewer.propertiesindex ec4352dc4..97681016a 100644--- a/data/libs/pdfjs/web/locale/rw/viewer.properties+++ b/data/libs/pdfjs/web/locale/rw/viewer.properties@@ -67,6 +67,7 @@ loading_error_indicator=Ikosa# "{{type}}" will be replaced with an annotation type from a list defined in# the PDF spec (32000-1:2008 Table 169 – Annotation types).# Some common types are e.g.: "Check", "Text", "Comment", "Note"+password_invalid=Ijambo ry'ibanga ridahari. Wakongera ukageragezapassword_ok=YEGOpassword_cancel=Kurekadiff --git a/data/libs/pdfjs/web/locale/sl/viewer.properties b/data/libs/pdfjs/web/locale/sl/viewer.propertiesindex bdc7fff84..734f9412f 100644--- a/data/libs/pdfjs/web/locale/sl/viewer.properties+++ b/data/libs/pdfjs/web/locale/sl/viewer.properties@@ -120,8 +120,8 @@ find_not_found=Iskanega ni mogoče najtierror_more_info=Več informacijerror_less_info=Manj informacijerror_close=Zapri-# LOCALIZATION NOTE (error_build): "{{build}}" will be replaced by the PDF.JS-# build ID.+# LOCALIZATION NOTE (error_version_info): "{{version}}" and "{{build}}" will be+# replaced by the PDF.JS version and build ID.error_version_info=PDF.js r{{version}} (graditev: {{build}})# LOCALIZATION NOTE (error_message): "{{message}}" will be replaced by an# english string describing the error.diff --git a/data/libs/pdfjs/web/locale/son/viewer.properties b/data/libs/pdfjs/web/locale/son/viewer.propertiesindex 23f23bfb5..83e48dc8c 100644--- a/data/libs/pdfjs/web/locale/son/viewer.properties+++ b/data/libs/pdfjs/web/locale/son/viewer.properties@@ -68,7 +68,7 @@ document_properties_label=Takadda mayrawey…document_properties_file_name=Tuku maa:document_properties_file_size=Tuku adadu:document_properties_kb=KB {{size_kb}} (cebsu-ize {{size_b}})-document_properties_mb=MB {{size_kb}} (cebsu-ize {{size_b}})+document_properties_mb=MB {{size_mb}} (cebsu-ize {{size_b}})document_properties_title=Tiiramaa:document_properties_author=Hantumkaw:document_properties_subject=Dalil:diff --git a/data/libs/pdfjs/web/locale/sq/viewer.properties b/data/libs/pdfjs/web/locale/sq/viewer.propertiesindex 8d17d7777..68ab16b79 100644--- a/data/libs/pdfjs/web/locale/sq/viewer.properties+++ b/data/libs/pdfjs/web/locale/sq/viewer.properties@@ -15,12 +15,12 @@ next_label=Pasuesjapage_label=Faqja:page_of=nga {{pageCount}}-zoom_out.title=Zoom Out-zoom_out_label=Zoom Out-zoom_in.title=Zoom In-zoom_in_label=Zoom In+zoom_out.title=Zmadhim+zoom_out_label=Zmadhoji+zoom_in.title=Zvogëlim+zoom_in_label=Zvogëlojizoom.title=Zoom-print.title=Shtype+print.title=Shtypjeprint_label=Shtypenipresentation_mode.title=Kalo te Mënyra Paraqitjepresentation_mode_label=Mënyra Paraqitjediff --git a/data/libs/pdfjs/web/locale/te/viewer.properties b/data/libs/pdfjs/web/locale/te/viewer.propertiesindex 5b56cc4b5..bd1ecac4f 100644--- a/data/libs/pdfjs/web/locale/te/viewer.properties+++ b/data/libs/pdfjs/web/locale/te/viewer.properties@@ -142,6 +142,7 @@ page_scale_auto=స్వయంచాలక జూమ్page_scale_actual=యథార్ధ పరిమాణం# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=దోషంdiff --git a/data/libs/pdfjs/web/locale/th/viewer.properties b/data/libs/pdfjs/web/locale/th/viewer.propertiesindex 9ccaa382a..543d8709b 100644--- a/data/libs/pdfjs/web/locale/th/viewer.properties+++ b/data/libs/pdfjs/web/locale/th/viewer.properties@@ -161,7 +161,7 @@ password_invalid=รหัสผ่านไม่ถูกต้อง โปpassword_ok=ตกลงpassword_cancel=ยกเลิก-printing_not_supported=คำเตือน: เบราเซอร์นี้ไม่ได้สนับสนุนการพิมพ์อย่างเต็มที่+printing_not_supported=คำเตือน: เบราว์เซอร์นี้ไม่ได้สนับสนุนการพิมพ์อย่างเต็มที่printing_not_ready=คำเตือน: PDF ไม่ได้รับการโหลดอย่างเต็มที่สำหรับการพิมพ์web_fonts_disabled=แบบอักษรเว็บถูกปิดการใช้งาน: ไม่สามารถใช้แบบอักษรฝังตัวใน PDF-document_colors_disabled=เอกสาร PDF ไม่ได้รับอนุญาตให้ใช้สีของตัวเอง: 'อนุญาตให้หน้าเอกสารสามารถเลือกสีของตัวเอง' ถูกปิดใช้งานในเบราเซอร์+document_colors_disabled=เอกสาร PDF ไม่ได้รับอนุญาตให้ใช้สีของตัวเอง: 'อนุญาตให้หน้าเอกสารสามารถเลือกสีของตัวเอง' ถูกปิดใช้งานในเบราว์เซอร์diff --git a/data/libs/pdfjs/web/locale/tn/viewer.properties b/data/libs/pdfjs/web/locale/tn/viewer.propertiesindex 805a688c0..702d557c0 100644--- a/data/libs/pdfjs/web/locale/tn/viewer.properties+++ b/data/libs/pdfjs/web/locale/tn/viewer.properties@@ -26,6 +26,8 @@ open_file_label=Bula# Secondary toolbar and context menu+hand_tool_disable.title=Thibela go dira ga sediriswa sa seatla+hand_tool_disable_label=Thibela go dira ga sediriswa sa seatla# Document properties dialog boxdocument_properties_file_name=Leina la faele:@@ -59,6 +61,8 @@ error_more_info=Tshedimosetso e Nngwe# LOCALIZATION NOTE (error_line): "{{line}}" will be replaced with a line number# Predefined zoom values+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.# Loading indicator messagesloading_error_indicator=Phoso@@ -70,3 +74,4 @@ loading_error_indicator=Phosopassword_ok=Siamepassword_cancel=Khansela+web_fonts_disabled=Mefutatlhaka ya Webo ga e dire: ga e kgone go dirisa mofutatlhaka wa PDF o tsentsweng.diff --git a/data/libs/pdfjs/web/locale/vi/viewer.properties b/data/libs/pdfjs/web/locale/vi/viewer.propertiesindex 15acc8efa..bc5729273 100644--- a/data/libs/pdfjs/web/locale/vi/viewer.properties+++ b/data/libs/pdfjs/web/locale/vi/viewer.properties@@ -23,16 +23,16 @@ next_label=Tiếp# Do not translate "{{pageCount}}", it will be substituted with a number# representing the total number of pages.page_label=Trang:-page_of=thuộc về {{pageCount}}+page_of=trên {{pageCount}}zoom_out.title=Thu nhỏzoom_out_label=Thu nhỏzoom_in.title=Phóng tozoom_in_label=Phóng to-zoom.title=Thu phóng+zoom.title=Chỉnh kích thướcpresentation_mode.title=Chuyển sang chế độ trình chiếupresentation_mode_label=Chế độ trình chiếu-open_file.title=Mở Tập Tin+open_file.title=Mở tập tinopen_file_label=Mở tập tinprint.title=Inprint_label=In@@ -43,6 +43,13 @@ bookmark_label=Chế độ xem hiện tại# Secondary toolbar and context menutools.title=Công cụ+tools_label=Công cụ+first_page.title=Về trang đầu+first_page.label=Về trang đầu+first_page_label=Về trang đầu+last_page.title=Đến trang cuối+last_page.label=Đến trang cuối+last_page_label=Đến trang cuốipage_rotate_cw.title=Xoay theo chiều kim đồng hồpage_rotate_cw.label=Xoay theo chiều kim đồng hồpage_rotate_cw_label=Xoay theo chiều kim đồng hồ@@ -50,16 +57,27 @@ page_rotate_ccw.title=Xoay ngược chiều kim đồng hồpage_rotate_ccw.label=Xoay ngược chiều kim đồng hồpage_rotate_ccw_label=Xoay ngược chiều kim đồng hồ+hand_tool_enable.title=Cho phép kéo để cuộn trang+hand_tool_enable_label=Cho phép kéo để cuộn trang+hand_tool_disable.title=Tắt kéo để cuộn trang+hand_tool_disable_label=Tắt kéo để cuộn trang# Document properties dialog box-document_properties_file_size=Kích thước tập tin:+document_properties.title=Thuộc tính của tài liệu…+document_properties_label=Thuộc tính của tài liệu…+document_properties_file_name=Tên tập tin:+document_properties_file_size=Kích thước:+document_properties_kb={{size_kb}} KB ({{size_b}} byte)+document_properties_mb={{size_mb}} MB ({{size_b}} byte)document_properties_title=Tiêu đề:document_properties_author=Tác giả:document_properties_subject=Chủ đề:document_properties_keywords=Từ khóa:document_properties_creation_date=Ngày tạo:document_properties_modification_date=Ngày sửa đổi:-document_properties_producer=Nhà sản xuất PDF:+document_properties_date_string={{date}}, {{time}}+document_properties_creator=Người tạo:+document_properties_producer=Phần mềm tạo PDF:document_properties_version=Phiên bản PDF:document_properties_page_count=Tổng số trang:document_properties_close=Ðóng@@ -67,12 +85,14 @@ document_properties_close=Ðóng# Tooltips and alt text for side panel toolbar buttons# (the _label strings are alt text for the buttons, the .title strings are# tooltips)-toggle_sidebar.title=Bật/Tắt Thanh Lề-toggle_sidebar_label=Bật/Tắt Thanh Lề+toggle_sidebar.title=Bật/Tắt thanh lề+toggle_sidebar_label=Bật/Tắt thanh lềoutline.title=Hiển thị bản phác tài liệu-outline_label=Bản phác họa Tài liệu-thumbs.title=Hiển thị Thumbnails-thumbs_label=Thumbnails (hình biểu diễn nhỏ)+outline_label=Bản phác tài liệu+attachments.title=Hiện nội dung đính kèm+attachments_label=Nội dung đính kèm+thumbs.title=Hiển thị ảnh thu nhỏ+thumbs_label=Ảnh thu nhỏfindbar.title=Tìm trong tài liệufindbar_label=Tìm@@ -82,19 +102,19 @@ findbar_label=Tìmthumb_page_title=Trang {{page}}# LOCALIZATION NOTE (thumb_page_canvas): "{{page}}" will be replaced by the page# number.-thumb_page_canvas=Hình ảnh thu nhỏ của trang {{page}}+thumb_page_canvas=Ảnh thu nhỏ của trang {{page}}# Find panel button title and messages-find_label=Tìm kiếm:+find_label=Tìm:find_previous.title=Tìm cụm từ ở phần trướcfind_previous_label=Trướcfind_next.title=Tìm cụm từ ở phần saufind_next_label=Tiếpfind_highlight=Tô sáng tất cả-find_match_case_label=Phân biệt chữ hoa, chữ thường+find_match_case_label=Phân biệt hoa, thườngfind_reached_top=Đã đến phần đầu tài liệu, quay trở lại từ cuốifind_reached_bottom=Đã đến phần cuối của tài liệu, quay trở lại từ đầu-find_not_found=Không tìm thấy cụm từ+find_not_found=Không tìm thấy cụm từ này# Error panel labelserror_more_info=Thông tin thêm@@ -116,16 +136,20 @@ error_line=Dòng: {{line}}rendering_error=Lỗi khi hiển thị trang.# Predefined zoom values-page_scale_width=Chiều rộng trang-page_scale_fit=Độ vừa của trang-page_scale_auto=Tự động thu/phóng+page_scale_width=Vừa chiều rộng+page_scale_fit=Vừa chiều cao+page_scale_auto=Tự động chọn kích thướcpage_scale_actual=Kích thước thực+# LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a+# numerical scale value.+page_scale_percent={{scale}}%# Loading indicator messagesloading_error_indicator=Lỗiloading_error=Lỗi khi tải tài liệu PDF.invalid_file_error=Tập tin PDF hỏng hoặc không hợp lệ.missing_file_error=Thiếu tập tin PDF.+unexpected_response_error=Máy chủ có phản hồi lạ.# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.# "{{type}}" will be replaced with an annotation type from a list defined indiff --git a/data/libs/pdfjs/web/locale/zh-TW/viewer.properties b/data/libs/pdfjs/web/locale/zh-TW/viewer.propertiesindex f1849d48e..11f20d71a 100644--- a/data/libs/pdfjs/web/locale/zh-TW/viewer.properties+++ b/data/libs/pdfjs/web/locale/zh-TW/viewer.properties@@ -68,7 +68,7 @@ document_properties_label=文件內容…document_properties_file_name=檔案名稱:document_properties_file_size=檔案大小:document_properties_kb={{size_kb}} KB({{size_b}} 位元組)-document_properties_mb={{size_kb}} MB({{size_b}} 位元組)+document_properties_mb={{size_mb}} MB({{size_b}} 位元組)document_properties_title=標題:document_properties_author=作者:document_properties_subject=主旨:diff --git a/data/libs/pdfjs/web/viewer.css b/data/libs/pdfjs/web/viewer.cssindex 3f9196993..309a7001f 100644--- a/data/libs/pdfjs/web/viewer.css+++ b/data/libs/pdfjs/web/viewer.css@@ -62,6 +62,57 @@.textLayer ::selection { background: rgb(0,0,255); }.textLayer ::-moz-selection { background: rgb(0,0,255); }++.annotationLayer .annotLink > a:hover {+ opacity: 0.2;+ background: #ff0;+ box-shadow: 0px 2px 10px #ff0;+}++.annotationLayer .annotText > img {+ position: absolute;+ cursor: pointer;+}++.annotationLayer .annotTextContentWrapper {+ position: absolute;+ width: 20em;+}++.annotationLayer .annotTextContent {+ z-index: 200;+ float: left;+ max-width: 20em;+ background-color: #FFFF99;+ box-shadow: 0px 2px 5px #333;+ border-radius: 2px;+ padding: 0.6em;+ cursor: pointer;+}++.annotationLayer .annotTextContent > h1 {+ font-size: 1em;+ border-bottom: 1px solid #000000;+ padding-bottom: 0.2em;+}++.annotationLayer .annotTextContent > p {+ padding-top: 0.2em;+}++.annotationLayer .annotLink > a {+ position: absolute;+ font-size: 1em;+ top: 0;+ left: 0;+ width: 100%;+ height: 100%;+}++.annotationLayer .annotLink > a /* -ms-a */ {+ background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") 0 0 repeat;+}+.pdfViewer .canvasWrapper {overflow: hidden;}@@ -79,6 +130,11 @@background-color: white;}+.pdfViewer.removePageBorders .page {+ margin: 0px auto 10px auto;+ border: none;+}+.pdfViewer .page canvas {margin: 0;display: block;@@ -94,77 +150,26 @@background: url('images/loading-icon.gif') center no-repeat;}-.pdfViewer .page .annotLink > a:hover {- opacity: 0.2;- background: #ff0;- box-shadow: 0px 2px 10px #ff0;-}--:-webkit-full-screen .pdfViewer .page {+.pdfPresentationMode:-webkit-full-screen .pdfViewer .page {margin-bottom: 100%;border: 0;}-:-moz-full-screen .pdfViewer .page {+.pdfPresentationMode:-moz-full-screen .pdfViewer .page {margin-bottom: 100%;border: 0;}-:-ms-fullscreen .pdfViewer .page {+.pdfPresentationMode:-ms-fullscreen .pdfViewer .page {margin-bottom: 100% !important;border: 0;}-:fullscreen .pdfViewer .page {+.pdfPresentationMode:fullscreen .pdfViewer .page {margin-bottom: 100%;border: 0;}-.pdfViewer .page .annotText > img {- position: absolute;- cursor: pointer;-}--.pdfViewer .page .annotTextContentWrapper {- position: absolute;- width: 20em;-}--.pdfViewer .page .annotTextContent {- z-index: 200;- float: left;- max-width: 20em;- background-color: #FFFF99;- box-shadow: 0px 2px 5px #333;- border-radius: 2px;- padding: 0.6em;- cursor: pointer;-}--.pdfViewer .page .annotTextContent > h1 {- font-size: 1em;- border-bottom: 1px solid #000000;- padding-bottom: 0.2em;-}--.pdfViewer .page .annotTextContent > p {- padding-top: 0.2em;-}--.pdfViewer .page .annotLink > a {- position: absolute;- font-size: 1em;- top: 0;- left: 0;- width: 100%;- height: 100%;-}--.pdfViewer .page .annotLink > a /* -ms-a */ {- background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAA\- LAAAAAABAAEAAAIBRAA7") 0 0 repeat;-}-* {padding: 0;margin: 0;@@ -197,7 +202,7 @@ select {display: none !important;}-#viewerContainer:-webkit-full-screen {+#viewerContainer.pdfPresentationMode:-webkit-full-screen {top: 0px;border-top: 2px solid transparent;background-color: #000;@@ -208,7 +213,7 @@ select {-webkit-user-select: none;}-#viewerContainer:-moz-full-screen {+#viewerContainer.pdfPresentationMode:-moz-full-screen {top: 0px;border-top: 2px solid transparent;background-color: #000;@@ -219,7 +224,7 @@ select {-moz-user-select: none;}-#viewerContainer:-ms-fullscreen {+#viewerContainer.pdfPresentationMode:-ms-fullscreen {top: 0px !important;border-top: 2px solid transparent;width: 100%;@@ -229,11 +234,11 @@ select {-ms-user-select: none;}-#viewerContainer:-ms-fullscreen::-ms-backdrop {+#viewerContainer.pdfPresentationMode:-ms-fullscreen::-ms-backdrop {background-color: #000;}-#viewerContainer:fullscreen {+#viewerContainer.pdfPresentationMode:fullscreen {top: 0px;border-top: 2px solid transparent;background-color: #000;@@ -246,36 +251,40 @@ select {-ms-user-select: none;}-:-webkit-full-screen a:not(.internalLink) {+.pdfPresentationMode:-webkit-full-screen a:not(.internalLink) {display: none;}-:-moz-full-screen a:not(.internalLink) {+.pdfPresentationMode:-moz-full-screen a:not(.internalLink) {display: none;}-:-ms-fullscreen a:not(.internalLink) {+.pdfPresentationMode:-ms-fullscreen a:not(.internalLink) {display: none !important;}-:fullscreen a:not(.internalLink) {+.pdfPresentationMode:fullscreen a:not(.internalLink) {display: none;}-:-webkit-full-screen .textLayer > div {+.pdfPresentationMode:-webkit-full-screen .textLayer > div {cursor: none;}-:-moz-full-screen .textLayer > div {+.pdfPresentationMode:-moz-full-screen .textLayer > div {cursor: none;}-:fullscreen .textLayer > div {+.pdfPresentationMode:-ms-fullscreen .textLayer > div {cursor: none;}-#viewerContainer.presentationControls,-#viewerContainer.presentationControls .textLayer > div {+.pdfPresentationMode:fullscreen .textLayer > div {+ cursor: none;+}++.pdfPresentationMode.pdfPresentationModeControls > *,+.pdfPresentationMode.pdfPresentationModeControls .textLayer > div {cursor: default;}@@ -737,6 +746,7 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {.splitToolbarButton > .toolbarButton:focus,.dropdownToolbarButton:hover,.overlayButton:hover,+.overlayButton:focus,.toolbarButton.textButton:hover,.toolbarButton.textButton:focus {background-color: hsla(0,0%,0%,.2);@@ -893,7 +903,7 @@ html[dir='rtl'] .dropdownToolbarButton {.dropdownToolbarButton {width: 120px;max-width: 120px;- padding: 3px 2px 2px;+ padding: 0;overflow: hidden;background: url(images/toolbarButton-menuArrows.png) no-repeat;}@@ -909,7 +919,7 @@ html[dir='rtl'] .dropdownToolbarButton {font-size: 12px;color: hsl(0,0%,95%);margin: 0;- padding: 0;+ padding: 3px 2px 2px;border: none;background: rgba(0,0,0,0); /* Opera does not support 'transparent' <select> background */}@@ -1273,7 +1283,6 @@ html[dir='rtl'] .verticalToolbarSeparator {}.thumbnailImage {- transition-duration: 150ms;border: 1px solid transparent;box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);opacity: 0.8;@@ -1285,7 +1294,6 @@ html[dir='rtl'] .verticalToolbarSeparator {.thumbnailSelectionRing {border-radius: 2px;padding: 7px;- transition-duration: 150ms;}a:focus > .thumbnail > .thumbnailSelectionRing > .thumbnailImage,@@ -1504,10 +1512,6 @@ html[dir='rtl'] .attachmentsItem > button {.dialog .toolbarField {margin: 5px 0;}-.dialog .toolbarField:hover,-.dialog .toolbarField:focus {- border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42);-}.dialog .separator {display: block;@@ -1861,10 +1865,14 @@ html[dir='rtl'] #documentPropertiesOverlay .row > * {body[data-mozPrintCallback] #printContainer {display: block;}- #printContainer canvas {+ /* wrapper around (scaled) print canvas elements */+ #printContainer > div {position: relative;top: 0;left: 0;+ overflow: hidden;+ }+ #printContainer canvas {display: block;}}diff --git a/data/libs/pdfjs/web/viewer.html b/data/libs/pdfjs/web/viewer.htmlindex 1e7dd87a7..14416a4e6 100644--- a/data/libs/pdfjs/web/viewer.html+++ b/data/libs/pdfjs/web/viewer.html@@ -14,8 +14,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.-Adobe CMap resources are covered by their own copyright and license:-http://sourceforge.net/adobe/cmap/wiki/License/+Adobe CMap resources are covered by their own copyright but the same license:++ Copyright 1990-2015 Adobe Systems Incorporated.++See https://github.com/adobe-type-tools/cmap-resources--><html dir="ltr" mozdisallowselectionprint moznomarginboxes><head>@@ -83,10 +86,10 @@ http://sourceforge.net/adobe/cmap/wiki/License/<span data-l10n-id="find_next_label">Next</span></button></div>- <input type="checkbox" id="findHighlightAll" class="toolbarField">- <label for="findHighlightAll" class="toolbarLabel" tabindex="94" data-l10n-id="find_highlight">Highlight all</label>- <input type="checkbox" id="findMatchCase" class="toolbarField">- <label for="findMatchCase" class="toolbarLabel" tabindex="95" data-l10n-id="find_match_case_label">Match case</label>+ <input type="checkbox" id="findHighlightAll" class="toolbarField" tabindex="94">+ <label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label>+ <input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">+ <label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label><span id="findMsg" class="toolbarLabel"></span></div> <!-- findbar -->@@ -184,7 +187,6 @@ http://sourceforge.net/adobe/cmap/wiki/License/<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="34" data-l10n-id="download"><span data-l10n-id="download_label">Download</span></button>- <!-- <div class="toolbarButtonSpacer"></div> --><a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="35" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>diff --git a/data/libs/pdfjs/web/viewer.js b/data/libs/pdfjs/web/viewer.jsindex 51f66f14b..b8c6ff82a 100644--- a/data/libs/pdfjs/web/viewer.js+++ b/data/libs/pdfjs/web/viewer.js@@ -15,14 +15,14 @@* limitations under the License.*//* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, ProgressBar,- DownloadManager, getFileName, scrollIntoView, getPDFFileNameFromURL,+ DownloadManager, getFileName, getPDFFileNameFromURL,PDFHistory, Preferences, SidebarView, ViewHistory, Stats,PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,- PasswordPrompt, PresentationMode, HandTool, Promise,- DocumentProperties, PDFOutlineView, PDFAttachmentView,- OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,- watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,- RenderingStates, DEFAULT_SCALE, UNKNOWN_SCALE,+ PasswordPrompt, PDFPresentationMode, PDFDocumentProperties, HandTool,+ Promise, PDFLinkService, PDFOutlineView, PDFAttachmentView,+ OverlayManager, PDFFindController, PDFFindBar, PDFViewer,+ PDFRenderingQueue, PresentationModeState, parseQueryString,+ RenderingStates, UNKNOWN_SCALE, DEFAULT_SCALE_VALUE,IGNORE_CURRENT_POSITION_ON_ZOOM: true */'use strict';@@ -46,7 +46,8 @@ var mozL10n = document.mozL10n || document.webL10n;var CSS_UNITS = 96.0 / 72.0;-var DEFAULT_SCALE = 'auto';+var DEFAULT_SCALE_VALUE = 'auto';+var DEFAULT_SCALE = 1.0;var UNKNOWN_SCALE = 0;var MAX_AUTO_SCALE = 1.25;var SCROLLBAR_PADDING = 40;@@ -208,6 +209,21 @@ function watchScroll(viewAreaElement, callback) {return state;}+/**+ * Helper function to parse query string (e.g. ?param1=value&parm2=...).+ */+function parseQueryString(query) {+ var parts = query.split('&');+ var params = {};+ for (var i = 0, ii = parts.length; i < ii; ++i) {+ var param = parts[i].split('=');+ var key = param[0].toLowerCase();+ var value = param.length > 1 ? param[1] : null;+ params[decodeURIComponent(key)] = decodeURIComponent(value);+ }+ return params;+}+/*** Use binary search to find the index of the first item in a given array which* passes a given condition. The items are expected to be sorted in the sense@@ -581,7 +597,6 @@ var Preferences = {};-Preferences._writeToStorage = function (prefObj) {return new Promise(function (resolve) {localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));@@ -662,7 +677,7 @@ Preferences._readFromStorage = function (prefObj) {function renderProgress() {var progressContainer = document.getElementById('mozPrintCallback-shim');- if (canvases) {+ if (canvases && canvases.length) {var progress = Math.round(100 * index / canvases.length);var progressBar = progressContainer.querySelector('progress');var progressPerc = progressContainer.querySelector('.relative-progress');@@ -819,7 +834,6 @@ var DownloadManager = (function DownloadManagerClosure() {* The way that the view parameters are stored depends on how PDF.js is built,* for 'node make <flag>' the following cases exist:* - FIREFOX or MOZCENTRAL - uses sessionStorage.- * - B2G - uses asyncStorage.* - GENERIC or CHROME - uses localStorage, if it is available.*/var ViewHistory = (function ViewHistoryClosure() {@@ -859,7 +873,6 @@ var ViewHistory = (function ViewHistoryClosure() {var databaseStr = JSON.stringify(this.database);-localStorage.setItem('database', databaseStr);resolve();}.bind(this));@@ -868,7 +881,6 @@ var ViewHistory = (function ViewHistoryClosure() {_readFromStorage: function ViewHistory_readFromStorage() {return new Promise(function (resolve) {-resolve(localStorage.getItem('database'));});},@@ -1435,368 +1447,674 @@ var PDFFindController = (function PDFFindControllerClosure() {})();-var PDFHistory = {- initialized: false,- initialDestination: null,-+/**+ * Performs navigation functions inside PDF, such as opening specified page,+ * or destination.+ * @class+ * @implements {IPDFLinkService}+ */+var PDFLinkService = (function () {/**- * @param {string} fingerprint- * @param {IPDFLinkService} linkService+ * @constructs PDFLinkService*/- initialize: function pdfHistoryInitialize(fingerprint, linkService) {- this.initialized = true;- this.reInitialized = false;- this.allowHashChange = true;- this.historyUnlocked = true;-- this.previousHash = window.location.hash.substring(1);- this.currentBookmark = '';- this.currentPage = 0;- this.updatePreviousBookmark = false;- this.previousBookmark = '';- this.previousPage = 0;- this.nextHashParam = '';+ function PDFLinkService() {+ this.baseUrl = null;+ this.pdfDocument = null;+ this.pdfViewer = null;+ this.pdfHistory = null;- this.fingerprint = fingerprint;- this.linkService = linkService;- this.currentUid = this.uid = 0;- this.current = {};+ this._pagesRefCache = null;+ }- var state = window.history.state;- if (this._isStateObjectDefined(state)) {- // This corresponds to navigating back to the document- // from another page in the browser history.- if (state.target.dest) {- this.initialDestination = state.target.dest;+ PDFLinkService.prototype = {+ setDocument: function PDFLinkService_setDocument(pdfDocument, baseUrl) {+ this.baseUrl = baseUrl;+ this.pdfDocument = pdfDocument;+ this._pagesRefCache = Object.create(null);+ },++ setViewer: function PDFLinkService_setViewer(pdfViewer) {+ this.pdfViewer = pdfViewer;+ },++ setHistory: function PDFLinkService_setHistory(pdfHistory) {+ this.pdfHistory = pdfHistory;+ },++ /**+ * @returns {number}+ */+ get pagesCount() {+ return this.pdfDocument.numPages;+ },++ /**+ * @returns {number}+ */+ get page() {+ return this.pdfViewer.currentPageNumber;+ },++ /**+ * @param {number} value+ */+ set page(value) {+ this.pdfViewer.currentPageNumber = value;+ },++ /**+ * @param dest - The PDF destination object.+ */+ navigateTo: function PDFLinkService_navigateTo(dest) {+ var destString = '';+ var self = this;++ var goToDestination = function(destRef) {+ // dest array looks like that: <page-ref> </XYZ|FitXXX> <args..>+ var pageNumber = destRef instanceof Object ?+ self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] :+ (destRef + 1);+ if (pageNumber) {+ if (pageNumber > self.pagesCount) {+ pageNumber = self.pagesCount;+ }+ self.pdfViewer.scrollPageIntoView(pageNumber, dest);++ if (self.pdfHistory) {+ // Update the browsing history.+ self.pdfHistory.push({+ dest: dest,+ hash: destString,+ page: pageNumber+ });+ }+ } else {+ self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {+ var pageNum = pageIndex + 1;+ var cacheKey = destRef.num + ' ' + destRef.gen + ' R';+ self._pagesRefCache[cacheKey] = pageNum;+ goToDestination(destRef);+ });+ }+ };++ var destinationPromise;+ if (typeof dest === 'string') {+ destString = dest;+ destinationPromise = this.pdfDocument.getDestination(dest);} else {- linkService.setHash(state.target.hash);+ destinationPromise = Promise.resolve(dest);}- this.currentUid = state.uid;- this.uid = state.uid + 1;- this.current = state.target;- } else {- // This corresponds to the loading of a new document.- if (state && state.fingerprint &&- this.fingerprint !== state.fingerprint) {- // Reinitialize the browsing history when a new document- // is opened in the web viewer.- this.reInitialized = true;+ destinationPromise.then(function(destination) {+ dest = destination;+ if (!(destination instanceof Array)) {+ return; // invalid destination+ }+ goToDestination(destination[0]);+ });+ },++ /**+ * @param dest - The PDF destination object.+ * @returns {string} The hyperlink to the PDF object.+ */+ getDestinationHash: function PDFLinkService_getDestinationHash(dest) {+ if (typeof dest === 'string') {+ return this.getAnchorUrl('#' + escape(dest));+ }+ if (dest instanceof Array) {+ var destRef = dest[0]; // see navigateTo method for dest format+ var pageNumber = destRef instanceof Object ?+ this._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] :+ (destRef + 1);+ if (pageNumber) {+ var pdfOpenParams = this.getAnchorUrl('#page=' + pageNumber);+ var destKind = dest[1];+ if (typeof destKind === 'object' && 'name' in destKind &&+ destKind.name === 'XYZ') {+ var scale = (dest[4] || this.pdfViewer.currentScaleValue);+ var scaleNumber = parseFloat(scale);+ if (scaleNumber) {+ scale = scaleNumber * 100;+ }+ pdfOpenParams += '&zoom=' + scale;+ if (dest[2] || dest[3]) {+ pdfOpenParams += ',' + (dest[2] || 0) + ',' + (dest[3] || 0);+ }+ }+ return pdfOpenParams;+ }}- this._pushOrReplaceState({ fingerprint: this.fingerprint }, true);- }+ return '';+ },- var self = this;- window.addEventListener('popstate', function pdfHistoryPopstate(evt) {- evt.preventDefault();- evt.stopPropagation();+ /**+ * Prefix the full url on anchor links to make sure that links are resolved+ * relative to the current URL instead of the one defined in <base href>.+ * @param {String} anchor The anchor hash, including the #.+ * @returns {string} The hyperlink to the PDF object.+ */+ getAnchorUrl: function PDFLinkService_getAnchorUrl(anchor) {+ return (this.baseUrl || '') + anchor;+ },- if (!self.historyUnlocked) {- return;- }- if (evt.state) {- // Move back/forward in the history.- self._goTo(evt.state);- } else {- // Handle the user modifying the hash of a loaded document.- self.previousHash = window.location.hash.substring(1);-- // If the history is empty when the hash changes,- // update the previous entry in the browser history.- if (self.uid === 0) {- var previousParams = (self.previousHash && self.currentBookmark &&- self.previousHash !== self.currentBookmark) ?- { hash: self.currentBookmark, page: self.currentPage } :- { page: 1 };- self.historyUnlocked = false;- self.allowHashChange = false;- window.history.back();- self._pushToHistory(previousParams, false, true);- window.history.forward();- self.historyUnlocked = true;+ /**+ * @param {string} hash+ */+ setHash: function PDFLinkService_setHash(hash) {+ if (hash.indexOf('=') >= 0) {+ var params = parseQueryString(hash);+ // borrowing syntax from "Parameters for Opening PDF Files"+ if ('nameddest' in params) {+ if (this.pdfHistory) {+ this.pdfHistory.updateNextHashParam(params.nameddest);+ }+ this.navigateTo(params.nameddest);+ return;+ }+ var pageNumber, dest;+ if ('page' in params) {+ pageNumber = (params.page | 0) || 1;+ }+ if ('zoom' in params) {+ // Build the destination array.+ var zoomArgs = params.zoom.split(','); // scale,left,top+ var zoomArg = zoomArgs[0];+ var zoomArgNumber = parseFloat(zoomArg);++ if (zoomArg.indexOf('Fit') === -1) {+ // If the zoomArg is a number, it has to get divided by 100. If it's+ // a string, it should stay as it is.+ dest = [null, { name: 'XYZ' },+ zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null,+ zoomArgs.length > 2 ? (zoomArgs[2] | 0) : null,+ (zoomArgNumber ? zoomArgNumber / 100 : zoomArg)];+ } else {+ if (zoomArg === 'Fit' || zoomArg === 'FitB') {+ dest = [null, { name: zoomArg }];+ } else if ((zoomArg === 'FitH' || zoomArg === 'FitBH') ||+ (zoomArg === 'FitV' || zoomArg === 'FitBV')) {+ dest = [null, { name: zoomArg },+ zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null];+ } else if (zoomArg === 'FitR') {+ if (zoomArgs.length !== 5) {+ console.error('PDFLinkService_setHash: ' ++ 'Not enough parameters for \'FitR\'.');+ } else {+ dest = [null, { name: zoomArg },+ (zoomArgs[1] | 0), (zoomArgs[2] | 0),+ (zoomArgs[3] | 0), (zoomArgs[4] | 0)];+ }+ } else {+ console.error('PDFLinkService_setHash: \'' + zoomArg ++ '\' is not a valid zoom value.');+ }+ }+ }+ if (dest) {+ this.pdfViewer.scrollPageIntoView(pageNumber || this.page, dest);+ } else if (pageNumber) {+ this.page = pageNumber; // simple page+ }+ if ('pagemode' in params) {+ if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks' ||+ params.pagemode === 'attachments') {+ this.switchSidebarView((params.pagemode === 'bookmarks' ?+ 'outline' : params.pagemode), true);+ } else if (params.pagemode === 'none' && this.sidebarOpen) {+ document.getElementById('sidebarToggle').click();+ }+ }+ } else if (/^\d+$/.test(hash)) { // page number+ this.page = hash;+ } else { // named destination+ if (this.pdfHistory) {+ this.pdfHistory.updateNextHashParam(unescape(hash));}- self._pushToHistory({ hash: self.previousHash }, false, true);- self._updatePreviousBookmark();+ this.navigateTo(unescape(hash));}- }, false);+ },++ /**+ * @param {string} action+ */+ executeNamedAction: function PDFLinkService_executeNamedAction(action) {+ // See PDF reference, table 8.45 - Named action+ switch (action) {+ case 'GoBack':+ if (this.pdfHistory) {+ this.pdfHistory.back();+ }+ break;++ case 'GoForward':+ if (this.pdfHistory) {+ this.pdfHistory.forward();+ }+ break;++ case 'NextPage':+ this.page++;+ break;++ case 'PrevPage':+ this.page--;+ break;++ case 'LastPage':+ this.page = this.pagesCount;+ break;++ case 'FirstPage':+ this.page = 1;+ break;- function pdfHistoryBeforeUnload() {- var previousParams = self._getPreviousParams(null, true);- if (previousParams) {- var replacePrevious = (!self.current.dest &&- self.current.hash !== self.previousHash);- self._pushToHistory(previousParams, false, replacePrevious);- self._updatePreviousBookmark();+ default:+ break; // No action according to spec}- // Remove the event listener when navigating away from the document,- // since 'beforeunload' prevents Firefox from caching the document.- window.removeEventListener('beforeunload', pdfHistoryBeforeUnload, false);++ var event = document.createEvent('CustomEvent');+ event.initCustomEvent('namedaction', true, true, {+ action: action+ });+ this.pdfViewer.container.dispatchEvent(event);+ },++ /**+ * @param {number} pageNum - page number.+ * @param {Object} pageRef - reference to the page.+ */+ cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) {+ var refStr = pageRef.num + ' ' + pageRef.gen + ' R';+ this._pagesRefCache[refStr] = pageNum;}- window.addEventListener('beforeunload', pdfHistoryBeforeUnload, false);+ };- window.addEventListener('pageshow', function pdfHistoryPageShow(evt) {- // If the entire viewer (including the PDF file) is cached in the browser,- // we need to reattach the 'beforeunload' event listener since- // the 'DOMContentLoaded' event is not fired on 'pageshow'.- window.addEventListener('beforeunload', pdfHistoryBeforeUnload, false);- }, false);- },+ return PDFLinkService;+})();- _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {- return (state && state.uid >= 0 &&- state.fingerprint && this.fingerprint === state.fingerprint &&- state.target && state.target.hash) ? true : false;- },- _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj,- replace) {- if (replace) {- window.history.replaceState(stateObj, '', document.URL);- } else {- window.history.pushState(stateObj, '', document.URL);- }- },+var PDFHistory = (function () {+ function PDFHistory(options) {+ this.linkService = options.linkService;- get isHashChangeUnlocked() {- if (!this.initialized) {- return true;- }- // If the current hash changes when moving back/forward in the history,- // this will trigger a 'popstate' event *as well* as a 'hashchange' event.- // Since the hash generally won't correspond to the exact the position- // stored in the history's state object, triggering the 'hashchange' event- // can thus corrupt the browser history.- //- // When the hash changes during a 'popstate' event, we *only* prevent the- // first 'hashchange' event and immediately reset allowHashChange.- // If it is not reset, the user would not be able to change the hash.-- var temp = this.allowHashChange;- this.allowHashChange = true;- return temp;- },+ this.initialized = false;+ this.initialDestination = null;+ this.initialBookmark = null;+ }- _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {- if (this.updatePreviousBookmark &&- this.currentBookmark && this.currentPage) {- this.previousBookmark = this.currentBookmark;- this.previousPage = this.currentPage;+ PDFHistory.prototype = {+ /**+ * @param {string} fingerprint+ * @param {IPDFLinkService} linkService+ */+ initialize: function pdfHistoryInitialize(fingerprint) {+ this.initialized = true;+ this.reInitialized = false;+ this.allowHashChange = true;+ this.historyUnlocked = true;+ this.isViewerInPresentationMode = false;++ this.previousHash = window.location.hash.substring(1);+ this.currentBookmark = '';+ this.currentPage = 0;this.updatePreviousBookmark = false;- }- },-- updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark,- pageNum) {- if (this.initialized) {- this.currentBookmark = bookmark.substring(1);- this.currentPage = pageNum | 0;- this._updatePreviousBookmark();- }- },+ this.previousBookmark = '';+ this.previousPage = 0;+ this.nextHashParam = '';- updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {- if (this.initialized) {- this.nextHashParam = param;- }- },+ this.fingerprint = fingerprint;+ this.currentUid = this.uid = 0;+ this.current = {};- push: function pdfHistoryPush(params, isInitialBookmark) {- if (!(this.initialized && this.historyUnlocked)) {- return;- }- if (params.dest && !params.hash) {- params.hash = (this.current.hash && this.current.dest &&- this.current.dest === params.dest) ?- this.current.hash :- this.linkService.getDestinationHash(params.dest).split('#')[1];- }- if (params.page) {- params.page |= 0;- }- if (isInitialBookmark) {- var target = window.history.state.target;- if (!target) {- // Invoked when the user specifies an initial bookmark,- // thus setting initialBookmark, when the document is loaded.- this._pushToHistory(params, false);- this.previousHash = window.location.hash.substring(1);- }- this.updatePreviousBookmark = this.nextHashParam ? false : true;- if (target) {- // If the current document is reloaded,- // avoid creating duplicate entries in the history.- this._updatePreviousBookmark();- }- return;- }- if (this.nextHashParam) {- if (this.nextHashParam === params.hash) {- this.nextHashParam = null;- this.updatePreviousBookmark = true;- return;+ var state = window.history.state;+ if (this._isStateObjectDefined(state)) {+ // This corresponds to navigating back to the document+ // from another page in the browser history.+ if (state.target.dest) {+ this.initialDestination = state.target.dest;+ } else {+ this.initialBookmark = state.target.hash;+ }+ this.currentUid = state.uid;+ this.uid = state.uid + 1;+ this.current = state.target;} else {- this.nextHashParam = null;+ // This corresponds to the loading of a new document.+ if (state && state.fingerprint &&+ this.fingerprint !== state.fingerprint) {+ // Reinitialize the browsing history when a new document+ // is opened in the web viewer.+ this.reInitialized = true;+ }+ this._pushOrReplaceState({fingerprint: this.fingerprint}, true);}- }- if (params.hash) {- if (this.current.hash) {- if (this.current.hash !== params.hash) {- this._pushToHistory(params, true);+ var self = this;+ window.addEventListener('popstate', function pdfHistoryPopstate(evt) {+ evt.preventDefault();+ evt.stopPropagation();++ if (!self.historyUnlocked) {+ return;+ }+ if (evt.state) {+ // Move back/forward in the history.+ self._goTo(evt.state);} else {- if (!this.current.page && params.page) {- this._pushToHistory(params, false, true);+ // Handle the user modifying the hash of a loaded document.+ self.previousHash = window.location.hash.substring(1);++ // If the history is empty when the hash changes,+ // update the previous entry in the browser history.+ if (self.uid === 0) {+ var previousParams = (self.previousHash && self.currentBookmark &&+ self.previousHash !== self.currentBookmark) ?+ {hash: self.currentBookmark, page: self.currentPage} :+ {page: 1};+ self.historyUnlocked = false;+ self.allowHashChange = false;+ window.history.back();+ self._pushToHistory(previousParams, false, true);+ window.history.forward();+ self.historyUnlocked = true;}- this.updatePreviousBookmark = true;+ self._pushToHistory({hash: self.previousHash}, false, true);+ self._updatePreviousBookmark();}- } else {- this._pushToHistory(params, true);- }- } else if (this.current.page && params.page &&- this.current.page !== params.page) {- this._pushToHistory(params, true);- }- },-- _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage,- beforeUnload) {- if (!(this.currentBookmark && this.currentPage)) {- return null;- } else if (this.updatePreviousBookmark) {- this.updatePreviousBookmark = false;- }- if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {- // Prevent the history from getting stuck in the current state,- // effectively preventing the user from going back/forward in the history.- //- // This happens if the current position in the document didn't change when- // the history was previously updated. The reasons for this are either:- // 1. The current zoom value is such that the document does not need to,- // or cannot, be scrolled to display the destination.- // 2. The previous destination is broken, and doesn't actally point to a- // position within the document.- // (This is either due to a bad PDF generator, or the user making a- // mistake when entering a destination in the hash parameters.)- return null;- }- if ((!this.current.dest && !onlyCheckPage) || beforeUnload) {- if (this.previousBookmark === this.currentBookmark) {- return null;- }- } else if (this.current.page || onlyCheckPage) {- if (this.previousPage === this.currentPage) {- return null;+ }, false);++ function pdfHistoryBeforeUnload() {+ var previousParams = self._getPreviousParams(null, true);+ if (previousParams) {+ var replacePrevious = (!self.current.dest &&+ self.current.hash !== self.previousHash);+ self._pushToHistory(previousParams, false, replacePrevious);+ self._updatePreviousBookmark();+ }+ // Remove the event listener when navigating away from the document,+ // since 'beforeunload' prevents Firefox from caching the document.+ window.removeEventListener('beforeunload', pdfHistoryBeforeUnload,+ false);}- } else {- return null;- }- var params = { hash: this.currentBookmark, page: this.currentPage };- if (PresentationMode.active) {- params.hash = null;- }- return params;- },- _stateObj: function pdfHistory_stateObj(params) {- return { fingerprint: this.fingerprint, uid: this.uid, target: params };- },+ window.addEventListener('beforeunload', pdfHistoryBeforeUnload, false);- _pushToHistory: function pdfHistory_pushToHistory(params,- addPrevious, overwrite) {- if (!this.initialized) {- return;- }- if (!params.hash && params.page) {- params.hash = ('page=' + params.page);- }- if (addPrevious && !overwrite) {- var previousParams = this._getPreviousParams();- if (previousParams) {- var replacePrevious = (!this.current.dest &&- this.current.hash !== this.previousHash);- this._pushToHistory(previousParams, false, replacePrevious);- }- }- this._pushOrReplaceState(this._stateObj(params),- (overwrite || this.uid === 0));- this.currentUid = this.uid++;- this.current = params;- this.updatePreviousBookmark = true;- },+ window.addEventListener('pageshow', function pdfHistoryPageShow(evt) {+ // If the entire viewer (including the PDF file) is cached in+ // the browser, we need to reattach the 'beforeunload' event listener+ // since the 'DOMContentLoaded' event is not fired on 'pageshow'.+ window.addEventListener('beforeunload', pdfHistoryBeforeUnload, false);+ }, false);- _goTo: function pdfHistory_goTo(state) {- if (!(this.initialized && this.historyUnlocked &&- this._isStateObjectDefined(state))) {- return;- }- if (!this.reInitialized && state.uid < this.currentUid) {- var previousParams = this._getPreviousParams(true);- if (previousParams) {- this._pushToHistory(this.current, false);- this._pushToHistory(previousParams, false);- this.currentUid = state.uid;- window.history.back();- return;- }- }- this.historyUnlocked = false;+ window.addEventListener('presentationmodechanged', function(e) {+ self.isViewerInPresentationMode = !!e.detail.active;+ });+ },- if (state.target.dest) {- this.linkService.navigateTo(state.target.dest);- } else {- this.linkService.setHash(state.target.hash);- }- this.currentUid = state.uid;- if (state.uid > this.uid) {- this.uid = state.uid;- }- this.current = state.target;- this.updatePreviousBookmark = true;+ clearHistoryState: function pdfHistory_clearHistoryState() {+ this._pushOrReplaceState(null, true);+ },- var currentHash = window.location.hash.substring(1);- if (this.previousHash !== currentHash) {- this.allowHashChange = false;- }- this.previousHash = currentHash;+ _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {+ return (state && state.uid >= 0 &&+ state.fingerprint && this.fingerprint === state.fingerprint &&+ state.target && state.target.hash) ? true : false;+ },- this.historyUnlocked = true;- },+ _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj,+ replace) {+ if (replace) {+ window.history.replaceState(stateObj, '', document.URL);+ } else {+ window.history.pushState(stateObj, '', document.URL);+ }+ },- back: function pdfHistoryBack() {- this.go(-1);- },+ get isHashChangeUnlocked() {+ if (!this.initialized) {+ return true;+ }+ // If the current hash changes when moving back/forward in the history,+ // this will trigger a 'popstate' event *as well* as a 'hashchange' event.+ // Since the hash generally won't correspond to the exact the position+ // stored in the history's state object, triggering the 'hashchange' event+ // can thus corrupt the browser history.+ //+ // When the hash changes during a 'popstate' event, we *only* prevent the+ // first 'hashchange' event and immediately reset allowHashChange.+ // If it is not reset, the user would not be able to change the hash.- forward: function pdfHistoryForward() {- this.go(1);- },+ var temp = this.allowHashChange;+ this.allowHashChange = true;+ return temp;+ },- go: function pdfHistoryGo(direction) {- if (this.initialized && this.historyUnlocked) {- var state = window.history.state;- if (direction === -1 && state && state.uid > 0) {- window.history.back();- } else if (direction === 1 && state && state.uid < (this.uid - 1)) {- window.history.forward();+ _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {+ if (this.updatePreviousBookmark &&+ this.currentBookmark && this.currentPage) {+ this.previousBookmark = this.currentBookmark;+ this.previousPage = this.currentPage;+ this.updatePreviousBookmark = false;}- }- }-};-+ },-var SecondaryToolbar = {- opened: false,- previousContainerHeight: null,- newContainerHeight: null,+ updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark,+ pageNum) {+ if (this.initialized) {+ this.currentBookmark = bookmark.substring(1);+ this.currentPage = pageNum | 0;+ this._updatePreviousBookmark();+ }+ },- initialize: function secondaryToolbarInitialize(options) {- this.toolbar = options.toolbar;- this.presentationMode = options.presentationMode;- this.documentProperties = options.documentProperties;- this.buttonContainer = this.toolbar.firstElementChild;+ updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {+ if (this.initialized) {+ this.nextHashParam = param;+ }+ },- // Define the toolbar buttons.- this.toggleButton = options.toggleButton;- this.presentationModeButton = options.presentationModeButton;- this.openFile = options.openFile;+ push: function pdfHistoryPush(params, isInitialBookmark) {+ if (!(this.initialized && this.historyUnlocked)) {+ return;+ }+ if (params.dest && !params.hash) {+ params.hash = (this.current.hash && this.current.dest &&+ this.current.dest === params.dest) ?+ this.current.hash :+ this.linkService.getDestinationHash(params.dest).split('#')[1];+ }+ if (params.page) {+ params.page |= 0;+ }+ if (isInitialBookmark) {+ var target = window.history.state.target;+ if (!target) {+ // Invoked when the user specifies an initial bookmark,+ // thus setting initialBookmark, when the document is loaded.+ this._pushToHistory(params, false);+ this.previousHash = window.location.hash.substring(1);+ }+ this.updatePreviousBookmark = this.nextHashParam ? false : true;+ if (target) {+ // If the current document is reloaded,+ // avoid creating duplicate entries in the history.+ this._updatePreviousBookmark();+ }+ return;+ }+ if (this.nextHashParam) {+ if (this.nextHashParam === params.hash) {+ this.nextHashParam = null;+ this.updatePreviousBookmark = true;+ return;+ } else {+ this.nextHashParam = null;+ }+ }++ if (params.hash) {+ if (this.current.hash) {+ if (this.current.hash !== params.hash) {+ this._pushToHistory(params, true);+ } else {+ if (!this.current.page && params.page) {+ this._pushToHistory(params, false, true);+ }+ this.updatePreviousBookmark = true;+ }+ } else {+ this._pushToHistory(params, true);+ }+ } else if (this.current.page && params.page &&+ this.current.page !== params.page) {+ this._pushToHistory(params, true);+ }+ },++ _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage,+ beforeUnload) {+ if (!(this.currentBookmark && this.currentPage)) {+ return null;+ } else if (this.updatePreviousBookmark) {+ this.updatePreviousBookmark = false;+ }+ if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {+ // Prevent the history from getting stuck in the current state,+ // effectively preventing the user from going back/forward in+ // the history.+ //+ // This happens if the current position in the document didn't change+ // when the history was previously updated. The reasons for this are+ // either:+ // 1. The current zoom value is such that the document does not need to,+ // or cannot, be scrolled to display the destination.+ // 2. The previous destination is broken, and doesn't actally point to a+ // position within the document.+ // (This is either due to a bad PDF generator, or the user making a+ // mistake when entering a destination in the hash parameters.)+ return null;+ }+ if ((!this.current.dest && !onlyCheckPage) || beforeUnload) {+ if (this.previousBookmark === this.currentBookmark) {+ return null;+ }+ } else if (this.current.page || onlyCheckPage) {+ if (this.previousPage === this.currentPage) {+ return null;+ }+ } else {+ return null;+ }+ var params = {hash: this.currentBookmark, page: this.currentPage};+ if (this.isViewerInPresentationMode) {+ params.hash = null;+ }+ return params;+ },++ _stateObj: function pdfHistory_stateObj(params) {+ return {fingerprint: this.fingerprint, uid: this.uid, target: params};+ },++ _pushToHistory: function pdfHistory_pushToHistory(params,+ addPrevious, overwrite) {+ if (!this.initialized) {+ return;+ }+ if (!params.hash && params.page) {+ params.hash = ('page=' + params.page);+ }+ if (addPrevious && !overwrite) {+ var previousParams = this._getPreviousParams();+ if (previousParams) {+ var replacePrevious = (!this.current.dest &&+ this.current.hash !== this.previousHash);+ this._pushToHistory(previousParams, false, replacePrevious);+ }+ }+ this._pushOrReplaceState(this._stateObj(params),+ (overwrite || this.uid === 0));+ this.currentUid = this.uid++;+ this.current = params;+ this.updatePreviousBookmark = true;+ },++ _goTo: function pdfHistory_goTo(state) {+ if (!(this.initialized && this.historyUnlocked &&+ this._isStateObjectDefined(state))) {+ return;+ }+ if (!this.reInitialized && state.uid < this.currentUid) {+ var previousParams = this._getPreviousParams(true);+ if (previousParams) {+ this._pushToHistory(this.current, false);+ this._pushToHistory(previousParams, false);+ this.currentUid = state.uid;+ window.history.back();+ return;+ }+ }+ this.historyUnlocked = false;++ if (state.target.dest) {+ this.linkService.navigateTo(state.target.dest);+ } else {+ this.linkService.setHash(state.target.hash);+ }+ this.currentUid = state.uid;+ if (state.uid > this.uid) {+ this.uid = state.uid;+ }+ this.current = state.target;+ this.updatePreviousBookmark = true;++ var currentHash = window.location.hash.substring(1);+ if (this.previousHash !== currentHash) {+ this.allowHashChange = false;+ }+ this.previousHash = currentHash;++ this.historyUnlocked = true;+ },++ back: function pdfHistoryBack() {+ this.go(-1);+ },++ forward: function pdfHistoryForward() {+ this.go(1);+ },++ go: function pdfHistoryGo(direction) {+ if (this.initialized && this.historyUnlocked) {+ var state = window.history.state;+ if (direction === -1 && state && state.uid > 0) {+ window.history.back();+ } else if (direction === 1 && state && state.uid < (this.uid - 1)) {+ window.history.forward();+ }+ }+ }+ };++ return PDFHistory;+})();+++var SecondaryToolbar = {+ opened: false,+ previousContainerHeight: null,+ newContainerHeight: null,++ initialize: function secondaryToolbarInitialize(options) {+ this.toolbar = options.toolbar;+ this.buttonContainer = this.toolbar.firstElementChild;++ // Define the toolbar buttons.+ this.toggleButton = options.toggleButton;+ this.presentationModeButton = options.presentationModeButton;+ this.openFile = options.openFile;this.print = options.print;this.download = options.download;this.viewBookmark = options.viewBookmark;@@ -1836,7 +2154,7 @@ var SecondaryToolbar = {// Event handling functions.presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {- this.presentationMode.request();+ PDFViewerApplication.requestPresentationMode();this.close();},@@ -1880,7 +2198,7 @@ var SecondaryToolbar = {},documentPropertiesClick: function secondaryToolbarDocumentPropsClick(evt) {- this.documentProperties.open();+ PDFViewerApplication.pdfDocumentProperties.open();this.close();},@@ -1928,249 +2246,382 @@ var SecondaryToolbar = {};+var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; // in msvar DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms-var SELECTOR = 'presentationControls';-var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1000; // in ms+var ACTIVE_SELECTOR = 'pdfPresentationMode';+var CONTROLS_SELECTOR = 'pdfPresentationModeControls';-var PresentationMode = {- active: false,- args: null,- contextMenuOpen: false,- prevCoords: { x: null, y: null },+/**+ * @typedef {Object} PDFPresentationModeOptions+ * @property {HTMLDivElement} container - The container for the viewer element.+ * @property {HTMLDivElement} viewer - (optional) The viewer element.+ * @property {PDFViewer} pdfViewer - The document viewer.+ * @property {PDFThumbnailViewer} pdfThumbnailViewer - (optional) The thumbnail+ * viewer.+ * @property {Array} contextMenuItems - (optional) The menuitems that are added+ * to the context menu in Presentation Mode.+ */- initialize: function presentationModeInitialize(options) {+/**+ * @class+ */+var PDFPresentationMode = (function PDFPresentationModeClosure() {+ /**+ * @constructs PDFPresentationMode+ * @param {PDFPresentationModeOptions} options+ */+ function PDFPresentationMode(options) {this.container = options.container;- this.secondaryToolbar = options.secondaryToolbar;+ this.viewer = options.viewer || options.container.firstElementChild;+ this.pdfViewer = options.pdfViewer;+ this.pdfThumbnailViewer = options.pdfThumbnailViewer || null;+ var contextMenuItems = options.contextMenuItems || null;- this.viewer = this.container.firstElementChild;+ this.active = false;+ this.args = null;+ this.contextMenuOpen = false;+ this.mouseScrollTimeStamp = 0;+ this.mouseScrollDelta = 0;- this.firstPage = options.firstPage;- this.lastPage = options.lastPage;- this.pageRotateCw = options.pageRotateCw;- this.pageRotateCcw = options.pageRotateCcw;+ if (contextMenuItems) {+ for (var i = 0, ii = contextMenuItems.length; i < ii; i++) {+ var item = contextMenuItems[i];+ item.element.addEventListener('click', function (handler) {+ this.contextMenuOpen = false;+ handler();+ }.bind(this, item.handler));+ }+ }+ }- this.firstPage.addEventListener('click', function() {- this.contextMenuOpen = false;- this.secondaryToolbar.firstPageClick();- }.bind(this));- this.lastPage.addEventListener('click', function() {- this.contextMenuOpen = false;- this.secondaryToolbar.lastPageClick();- }.bind(this));+ PDFPresentationMode.prototype = {+ /**+ * Request the browser to enter fullscreen mode.+ * @returns {boolean} Indicating if the request was successful.+ */+ request: function PDFPresentationMode_request() {+ if (this.switchInProgress || this.active ||+ !this.viewer.hasChildNodes()) {+ return false;+ }+ this._addFullscreenChangeListeners();+ this._setSwitchInProgress();+ this._notifyStateChange();- this.pageRotateCw.addEventListener('click', function() {- this.contextMenuOpen = false;- this.secondaryToolbar.pageRotateCwClick();- }.bind(this));- this.pageRotateCcw.addEventListener('click', function() {- this.contextMenuOpen = false;- this.secondaryToolbar.pageRotateCcwClick();- }.bind(this));- },+ if (this.container.requestFullscreen) {+ this.container.requestFullscreen();+ } else if (this.container.mozRequestFullScreen) {+ this.container.mozRequestFullScreen();+ } else if (this.container.webkitRequestFullscreen) {+ this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);+ } else if (this.container.msRequestFullscreen) {+ this.container.msRequestFullscreen();+ } else {+ return false;+ }- get isFullscreen() {- return (document.fullscreenElement ||- document.mozFullScreen ||- document.webkitIsFullScreen ||- document.msFullscreenElement);- },+ this.args = {+ page: this.pdfViewer.currentPageNumber,+ previousScale: this.pdfViewer.currentScaleValue,+ };- /**- * Initialize a timeout that is used to specify switchInProgress when the- * browser transitions to fullscreen mode. Since resize events are triggered- * multiple times during the switch to fullscreen mode, this is necessary in- * order to prevent the page from being scrolled partially, or completely,- * out of view when Presentation Mode is enabled.- * Note: This is only an issue at certain zoom levels, e.g. 'page-width'.- */- _setSwitchInProgress: function presentationMode_setSwitchInProgress() {- if (this.switchInProgress) {- clearTimeout(this.switchInProgress);- }- this.switchInProgress = setTimeout(function switchInProgressTimeout() {- delete this.switchInProgress;- this._notifyStateChange();- }.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);- },+ return true;+ },- _resetSwitchInProgress: function presentationMode_resetSwitchInProgress() {- if (this.switchInProgress) {- clearTimeout(this.switchInProgress);- delete this.switchInProgress;- }- },+ /**+ * Switches page when the user scrolls (using a scroll wheel or a touchpad)+ * with large enough motion, to prevent accidental page switches.+ * @param {number} delta - The delta value from the mouse event.+ */+ mouseScroll: function PDFPresentationMode_mouseScroll(delta) {+ if (!this.active) {+ return;+ }+ var MOUSE_SCROLL_COOLDOWN_TIME = 50;+ var PAGE_SWITCH_THRESHOLD = 120;+ var PageSwitchDirection = {+ UP: -1,+ DOWN: 1+ };- request: function presentationModeRequest() {- if (!PDFViewerApplication.supportsFullscreen || this.isFullscreen ||- !this.viewer.hasChildNodes()) {- return false;- }- this._setSwitchInProgress();- this._notifyStateChange();-- if (this.container.requestFullscreen) {- this.container.requestFullscreen();- } else if (this.container.mozRequestFullScreen) {- this.container.mozRequestFullScreen();- } else if (this.container.webkitRequestFullscreen) {- this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);- } else if (this.container.msRequestFullscreen) {- this.container.msRequestFullscreen();- } else {- return false;- }+ var currentTime = (new Date()).getTime();+ var storedTime = this.mouseScrollTimeStamp;- this.args = {- page: PDFViewerApplication.page,- previousScale: PDFViewerApplication.currentScaleValue- };+ // If we've already switched page, avoid accidentally switching again.+ if (currentTime > storedTime &&+ currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {+ return;+ }+ // If the scroll direction changed, reset the accumulated scroll delta.+ if ((this.mouseScrollDelta > 0 && delta < 0) ||+ (this.mouseScrollDelta < 0 && delta > 0)) {+ this._resetMouseScrollState();+ }+ this.mouseScrollDelta += delta;- return true;- },+ if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {+ var pageSwitchDirection = (this.mouseScrollDelta > 0) ?+ PageSwitchDirection.UP : PageSwitchDirection.DOWN;+ var page = this.pdfViewer.currentPageNumber;+ this._resetMouseScrollState();- _notifyStateChange: function presentationModeNotifyStateChange() {- var event = document.createEvent('CustomEvent');- event.initCustomEvent('presentationmodechanged', true, true, {- active: PresentationMode.active,- switchInProgress: !!PresentationMode.switchInProgress- });- window.dispatchEvent(event);- },+ // If we're at the first/last page, we don't need to do anything.+ if ((page === 1 && pageSwitchDirection === PageSwitchDirection.UP) ||+ (page === this.pdfViewer.pagesCount &&+ pageSwitchDirection === PageSwitchDirection.DOWN)) {+ return;+ }+ this.pdfViewer.currentPageNumber = (page + pageSwitchDirection);+ this.mouseScrollTimeStamp = currentTime;+ }+ },- enter: function presentationModeEnter() {- this.active = true;- this._resetSwitchInProgress();- this._notifyStateChange();-- // Ensure that the correct page is scrolled into view when entering- // Presentation Mode, by waiting until fullscreen mode in enabled.- // Note: This is only necessary in non-Mozilla browsers.- setTimeout(function enterPresentationModeTimeout() {- PDFViewerApplication.page = this.args.page;- PDFViewerApplication.setScale('page-fit', true);- }.bind(this), 0);-- window.addEventListener('mousemove', this.mouseMove, false);- window.addEventListener('mousedown', this.mouseDown, false);- window.addEventListener('contextmenu', this.contextMenu, false);-- this.showControls();- HandTool.enterPresentationMode();- this.contextMenuOpen = false;- this.container.setAttribute('contextmenu', 'viewerContextMenu');+ get isFullscreen() {+ return !!(document.fullscreenElement ||+ document.mozFullScreen ||+ document.webkitIsFullScreen ||+ document.msFullscreenElement);+ },- // Text selection is disabled in Presentation Mode, thus it's not possible- // for the user to deselect text that is selected (e.g. with "Select all")- // when entering Presentation Mode, hence we remove any active selection.- window.getSelection().removeAllRanges();- },+ /**+ * @private+ */+ _notifyStateChange: function PDFPresentationMode_notifyStateChange() {+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent('presentationmodechanged', true, true, {+ active: this.active,+ switchInProgress: !!this.switchInProgress+ });+ window.dispatchEvent(event);+ },++ /**+ * Used to initialize a timeout when requesting Presentation Mode,+ * i.e. when the browser is requested to enter fullscreen mode.+ * This timeout is used to prevent the current page from being scrolled+ * partially, or completely, out of view when entering Presentation Mode.+ * NOTE: This issue seems limited to certain zoom levels (e.g. page-width).+ * @private+ */+ _setSwitchInProgress: function PDFPresentationMode_setSwitchInProgress() {+ if (this.switchInProgress) {+ clearTimeout(this.switchInProgress);+ }+ this.switchInProgress = setTimeout(function switchInProgressTimeout() {+ this._removeFullscreenChangeListeners();+ delete this.switchInProgress;+ this._notifyStateChange();+ }.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);+ },- exit: function presentationModeExit() {- var page = PDFViewerApplication.page;+ /**+ * @private+ */+ _resetSwitchInProgress:+ function PDFPresentationMode_resetSwitchInProgress() {+ if (this.switchInProgress) {+ clearTimeout(this.switchInProgress);+ delete this.switchInProgress;+ }+ },- // Ensure that the correct page is scrolled into view when exiting- // Presentation Mode, by waiting until fullscreen mode is disabled.- // Note: This is only necessary in non-Mozilla browsers.- setTimeout(function exitPresentationModeTimeout() {- this.active = false;+ /**+ * @private+ */+ _enter: function PDFPresentationMode_enter() {+ this.active = true;+ this._resetSwitchInProgress();this._notifyStateChange();+ this.container.classList.add(ACTIVE_SELECTOR);- PDFViewerApplication.setScale(this.args.previousScale, true);- PDFViewerApplication.page = page;- this.args = null;- }.bind(this), 0);+ // Ensure that the correct page is scrolled into view when entering+ // Presentation Mode, by waiting until fullscreen mode in enabled.+ setTimeout(function enterPresentationModeTimeout() {+ this.pdfViewer.currentPageNumber = this.args.page;+ this.pdfViewer.currentScaleValue = 'page-fit';+ }.bind(this), 0);- window.removeEventListener('mousemove', this.mouseMove, false);- window.removeEventListener('mousedown', this.mouseDown, false);- window.removeEventListener('contextmenu', this.contextMenu, false);+ this._addWindowListeners();+ this._showControls();+ this.contextMenuOpen = false;+ this.container.setAttribute('contextmenu', 'viewerContextMenu');- this.hideControls();- PDFViewerApplication.clearMouseScrollState();- HandTool.exitPresentationMode();- this.container.removeAttribute('contextmenu');- this.contextMenuOpen = false;+ // Text selection is disabled in Presentation Mode, thus it's not possible+ // for the user to deselect text that is selected (e.g. with "Select all")+ // when entering Presentation Mode, hence we remove any active selection.+ window.getSelection().removeAllRanges();+ },- // Ensure that the thumbnail of the current page is visible- // when exiting presentation mode.- scrollIntoView(document.getElementById('thumbnailContainer' + page));- },+ /**+ * @private+ */+ _exit: function PDFPresentationMode_exit() {+ var page = this.pdfViewer.currentPageNumber;+ this.container.classList.remove(ACTIVE_SELECTOR);- showControls: function presentationModeShowControls() {- if (this.controlsTimeout) {- clearTimeout(this.controlsTimeout);- } else {- this.container.classList.add(SELECTOR);- }- this.controlsTimeout = setTimeout(function hideControlsTimeout() {- this.container.classList.remove(SELECTOR);- delete this.controlsTimeout;- }.bind(this), DELAY_BEFORE_HIDING_CONTROLS);- },+ // Ensure that the correct page is scrolled into view when exiting+ // Presentation Mode, by waiting until fullscreen mode is disabled.+ setTimeout(function exitPresentationModeTimeout() {+ this.active = false;+ this._removeFullscreenChangeListeners();+ this._notifyStateChange();++ this.pdfViewer.currentScaleValue = this.args.previousScale;+ this.pdfViewer.currentPageNumber = page;+ this.args = null;+ }.bind(this), 0);++ this._removeWindowListeners();+ this._hideControls();+ this._resetMouseScrollState();+ this.container.removeAttribute('contextmenu');+ this.contextMenuOpen = false;- hideControls: function presentationModeHideControls() {- if (!this.controlsTimeout) {- return;- }- this.container.classList.remove(SELECTOR);- clearTimeout(this.controlsTimeout);- delete this.controlsTimeout;- },+ if (this.pdfThumbnailViewer) {+ this.pdfThumbnailViewer.ensureThumbnailVisible(page);+ }+ },- mouseMove: function presentationModeMouseMove(evt) {- // Workaround for a bug in WebKit browsers that causes the 'mousemove' event- // to be fired when the cursor is changed. For details, see:- // http://code.google.com/p/chromium/issues/detail?id=103041.+ /**+ * @private+ */+ _mouseDown: function PDFPresentationMode_mouseDown(evt) {+ if (this.contextMenuOpen) {+ this.contextMenuOpen = false;+ evt.preventDefault();+ return;+ }+ if (evt.button === 0) {+ // Enable clicking of links in presentation mode. Please note:+ // Only links pointing to destinations in the current PDF document work.+ var isInternalLink = (evt.target.href &&+ evt.target.classList.contains('internalLink'));+ if (!isInternalLink) {+ // Unless an internal link was clicked, advance one page.+ evt.preventDefault();+ this.pdfViewer.currentPageNumber += (evt.shiftKey ? -1 : 1);+ }+ }+ },- var currCoords = { x: evt.clientX, y: evt.clientY };- var prevCoords = PresentationMode.prevCoords;- PresentationMode.prevCoords = currCoords;+ /**+ * @private+ */+ _contextMenu: function PDFPresentationMode_contextMenu() {+ this.contextMenuOpen = true;+ },- if (currCoords.x === prevCoords.x && currCoords.y === prevCoords.y) {- return;- }- PresentationMode.showControls();- },+ /**+ * @private+ */+ _showControls: function PDFPresentationMode_showControls() {+ if (this.controlsTimeout) {+ clearTimeout(this.controlsTimeout);+ } else {+ this.container.classList.add(CONTROLS_SELECTOR);+ }+ this.controlsTimeout = setTimeout(function showControlsTimeout() {+ this.container.classList.remove(CONTROLS_SELECTOR);+ delete this.controlsTimeout;+ }.bind(this), DELAY_BEFORE_HIDING_CONTROLS);+ },- mouseDown: function presentationModeMouseDown(evt) {- var self = PresentationMode;- if (self.contextMenuOpen) {- self.contextMenuOpen = false;- evt.preventDefault();- return;- }+ /**+ * @private+ */+ _hideControls: function PDFPresentationMode_hideControls() {+ if (!this.controlsTimeout) {+ return;+ }+ clearTimeout(this.controlsTimeout);+ this.container.classList.remove(CONTROLS_SELECTOR);+ delete this.controlsTimeout;+ },- if (evt.button === 0) {- // Enable clicking of links in presentation mode. Please note:- // Only links pointing to destinations in the current PDF document work.- var isInternalLink = (evt.target.href &&- evt.target.classList.contains('internalLink'));- if (!isInternalLink) {- // Unless an internal link was clicked, advance one page.- evt.preventDefault();- PDFViewerApplication.page += (evt.shiftKey ? -1 : 1);+ /**+ * Resets the properties used for tracking mouse scrolling events.+ * @private+ */+ _resetMouseScrollState:+ function PDFPresentationMode_resetMouseScrollState() {+ this.mouseScrollTimeStamp = 0;+ this.mouseScrollDelta = 0;+ },++ /**+ * @private+ */+ _addWindowListeners: function PDFPresentationMode_addWindowListeners() {+ this.showControlsBind = this._showControls.bind(this);+ this.mouseDownBind = this._mouseDown.bind(this);+ this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);+ this.contextMenuBind = this._contextMenu.bind(this);++ window.addEventListener('mousemove', this.showControlsBind);+ window.addEventListener('mousedown', this.mouseDownBind);+ window.addEventListener('keydown', this.resetMouseScrollStateBind);+ window.addEventListener('contextmenu', this.contextMenuBind);+ },++ /**+ * @private+ */+ _removeWindowListeners:+ function PDFPresentationMode_removeWindowListeners() {+ window.removeEventListener('mousemove', this.showControlsBind);+ window.removeEventListener('mousedown', this.mouseDownBind);+ window.removeEventListener('keydown', this.resetMouseScrollStateBind);+ window.removeEventListener('contextmenu', this.contextMenuBind);++ delete this.showControlsBind;+ delete this.mouseDownBind;+ delete this.resetMouseScrollStateBind;+ delete this.contextMenuBind;+ },++ /**+ * @private+ */+ _fullscreenChange: function PDFPresentationMode_fullscreenChange() {+ if (this.isFullscreen) {+ this._enter();+ } else {+ this._exit();}- }- },+ },- contextMenu: function presentationModeContextMenu(evt) {- PresentationMode.contextMenuOpen = true;- }-};+ /**+ * @private+ */+ _addFullscreenChangeListeners:+ function PDFPresentationMode_addFullscreenChangeListeners() {+ this.fullscreenChangeBind = this._fullscreenChange.bind(this);++ window.addEventListener('fullscreenchange', this.fullscreenChangeBind);+ window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);+ window.addEventListener('webkitfullscreenchange',+ this.fullscreenChangeBind);+ window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);+ },-(function presentationModeClosure() {- function presentationModeChange(e) {- if (PresentationMode.isFullscreen) {- PresentationMode.enter();- } else {- PresentationMode.exit();+ /**+ * @private+ */+ _removeFullscreenChangeListeners:+ function PDFPresentationMode_removeFullscreenChangeListeners() {+ window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);+ window.removeEventListener('mozfullscreenchange',+ this.fullscreenChangeBind);+ window.removeEventListener('webkitfullscreenchange',+ this.fullscreenChangeBind);+ window.removeEventListener('MSFullscreenChange',+ this.fullscreenChangeBind);++ delete this.fullscreenChangeBind;}- }+ };- window.addEventListener('fullscreenchange', presentationModeChange, false);- window.addEventListener('mozfullscreenchange', presentationModeChange, false);- window.addEventListener('webkitfullscreenchange', presentationModeChange,- false);- window.addEventListener('MSFullscreenChange', presentationModeChange, false);+ return PDFPresentationMode;})();@@ -2428,6 +2879,17 @@ var HandTool = {}}.bind(this), function rejected(reason) {});}.bind(this));++ window.addEventListener('presentationmodechanged', function (evt) {+ if (evt.detail.switchInProgress) {+ return;+ }+ if (evt.detail.active) {+ this.enterPresentationMode();+ } else {+ this.exitPresentationMode();+ }+ }.bind(this));}},@@ -2643,42 +3105,28 @@ var PasswordPrompt = {};-var DocumentProperties = {- overlayName: null,- rawFileSize: 0,-- // Document property fields (in the viewer).- fileNameField: null,- fileSizeField: null,- titleField: null,- authorField: null,- subjectField: null,- keywordsField: null,- creationDateField: null,- modificationDateField: null,- creatorField: null,- producerField: null,- versionField: null,- pageCountField: null,- url: null,- pdfDocument: null,+/**+ * @typedef {Object} PDFDocumentPropertiesOptions+ * @property {string} overlayName - Name/identifier for the overlay.+ * @property {Object} fields - Names and elements of the overlay's fields.+ * @property {HTMLButtonElement} closeButton - Button for closing the overlay.+ */- initialize: function documentPropertiesInitialize(options) {+/**+ * @class+ */+var PDFDocumentProperties = (function PDFDocumentPropertiesClosure() {+ /**+ * @constructs PDFDocumentProperties+ * @param {PDFDocumentPropertiesOptions} options+ */+ function PDFDocumentProperties(options) {+ this.fields = options.fields;this.overlayName = options.overlayName;- // Set the document property fields.- this.fileNameField = options.fileNameField;- this.fileSizeField = options.fileSizeField;- this.titleField = options.titleField;- this.authorField = options.authorField;- this.subjectField = options.subjectField;- this.keywordsField = options.keywordsField;- this.creationDateField = options.creationDateField;- this.modificationDateField = options.modificationDateField;- this.creatorField = options.creatorField;- this.producerField = options.producerField;- this.versionField = options.versionField;- this.pageCountField = options.pageCountField;+ this.rawFileSize = 0;+ this.url = null;+ this.pdfDocument = null;// Bind the event listener for the Close button.if (options.closeButton) {@@ -2690,139 +3138,179 @@ var DocumentProperties = {}.bind(this));OverlayManager.register(this.overlayName, this.close.bind(this));- },+ }- getProperties: function documentPropertiesGetProperties() {- if (!OverlayManager.active) {- // If the dialog was closed before dataAvailablePromise was resolved,- // don't bother updating the properties.- return;- }- // Get the file size (if it hasn't already been set).- this.pdfDocument.getDownloadInfo().then(function(data) {- if (data.length === this.rawFileSize) {- return;- }- this.setFileSize(data.length);- this.updateUI(this.fileSizeField, this.parseFileSize());- }.bind(this));+ PDFDocumentProperties.prototype = {+ /**+ * Open the document properties overlay.+ */+ open: function PDFDocumentProperties_open() {+ Promise.all([OverlayManager.open(this.overlayName),+ this.dataAvailablePromise]).then(function () {+ this._getProperties();+ }.bind(this));+ },- // Get the document properties.- this.pdfDocument.getMetadata().then(function(data) {- var fields = [- { field: this.fileNameField,- content: getPDFFileNameFromURL(this.url) },- { field: this.fileSizeField, content: this.parseFileSize() },- { field: this.titleField, content: data.info.Title },- { field: this.authorField, content: data.info.Author },- { field: this.subjectField, content: data.info.Subject },- { field: this.keywordsField, content: data.info.Keywords },- { field: this.creationDateField,- content: this.parseDate(data.info.CreationDate) },- { field: this.modificationDateField,- content: this.parseDate(data.info.ModDate) },- { field: this.creatorField, content: data.info.Creator },- { field: this.producerField, content: data.info.Producer },- { field: this.versionField, content: data.info.PDFFormatVersion },- { field: this.pageCountField, content: this.pdfDocument.numPages }- ];+ /**+ * Close the document properties overlay.+ */+ close: function PDFDocumentProperties_close() {+ OverlayManager.close(this.overlayName);+ },- // Show the properties in the dialog.- for (var item in fields) {- var element = fields[item];- this.updateUI(element.field, element.content);+ /**+ * Set the file size of the PDF document. This method is used to+ * update the file size in the document properties overlay once it+ * is known so we do not have to wait until the entire file is loaded.+ *+ * @param {number} fileSize - The file size of the PDF document.+ */+ setFileSize: function PDFDocumentProperties_setFileSize(fileSize) {+ if (fileSize > 0) {+ this.rawFileSize = fileSize;}- }.bind(this));- },+ },- updateUI: function documentPropertiesUpdateUI(field, content) {- if (field && content !== undefined && content !== '') {- field.textContent = content;- }- },+ /**+ * Set a reference to the PDF document and the URL in order+ * to populate the overlay fields with the document properties.+ * Note that the overlay will contain no information if this method+ * is not called.+ *+ * @param {Object} pdfDocument - A reference to the PDF document.+ * @param {string} url - The URL of the document.+ */+ setDocumentAndUrl:+ function PDFDocumentProperties_setDocumentAndUrl(pdfDocument, url) {+ this.pdfDocument = pdfDocument;+ this.url = url;+ this.resolveDataAvailable();+ },- setFileSize: function documentPropertiesSetFileSize(fileSize) {- if (fileSize > 0) {- this.rawFileSize = fileSize;- }- },+ /**+ * @private+ */+ _getProperties: function PDFDocumentProperties_getProperties() {+ if (!OverlayManager.active) {+ // If the dialog was closed before dataAvailablePromise was resolved,+ // don't bother updating the properties.+ return;+ }+ // Get the file size (if it hasn't already been set).+ this.pdfDocument.getDownloadInfo().then(function(data) {+ if (data.length === this.rawFileSize) {+ return;+ }+ this.setFileSize(data.length);+ this._updateUI(this.fields['fileSize'], this._parseFileSize());+ }.bind(this));- parseFileSize: function documentPropertiesParseFileSize() {- var fileSize = this.rawFileSize, kb = fileSize / 1024;- if (!kb) {- return;- } else if (kb < 1024) {- return mozL10n.get('document_properties_kb', {- size_kb: (+kb.toPrecision(3)).toLocaleString(),- size_b: fileSize.toLocaleString()- }, '{{size_kb}} KB ({{size_b}} bytes)');- } else {- return mozL10n.get('document_properties_mb', {- size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),- size_b: fileSize.toLocaleString()- }, '{{size_mb}} MB ({{size_b}} bytes)');- }- },+ // Get the document properties.+ this.pdfDocument.getMetadata().then(function(data) {+ var content = {+ 'fileName': getPDFFileNameFromURL(this.url),+ 'fileSize': this._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),+ 'creator': data.info.Creator,+ 'producer': data.info.Producer,+ 'version': data.info.PDFFormatVersion,+ 'pageCount': this.pdfDocument.numPages+ };- open: function documentPropertiesOpen() {- Promise.all([OverlayManager.open(this.overlayName),- this.dataAvailablePromise]).then(function () {- this.getProperties();- }.bind(this));- },+ // Show the properties in the dialog.+ for (var identifier in content) {+ this._updateUI(this.fields[identifier], content[identifier]);+ }+ }.bind(this));+ },- close: function documentPropertiesClose() {- OverlayManager.close(this.overlayName);- },+ /**+ * @private+ */+ _updateUI: function PDFDocumentProperties_updateUI(field, content) {+ if (field && content !== undefined && content !== '') {+ field.textContent = content;+ }+ },++ /**+ * @private+ */+ _parseFileSize: function PDFDocumentProperties_parseFileSize() {+ var fileSize = this.rawFileSize, kb = fileSize / 1024;+ if (!kb) {+ return;+ } else if (kb < 1024) {+ return mozL10n.get('document_properties_kb', {+ size_kb: (+kb.toPrecision(3)).toLocaleString(),+ size_b: fileSize.toLocaleString()+ }, '{{size_kb}} KB ({{size_b}} bytes)');+ } else {+ return mozL10n.get('document_properties_mb', {+ size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),+ size_b: fileSize.toLocaleString()+ }, '{{size_mb}} MB ({{size_b}} bytes)');+ }+ },- parseDate: function documentPropertiesParseDate(inputDate) {- // This is implemented according to the PDF specification (see- // http://www.gnupdf.org/Date for an overview), but note that- // Adobe Reader doesn't handle changing the date to universal time- // and doesn't use the user's time zone (they're effectively ignoring- // the HH' and mm' parts of the date string).- var dateToParse = inputDate;- if (dateToParse === undefined) {- return '';+ /**+ * @private+ */+ _parseDate: function PDFDocumentProperties_parseDate(inputDate) {+ // This is implemented according to the PDF specification, but note that+ // Adobe Reader doesn't handle changing the date to universal time+ // and doesn't use the user's time zone (they're effectively ignoring+ // the HH' and mm' parts of the date string).+ var dateToParse = inputDate;+ if (dateToParse === undefined) {+ return '';+ }++ // Remove the D: prefix if it is available.+ if (dateToParse.substring(0,2) === 'D:') {+ dateToParse = dateToParse.substring(2);+ }++ // Get all elements from the PDF date string.+ // JavaScript's Date object expects the month to be between+ // 0 and 11 instead of 1 and 12, so we're correcting for this.+ var year = parseInt(dateToParse.substring(0,4), 10);+ var month = parseInt(dateToParse.substring(4,6), 10) - 1;+ var day = parseInt(dateToParse.substring(6,8), 10);+ var hours = parseInt(dateToParse.substring(8,10), 10);+ var minutes = parseInt(dateToParse.substring(10,12), 10);+ var seconds = parseInt(dateToParse.substring(12,14), 10);+ var utRel = dateToParse.substring(14,15);+ var offsetHours = parseInt(dateToParse.substring(15,17), 10);+ var offsetMinutes = parseInt(dateToParse.substring(18,20), 10);++ // As per spec, utRel = 'Z' means equal to universal time.+ // The other cases ('-' and '+') have to be handled here.+ if (utRel === '-') {+ hours += offsetHours;+ minutes += offsetMinutes;+ } else if (utRel === '+') {+ hours -= offsetHours;+ minutes -= offsetMinutes;+ }++ // Return the new date format from the user's locale.+ var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));+ var dateString = date.toLocaleDateString();+ var timeString = date.toLocaleTimeString();+ return mozL10n.get('document_properties_date_string',+ {date: dateString, time: timeString},+ '{{date}}, {{time}}');}+ };- // Remove the D: prefix if it is available.- if (dateToParse.substring(0,2) === 'D:') {- dateToParse = dateToParse.substring(2);- }-- // Get all elements from the PDF date string.- // JavaScript's Date object expects the month to be between- // 0 and 11 instead of 1 and 12, so we're correcting for this.- var year = parseInt(dateToParse.substring(0,4), 10);- var month = parseInt(dateToParse.substring(4,6), 10) - 1;- var day = parseInt(dateToParse.substring(6,8), 10);- var hours = parseInt(dateToParse.substring(8,10), 10);- var minutes = parseInt(dateToParse.substring(10,12), 10);- var seconds = parseInt(dateToParse.substring(12,14), 10);- var utRel = dateToParse.substring(14,15);- var offsetHours = parseInt(dateToParse.substring(15,17), 10);- var offsetMinutes = parseInt(dateToParse.substring(18,20), 10);-- // As per spec, utRel = 'Z' means equal to universal time.- // The other cases ('-' and '+') have to be handled here.- if (utRel === '-') {- hours += offsetHours;- minutes += offsetMinutes;- } else if (utRel === '+') {- hours -= offsetHours;- minutes -= offsetMinutes;- }-- // Return the new date format from the user's locale.- var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));- var dateString = date.toLocaleDateString();- var timeString = date.toLocaleTimeString();- return mozL10n.get('document_properties_date_string',- {date: dateString, time: timeString},- '{{date}}, {{time}}');- }-};+ return PDFDocumentProperties;+})();var PresentationModeState = {@@ -3059,6 +3547,7 @@ var PDFPageView = (function PDFPageViewClosure() {div.className = 'page';div.style.width = Math.floor(this.viewport.width) + 'px';div.style.height = Math.floor(this.viewport.height) + 'px';+ div.setAttribute('data-page-number', this.id);this.div = div;container.appendChild(div);@@ -3341,10 +3830,9 @@ var PDFPageView = (function PDFPageViewClosure() {}this.textLayer = textLayer;- // TODO(mack): use data attributes to store these- ctx._scaleX = outputScale.sx;- ctx._scaleY = outputScale.sy;if (outputScale.scaled) {+ // Used by the mozCurrentTransform polyfill in src/display/canvas.js.+ ctx._transformMatrix = [outputScale.sx, 0, 0, outputScale.sy, 0, 0];ctx.scale(outputScale.sx, outputScale.sy);}@@ -3470,10 +3958,15 @@ var PDFPageView = (function PDFPageViewClosure() {// better output until bug 811002 is fixed in FF.var PRINT_OUTPUT_SCALE = 2;var canvas = document.createElement('canvas');++ // The logical size of the canvas.canvas.width = Math.floor(viewport.width) * PRINT_OUTPUT_SCALE;canvas.height = Math.floor(viewport.height) * PRINT_OUTPUT_SCALE;- canvas.style.width = (PRINT_OUTPUT_SCALE * viewport.width) + 'pt';- canvas.style.height = (PRINT_OUTPUT_SCALE * viewport.height) + 'pt';++ // The rendered size of the canvas, relative to the size of canvasWrapper.+ canvas.style.width = (PRINT_OUTPUT_SCALE * 100) + '%';+ canvas.style.height = (PRINT_OUTPUT_SCALE * 100) + '%';+var cssScale = 'scale(' + (1 / PRINT_OUTPUT_SCALE) + ', ' +(1 / PRINT_OUTPUT_SCALE) + ')';CustomStyle.setProp('transform' , canvas, cssScale);@@ -3493,6 +3986,9 @@ var PDFPageView = (function PDFPageViewClosure() {ctx.fillStyle = 'rgb(255, 255, 255)';ctx.fillRect(0, 0, canvas.width, canvas.height);ctx.restore();+ // Used by the mozCurrentTransform polyfill in src/display/canvas.js.+ ctx._transformMatrix =+ [PRINT_OUTPUT_SCALE, 0, 0, PRINT_OUTPUT_SCALE, 0, 0];ctx.scale(PRINT_OUTPUT_SCALE, PRINT_OUTPUT_SCALE);var renderContext = {@@ -3702,7 +4198,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {// We don't bother scaling single-char text divs, because it has very// little effect on text highlighting. This makes scrolling on docs with// lots of such divs a lot faster.- if (textDiv.textContent.length > 1) {+ if (geom.str.length > 1) {if (style.vertical) {textDiv.dataset.canvasWidth = geom.height * this.viewport.scale;} else {@@ -4077,7 +4573,8 @@ DefaultAnnotationsLayerFactory.prototype = {createAnnotationsLayerBuilder: function (pageDiv, pdfPage) {return new AnnotationsLayerBuilder({pageDiv: pageDiv,- pdfPage: pdfPage+ pdfPage: pdfPage,+ linkService: new SimpleLinkService(),});}};@@ -4090,6 +4587,8 @@ DefaultAnnotationsLayerFactory.prototype = {* @property {IPDFLinkService} linkService - The navigation/linking service.* @property {PDFRenderingQueue} renderingQueue - (optional) The rendering* queue object.+ * @property {boolean} removePageBorders - (optional) Removes the border shadow+ * around the pages. The default is false.*//**@@ -4118,6 +4617,18 @@ var PDFViewer = (function pdfViewer() {};}+ function isSameScale(oldScale, newScale) {+ if (newScale === oldScale) {+ return true;+ }+ if (Math.abs(newScale - oldScale) < 1e-15) {+ // Prevent unnecessary re-rendering of all pages when the scale+ // changes only because of limited numerical precision.+ return true;+ }+ return false;+ }+/*** @constructs PDFViewer* @param {PDFViewerOptions} options@@ -4125,7 +4636,8 @@ var PDFViewer = (function pdfViewer() {function PDFViewer(options) {this.container = options.container;this.viewer = options.viewer || options.container.firstElementChild;- this.linkService = options.linkService || new SimpleLinkService(this);+ this.linkService = options.linkService || new SimpleLinkService();+ this.removePageBorders = options.removePageBorders || false;this.defaultRenderingQueue = !options.renderingQueue;if (this.defaultRenderingQueue) {@@ -4140,15 +4652,19 @@ var PDFViewer = (function pdfViewer() {this.updateInProgress = false;this.presentationModeState = PresentationModeState.UNKNOWN;this._resetView();++ if (this.removePageBorders) {+ this.viewer.classList.add('removePageBorders');+ }}PDFViewer.prototype = /** @lends PDFViewer.prototype */{get pagesCount() {- return this.pages.length;+ return this._pages.length;},getPageView: function (index) {- return this.pages[index];+ return this._pages[index];},get currentPageNumber() {@@ -4176,13 +4692,20 @@ var PDFViewer = (function pdfViewer() {this._currentPageNumber = val;event.pageNumber = val;this.container.dispatchEvent(event);++ // Check if the caller is `PDFViewer_update`, to avoid breaking scrolling.+ if (this.updateInProgress) {+ return;+ }+ this.scrollPageIntoView(val);},/*** @returns {number}*/get currentScale() {- return this._currentScale;+ return this._currentScale !== UNKNOWN_SCALE ? this._currentScale :+ DEFAULT_SCALE;},/**@@ -4194,7 +4717,7 @@ var PDFViewer = (function pdfViewer() {}if (!this.pdfDocument) {this._currentScale = val;- this._currentScaleValue = val.toString();+ this._currentScaleValue = val !== UNKNOWN_SCALE ? val.toString() : null;return;}this._setScale(val, false);@@ -4232,12 +4755,16 @@ var PDFViewer = (function pdfViewer() {set pagesRotation(rotation) {this._pagesRotation = rotation;- for (var i = 0, l = this.pages.length; i < l; i++) {- var page = this.pages[i];- page.update(page.scale, rotation);+ for (var i = 0, l = this._pages.length; i < l; i++) {+ var pageView = this._pages[i];+ pageView.update(pageView.scale, rotation);}this._setScale(this._currentScaleValue, true);++ if (this.defaultRenderingQueue) {+ this.update();+ }},/**@@ -4254,7 +4781,6 @@ var PDFViewer = (function pdfViewer() {}var pagesCount = pdfDocument.numPages;- var pagesRefMap = this.pagesRefMap = {};var self = this;var resolvePagesPromise;@@ -4299,7 +4825,7 @@ var PDFViewer = (function pdfViewer() {// Fetch a single page so we can get a viewport that will be the default// viewport for all pagesreturn firstPagePromise.then(function(pdfPage) {- var scale = this._currentScale || 1.0;+ var scale = this.currentScale;var viewport = pdfPage.getViewport(scale * CSS_UNITS);for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {var textLayerFactory = null;@@ -4316,9 +4842,11 @@ var PDFViewer = (function pdfViewer() {annotationsLayerFactory: this});bindOnAfterAndBeforeDraw(pageView);- this.pages.push(pageView);+ this._pages.push(pageView);}+ var linkService = this.linkService;+// Fetch all the pages since the viewport is needed before printing// starts to create the correct size canvas. Wait until one page is// rendered so we don't tie up too many resources early on.@@ -4327,12 +4855,11 @@ var PDFViewer = (function pdfViewer() {var getPagesLeft = pagesCount;for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {- var pageView = self.pages[pageNum - 1];+ var pageView = self._pages[pageNum - 1];if (!pageView.pdfPage) {pageView.setPdfPage(pdfPage);}- var refStr = pdfPage.ref.num + ' ' + pdfPage.ref.gen + ' R';- pagesRefMap[refStr] = pageNum;+ linkService.cachePageRef(pageNum, pdfPage.ref);getPagesLeft--;if (!getPagesLeft) {resolvePagesPromise();@@ -4360,12 +4887,12 @@ var PDFViewer = (function pdfViewer() {},_resetView: function () {- this.pages = [];+ this._pages = [];this._currentPageNumber = 1;this._currentScale = UNKNOWN_SCALE;this._currentScaleValue = null;this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);- this.location = null;+ this._location = null;this._pagesRotation = 0;this._pagesRequests = [];@@ -4375,13 +4902,13 @@ var PDFViewer = (function pdfViewer() {}},- _scrollUpdate: function () {+ _scrollUpdate: function PDFViewer_scrollUpdate() {if (this.pagesCount === 0) {return;}this.update();- for (var i = 0, ii = this.pages.length; i < ii; i++) {- this.pages[i].updatePosition();+ for (var i = 0, ii = this._pages.length; i < ii; i++) {+ this._pages[i].updatePosition();}},@@ -4399,52 +4926,51 @@ var PDFViewer = (function pdfViewer() {_setScaleUpdatePages: function pdfViewer_setScaleUpdatePages(newScale, newValue, noScroll, preset) {this._currentScaleValue = newValue;- if (newScale === this._currentScale) {++ if (isSameScale(this._currentScale, newScale)) {if (preset) {this._setScaleDispatchEvent(newScale, newValue, true);}return;}- for (var i = 0, ii = this.pages.length; i < ii; i++) {- this.pages[i].update(newScale);+ for (var i = 0, ii = this._pages.length; i < ii; i++) {+ this._pages[i].update(newScale);}this._currentScale = newScale;if (!noScroll) {var page = this._currentPageNumber, dest;- var inPresentationMode =- this.presentationModeState === PresentationModeState.CHANGING ||- this.presentationModeState === PresentationModeState.FULLSCREEN;- if (this.location && !inPresentationMode &&- !IGNORE_CURRENT_POSITION_ON_ZOOM) {- page = this.location.pageNumber;- dest = [null, { name: 'XYZ' }, this.location.left,- this.location.top, null];+ if (this._location && !IGNORE_CURRENT_POSITION_ON_ZOOM &&+ !(this.isInPresentationMode || this.isChangingPresentationMode)) {+ page = this._location.pageNumber;+ dest = [null, { name: 'XYZ' }, this._location.left,+ this._location.top, null];}this.scrollPageIntoView(page, dest);}this._setScaleDispatchEvent(newScale, newValue, preset);++ if (this.defaultRenderingQueue) {+ this.update();+ }},_setScale: function pdfViewer_setScale(value, noScroll) {- if (value === 'custom') {- return;- }var scale = parseFloat(value);if (scale > 0) {this._setScaleUpdatePages(scale, value, noScroll, false);} else {- var currentPage = this.pages[this._currentPageNumber - 1];+ var currentPage = this._pages[this._currentPageNumber - 1];if (!currentPage) {return;}- var inPresentationMode =- this.presentationModeState === PresentationModeState.FULLSCREEN;- var hPadding = inPresentationMode ? 0 : SCROLLBAR_PADDING;- var vPadding = inPresentationMode ? 0 : VERTICAL_PADDING;+ var hPadding = (this.isInPresentationMode || this.removePageBorders) ?+ 0 : SCROLLBAR_PADDING;+ var vPadding = (this.isInPresentationMode || this.removePageBorders) ?+ 0 : VERTICAL_PADDING;var pageWidthScale = (this.container.clientWidth - hPadding) /currentPage.width * currentPage.scale;var pageHeightScale = (this.container.clientHeight - vPadding) /@@ -4487,18 +5013,17 @@ var PDFViewer = (function pdfViewer() {*/scrollPageIntoView: function PDFViewer_scrollPageIntoView(pageNumber,dest) {- var pageView = this.pages[pageNumber - 1];+ var pageView = this._pages[pageNumber - 1];- if (this.presentationModeState ===- PresentationModeState.FULLSCREEN) {- if (this.linkService.page !== pageView.id) {+ if (this.isInPresentationMode) {+ if (this._currentPageNumber !== pageView.id) {// Avoid breaking getVisiblePages in presentation mode.- this.linkService.page = pageView.id;+ this.currentPageNumber = pageView.id;return;}dest = null;// Fixes the case when PDF has different page sizes.- this._setScale(this.currentScaleValue, true);+ this._setScale(this._currentScaleValue, true);}if (!dest) {scrollIntoView(pageView.div);@@ -4546,10 +5071,12 @@ var PDFViewer = (function pdfViewer() {y = dest[3];width = dest[4] - x;height = dest[5] - y;- var viewerContainer = this.container;- widthScale = (viewerContainer.clientWidth - SCROLLBAR_PADDING) /+ var hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;+ var vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;++ widthScale = (this.container.clientWidth - hPadding) /width / CSS_UNITS;- heightScale = (viewerContainer.clientHeight - SCROLLBAR_PADDING) /+ heightScale = (this.container.clientHeight - vPadding) /height / CSS_UNITS;scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));break;@@ -4557,10 +5084,10 @@ var PDFViewer = (function pdfViewer() {return;}- if (scale && scale !== this.currentScale) {+ if (scale && scale !== this._currentScale) {this.currentScaleValue = scale;- } else if (this.currentScale === UNKNOWN_SCALE) {- this.currentScaleValue = DEFAULT_SCALE;+ } else if (this._currentScale === UNKNOWN_SCALE) {+ this.currentScaleValue = DEFAULT_SCALE_VALUE;}if (scale === 'page-fit' && !dest[4]) {@@ -4588,7 +5115,7 @@ var PDFViewer = (function pdfViewer() {var pageNumber = firstPage.id;var pdfOpenParams = '#page=' + pageNumber;pdfOpenParams += '&zoom=' + normalizedScaleValue;- var currentPageView = this.pages[pageNumber - 1];+ var currentPageView = this._pages[pageNumber - 1];var container = this.container;var topLeft = currentPageView.getPagePoint((container.scrollLeft - firstPage.x),@@ -4597,7 +5124,7 @@ var PDFViewer = (function pdfViewer() {var intTop = Math.round(topLeft[1]);pdfOpenParams += ',' + intLeft + ',' + intTop;- this.location = {+ this._location = {pageNumber: pageNumber,scale: normalizedScaleValue,top: intTop,@@ -4606,7 +5133,7 @@ var PDFViewer = (function pdfViewer() {};},- update: function () {+ update: function PDFViewer_update() {var visible = this._getVisiblePages();var visiblePages = visible.views;if (visiblePages.length === 0) {@@ -4621,7 +5148,7 @@ var PDFViewer = (function pdfViewer() {this.renderingQueue.renderHighestPriority(visible);- var currentId = this.currentPageNumber;+ var currentId = this._currentPageNumber;var firstPage = visible.first;for (var i = 0, ii = visiblePages.length, stillFullyVisible = false;@@ -4641,7 +5168,7 @@ var PDFViewer = (function pdfViewer() {currentId = visiblePages[0].id;}- if (this.presentationModeState !== PresentationModeState.FULLSCREEN) {+ if (!this.isInPresentationMode) {this.currentPageNumber = currentId;}@@ -4651,6 +5178,7 @@ var PDFViewer = (function pdfViewer() {var event = document.createEvent('UIEvents');event.initUIEvent('updateviewarea', true, true, window, 0);+ event.location = this._location;this.container.dispatchEvent(event);},@@ -4662,33 +5190,37 @@ var PDFViewer = (function pdfViewer() {this.container.focus();},- blur: function () {- this.container.blur();+ get isInPresentationMode() {+ return this.presentationModeState === PresentationModeState.FULLSCREEN;+ },++ get isChangingPresentationMode() {+ return this.PresentationModeState === PresentationModeState.CHANGING;},get isHorizontalScrollbarEnabled() {- return (this.presentationModeState === PresentationModeState.FULLSCREEN ?+ return (this.isInPresentationMode ?false : (this.container.scrollWidth > this.container.clientWidth));},_getVisiblePages: function () {- if (this.presentationModeState !== PresentationModeState.FULLSCREEN) {- return getVisibleElements(this.container, this.pages, true);+ if (!this.isInPresentationMode) {+ return getVisibleElements(this.container, this._pages, true);} else {// The algorithm in getVisibleElements doesn't work in all browsers and// configurations when presentation mode is active.var visible = [];- var currentPage = this.pages[this._currentPageNumber - 1];+ var currentPage = this._pages[this._currentPageNumber - 1];visible.push({ id: currentPage.id, view: currentPage });return { first: currentPage, last: currentPage, views: visible };}},cleanup: function () {- for (var i = 0, ii = this.pages.length; i < ii; i++) {- if (this.pages[i] &&- this.pages[i].renderingState !== RenderingStates.FINISHED) {- this.pages[i].reset();+ for (var i = 0, ii = this._pages.length; i < ii; i++) {+ if (this._pages[i] &&+ this._pages[i].renderingState !== RenderingStates.FINISHED) {+ this._pages[i].reset();}}},@@ -4719,7 +5251,7 @@ var PDFViewer = (function pdfViewer() {forceRendering: function (currentlyVisiblePages) {var visiblePages = currentlyVisiblePages || this._getVisiblePages();var pageView = this.renderingQueue.getHighestPriority(visiblePages,- this.pages,+ this._pages,this.scroll.down);if (pageView) {this._ensurePdfPageLoaded(pageView).then(function () {@@ -4743,13 +5275,11 @@ var PDFViewer = (function pdfViewer() {* @returns {TextLayerBuilder}*/createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport) {- var isViewerInPresentationMode =- this.presentationModeState === PresentationModeState.FULLSCREEN;return new TextLayerBuilder({textLayerDiv: textLayerDiv,pageIndex: pageIndex,viewport: viewport,- findController: isViewerInPresentationMode ? null : this.findController+ findController: this.isInPresentationMode ? null : this.findController});},@@ -4775,22 +5305,19 @@ var PDFViewer = (function pdfViewer() {})();var SimpleLinkService = (function SimpleLinkServiceClosure() {- function SimpleLinkService(pdfViewer) {- this.pdfViewer = pdfViewer;- }+ function SimpleLinkService() {}+SimpleLinkService.prototype = {/*** @returns {number}*/get page() {- return this.pdfViewer.currentPageNumber;+ return 0;},/*** @param {number} value*/- set page(value) {- this.pdfViewer.currentPageNumber = value;- },+ set page(value) {},/*** @param dest - The PDF destination object.*/@@ -4817,6 +5344,11 @@ var SimpleLinkService = (function SimpleLinkServiceClosure() {* @param {string} action*/executeNamedAction: function (action) {},+ /**+ * @param {number} pageNum - page number.+ * @param {Object} pageRef - reference to the page.+ */+ cachePageRef: function (pageNum, pageRef) {}};return SimpleLinkService;})();@@ -4984,12 +5516,11 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {/*** @private*/- _getPageDrawContext: function PDFThumbnailView_getPageDrawContext() {+ _getPageDrawContext:+ function PDFThumbnailView_getPageDrawContext(noCtxScale) {var canvas = document.createElement('canvas');canvas.id = this.renderingId;- canvas.width = this.canvasWidth;- canvas.height = this.canvasHeight;canvas.className = 'thumbnailImage';canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',{page: this.id}, 'Thumbnail of Page {{page}}'));@@ -4998,7 +5529,16 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {this.div.setAttribute('data-loaded', true);this.ring.appendChild(canvas);- return canvas.getContext('2d');+ var ctx = canvas.getContext('2d');+ var outputScale = getOutputScale(ctx);+ canvas.width = (this.canvasWidth * outputScale.sx) | 0;+ canvas.height = (this.canvasHeight * outputScale.sy) | 0;+ canvas.style.width = this.canvasWidth + 'px';+ canvas.style.height = this.canvasHeight + 'px';+ if (!noCtxScale && outputScale.scaled) {+ ctx.scale(outputScale.sx, outputScale.sy);+ }+ return ctx;},draw: function PDFThumbnailView_draw() {@@ -5081,7 +5621,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {this.hasImage = true;this.renderingState = RenderingStates.FINISHED;- var ctx = this._getPageDrawContext();+ var ctx = this._getPageDrawContext(true);var canvas = ctx.canvas;if (img.width <= 2 * canvas.width) {@@ -5332,6 +5872,17 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {}},+ /**+ * @private+ */+ _dispatchEvent: function PDFOutlineView_dispatchEvent(outlineCount) {+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent('outlineloaded', true, true, {+ outlineCount: outlineCount+ });+ this.container.dispatchEvent(event);+ },+/*** @private*/@@ -5346,10 +5897,12 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {render: function PDFOutlineView_render() {var outline = this.outline;+ var outlineCount = 0;this.reset();if (!outline) {+ this._dispatchEvent(outlineCount);return;}@@ -5373,8 +5926,11 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {}levelData.parent.appendChild(div);+ outlineCount++;}}++ this._dispatchEvent(outlineCount);}};@@ -5411,6 +5967,17 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {}},+ /**+ * @private+ */+ _dispatchEvent: function PDFAttachmentView_dispatchEvent(attachmentsCount) {+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent('attachmentsloaded', true, true, {+ attachmentsCount: attachmentsCount+ });+ this.container.dispatchEvent(event);+ },+/*** @private*/@@ -5423,17 +5990,21 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {render: function PDFAttachmentView_render() {var attachments = this.attachments;+ var attachmentsCount = 0;this.reset();if (!attachments) {+ this._dispatchEvent(attachmentsCount);return;}var names = Object.keys(attachments).sort(function(a, b) {return a.toLowerCase().localeCompare(b.toLowerCase());});- for (var i = 0, len = names.length; i < len; i++) {+ attachmentsCount = names.length;++ for (var i = 0; i < attachmentsCount; i++) {var item = attachments[names[i]];var filename = getFileName(item.filename);var div = document.createElement('div');@@ -5444,6 +6015,8 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {div.appendChild(button);this.container.appendChild(div);}++ this._dispatchEvent(attachmentsCount);}};@@ -5453,6 +6026,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {var PDFViewerApplication = {initialBookmark: document.location.hash.substring(1),+ initialDestination: null,initialized: false,fellback: false,pdfDocument: null,@@ -5464,15 +6038,21 @@ var PDFViewerApplication = {pdfThumbnailViewer: null,/** @type {PDFRenderingQueue} */pdfRenderingQueue: null,+ /** @type {PDFPresentationMode} */+ pdfPresentationMode: null,+ /** @type {PDFDocumentProperties} */+ pdfDocumentProperties: null,+ /** @type {PDFLinkService} */+ pdfLinkService: null,+ /** @type {PDFHistory} */+ pdfHistory: null,pageRotation: 0,- updateScaleControls: true,isInitialViewSet: false,animationStartedPromise: null,- mouseScrollTimeStamp: 0,- mouseScrollDelta: 0,preferenceSidebarViewOnLoad: SidebarView.NONE,preferencePdfBugEnabled: false,preferenceShowPreviousViewOnLoad: true,+ preferenceDefaultZoomValue: '',isViewerEmbedded: (window.parent !== window),url: '',@@ -5482,26 +6062,35 @@ var PDFViewerApplication = {pdfRenderingQueue.onIdle = this.cleanup.bind(this);this.pdfRenderingQueue = pdfRenderingQueue;+ var pdfLinkService = new PDFLinkService();+ this.pdfLinkService = pdfLinkService;+var container = document.getElementById('viewerContainer');var viewer = document.getElementById('viewer');this.pdfViewer = new PDFViewer({container: container,viewer: viewer,renderingQueue: pdfRenderingQueue,- linkService: this+ linkService: pdfLinkService});pdfRenderingQueue.setViewer(this.pdfViewer);+ pdfLinkService.setViewer(this.pdfViewer);var thumbnailContainer = document.getElementById('thumbnailView');this.pdfThumbnailViewer = new PDFThumbnailViewer({container: thumbnailContainer,renderingQueue: pdfRenderingQueue,- linkService: this+ linkService: pdfLinkService});pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);Preferences.initialize();+ this.pdfHistory = new PDFHistory({+ linkService: pdfLinkService+ });+ pdfLinkService.setHistory(this.pdfHistory);+this.findController = new PDFFindController({pdfViewer: this.pdfViewer,integratedFind: this.supportsIntegratedFind@@ -5528,9 +6117,27 @@ var PDFViewerApplication = {toggleHandTool: document.getElementById('toggleHandTool')});+ this.pdfDocumentProperties = new PDFDocumentProperties({+ overlayName: 'documentPropertiesOverlay',+ closeButton: document.getElementById('documentPropertiesClose'),+ fields: {+ 'fileName': document.getElementById('fileNameField'),+ 'fileSize': document.getElementById('fileSizeField'),+ 'title': document.getElementById('titleField'),+ 'author': document.getElementById('authorField'),+ 'subject': document.getElementById('subjectField'),+ 'keywords': document.getElementById('keywordsField'),+ 'creationDate': document.getElementById('creationDateField'),+ 'modificationDate': document.getElementById('modificationDateField'),+ 'creator': document.getElementById('creatorField'),+ 'producer': document.getElementById('producerField'),+ 'version': document.getElementById('versionField'),+ 'pageCount': document.getElementById('pageCountField')+ }+ });+SecondaryToolbar.initialize({toolbar: document.getElementById('secondaryToolbar'),- presentationMode: PresentationMode,toggleButton: document.getElementById('secondaryToolbarToggle'),presentationModeButton:document.getElementById('secondaryPresentationMode'),@@ -5542,18 +6149,28 @@ var PDFViewerApplication = {lastPage: document.getElementById('lastPage'),pageRotateCw: document.getElementById('pageRotateCw'),pageRotateCcw: document.getElementById('pageRotateCcw'),- documentProperties: DocumentProperties,documentPropertiesButton: document.getElementById('documentProperties')});- PresentationMode.initialize({- container: container,- secondaryToolbar: SecondaryToolbar,- firstPage: document.getElementById('contextFirstPage'),- lastPage: document.getElementById('contextLastPage'),- pageRotateCw: document.getElementById('contextPageRotateCw'),- pageRotateCcw: document.getElementById('contextPageRotateCcw')- });+ if (this.supportsFullscreen) {+ var toolbar = SecondaryToolbar;+ this.pdfPresentationMode = new PDFPresentationMode({+ container: container,+ viewer: viewer,+ pdfViewer: this.pdfViewer,+ pdfThumbnailViewer: this.pdfThumbnailViewer,+ contextMenuItems: [+ { element: document.getElementById('contextFirstPage'),+ handler: toolbar.firstPageClick.bind(toolbar) },+ { element: document.getElementById('contextLastPage'),+ handler: toolbar.lastPageClick.bind(toolbar) },+ { element: document.getElementById('contextPageRotateCw'),+ handler: toolbar.pageRotateCwClick.bind(toolbar) },+ { element: document.getElementById('contextPageRotateCcw'),+ handler: toolbar.pageRotateCcwClick.bind(toolbar) }+ ]+ });+ }PasswordPrompt.initialize({overlayName: 'passwordOverlay',@@ -5563,23 +6180,6 @@ var PDFViewerApplication = {passwordCancel: document.getElementById('passwordCancel')});- DocumentProperties.initialize({- overlayName: 'documentPropertiesOverlay',- closeButton: document.getElementById('documentPropertiesClose'),- fileNameField: document.getElementById('fileNameField'),- fileSizeField: document.getElementById('fileSizeField'),- titleField: document.getElementById('titleField'),- authorField: document.getElementById('authorField'),- subjectField: document.getElementById('subjectField'),- keywordsField: document.getElementById('keywordsField'),- creationDateField: document.getElementById('creationDateField'),- modificationDateField: document.getElementById('modificationDateField'),- creatorField: document.getElementById('creatorField'),- producerField: document.getElementById('producerField'),- versionField: document.getElementById('versionField'),- pageCountField: document.getElementById('pageCountField')- });-var self = this;var initializedPromise = Promise.all([Preferences.get('enableWebGL').then(function resolved(value) {@@ -5593,9 +6193,9 @@ var PDFViewerApplication = {}),Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {self.preferenceShowPreviousViewOnLoad = value;- if (!value && window.history.state) {- window.history.replaceState(null, '');- }+ }),+ Preferences.get('defaultZoomValue').then(function resolved(value) {+ self.preferenceDefaultZoomValue = value;}),Preferences.get('disableTextLayer').then(function resolved(value) {if (PDFJS.disableTextLayer === true) {@@ -5621,7 +6221,6 @@ var PDFViewerApplication = {Preferences.get('useOnlyCssZoom').then(function resolved(value) {PDFJS.useOnlyCssZoom = value;})-// TODO move more preferences and other async stuff here]).catch(function (reason) { });@@ -5636,8 +6235,8 @@ var PDFViewerApplication = {newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);newScale = Math.ceil(newScale * 10) / 10;newScale = Math.min(MAX_SCALE, newScale);- } while (--ticks && newScale < MAX_SCALE);- this.setScale(newScale, true);+ } while (--ticks > 0 && newScale < MAX_SCALE);+ this.pdfViewer.currentScaleValue = newScale;},zoomOut: function pdfViewZoomOut(ticks) {@@ -5646,12 +6245,8 @@ var PDFViewerApplication = {newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);newScale = Math.floor(newScale * 10) / 10;newScale = Math.max(MIN_SCALE, newScale);- } while (--ticks && newScale > MIN_SCALE);- this.setScale(newScale, true);- },-- get currentScaleValue() {- return this.pdfViewer.currentScaleValue;+ } while (--ticks > 0 && newScale > MIN_SCALE);+ this.pdfViewer.currentScaleValue = newScale;},get pagesCount() {@@ -5659,11 +6254,11 @@ var PDFViewerApplication = {},set page(val) {- this.pdfViewer.currentPageNumber = val;+ this.pdfLinkService.page = val;},- get page() {- return this.pdfViewer.currentPageNumber;+ get page() { // TODO remove+ return this.pdfLinkService.page;},get supportsPrinting() {@@ -5675,8 +6270,8 @@ var PDFViewerApplication = {get supportsFullscreen() {var doc = document.documentElement;- var support = doc.requestFullscreen || doc.mozRequestFullScreen ||- doc.webkitRequestFullScreen || doc.msRequestFullscreen;+ var support = !!(doc.requestFullscreen || doc.mozRequestFullScreen ||+ doc.webkitRequestFullScreen || doc.msRequestFullscreen);if (document.fullscreenEnabled === false ||document.mozFullScreenEnabled === false ||@@ -5748,6 +6343,7 @@ var PDFViewerApplication = {this.pdfThumbnailViewer.setDocument(null);this.pdfViewer.setDocument(null);+ this.pdfLinkService.setDocument(null, null);if (typeof PDFBug !== 'undefined') {PDFBug.cleanup();@@ -5780,7 +6376,6 @@ var PDFViewerApplication = {}var self = this;- self.loading = true;self.downloadComplete = false;var passwordNeeded = function passwordNeeded(updatePassword, reason) {@@ -5797,7 +6392,6 @@ var PDFViewerApplication = {getDocumentProgress).then(function getDocumentCallback(pdfDocument) {self.load(pdfDocument, scale);- self.loading = false;},function getDocumentError(exception) {var message = exception && exception.message;@@ -5821,12 +6415,11 @@ var PDFViewerApplication = {message: message};self.error(loadingErrorMessage, moreInfo);- self.loading = false;});if (args && args.length) {- DocumentProperties.setFileSize(args.length);+ PDFViewerApplication.pdfDocumentProperties.setFileSize(args.length);}},@@ -5864,131 +6457,6 @@ var PDFViewerApplication = {},fallback: function pdfViewFallback(featureId) {- return;- },-- navigateTo: function pdfViewNavigateTo(dest) {- var destString = '';- var self = this;-- var goToDestination = function(destRef) {- self.pendingRefStr = null;- // dest array looks like that: <page-ref> </XYZ|FitXXX> <args..>- var pageNumber = destRef instanceof Object ?- self.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] :- (destRef + 1);- if (pageNumber) {- if (pageNumber > self.pagesCount) {- pageNumber = self.pagesCount;- }- self.pdfViewer.scrollPageIntoView(pageNumber, dest);-- // Update the browsing history.- PDFHistory.push({ dest: dest, hash: destString, page: pageNumber });- } else {- self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {- var pageNum = pageIndex + 1;- self.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] = pageNum;- goToDestination(destRef);- });- }- };-- var destinationPromise;- if (typeof dest === 'string') {- destString = dest;- destinationPromise = this.pdfDocument.getDestination(dest);- } else {- destinationPromise = Promise.resolve(dest);- }- destinationPromise.then(function(destination) {- dest = destination;- if (!(destination instanceof Array)) {- return; // invalid destination- }- goToDestination(destination[0]);- });- },-- executeNamedAction: function pdfViewExecuteNamedAction(action) {- // See PDF reference, table 8.45 - Named action- switch (action) {- case 'GoToPage':- document.getElementById('pageNumber').focus();- break;-- case 'GoBack':- PDFHistory.back();- break;-- case 'GoForward':- PDFHistory.forward();- break;-- case 'Find':- if (!this.supportsIntegratedFind) {- this.findBar.toggle();- }- break;-- case 'NextPage':- this.page++;- break;-- case 'PrevPage':- this.page--;- break;-- case 'LastPage':- this.page = this.pagesCount;- break;-- case 'FirstPage':- this.page = 1;- break;-- default:- break; // No action according to spec- }- },-- getDestinationHash: function pdfViewGetDestinationHash(dest) {- if (typeof dest === 'string') {- return this.getAnchorUrl('#' + escape(dest));- }- if (dest instanceof Array) {- var destRef = dest[0]; // see navigateTo method for dest format- var pageNumber = destRef instanceof Object ?- this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] :- (destRef + 1);- if (pageNumber) {- var pdfOpenParams = this.getAnchorUrl('#page=' + pageNumber);- var destKind = dest[1];- if (typeof destKind === 'object' && 'name' in destKind &&- destKind.name === 'XYZ') {- var scale = (dest[4] || this.currentScaleValue);- var scaleNumber = parseFloat(scale);- if (scaleNumber) {- scale = scaleNumber * 100;- }- pdfOpenParams += '&zoom=' + scale;- if (dest[2] || dest[3]) {- pdfOpenParams += ',' + (dest[2] || 0) + ',' + (dest[3] || 0);- }- }- return pdfOpenParams;- }- }- return '';- },-- /**- * Prefix the full url on anchor links to make sure that links are resolved- * relative to the current URL instead of the one defined in <base href>.- * @param {String} anchor The anchor hash, including the #.- */- getAnchorUrl: function getAnchorUrl(anchor) {- return anchor;},/**@@ -6094,9 +6562,7 @@ var PDFViewerApplication = {this.pdfDocument = pdfDocument;- DocumentProperties.url = this.url;- DocumentProperties.pdfDocument = pdfDocument;- DocumentProperties.resolveDataAvailable();+ this.pdfDocumentProperties.setDocumentAndUrl(pdfDocument, this.url);var downloadedPromise = pdfDocument.getDownloadInfo().then(function() {self.downloadComplete = true;@@ -6111,6 +6577,9 @@ var PDFViewerApplication = {var id = this.documentFingerprint = pdfDocument.fingerprint;var store = this.store = new ViewHistory(id);+ var baseDocumentUrl = null;+ this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);+var pdfViewer = this.pdfViewer;pdfViewer.currentScale = scale;pdfViewer.setDocument(pdfDocument);@@ -6120,7 +6589,6 @@ var PDFViewerApplication = {this.pageRotation = 0;this.isInitialViewSet = false;- this.pagesRefMap = pdfViewer.pagesRefMap;this.pdfThumbnailViewer.setDocument(pdfDocument);@@ -6136,45 +6604,42 @@ var PDFViewerApplication = {if (!PDFJS.disableHistory && !self.isViewerEmbedded) {// The browsing history is only enabled when the viewer is standalone,// i.e. not when it is embedded in a web page.- PDFHistory.initialize(self.documentFingerprint, self);+ if (!self.preferenceShowPreviousViewOnLoad) {+ self.pdfHistory.clearHistoryState();+ }+ self.pdfHistory.initialize(self.documentFingerprint);++ if (self.pdfHistory.initialDestination) {+ self.initialDestination = self.pdfHistory.initialDestination;+ } else if (self.pdfHistory.initialBookmark) {+ self.initialBookmark = self.pdfHistory.initialBookmark;+ }}- });- // Fetch the necessary preference values.- var defaultZoomValue;- var defaultZoomValuePromise =- Preferences.get('defaultZoomValue').then(function (prefValue) {- defaultZoomValue = prefValue;- });+ store.initializedPromise.then(function resolved() {+ var storedHash = null;+ if (self.preferenceShowPreviousViewOnLoad &&+ store.get('exists', false)) {+ var pageNum = store.get('page', '1');+ var zoom = self.preferenceDefaultZoomValue ||+ store.get('zoom', DEFAULT_SCALE_VALUE);+ var left = store.get('scrollLeft', '0');+ var top = store.get('scrollTop', '0');++ storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' ++ left + ',' + top;+ } else if (self.preferenceDefaultZoomValue) {+ storedHash = 'page=1&zoom=' + self.preferenceDefaultZoomValue;+ }+ self.setInitialView(storedHash, scale);- var storePromise = store.initializedPromise;- Promise.all([firstPagePromise, storePromise, defaultZoomValuePromise]).then(- function resolved() {- var storedHash = null;- if (PDFViewerApplication.preferenceShowPreviousViewOnLoad &&- store.get('exists', false)) {- var pageNum = store.get('page', '1');- var zoom = defaultZoomValue ||- store.get('zoom', self.pdfViewer.currentScale);- var left = store.get('scrollLeft', '0');- var top = store.get('scrollTop', '0');-- storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' +- left + ',' + top;- } else if (defaultZoomValue) {- storedHash = 'page=1&zoom=' + defaultZoomValue;- }- self.setInitialView(storedHash, scale);-- // Make all navigation keys work on document load,- // unless the viewer is embedded in a web page.- if (!self.isViewerEmbedded) {- self.pdfViewer.focus();- }- }, function rejected(reason) {- console.error(reason);-- firstPagePromise.then(function () {+ // Make all navigation keys work on document load,+ // unless the viewer is embedded in a web page.+ if (!self.isViewerEmbedded) {+ self.pdfViewer.focus();+ }+ }, function rejected(reason) {+ console.error(reason);self.setInitialView(null, scale);});});@@ -6187,7 +6652,7 @@ var PDFViewerApplication = {self.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript);}// Hack to support auto printing.- var regex = /\bprint\s*\(/g;+ var regex = /\bprint\s*\(/;for (var i = 0, ii = javaScript.length; i < ii; i++) {var js = javaScript[i];if (js && regex.test(js)) {@@ -6209,7 +6674,7 @@ var PDFViewerApplication = {self.outline = new PDFOutlineView({container: container,outline: outline,- linkService: self+ linkService: self.pdfLinkService});self.outline.render();document.getElementById('viewOutline').disabled = !outline;@@ -6288,30 +6753,29 @@ var PDFViewerApplication = {setInitialView: function pdfViewSetInitialView(storedHash, scale) {this.isInitialViewSet = true;- // When opening a new file (when one is already loaded in the viewer):- // Reset 'currentPageNumber', since otherwise the page's scale will be wrong- // if 'currentPageNumber' is larger than the number of pages in the file.+ // When opening a new file, when one is already loaded in the viewer,+ // ensure that the 'pageNumber' element displays the correct value.document.getElementById('pageNumber').value =- this.pdfViewer.currentPageNumber = 1;+ this.pdfViewer.currentPageNumber;- if (PDFHistory.initialDestination) {- this.navigateTo(PDFHistory.initialDestination);- PDFHistory.initialDestination = null;+ if (this.initialDestination) {+ this.pdfLinkService.navigateTo(this.initialDestination);+ this.initialDestination = null;} else if (this.initialBookmark) {- this.setHash(this.initialBookmark);- PDFHistory.push({ hash: this.initialBookmark }, !!this.initialBookmark);+ this.pdfLinkService.setHash(this.initialBookmark);+ this.pdfHistory.push({ hash: this.initialBookmark }, true);this.initialBookmark = null;} else if (storedHash) {- this.setHash(storedHash);+ this.pdfLinkService.setHash(storedHash);} else if (scale) {- this.setScale(scale, true);+ this.pdfViewer.currentScaleValue = scale;this.page = 1;}- if (this.pdfViewer.currentScale === UNKNOWN_SCALE) {+ if (!this.pdfViewer.currentScaleValue) {// Scale was not initialized: invalid bookmark or scale was not specified.// Setting the default one.- this.setScale(DEFAULT_SCALE, true);+ this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;}},@@ -6327,84 +6791,6 @@ var PDFViewerApplication = {this.pdfRenderingQueue.renderHighestPriority();},- setHash: function pdfViewSetHash(hash) {- if (!this.isInitialViewSet) {- this.initialBookmark = hash;- return;- }- if (!hash) {- return;- }-- if (hash.indexOf('=') >= 0) {- var params = this.parseQueryString(hash);- // borrowing syntax from "Parameters for Opening PDF Files"- if ('nameddest' in params) {- PDFHistory.updateNextHashParam(params.nameddest);- this.navigateTo(params.nameddest);- return;- }- var pageNumber, dest;- if ('page' in params) {- pageNumber = (params.page | 0) || 1;- }- if ('zoom' in params) {- // Build the destination array.- var zoomArgs = params.zoom.split(','); // scale,left,top- var zoomArg = zoomArgs[0];- var zoomArgNumber = parseFloat(zoomArg);-- if (zoomArg.indexOf('Fit') === -1) {- // If the zoomArg is a number, it has to get divided by 100. If it's- // a string, it should stay as it is.- dest = [null, { name: 'XYZ' },- zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null,- zoomArgs.length > 2 ? (zoomArgs[2] | 0) : null,- (zoomArgNumber ? zoomArgNumber / 100 : zoomArg)];- } else {- if (zoomArg === 'Fit' || zoomArg === 'FitB') {- dest = [null, { name: zoomArg }];- } else if ((zoomArg === 'FitH' || zoomArg === 'FitBH') ||- (zoomArg === 'FitV' || zoomArg === 'FitBV')) {- dest = [null, { name: zoomArg },- zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null];- } else if (zoomArg === 'FitR') {- if (zoomArgs.length !== 5) {- console.error('pdfViewSetHash: ' +- 'Not enough parameters for \'FitR\'.');- } else {- dest = [null, { name: zoomArg },- (zoomArgs[1] | 0), (zoomArgs[2] | 0),- (zoomArgs[3] | 0), (zoomArgs[4] | 0)];- }- } else {- console.error('pdfViewSetHash: \'' + zoomArg +- '\' is not a valid zoom value.');- }- }- }- if (dest) {- this.pdfViewer.scrollPageIntoView(pageNumber || this.page, dest);- } else if (pageNumber) {- this.page = pageNumber; // simple page- }- if ('pagemode' in params) {- if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks' ||- params.pagemode === 'attachments') {- this.switchSidebarView((params.pagemode === 'bookmarks' ?- 'outline' : params.pagemode), true);- } else if (params.pagemode === 'none' && this.sidebarOpen) {- document.getElementById('sidebarToggle').click();- }- }- } else if (/^\d+$/.test(hash)) { // page number- this.page = hash;- } else { // named destination- PDFHistory.updateNextHashParam(unescape(hash));- this.navigateTo(unescape(hash));- }- },-refreshThumbnailViewer: function pdfViewRefreshThumbnailViewer() {var pdfViewer = this.pdfViewer;var thumbnailViewer = this.pdfThumbnailViewer;@@ -6480,19 +6866,6 @@ var PDFViewerApplication = {}},- // Helper function to parse query string (e.g. ?param1=value&parm2=...).- parseQueryString: function pdfViewParseQueryString(query) {- var parts = query.split('&');- var params = {};- for (var i = 0, ii = parts.length; i < ii; ++i) {- var param = parts[i].split('=');- var key = param[0].toLowerCase();- var value = param.length > 1 ? param[1] : null;- params[decodeURIComponent(key)] = decodeURIComponent(value);- }- return params;- },-beforePrint: function pdfViewSetupBeforePrint() {if (!this.supportsPrinting) {var printMessage = mozL10n.get('printing_not_supported', null,@@ -6503,7 +6876,7 @@ var PDFViewerApplication = {var alertNotReady = false;var i, ii;- if (!this.pagesCount) {+ if (!this.pdfDocument || !this.pagesCount) {alertNotReady = true;} else {for (i = 0, ii = this.pagesCount; i < ii; ++i) {@@ -6525,28 +6898,69 @@ var PDFViewerApplication = {var body = document.querySelector('body');body.setAttribute('data-mozPrintCallback', true);++ if (!this.hasEqualPageSizes) {+ console.warn('Not all pages have the same size. The printed result ' ++ 'may be incorrect!');+ }++ // Insert a @page + size rule to make sure that the page size is correctly+ // set. Note that we assume that all pages have the same size, because+ // variable-size pages are not supported yet (at least in Chrome & Firefox).+ // TODO(robwu): Use named pages when size calculation bugs get resolved+ // (e.g. https://crbug.com/355116) AND when support for named pages is+ // added (http://www.w3.org/TR/css3-page/#using-named-pages).+ // In browsers where @page + size is not supported (such as Firefox,+ // https://bugzil.la/851441), the next stylesheet will be ignored and the+ // user has to select the correct paper size in the UI if wanted.+ this.pageStyleSheet = document.createElement('style');+ var pageSize = this.pdfViewer.getPageView(0).pdfPage.getViewport(1);+ this.pageStyleSheet.textContent =+ // "size:<width> <height>" is what we need. But also add "A4" because+ // Firefox incorrectly reports support for the other value.+ '@supports ((size:A4) and (size:1pt 1pt)) {' ++ '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' ++ // The canvas and each ancestor node must have a height of 100% to make+ // sure that each canvas is printed on exactly one page.+ '#printContainer {height:100%}' ++ '#printContainer > div {width:100% !important;height:100% !important;}' ++ '}';+ body.appendChild(this.pageStyleSheet);+for (i = 0, ii = this.pagesCount; i < ii; ++i) {this.pdfViewer.getPageView(i).beforePrint();}},+ // Whether all pages of the PDF have the same width and height.+ get hasEqualPageSizes() {+ var firstPage = this.pdfViewer.getPageView(0);+ for (var i = 1, ii = this.pagesCount; i < ii; ++i) {+ var pageView = this.pdfViewer.getPageView(i);+ if (pageView.width !== firstPage.width ||+ pageView.height !== firstPage.height) {+ return false;+ }+ }+ return true;+ },+afterPrint: function pdfViewSetupAfterPrint() {var div = document.getElementById('printContainer');while (div.hasChildNodes()) {div.removeChild(div.lastChild);}+ if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {+ this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);+ this.pageStyleSheet = null;+ }+this.printing = false;this.forceRendering();},- setScale: function (value, resetAutoSettings) {- this.updateScaleControls = !!resetAutoSettings;- this.pdfViewer.currentScaleValue = value;- this.updateScaleControls = true;- },-rotatePages: function pdfViewRotatePages(delta) {var pageNumber = this.page;this.pageRotation = (this.pageRotation + 360 + delta) % 360;@@ -6558,72 +6972,21 @@ var PDFViewerApplication = {this.pdfViewer.scrollPageIntoView(pageNumber);},- /**- * This function flips the page in presentation mode if the user scrolls up- * or down with large enough motion and prevents page flipping too often.- *- * @this {PDFView}- * @param {number} mouseScrollDelta The delta value from the mouse event.- */- mouseScroll: function pdfViewMouseScroll(mouseScrollDelta) {- var MOUSE_SCROLL_COOLDOWN_TIME = 50;-- var currentTime = (new Date()).getTime();- var storedTime = this.mouseScrollTimeStamp;-- // In case one page has already been flipped there is a cooldown time- // which has to expire before next page can be scrolled on to.- if (currentTime > storedTime &&- currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {+ requestPresentationMode: function pdfViewRequestPresentationMode() {+ if (!this.pdfPresentationMode) {return;}-- // In case the user decides to scroll to the opposite direction than before- // clear the accumulated delta.- if ((this.mouseScrollDelta > 0 && mouseScrollDelta < 0) ||- (this.mouseScrollDelta < 0 && mouseScrollDelta > 0)) {- this.clearMouseScrollState();- }-- this.mouseScrollDelta += mouseScrollDelta;-- var PAGE_FLIP_THRESHOLD = 120;- if (Math.abs(this.mouseScrollDelta) >= PAGE_FLIP_THRESHOLD) {-- var PageFlipDirection = {- UP: -1,- DOWN: 1- };-- // In presentation mode scroll one page at a time.- var pageFlipDirection = (this.mouseScrollDelta > 0) ?- PageFlipDirection.UP :- PageFlipDirection.DOWN;- this.clearMouseScrollState();- var currentPage = this.page;-- // In case we are already on the first or the last page there is no need- // to do anything.- if ((currentPage === 1 && pageFlipDirection === PageFlipDirection.UP) ||- (currentPage === this.pagesCount &&- pageFlipDirection === PageFlipDirection.DOWN)) {- return;- }-- this.page += pageFlipDirection;- this.mouseScrollTimeStamp = currentTime;- }+ this.pdfPresentationMode.request();},/**- * This function clears the member attributes used with mouse scrolling in- * presentation mode.- *- * @this {PDFView}+ * @param {number} delta - The delta value from the mouse event.*/- clearMouseScrollState: function pdfViewClearMouseScrollState() {- this.mouseScrollTimeStamp = 0;- this.mouseScrollDelta = 0;+ scrollPresentationMode: function pdfViewScrollPresentationMode(delta) {+ if (!this.pdfPresentationMode) {+ return;+ }+ this.pdfPresentationMode.mouseScroll(delta);}};window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias@@ -6635,7 +6998,7 @@ function webViewerLoad(evt) {function webViewerInitialized() {var queryString = document.location.search.substring(1);- var params = PDFViewerApplication.parseQueryString(queryString);+ var params = parseQueryString(queryString);var file = 'file' in params ? params.file : DEFAULT_URL;var fileInput = document.createElement('input');@@ -6657,7 +7020,7 @@ function webViewerInitialized() {if (PDFViewerApplication.preferencePdfBugEnabled) {// Special debugging flags in the hash section of the URL.var hash = document.location.hash.substring(1);- var hashParams = PDFViewerApplication.parseQueryString(hash);+ var hashParams = parseQueryString(hash);if ('disableworker' in hashParams) {PDFJS.disableWorker = (hashParams['disableworker'] === 'true');@@ -6811,10 +7174,12 @@ function webViewerInitialized() {}});- document.getElementById('scaleSelect').addEventListener('change',- function() {- PDFViewerApplication.setScale(this.value, false);- });+ document.getElementById('scaleSelect').addEventListener('change', function() {+ if (this.value === 'custom') {+ return;+ }+ PDFViewerApplication.pdfViewer.currentScaleValue = this.value;+ });document.getElementById('presentationMode').addEventListener('click',SecondaryToolbar.presentationModeClick.bind(SecondaryToolbar));@@ -6876,13 +7241,13 @@ document.addEventListener('pagerendered', function (e) {'An error occurred while rendering the page.'), pageView.error);}-// If the page is still visible when it has finished rendering,// ensure that the page number input loading indicator is hidden.if (pageNumber === PDFViewerApplication.page) {var pageNumberInput = document.getElementById('pageNumber');pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);}+}, true);document.addEventListener('textlayerrendered', function (e) {@@ -6891,6 +7256,23 @@ document.addEventListener('textlayerrendered', function (e) {}, true);+document.addEventListener('namedaction', function (e) {+ // Processing couple of named actions that might be useful.+ // See also PDFLinkService.executeNamedAction+ var action = e.action;+ switch (action) {+ case 'GoToPage':+ document.getElementById('pageNumber').focus();+ break;++ case 'Find':+ if (!this.supportsIntegratedFind) {+ this.findBar.toggle();+ }+ break;+ }+}, true);+window.addEventListener('presentationmodechanged', function (e) {var active = e.detail.active;var switchInProgress = e.detail.switchInProgress;@@ -6899,19 +7281,11 @@ window.addEventListener('presentationmodechanged', function (e) {active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;});-function updateViewarea() {- if (!PDFViewerApplication.initialized) {- return;- }- PDFViewerApplication.pdfViewer.update();-}--window.addEventListener('updateviewarea', function () {+window.addEventListener('updateviewarea', function (evt) {if (!PDFViewerApplication.initialized) {return;}-- var location = PDFViewerApplication.pdfViewer.location;+ var location = evt.location;PDFViewerApplication.store.initializedPromise.then(function() {PDFViewerApplication.store.setMultiple({@@ -6924,12 +7298,14 @@ window.addEventListener('updateviewarea', function () {// unable to write to storage});});- var href = PDFViewerApplication.getAnchorUrl(location.pdfOpenParams);+ var href =+ PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);document.getElementById('viewBookmark').href = href;document.getElementById('secondaryViewBookmark').href = href;// Update the current bookmark in the browsing history.- PDFHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);+ PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams,+ location.pageNumber);// Show/hide the loading indicator in the page number input element.var pageNumberInput = document.getElementById('pageNumber');@@ -6944,22 +7320,37 @@ window.addEventListener('updateviewarea', function () {}, true);window.addEventListener('resize', function webViewerResize(evt) {- if (PDFViewerApplication.initialized &&- (document.getElementById('pageWidthOption').selected ||- document.getElementById('pageFitOption').selected ||- document.getElementById('pageAutoOption').selected)) {- var selectedScale = document.getElementById('scaleSelect').value;- PDFViewerApplication.setScale(selectedScale, false);+ if (PDFViewerApplication.initialized) {+ var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue;+ if (currentScaleValue === 'auto' ||+ currentScaleValue === 'page-fit' ||+ currentScaleValue === 'page-width') {+ // Note: the scale is constant for 'page-actual'.+ PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;+ } else if (!currentScaleValue) {+ // Normally this shouldn't happen, but if the scale wasn't initialized+ // we set it to the default value in order to prevent any issues.+ // (E.g. the document being rendered with the wrong scale on load.)+ PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;+ }+ PDFViewerApplication.pdfViewer.update();}- updateViewarea();// Set the 'max-height' CSS property of the secondary toolbar.SecondaryToolbar.setMaxHeight(document.getElementById('viewerContainer'));});window.addEventListener('hashchange', function webViewerHashchange(evt) {- if (PDFHistory.isHashChangeUnlocked) {- PDFViewerApplication.setHash(document.location.hash.substring(1));+ if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) {+ var hash = document.location.hash.substring(1);+ if (!hash) {+ return;+ }+ if (!PDFViewerApplication.isInitialViewSet) {+ PDFViewerApplication.initialBookmark = hash;+ } else {+ PDFViewerApplication.pdfLinkService.setHash(hash);+ }}});@@ -6997,7 +7388,7 @@ window.addEventListener('change', function webViewerChange(evt) {function selectScaleOption(value) {var options = document.getElementById('scaleSelect').options;var predefinedValueFound = false;- for (var i = 0; i < options.length; i++) {+ for (var i = 0, ii = options.length; i < ii; i++) {var option = options[i];if (option.value !== value) {option.selected = false;@@ -7039,31 +7430,20 @@ window.addEventListener('scalechange', function scalechange(evt) {document.getElementById('zoomOut').disabled = (evt.scale === MIN_SCALE);document.getElementById('zoomIn').disabled = (evt.scale === MAX_SCALE);- var customScaleOption = document.getElementById('customScaleOption');- customScaleOption.selected = false;-- if (!PDFViewerApplication.updateScaleControls &&- (document.getElementById('pageWidthOption').selected ||- document.getElementById('pageFitOption').selected ||- document.getElementById('pageAutoOption').selected)) {- updateViewarea();- return;- }-- if (evt.presetValue) {- selectScaleOption(evt.presetValue);- updateViewarea();- return;- }-- var predefinedValueFound = selectScaleOption('' + evt.scale);+ // Update the 'scaleSelect' DOM element.+ var predefinedValueFound = selectScaleOption(evt.presetValue ||+ '' + evt.scale);if (!predefinedValueFound) {+ var customScaleOption = document.getElementById('customScaleOption');var customScale = Math.round(evt.scale * 10000) / 100;customScaleOption.textContent =mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');customScaleOption.selected = true;}- updateViewarea();+ if (!PDFViewerApplication.initialized) {+ return;+ }+ PDFViewerApplication.pdfViewer.update();}, true);window.addEventListener('pagechange', function pagechange(evt) {@@ -7089,16 +7469,6 @@ window.addEventListener('pagechange', function pagechange(evt) {Stats.add(page, pageView.stats);}}-- // checking if the this.page was called from the updateViewarea function- if (evt.updateInProgress) {- return;- }- // Avoid scrolling the first page during loading- if (this.loading && page === 1) {- return;- }- PDFViewerApplication.pdfViewer.scrollPageIntoView(page);}, true);function handleMouseWheel(evt) {@@ -7107,12 +7477,31 @@ function handleMouseWheel(evt) {evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR;var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn';- if (PresentationMode.active) {+ var pdfViewer = PDFViewerApplication.pdfViewer;+ if (pdfViewer.isInPresentationMode) {evt.preventDefault();- PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);- } else if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer+ PDFViewerApplication.scrollPresentationMode(ticks *+ MOUSE_WHEEL_DELTA_FACTOR);+ } else if (evt.ctrlKey || evt.metaKey) {+ // Only zoom the pages, not the entire viewer.evt.preventDefault();++ var previousScale = pdfViewer.currentScale;+PDFViewerApplication[direction](Math.abs(ticks));++ var currentScale = pdfViewer.currentScale;+ if (previousScale !== currentScale) {+ // After scaling the page via zoomIn/zoomOut, the position of the upper-+ // left corner is restored. When the mouse wheel is used, the position+ // under the cursor should be restored instead.+ var scaleCorrectionFactor = currentScale / previousScale - 1;+ var rect = pdfViewer.container.getBoundingClientRect();+ var dx = evt.clientX - rect.left;+ var dy = evt.clientY - rect.top;+ pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;+ pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;+ }}}@@ -7120,15 +7509,9 @@ window.addEventListener('DOMMouseScroll', handleMouseWheel);window.addEventListener('mousewheel', handleMouseWheel);window.addEventListener('click', function click(evt) {- if (!PresentationMode.active) {- if (SecondaryToolbar.opened &&+ if (SecondaryToolbar.opened &&PDFViewerApplication.pdfViewer.containsElement(evt.target)) {- SecondaryToolbar.close();- }- } else if (evt.button === 0) {- // Necessary since preventDefault() in 'mousedown' won't stop- // the event propagation in all circumstances in presentation mode.- evt.preventDefault();+ SecondaryToolbar.close();}}, false);@@ -7143,15 +7526,13 @@ window.addEventListener('keydown', function keydown(evt) {(evt.shiftKey ? 4 : 0) |(evt.metaKey ? 8 : 0);+ var pdfViewer = PDFViewerApplication.pdfViewer;+ var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;+// First, handle the key bindings that are independent whether an input// control is selected or not.if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {// either CTRL or META key with optional SHIFT.- var pdfViewer = PDFViewerApplication.pdfViewer;- var inPresentationMode = pdfViewer &&- (pdfViewer.presentationModeState === PresentationModeState.CHANGING ||- pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN);-switch (evt.keyCode) {case 70: // fif (!PDFViewerApplication.supportsIntegratedFind) {@@ -7170,7 +7551,7 @@ window.addEventListener('keydown', function keydown(evt) {case 107: // FF '+' and '='case 187: // Chrome '+'case 171: // FF with German keyboard- if (!inPresentationMode) {+ if (!isViewerInPresentationMode) {PDFViewerApplication.zoomIn();}handled = true;@@ -7178,18 +7559,18 @@ window.addEventListener('keydown', function keydown(evt) {case 173: // FF/Mac '-'case 109: // FF '-'case 189: // Chrome '-'- if (!inPresentationMode) {+ if (!isViewerInPresentationMode) {PDFViewerApplication.zoomOut();}handled = true;break;case 48: // '0'case 96: // '0' on Numpad of Swedish keyboard- if (!inPresentationMode) {+ if (!isViewerInPresentationMode) {// keeping it unhandled (to restore page zoom to 100%)setTimeout(function () {// ... and resetting the scale after browser adjusts its scale- PDFViewerApplication.setScale(DEFAULT_SCALE, true);+ pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;});handled = false;}@@ -7211,7 +7592,7 @@ window.addEventListener('keydown', function keydown(evt) {if (cmd === 3 || cmd === 10) {switch (evt.keyCode) {case 80: // p- SecondaryToolbar.presentationModeClick();+ PDFViewerApplication.requestPresentationMode();handled = true;break;case 71: // g@@ -7239,21 +7620,22 @@ window.addEventListener('keydown', function keydown(evt) {return;}}+ var ensureViewerFocused = false;if (cmd === 0) { // no control key pressed at all.switch (evt.keyCode) {case 38: // up arrowcase 33: // pg upcase 8: // backspace- if (!PresentationMode.active &&- PDFViewerApplication.currentScaleValue !== 'page-fit') {+ if (!isViewerInPresentationMode &&+ pdfViewer.currentScaleValue !== 'page-fit') {break;}/* in presentation mode *//* falls through */case 37: // left arrow// horizontal scrolling using arrow keys- if (PDFViewerApplication.pdfViewer.isHorizontalScrollbarEnabled) {+ if (pdfViewer.isHorizontalScrollbarEnabled) {break;}/* falls through */@@ -7276,14 +7658,14 @@ window.addEventListener('keydown', function keydown(evt) {case 40: // down arrowcase 34: // pg downcase 32: // spacebar- if (!PresentationMode.active &&- PDFViewerApplication.currentScaleValue !== 'page-fit') {+ if (!isViewerInPresentationMode &&+ pdfViewer.currentScaleValue !== 'page-fit') {break;}/* falls through */case 39: // right arrow// horizontal scrolling using arrow keys- if (PDFViewerApplication.pdfViewer.isHorizontalScrollbarEnabled) {+ if (pdfViewer.isHorizontalScrollbarEnabled) {break;}/* falls through */@@ -7294,21 +7676,23 @@ window.addEventListener('keydown', function keydown(evt) {break;case 36: // home- if (PresentationMode.active || PDFViewerApplication.page > 1) {+ if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {PDFViewerApplication.page = 1;handled = true;+ ensureViewerFocused = true;}break;case 35: // end- if (PresentationMode.active || (PDFViewerApplication.pdfDocument &&+ if (isViewerInPresentationMode || (PDFViewerApplication.pdfDocument &&PDFViewerApplication.page < PDFViewerApplication.pagesCount)) {PDFViewerApplication.page = PDFViewerApplication.pagesCount;handled = true;+ ensureViewerFocused = true;}break;case 72: // 'h'- if (!PresentationMode.active) {+ if (!isViewerInPresentationMode) {HandTool.toggle();}break;@@ -7321,8 +7705,8 @@ window.addEventListener('keydown', function keydown(evt) {if (cmd === 4) { // shift-keyswitch (evt.keyCode) {case 32: // spacebar- if (!PresentationMode.active &&- PDFViewerApplication.currentScaleValue !== 'page-fit') {+ if (!isViewerInPresentationMode &&+ pdfViewer.currentScaleValue !== 'page-fit') {break;}PDFViewerApplication.page--;@@ -7335,44 +7719,42 @@ window.addEventListener('keydown', function keydown(evt) {}}- if (!handled && !PresentationMode.active) {+ if (!handled && !isViewerInPresentationMode) {// 33=Page Up 34=Page Down 35=End 36=Home// 37=Left 38=Up 39=Right 40=Down- if (evt.keyCode >= 33 && evt.keyCode <= 40 &&- !PDFViewerApplication.pdfViewer.containsElement(curElement)) {- // The page container is not focused, but a page navigation key has been- // pressed. Change the focus to the viewer container to make sure that- // navigation by keyboard works as expected.- PDFViewerApplication.pdfViewer.focus();- }// 32=Spacebar- if (evt.keyCode === 32 && curElementTagName !== 'BUTTON') {- if (!PDFViewerApplication.pdfViewer.containsElement(curElement)) {- PDFViewerApplication.pdfViewer.focus();- }+ if ((evt.keyCode >= 33 && evt.keyCode <= 40) ||+ (evt.keyCode === 32 && curElementTagName !== 'BUTTON')) {+ ensureViewerFocused = true;}}if (cmd === 2) { // alt-keyswitch (evt.keyCode) {case 37: // left arrow- if (PresentationMode.active) {- PDFHistory.back();+ if (isViewerInPresentationMode) {+ PDFViewerApplication.pdfHistory.back();handled = true;}break;case 39: // right arrow- if (PresentationMode.active) {- PDFHistory.forward();+ if (isViewerInPresentationMode) {+ PDFViewerApplication.pdfHistory.forward();handled = true;}break;}}+ if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {+ // The page container is not focused, but a page navigation key has been+ // pressed. Change the focus to the viewer container to make sure that+ // navigation by keyboard works as expected.+ pdfViewer.focus();+ }+if (handled) {evt.preventDefault();- PDFViewerApplication.clearMouseScrollState();}});@@ -7393,4 +7775,3 @@ window.addEventListener('afterprint', function afterPrint(evt) {});})();-