From 2ddac974c239792a3690837ea377ba94ba587ceb Mon Sep 17 00:00:00 2001 From: Daniel Varga Date: Mon, 10 Sep 2018 16:43:52 +0300 Subject: [PATCH] Backed out changeset c80bc4f44b7f (bug 1489996) for bc failures in browser/extensions/pdfjs/test/browser_pdfjs_main.js --- browser/extensions/pdfjs/README.mozilla | 4 +- browser/extensions/pdfjs/content/build/pdf.js | 36 +- .../pdfjs/content/build/pdf.worker.js | 284 +++-- .../extensions/pdfjs/content/web/viewer.html | 6 +- .../extensions/pdfjs/content/web/viewer.js | 984 ++++++++---------- browser/extensions/pdfjs/moz.yaml | 2 +- .../locales/en-US/pdfviewer/viewer.properties | 8 - 7 files changed, 599 insertions(+), 725 deletions(-) diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index c347382ddfd4..3fbbb6c55850 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,5 +1,5 @@ This is the PDF.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 2.0.841 +Current extension version is: 2.0.815 -Taken from upstream commit: bc5111d1 +Taken from upstream commit: d6927376 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 4303f96c166a..d386500ce8a3 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap "use strict"; -var pdfjsVersion = '2.0.841'; -var pdfjsBuild = 'bc5111d1'; +var pdfjsVersion = '2.0.815'; +var pdfjsBuild = 'd6927376'; var pdfjsSharedUtil = __w_pdfjs_require__(1); var pdfjsDisplayAPI = __w_pdfjs_require__(7); var pdfjsDisplayTextLayer = __w_pdfjs_require__(19); @@ -4226,7 +4226,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { } return worker.messageHandler.sendWithPromise('GetDocRequest', { docId, - apiVersion: '2.0.841', + apiVersion: '2.0.815', source: { data: source.data, url: source.url, @@ -5553,8 +5553,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { }(); var version, build; { - exports.version = version = '2.0.841'; - exports.build = build = 'bc5111d1'; + exports.version = version = '2.0.815'; + exports.build = build = 'd6927376'; } exports.getDocument = getDocument; exports.LoopbackPort = LoopbackPort; @@ -6354,7 +6354,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { if (canvasCtx) { addContextCurrentTransform(canvasCtx); } - this._cachedGetSinglePixelWidth = null; + this.cachedGetSinglePixelWidth = null; } function putBinaryImageData(ctx, imgData) { if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) { @@ -6829,12 +6829,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() { this.current = this.stateStack.pop(); this.ctx.restore(); this.pendingClip = null; - this._cachedGetSinglePixelWidth = null; + this.cachedGetSinglePixelWidth = null; } }, transform: function CanvasGraphics_transform(a, b, c, d, e, f) { this.ctx.transform(a, b, c, d, e, f); - this._cachedGetSinglePixelWidth = null; + this.cachedGetSinglePixelWidth = null; }, constructPath: function CanvasGraphics_constructPath(ops, args) { var ctx = this.ctx; @@ -7177,7 +7177,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { if (scale === 0 || lineWidth === 0) { var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK; if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { - this._cachedGetSinglePixelWidth = null; + this.cachedGetSinglePixelWidth = null; lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR; } } else { @@ -7269,7 +7269,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() { if (isTextInvisible || fontSize === 0) { return; } - this._cachedGetSinglePixelWidth = null; + this.cachedGetSinglePixelWidth = null; ctx.save(); ctx.transform.apply(ctx, current.textMatrix); ctx.translate(current.x, current.y); @@ -7737,12 +7737,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() { } ctx.beginPath(); }, - getSinglePixelWidth(scale) { - if (this._cachedGetSinglePixelWidth === null) { - const inverse = this.ctx.mozCurrentTransformInverse; - this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3])); + getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { + if (this.cachedGetSinglePixelWidth === null) { + this.ctx.save(); + var inverse = this.ctx.mozCurrentTransformInverse; + this.ctx.restore(); + this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3])); } - return this._cachedGetSinglePixelWidth; + return this.cachedGetSinglePixelWidth; }, getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { var transform = this.ctx.mozCurrentTransform; @@ -10013,8 +10015,8 @@ var renderTextLayer = function renderTextLayerClosure() { let fontFamily = textDiv.style.fontFamily; if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) { this._layoutTextCtx.font = fontSize + ' ' + fontFamily; - this._layoutTextLastFontSize = fontSize; - this._layoutTextLastFontFamily = fontFamily; + this._lastFontSize = fontSize; + this._lastFontFamily = fontFamily; } let width = this._layoutTextCtx.measureText(textDiv.textContent).width; let transform = ''; diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index 61b2c281be10..903de55cd2f8 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap "use strict"; -var pdfjsVersion = '2.0.841'; -var pdfjsBuild = 'bc5111d1'; +var pdfjsVersion = '2.0.815'; +var pdfjsBuild = 'd6927376'; var pdfjsCoreWorker = __w_pdfjs_require__(1); exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; @@ -327,7 +327,7 @@ var WorkerMessageHandler = { var cancelXHRs = null; var WorkerTasks = []; let apiVersion = docParams.apiVersion; - let workerVersion = '2.0.841'; + let workerVersion = '2.0.815'; if (apiVersion !== workerVersion) { throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); } @@ -22285,7 +22285,7 @@ exports.CMapFactory = CMapFactory; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getFontType = exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.SEAC_ANALYSIS_ENABLED = undefined; +exports.getFontType = exports.ProblematicCharRanges = exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.PRIVATE_USE_OFFSET_END = exports.PRIVATE_USE_OFFSET_START = exports.SEAC_ANALYSIS_ENABLED = undefined; var _util = __w_pdfjs_require__(2); @@ -22307,9 +22307,11 @@ var _stream = __w_pdfjs_require__(14); var _type1_parser = __w_pdfjs_require__(38); -const PRIVATE_USE_AREAS = [[0xE000, 0xF8FF], [0x100000, 0x10FFFD]]; +var PRIVATE_USE_OFFSET_START = 0xE000; +var PRIVATE_USE_OFFSET_END = 0xF8FF; +var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false; var PDF_GLYPH_SPACE_UNITS = 1000; -var SEAC_ANALYSIS_ENABLED = true; +var SEAC_ANALYSIS_ENABLED = false; var FontFlags = { FixedPitch: 1, Serif: 2, @@ -22588,6 +22590,7 @@ var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() { }; return OpenTypeFileBuilder; }(); +var ProblematicCharRanges = new Int32Array([0x0000, 0x0020, 0x007F, 0x00A1, 0x00AD, 0x00AE, 0x0600, 0x0780, 0x08A0, 0x10A0, 0x1780, 0x1800, 0x1C00, 0x1C50, 0x2000, 0x2010, 0x2011, 0x2012, 0x2028, 0x2030, 0x205F, 0x2070, 0x25CC, 0x25CD, 0x3000, 0x3001, 0x3164, 0x3165, 0xAA60, 0xAA80, 0xD800, 0xE000, 0xFFF0, 0x10000]); var Font = function FontClosure() { function Font(name, file, properties) { var charCode; @@ -22791,33 +22794,58 @@ var Font = function FontClosure() { } return toFontChar; } - function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId) { + function isProblematicUnicodeLocation(code) { + 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; + } + } + return !(i & 1); + } + function adjustMapping(charCodeToGlyphId, properties, missingGlyphs) { + var toUnicode = properties.toUnicode; + var isSymbolic = !!(properties.flags & FontFlags.Symbolic); + var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap; var newMap = Object.create(null); var toFontChar = []; - var privateUseAreaIndex = 0; - var nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0]; - var privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1]; + var usedFontCharCodes = []; + var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START; for (var originalCharCode in charCodeToGlyphId) { originalCharCode |= 0; var glyphId = charCodeToGlyphId[originalCharCode]; - if (!hasGlyph(glyphId)) { + if (missingGlyphs[glyphId]) { continue; } - if (nextAvailableFontCharCode > privateUseOffetEnd) { - privateUseAreaIndex++; - if (privateUseAreaIndex >= PRIVATE_USE_AREAS.length) { - (0, _util.warn)('Ran out of space in font private use area.'); - break; + var fontCharCode = originalCharCode; + var hasUnicodeValue = false; + if (!isIdentityUnicode && toUnicode.has(originalCharCode)) { + hasUnicodeValue = true; + var unicode = toUnicode.get(fontCharCode); + if (unicode.length === 1) { + fontCharCode = unicode.charCodeAt(0); } - nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0]; - privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1]; } - var fontCharCode = nextAvailableFontCharCode++; - if (glyphId === 0) { - glyphId = newGlyphZeroId; + if (usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) { + do { + if (nextAvailableFontCharCode > PRIVATE_USE_OFFSET_END) { + (0, _util.warn)('Ran out of space in font private use area.'); + break; + } + fontCharCode = nextAvailableFontCharCode++; + if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) { + fontCharCode = 0xF020; + nextAvailableFontCharCode = fontCharCode + 1; + } + } while (usedFontCharCodes[fontCharCode] !== undefined); } newMap[fontCharCode] = glyphId; toFontChar[originalCharCode] = fontCharCode; + usedFontCharCodes[fontCharCode] = true; } return { toFontChar, @@ -23004,9 +23032,6 @@ var Font = function FontClosure() { throw new _util.FormatError('Unicode ranges Bits > 123 are reserved for internal usage'); } } - if (lastCharIndex > 0xFFFF) { - lastCharIndex = 0xFFFF; - } } else { firstCharIndex = 0; lastCharIndex = 255; @@ -23560,12 +23585,13 @@ var Font = function FontClosure() { data[offset + 1] = value >> 1 & 0xFF; }; } - var numGlyphsOut = dupFirstEntry ? numGlyphs + 1 : numGlyphs; var locaData = loca.data; - var locaDataSize = itemSize * (1 + numGlyphsOut); - locaData = new Uint8Array(locaDataSize); - locaData.set(loca.data.subarray(0, locaDataSize)); - loca.data = locaData; + var locaDataSize = itemSize * (1 + numGlyphs); + if (locaData.length !== locaDataSize) { + locaData = new Uint8Array(locaDataSize); + locaData.set(loca.data.subarray(0, locaDataSize)); + loca.data = locaData; + } var oldGlyfData = glyf.data; var oldGlyfDataLength = oldGlyfData.length; var newGlyfData = new Uint8Array(oldGlyfDataLength); @@ -23574,7 +23600,8 @@ var Font = function FontClosure() { var missingGlyphs = Object.create(null); itemEncode(locaData, 0, writeOffset); var i, j; - for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { + var locaCount = dupFirstEntry ? numGlyphs - 1 : numGlyphs; + for (i = 0, j = itemSize; i < locaCount; i++, j += itemSize) { var endOffset = itemDecode(locaData, j); if (endOffset === 0) { endOffset = startOffset; @@ -23599,7 +23626,7 @@ var Font = function FontClosure() { } if (writeOffset === 0) { var simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]); - for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) { + for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { itemEncode(locaData, j, simpleGlyph.length); } glyf.data = simpleGlyph; @@ -24018,14 +24045,7 @@ var Font = function FontClosure() { } font.pos = (font.start || 0) + tables['maxp'].offset; var version = font.getInt32(); - const numGlyphs = font.getUint16(); - let numGlyphsOut = numGlyphs + 1; - let dupFirstEntry = true; - if (numGlyphsOut > 0xFFFF) { - dupFirstEntry = false; - numGlyphsOut = numGlyphs; - (0, _util.warn)('Not enough space in glyfs to duplicate first glyph.'); - } + var numGlyphs = font.getUint16(); var maxFunctionDefs = 0; var maxSizeOfInstructions = 0; if (version >= 0x00010000 && tables['maxp'].length >= 22) { @@ -24040,15 +24060,20 @@ var Font = function FontClosure() { font.pos += 4; maxSizeOfInstructions = font.getUint16(); } - tables['maxp'].data[4] = numGlyphsOut >> 8; - tables['maxp'].data[5] = numGlyphsOut & 255; + var dupFirstEntry = false; + if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') { + dupFirstEntry = true; + numGlyphs++; + tables['maxp'].data[4] = numGlyphs >> 8; + tables['maxp'].data[5] = numGlyphs & 255; + } var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs); if (!hintsValid) { delete tables['fpgm']; delete tables['prep']; delete tables['cvt ']; } - sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphsOut); + sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs); if (!tables['head']) { throw new _util.FormatError('Required "head" table is not found'); } @@ -24080,12 +24105,11 @@ var Font = function FontClosure() { this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm; this.descent = metricsOverride.descent / metricsOverride.unitsPerEm; if (tables['post']) { - readPostScriptTable(tables['post'], properties, numGlyphs); + var valid = readPostScriptTable(tables['post'], properties, numGlyphs); + if (!valid) { + tables['post'] = null; + } } - tables['post'] = { - tag: 'post', - data: createPostTable(properties) - }; var charCodeToGlyphId = [], charCode; function hasGlyph(glyphId) { @@ -24108,6 +24132,9 @@ var Font = function FontClosure() { charCodeToGlyphId[charCode] = glyphId; } }); + if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) { + charCodeToGlyphId[0] = numGlyphs - 1; + } } else { var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding); var cmapPlatformId = cmapTable.platformId; @@ -24175,15 +24202,11 @@ var Font = function FontClosure() { if (charCodeToGlyphId.length === 0) { charCodeToGlyphId[0] = 0; } - let glyphZeroId = numGlyphsOut - 1; - if (!dupFirstEntry) { - glyphZeroId = 0; - } - var newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId); + var newMapping = adjustMapping(charCodeToGlyphId, properties, missingGlyphs); this.toFontChar = newMapping.toFontChar; tables['cmap'] = { tag: 'cmap', - data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphsOut) + data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs) }; if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) { tables['OS/2'] = { @@ -24191,12 +24214,17 @@ var Font = function FontClosure() { data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride) }; } + if (!tables['post']) { + tables['post'] = { + tag: 'post', + data: createPostTable(properties) + }; + } if (!isTrueType) { try { cffFile = new _stream.Stream(tables['CFF '].data); var parser = new _cff_parser.CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED); cff = parser.parse(); - cff.duplicateFirstGlyph(); var compiler = new _cff_parser.CFFCompiler(cff); tables['CFF '].data = compiler.compile(); } catch (e) { @@ -24223,12 +24251,8 @@ var Font = function FontClosure() { if (properties.builtInEncoding) { adjustToUnicode(properties, properties.builtInEncoding); } - let glyphZeroId = 1; - if (font instanceof CFFFont) { - glyphZeroId = font.numGlyphs - 1; - } var mapping = font.getGlyphMapping(properties); - var newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId); + var newMapping = adjustMapping(mapping, properties, Object.create(null)); this.toFontChar = newMapping.toFontChar; var numGlyphs = font.numGlyphs; function getCharCodes(charCodeToGlyphId, glyphId) { @@ -24379,11 +24403,11 @@ var Font = function FontClosure() { var seac = this.seacMap[charcode]; fontCharCode = seac.baseFontCharCode; accent = { - fontChar: String.fromCodePoint(seac.accentFontCharCode), + fontChar: String.fromCharCode(seac.accentFontCharCode), offset: seac.accentOffset }; } - var fontChar = typeof fontCharCode === 'number' ? String.fromCodePoint(fontCharCode) : ''; + var fontChar = String.fromCharCode(fontCharCode); var glyph = this.glyphCache[charcode]; if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) { glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont); @@ -24645,16 +24669,6 @@ var Type1Font = function Type1FontClosure() { } return type1FontGlyphMapping(properties, builtInEncoding, glyphNames); }, - hasGlyphId: function Type1Font_hasGlyphID(id) { - if (id < 0 || id >= this.numGlyphs) { - return false; - } - if (id === 0) { - return true; - } - var glyph = this.charstrings[id - 1]; - return glyph.charstring.length > 0; - }, getSeacs: function Type1Font_getSeacs(charstrings) { var i, ii; var seacMap = []; @@ -24732,7 +24746,12 @@ var Type1Font = function Type1FontClosure() { var charStringsIndex = new _cff_parser.CFFIndex(); charStringsIndex.add([0x8B, 0x0E]); for (i = 0; i < count; i++) { - charStringsIndex.add(glyphs[i]); + var glyph = glyphs[i]; + if (glyph.length === 0) { + charStringsIndex.add([0x8B, 0x0E]); + continue; + } + charStringsIndex.add(glyph); } cff.charStrings = charStringsIndex; var privateDict = new _cff_parser.CFFPrivateDict(); @@ -24768,7 +24787,6 @@ var CFFFont = function CFFFontClosure() { this.properties = properties; var parser = new _cff_parser.CFFParser(file, properties, SEAC_ANALYSIS_ENABLED); this.cff = parser.parse(); - this.cff.duplicateFirstGlyph(); var compiler = new _cff_parser.CFFCompiler(this.cff); this.seacs = this.cff.seacs; try { @@ -24809,19 +24827,29 @@ var CFFFont = function CFFFontClosure() { var encoding = cff.encoding ? cff.encoding.encoding : null; charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets); return charCodeToGlyphId; - }, - hasGlyphId: function CFFFont_hasGlyphID(id) { - return this.cff.hasGlyphId(id); } }; return CFFFont; }(); +(function checkSeacSupport() { + if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) { + exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED = true; + } +})(); +(function checkChromeWindows() { + if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) { + SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true; + } +})(); exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED; +exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START; +exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END; exports.ErrorFont = ErrorFont; exports.Font = Font; exports.FontFlags = FontFlags; exports.ToUnicodeMap = ToUnicodeMap; exports.IdentityToUnicodeMap = IdentityToUnicodeMap; +exports.ProblematicCharRanges = ProblematicCharRanges; exports.getFontType = getFontType; /***/ }), @@ -24834,7 +24862,7 @@ exports.getFontType = getFontType; Object.defineProperty(exports, "__esModule", { value: true }); -exports.CFFFDSelect = exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = undefined; +exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = undefined; var _util = __w_pdfjs_require__(2); @@ -25598,16 +25626,20 @@ var CFFParser = function CFFParserClosure() { return new CFFEncoding(predefined, format, encoding, raw); }, parseFDSelect: function CFFParser_parseFDSelect(pos, length) { + var start = pos; var bytes = this.bytes; var format = bytes[pos++]; - var fdSelect = []; - var i; + var fdSelect = [], + rawBytes; + var i, + invalidFirstGID = false; switch (format) { case 0: for (i = 0; i < length; ++i) { var id = bytes[pos++]; fdSelect.push(id); } + rawBytes = bytes.subarray(start, pos); break; case 3: var rangesCount = bytes[pos++] << 8 | bytes[pos++]; @@ -25615,6 +25647,7 @@ var CFFParser = function CFFParserClosure() { var first = bytes[pos++] << 8 | bytes[pos++]; if (i === 0 && first !== 0) { (0, _util.warn)('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.'); + invalidFirstGID = true; first = 0; } var fdIndex = bytes[pos++]; @@ -25624,6 +25657,10 @@ var CFFParser = function CFFParserClosure() { } } pos += 2; + rawBytes = bytes.subarray(start, pos); + if (invalidFirstGID) { + rawBytes[3] = rawBytes[4] = 0; + } break; default: throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`); @@ -25631,7 +25668,7 @@ var CFFParser = function CFFParserClosure() { if (fdSelect.length !== length) { throw new _util.FormatError('parseFDSelect: Invalid font data.'); } - return new CFFFDSelect(format, fdSelect); + return new CFFFDSelect(fdSelect, rawBytes); } }; return CFFParser; @@ -25650,26 +25687,6 @@ var CFF = function CFFClosure() { this.fdSelect = null; this.isCIDFont = false; } - CFF.prototype = { - duplicateFirstGlyph: function CFF_duplicateFirstGlyph() { - if (this.charStrings.count >= 65535) { - (0, _util.warn)('Not enough space in charstrings to duplicate first glyph.'); - return; - } - var glyphZero = this.charStrings.get(0); - this.charStrings.add(glyphZero); - if (this.isCIDFont) { - this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]); - } - }, - hasGlyphId: function CFF_hasGlyphID(id) { - if (id < 0 || id >= this.charStrings.count) { - return false; - } - var glyph = this.charStrings.get(id); - return glyph.length > 0; - } - }; return CFF; }(); var CFFHeader = function CFFHeaderClosure() { @@ -25856,9 +25873,9 @@ var CFFEncoding = function CFFEncodingClosure() { return CFFEncoding; }(); var CFFFDSelect = function CFFFDSelectClosure() { - function CFFFDSelect(format, fdSelect) { - this.format = format; + function CFFFDSelect(fdSelect, raw) { this.fdSelect = fdSelect; + this.raw = raw; } CFFFDSelect.prototype = { getFDIndex: function CFFFDSelect_get(glyphIndex) { @@ -25949,7 +25966,6 @@ var CFFCompiler = function CFFCompilerClosure() { } } } - cff.topDict.setByName('charset', 0); var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont); output.add(compiled.output); var topDictTracker = compiled.trackers[0]; @@ -25966,15 +25982,21 @@ var CFFCompiler = function CFFCompilerClosure() { output.add(encoding); } } - var charset = this.compileCharset(cff.charset); - topDictTracker.setEntryLocation('charset', [output.length], output); - output.add(charset); + if (cff.charset && cff.topDict.hasName('charset')) { + if (cff.charset.predefined) { + topDictTracker.setEntryLocation('charset', [cff.charset.format], output); + } else { + var charset = this.compileCharset(cff.charset); + topDictTracker.setEntryLocation('charset', [output.length], output); + output.add(charset); + } + } var charStrings = this.compileCharStrings(cff.charStrings); topDictTracker.setEntryLocation('CharStrings', [output.length], output); output.add(charStrings); if (cff.isCIDFont) { topDictTracker.setEntryLocation('FDSelect', [output.length], output); - var fdSelect = this.compileFDSelect(cff.fdSelect); + var fdSelect = this.compileFDSelect(cff.fdSelect.raw); output.add(fdSelect); compiled = this.compileTopDicts(cff.fdArray, output.length, true); topDictTracker.setEntryLocation('FDArray', [output.length], output); @@ -26169,55 +26191,16 @@ var CFFCompiler = function CFFCompilerClosure() { this.out.writeByteArray(this.compileIndex(globalSubrIndex)); }, compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) { - var charStringsIndex = new CFFIndex(); - for (var i = 0; i < charStrings.count; i++) { - var glyph = charStrings.get(i); - if (glyph.length === 0) { - charStringsIndex.add(new Uint8Array([0x8B, 0x0E])); - continue; - } - charStringsIndex.add(glyph); - } - return this.compileIndex(charStringsIndex); + return this.compileIndex(charStrings); }, compileCharset: function CFFCompiler_compileCharset(charset) { - let length = 1 + (this.cff.charStrings.count - 1) * 2; - let out = new Uint8Array(length); - return this.compileTypedArray(out); + return this.compileTypedArray(charset.raw); }, compileEncoding: function CFFCompiler_compileEncoding(encoding) { return this.compileTypedArray(encoding.raw); }, compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) { - let format = fdSelect.format; - let out, i; - switch (format) { - case 0: - out = new Uint8Array(1 + fdSelect.fdSelect.length); - out[0] = format; - for (i = 0; i < fdSelect.fdSelect.length; i++) { - out[i + 1] = fdSelect.fdSelect[i]; - } - break; - case 3: - let start = 0; - let lastFD = fdSelect.fdSelect[0]; - let ranges = [format, 0, 0, start >> 8 & 0xFF, start & 0xFF, lastFD]; - for (i = 1; i < fdSelect.fdSelect.length; i++) { - let currentFD = fdSelect.fdSelect[i]; - if (currentFD !== lastFD) { - ranges.push(i >> 8 & 0xFF, i & 0xFF, currentFD); - lastFD = currentFD; - } - } - let numRanges = (ranges.length - 3) / 3; - ranges[1] = numRanges >> 8 & 0xFF; - ranges[2] = numRanges & 0xFF; - ranges.push(i >> 8 & 0xFF, i & 0xFF); - out = new Uint8Array(ranges); - break; - } - return this.compileTypedArray(out); + return this.compileTypedArray(fdSelect); }, compileTypedArray: function CFFCompiler_compileTypedArray(data) { var out = []; @@ -26288,7 +26271,6 @@ exports.CFFCharset = CFFCharset; exports.CFFTopDict = CFFTopDict; exports.CFFPrivateDict = CFFPrivateDict; exports.CFFCompiler = CFFCompiler; -exports.CFFFDSelect = CFFFDSelect; /***/ }), /* 32 */ @@ -33721,7 +33703,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() { return glyphs; } function lookupCmap(ranges, unicode) { - var code = unicode.codePointAt(0), + var code = unicode.charCodeAt(0), gid = 0; var l = 0, r = ranges.length - 1; diff --git a/browser/extensions/pdfjs/content/web/viewer.html b/browser/extensions/pdfjs/content/web/viewer.html index 11fc1b7a7193..2b8a5104edcb 100644 --- a/browser/extensions/pdfjs/content/web/viewer.html +++ b/browser/extensions/pdfjs/content/web/viewer.html @@ -82,15 +82,11 @@ See https://github.com/adobe-type-tools/cmap-resources -
+
-
-
- -
diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index 22ad010932b6..4258538ee4aa 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -120,8 +120,8 @@ let pdfjsWebApp, pdfjsWebAppOptions; pdfjsWebAppOptions = __webpack_require__(8); } { - __webpack_require__(34); - __webpack_require__(37); + __webpack_require__(33); + __webpack_require__(36); } ; ; @@ -200,9 +200,9 @@ function getViewerConfiguration() { findField: document.getElementById('findInput'), highlightAllCheckbox: document.getElementById('findHighlightAll'), caseSensitiveCheckbox: document.getElementById('findMatchCase'), - entireWordCheckbox: document.getElementById('findEntireWord'), findMsg: document.getElementById('findMsg'), findResultsCount: document.getElementById('findResultsCount'), + findStatusIcon: document.getElementById('findStatusIcon'), findPreviousButton: document.getElementById('findPrevious'), findNextButton: document.getElementById('findNext') }, @@ -298,32 +298,31 @@ var _pdf_find_bar = __webpack_require__(15); var _pdf_find_controller = __webpack_require__(16); -var _pdf_history = __webpack_require__(18); +var _pdf_history = __webpack_require__(17); -var _pdf_link_service = __webpack_require__(19); +var _pdf_link_service = __webpack_require__(18); -var _pdf_outline_viewer = __webpack_require__(20); +var _pdf_outline_viewer = __webpack_require__(19); -var _pdf_presentation_mode = __webpack_require__(21); +var _pdf_presentation_mode = __webpack_require__(20); -var _pdf_sidebar_resizer = __webpack_require__(22); +var _pdf_sidebar_resizer = __webpack_require__(21); -var _pdf_thumbnail_viewer = __webpack_require__(23); +var _pdf_thumbnail_viewer = __webpack_require__(22); -var _pdf_viewer = __webpack_require__(25); +var _pdf_viewer = __webpack_require__(24); -var _secondary_toolbar = __webpack_require__(30); +var _secondary_toolbar = __webpack_require__(29); -var _toolbar = __webpack_require__(32); +var _toolbar = __webpack_require__(31); -var _view_history = __webpack_require__(33); +var _view_history = __webpack_require__(32); const DEFAULT_SCALE_DELTA = 1.1; const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; const FORCE_PAGES_LOADED_TIMEOUT = 10000; const DefaultExternalServices = { updateFindControlState(data) {}, - updateFindMatchesCount(data) {}, initPassiveLoading(callbacks) {}, fallback(data, callback) {}, reportTelemetry(data) {}, @@ -380,214 +379,218 @@ let PDFViewerApplication = { externalServices: DefaultExternalServices, _boundEvents: {}, contentDispositionFilename: null, - async initialize(appConfig) { + initialize(appConfig) { this.preferences = this.externalServices.createPreferences(); this.appConfig = appConfig; - await this._readPreferences(); - await this._parseHashParameters(); - await this._initializeL10n(); - if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) { - _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP); - } - await this._initializeViewerComponents(); - this.bindEvents(); - this.bindWindowEvents(); - let appContainer = appConfig.appContainer || document.documentElement; - this.l10n.translate(appContainer).then(() => { - this.eventBus.dispatch('localized', { source: this }); + return this._readPreferences().then(() => { + return this._parseHashParameters(); + }).then(() => { + return this._initializeL10n(); + }).then(() => { + if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) { + _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP); + } + return this._initializeViewerComponents(); + }).then(() => { + this.bindEvents(); + this.bindWindowEvents(); + let appContainer = appConfig.appContainer || document.documentElement; + this.l10n.translate(appContainer).then(() => { + this.eventBus.dispatch('localized', { source: this }); + }); + this.initialized = true; }); - this.initialized = true; }, - async _readPreferences() { + _readPreferences() { const OVERRIDES = { disableFontFace: true, disableRange: true, disableStream: true, textLayerMode: _ui_utils.TextLayerMode.DISABLE }; - try { - const prefs = await this.preferences.getAll(); + return this.preferences.getAll().then(function (prefs) { for (let name in prefs) { if (name in OVERRIDES && _app_options.AppOptions.get(name) === OVERRIDES[name]) { continue; } _app_options.AppOptions.set(name, prefs[name]); } - } catch (reason) {} + }, function (reason) {}); }, - async _parseHashParameters() { - if (!_app_options.AppOptions.get('pdfBugEnabled')) { - return; - } + _parseHashParameters() { const waitOn = []; - let hash = document.location.hash.substring(1); - let hashParams = (0, _ui_utils.parseQueryString)(hash); - if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') { - waitOn.push(loadFakeWorker()); - } - if ('disablerange' in hashParams) { - _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true'); - } - if ('disablestream' in hashParams) { - _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true'); - } - if ('disableautofetch' in hashParams) { - _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true'); - } - if ('disablefontface' in hashParams) { - _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true'); - } - if ('disablehistory' in hashParams) { - _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true'); - } - if ('webgl' in hashParams) { - _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true'); - } - if ('useonlycsszoom' in hashParams) { - _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true'); - } - if ('verbosity' in hashParams) { - _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0); - } - if ('textlayer' in hashParams) { - switch (hashParams['textlayer']) { - case 'off': - _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE); - break; - case 'visible': - case 'shadow': - case 'hover': - let viewer = this.appConfig.viewerContainer; - viewer.classList.add('textLayer-' + hashParams['textlayer']); - break; + if (_app_options.AppOptions.get('pdfBugEnabled')) { + let hash = document.location.hash.substring(1); + let hashParams = (0, _ui_utils.parseQueryString)(hash); + if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') { + waitOn.push(loadFakeWorker()); + } + if ('disablerange' in hashParams) { + _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true'); + } + if ('disablestream' in hashParams) { + _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true'); + } + if ('disableautofetch' in hashParams) { + _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true'); + } + if ('disablefontface' in hashParams) { + _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true'); + } + if ('disablehistory' in hashParams) { + _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true'); + } + if ('webgl' in hashParams) { + _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true'); + } + if ('useonlycsszoom' in hashParams) { + _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true'); + } + if ('verbosity' in hashParams) { + _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0); + } + if ('textlayer' in hashParams) { + switch (hashParams['textlayer']) { + case 'off': + _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE); + break; + case 'visible': + case 'shadow': + case 'hover': + let viewer = this.appConfig.viewerContainer; + viewer.classList.add('textLayer-' + hashParams['textlayer']); + break; + } + } + if ('pdfbug' in hashParams) { + _app_options.AppOptions.set('pdfBug', true); + let enabled = hashParams['pdfbug'].split(','); + waitOn.push(loadAndEnablePDFBug(enabled)); } - } - if ('pdfbug' in hashParams) { - _app_options.AppOptions.set('pdfBug', true); - let enabled = hashParams['pdfbug'].split(','); - waitOn.push(loadAndEnablePDFBug(enabled)); } return Promise.all(waitOn); }, - async _initializeL10n() { + _initializeL10n() { this.l10n = this.externalServices.createL10n({ locale: _app_options.AppOptions.get('locale') }); - const dir = await this.l10n.getDirection(); - document.getElementsByTagName('html')[0].dir = dir; + return this.l10n.getDirection().then(dir => { + document.getElementsByTagName('html')[0].dir = dir; + }); }, - async _initializeViewerComponents() { - const appConfig = this.appConfig; - this.overlayManager = new _overlay_manager.OverlayManager(); - const dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM'); - let eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM); - this.eventBus = eventBus; - let pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); - pdfRenderingQueue.onIdle = this.cleanup.bind(this); - this.pdfRenderingQueue = pdfRenderingQueue; - let pdfLinkService = new _pdf_link_service.PDFLinkService({ - eventBus, - externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'), - externalLinkRel: _app_options.AppOptions.get('externalLinkRel') - }); - this.pdfLinkService = pdfLinkService; - let downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') }); - this.downloadManager = downloadManager; - let container = appConfig.mainContainer; - let viewer = appConfig.viewerContainer; - this.pdfViewer = new _pdf_viewer.PDFViewer({ - container, - viewer, - eventBus, - renderingQueue: pdfRenderingQueue, - linkService: pdfLinkService, - downloadManager, - renderer: _app_options.AppOptions.get('renderer'), - enableWebGL: _app_options.AppOptions.get('enableWebGL'), - l10n: this.l10n, - textLayerMode: _app_options.AppOptions.get('textLayerMode'), - imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'), - renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'), - enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'), - useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'), - maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels') - }); - pdfRenderingQueue.setViewer(this.pdfViewer); - pdfLinkService.setViewer(this.pdfViewer); - let thumbnailContainer = appConfig.sidebar.thumbnailView; - this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ - container: thumbnailContainer, - renderingQueue: pdfRenderingQueue, - linkService: pdfLinkService, - l10n: this.l10n - }); - pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); - this.pdfHistory = new _pdf_history.PDFHistory({ - linkService: pdfLinkService, - eventBus - }); - pdfLinkService.setHistory(this.pdfHistory); - this.findController = new _pdf_find_controller.PDFFindController({ - pdfViewer: this.pdfViewer, - eventBus - }); - this.findController.onUpdateResultsCount = matchesCount => { - if (this.supportsIntegratedFind) { - this.externalServices.updateFindMatchesCount(matchesCount); - } else { - this.findBar.updateResultsCount(matchesCount); - } - }; - this.findController.onUpdateState = (state, previous, matchesCount) => { - if (this.supportsIntegratedFind) { - this.externalServices.updateFindControlState({ - result: state, - findPrevious: previous, - matchesCount - }); - } else { - this.findBar.updateUIState(state, previous, matchesCount); - } - }; - this.pdfViewer.setFindController(this.findController); - let findBarConfig = Object.create(appConfig.findBar); - findBarConfig.findController = this.findController; - findBarConfig.eventBus = eventBus; - this.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, this.l10n); - this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n); - this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({ - container, - eventBus, - cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad') - }); - this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, this.l10n); - this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); - if (this.supportsFullscreen) { - this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ + _initializeViewerComponents() { + let { appConfig } = this; + return new Promise((resolve, reject) => { + this.overlayManager = new _overlay_manager.OverlayManager(); + const dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM'); + let eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM); + this.eventBus = eventBus; + let pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); + pdfRenderingQueue.onIdle = this.cleanup.bind(this); + this.pdfRenderingQueue = pdfRenderingQueue; + let pdfLinkService = new _pdf_link_service.PDFLinkService({ + eventBus, + externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'), + externalLinkRel: _app_options.AppOptions.get('externalLinkRel') + }); + this.pdfLinkService = pdfLinkService; + let downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') }); + this.downloadManager = downloadManager; + let container = appConfig.mainContainer; + let viewer = appConfig.viewerContainer; + this.pdfViewer = new _pdf_viewer.PDFViewer({ container, viewer, - pdfViewer: this.pdfViewer, eventBus, - contextMenuItems: appConfig.fullscreen + renderingQueue: pdfRenderingQueue, + linkService: pdfLinkService, + downloadManager, + renderer: _app_options.AppOptions.get('renderer'), + enableWebGL: _app_options.AppOptions.get('enableWebGL'), + l10n: this.l10n, + textLayerMode: _app_options.AppOptions.get('textLayerMode'), + imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'), + renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'), + enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'), + useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'), + maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels') }); - } - this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n); - this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ - container: appConfig.sidebar.outlineView, - eventBus, - linkService: pdfLinkService + pdfRenderingQueue.setViewer(this.pdfViewer); + pdfLinkService.setViewer(this.pdfViewer); + let thumbnailContainer = appConfig.sidebar.thumbnailView; + this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ + container: thumbnailContainer, + renderingQueue: pdfRenderingQueue, + linkService: pdfLinkService, + l10n: this.l10n + }); + pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); + this.pdfHistory = new _pdf_history.PDFHistory({ + linkService: pdfLinkService, + eventBus + }); + pdfLinkService.setHistory(this.pdfHistory); + this.findController = new _pdf_find_controller.PDFFindController({ + pdfViewer: this.pdfViewer, + eventBus + }); + this.findController.onUpdateResultsCount = matchCount => { + if (this.supportsIntegratedFind) { + return; + } + this.findBar.updateResultsCount(matchCount); + }; + this.findController.onUpdateState = (state, previous, matchCount) => { + if (this.supportsIntegratedFind) { + this.externalServices.updateFindControlState({ + result: state, + findPrevious: previous + }); + } else { + this.findBar.updateUIState(state, previous, matchCount); + } + }; + this.pdfViewer.setFindController(this.findController); + let findBarConfig = Object.create(appConfig.findBar); + findBarConfig.findController = this.findController; + findBarConfig.eventBus = eventBus; + this.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, this.l10n); + this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n); + this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({ + container, + eventBus, + cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad') + }); + this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, this.l10n); + this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); + if (this.supportsFullscreen) { + this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ + container, + viewer, + pdfViewer: this.pdfViewer, + eventBus, + contextMenuItems: appConfig.fullscreen + }); + } + this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n); + this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ + container: appConfig.sidebar.outlineView, + eventBus, + linkService: pdfLinkService + }); + this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ + container: appConfig.sidebar.attachmentsView, + eventBus, + downloadManager + }); + let sidebarConfig = Object.create(appConfig.sidebar); + sidebarConfig.pdfViewer = this.pdfViewer; + sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer; + sidebarConfig.pdfOutlineViewer = this.pdfOutlineViewer; + sidebarConfig.eventBus = eventBus; + this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, this.l10n); + this.pdfSidebar.onToggled = this.forceRendering.bind(this); + this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n); + resolve(undefined); }); - this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ - container: appConfig.sidebar.attachmentsView, - eventBus, - downloadManager - }); - let sidebarConfig = Object.create(appConfig.sidebar); - sidebarConfig.pdfViewer = this.pdfViewer; - sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer; - sidebarConfig.pdfOutlineViewer = this.pdfOutlineViewer; - sidebarConfig.eventBus = eventBus; - this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, this.l10n); - this.pdfSidebar.onToggled = this.forceRendering.bind(this); - this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n); }, run(config) { this.initialize(config).then(webViewerInitialized); @@ -700,11 +703,11 @@ let PDFViewerApplication = { } document.title = title; }, - async close() { + close() { let errorWrapper = this.appConfig.errorWrapper.container; errorWrapper.setAttribute('hidden', 'true'); if (!this.pdfLoadingTask) { - return; + return Promise.resolve(); } let promise = this.pdfLoadingTask.destroy(); this.pdfLoadingTask = null; @@ -733,9 +736,11 @@ let PDFViewerApplication = { } return promise; }, - async open(file, args) { + open(file, args) { if (this.pdfLoadingTask) { - await this.close(); + return this.close().then(() => { + return this.open(file, args); + }); } const workerParameters = _app_options.AppOptions.getAll('worker'); for (let key in workerParameters) { @@ -910,6 +915,10 @@ let PDFViewerApplication = { this.initialRotation = this.pdfHistory.initialRotation; } } + let initialParams = { + bookmark: null, + hash: null + }; let storePromise = store.getMultiple({ page: null, zoom: _ui_utils.DEFAULT_SCALE_VALUE, @@ -920,8 +929,7 @@ let PDFViewerApplication = { scrollMode: null, spreadMode: null }).catch(() => {}); - Promise.all([storePromise, pageModePromise]).then(async ([values = {}, pageMode]) => { - const initialBookmark = this.initialBookmark; + Promise.all([storePromise, pageModePromise]).then(([values = {}, pageMode]) => { const zoom = _app_options.AppOptions.get('defaultZoomValue'); let hash = zoom ? `zoom=${zoom}` : null; let rotation = null; @@ -938,6 +946,16 @@ let PDFViewerApplication = { if (pageMode && !_app_options.AppOptions.get('disablePageMode')) { sidebarView = sidebarView || apiPageModeToSidebarView(pageMode); } + return { + hash, + rotation, + sidebarView, + scrollMode, + spreadMode + }; + }).then(({ hash, rotation, sidebarView, scrollMode, spreadMode }) => { + initialParams.bookmark = this.initialBookmark; + initialParams.hash = hash; this.setInitialView(hash, { rotation, sidebarView, @@ -948,18 +966,19 @@ let PDFViewerApplication = { if (!this.isViewerEmbedded) { pdfViewer.focus(); } - await Promise.race([pagesPromise, new Promise(resolve => { + return Promise.race([pagesPromise, new Promise(resolve => { setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT); })]); - if (!initialBookmark && !hash) { + }).then(() => { + if (!initialParams.bookmark && !initialParams.hash) { return; } if (pdfViewer.hasEqualPageSizes) { return; } - this.initialBookmark = initialBookmark; + this.initialBookmark = initialParams.bookmark; pdfViewer.currentScaleValue = pdfViewer.currentScaleValue; - this.setInitialView(hash); + this.setInitialView(initialParams.hash); }).then(function () { pdfViewer.update(); }); @@ -1326,13 +1345,13 @@ function webViewerInitialized() { appConfig.sidebar.toggleButton.addEventListener('click', function () { PDFViewerApplication.pdfSidebar.toggle(); }); - try { + Promise.resolve().then(function () { webViewerOpenFileViaURL(file); - } catch (reason) { + }).catch(function (reason) { PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(msg => { PDFViewerApplication.error(msg, reason); }); - } + }); } let webViewerOpenFileViaURL; { @@ -1543,7 +1562,6 @@ function webViewerFind(evt) { query: evt.query, phraseSearch: evt.phraseSearch, caseSensitive: evt.caseSensitive, - entireWord: evt.entireWord, highlightAll: evt.highlightAll, findPrevious: evt.findPrevious }); @@ -1553,7 +1571,6 @@ function webViewerFindFromUrlHash(evt) { query: evt.query, phraseSearch: evt.phraseSearch, caseSensitive: false, - entireWord: false, highlightAll: true, findPrevious: false }); @@ -1657,7 +1674,6 @@ function webViewerKeyDown(evt) { query: findState.query, phraseSearch: findState.phraseSearch, caseSensitive: findState.caseSensitive, - entireWord: findState.entireWord, highlightAll: findState.highlightAll, findPrevious: cmd === 5 || cmd === 12 }); @@ -1925,16 +1941,18 @@ function formatL10nValue(text, args) { }); } let NullL10n = { - async getLanguage() { - return 'en-us'; + getLanguage() { + return Promise.resolve('en-us'); }, - async getDirection() { - return 'ltr'; + getDirection() { + return Promise.resolve('ltr'); }, - async get(property, args, fallback) { - return formatL10nValue(fallback, args); + get(property, args, fallback) { + return Promise.resolve(formatL10nValue(fallback, args)); }, - async translate(element) {} + translate(element) { + return Promise.resolve(); + } }; function getOutputScale(ctx) { let devicePixelRatio = window.devicePixelRatio || 1; @@ -3462,57 +3480,69 @@ class OverlayManager { get active() { return this._active; } - async register(name, element, callerCloseMethod = null, canForceClose = false) { - let container; - if (!name || !element || !(container = element.parentNode)) { - throw new Error('Not enough parameters.'); - } else if (this._overlays[name]) { - throw new Error('The overlay is already registered.'); - } - this._overlays[name] = { - element, - container, - callerCloseMethod, - canForceClose - }; + register(name, element, callerCloseMethod = null, canForceClose = false) { + return new Promise(resolve => { + let container; + if (!name || !element || !(container = element.parentNode)) { + throw new Error('Not enough parameters.'); + } else if (this._overlays[name]) { + throw new Error('The overlay is already registered.'); + } + this._overlays[name] = { + element, + container, + callerCloseMethod, + canForceClose + }; + resolve(); + }); } - async unregister(name) { - if (!this._overlays[name]) { - throw new Error('The overlay does not exist.'); - } else if (this._active === name) { - throw new Error('The overlay cannot be removed while it is active.'); - } - delete this._overlays[name]; - } - async open(name) { - if (!this._overlays[name]) { - throw new Error('The overlay does not exist.'); - } else if (this._active) { - if (this._overlays[name].canForceClose) { - this._closeThroughCaller(); + unregister(name) { + return new Promise(resolve => { + if (!this._overlays[name]) { + throw new Error('The overlay does not exist.'); } else if (this._active === name) { - throw new Error('The overlay is already active.'); - } else { + throw new Error('The overlay cannot be removed while it is active.'); + } + delete this._overlays[name]; + resolve(); + }); + } + open(name) { + return new Promise(resolve => { + if (!this._overlays[name]) { + throw new Error('The overlay does not exist.'); + } else if (this._active) { + if (this._overlays[name].canForceClose) { + this._closeThroughCaller(); + } else if (this._active === name) { + throw new Error('The overlay is already active.'); + } else { + throw new Error('Another overlay is currently active.'); + } + } + this._active = name; + this._overlays[this._active].element.classList.remove('hidden'); + this._overlays[this._active].container.classList.remove('hidden'); + window.addEventListener('keydown', this._keyDownBound); + resolve(); + }); + } + close(name) { + return new Promise(resolve => { + if (!this._overlays[name]) { + throw new Error('The overlay does not exist.'); + } else if (!this._active) { + throw new Error('The overlay is currently not active.'); + } else if (this._active !== name) { throw new Error('Another overlay is currently active.'); } - } - this._active = name; - this._overlays[this._active].element.classList.remove('hidden'); - this._overlays[this._active].container.classList.remove('hidden'); - window.addEventListener('keydown', this._keyDownBound); - } - async close(name) { - if (!this._overlays[name]) { - throw new Error('The overlay does not exist.'); - } else if (!this._active) { - throw new Error('The overlay is currently not active.'); - } else if (this._active !== name) { - throw new Error('Another overlay is currently active.'); - } - this._overlays[this._active].container.classList.add('hidden'); - this._overlays[this._active].element.classList.add('hidden'); - this._active = null; - window.removeEventListener('keydown', this._keyDownBound); + this._overlays[this._active].container.classList.add('hidden'); + this._overlays[this._active].element.classList.add('hidden'); + this._active = null; + window.removeEventListener('keydown', this._keyDownBound); + resolve(); + }); } _keyDown(evt) { if (this._active && evt.keyCode === 27) { @@ -3992,7 +4022,6 @@ var _pdf_find_controller = __webpack_require__(16); var _ui_utils = __webpack_require__(2); -const MATCHES_COUNT_LIMIT = 1000; class PDFFindBar { constructor(options, l10n = _ui_utils.NullL10n) { this.opened = false; @@ -4001,9 +4030,9 @@ class PDFFindBar { this.findField = options.findField || null; this.highlightAll = options.highlightAllCheckbox || null; this.caseSensitive = options.caseSensitiveCheckbox || null; - this.entireWord = options.entireWordCheckbox || null; this.findMsg = options.findMsg || null; this.findResultsCount = options.findResultsCount || null; + this.findStatusIcon = options.findStatusIcon || null; this.findPreviousButton = options.findPreviousButton || null; this.findNextButton = options.findNextButton || null; this.findController = options.findController || null; @@ -4042,9 +4071,6 @@ class PDFFindBar { this.caseSensitive.addEventListener('click', () => { this.dispatchEvent('casesensitivitychange'); }); - this.entireWord.addEventListener('click', () => { - this.dispatchEvent('entirewordchange'); - }); this.eventBus.on('resize', this._adjustWidth.bind(this)); } reset() { @@ -4055,14 +4081,13 @@ class PDFFindBar { source: this, type, query: this.findField.value, - phraseSearch: true, caseSensitive: this.caseSensitive.checked, - entireWord: this.entireWord.checked, + phraseSearch: true, highlightAll: this.highlightAll.checked, findPrevious: findPrev }); } - updateUIState(state, previous, matchesCount) { + updateUIState(state, previous, matchCount) { let notFound = false; let findMsg = ''; let status = ''; @@ -4094,28 +4119,20 @@ class PDFFindBar { this.findMsg.textContent = msg; this._adjustWidth(); }); - this.updateResultsCount(matchesCount); + this.updateResultsCount(matchCount); } - updateResultsCount({ current, total }) { + updateResultsCount(matchCount) { if (!this.findResultsCount) { return; } - let matchesCountMsg = ''; - if (total) { - if (total > MATCHES_COUNT_LIMIT) { - matchesCountMsg = this.l10n.get('find_matches_count_limit', { limit: MATCHES_COUNT_LIMIT.toLocaleString() }, 'More than {{limit}} matches'); - } else { - matchesCountMsg = this.l10n.get('find_matches_count', { - current: current.toLocaleString(), - total: total.toLocaleString() - }, '{{current}} of {{total}} matches'); - } + if (!matchCount) { + this.findResultsCount.classList.add('hidden'); + this.findResultsCount.textContent = ''; + } else { + this.findResultsCount.textContent = matchCount.toLocaleString(); + this.findResultsCount.classList.remove('hidden'); } - Promise.resolve(matchesCountMsg).then(msg => { - this.findResultsCount.textContent = msg; - this.findResultsCount.classList[!total ? 'add' : 'remove']('hidden'); - this._adjustWidth(); - }); + this._adjustWidth(); } open() { if (!this.opened) { @@ -4171,8 +4188,6 @@ exports.PDFFindController = exports.FindState = undefined; var _pdfjsLib = __webpack_require__(3); -var _pdf_find_utils = __webpack_require__(17); - var _dom_events = __webpack_require__(10); var _ui_utils = __webpack_require__(2); @@ -4217,7 +4232,7 @@ class PDFFindController { this.pageContents = []; this.pageMatches = []; this.pageMatchesLength = null; - this.matchesCountTotal = 0; + this.matchCount = 0; this.selected = { pageIdx: -1, matchIdx: -1 @@ -4303,25 +4318,7 @@ class PDFFindController { matchesLength.push(matchesWithLength[i].matchLength); } } - _isEntireWord(content, startIdx, length) { - if (startIdx > 0) { - const first = content.charCodeAt(startIdx); - const limit = content.charCodeAt(startIdx - 1); - if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) { - return false; - } - } - const endIdx = startIdx + length - 1; - if (endIdx < content.length - 1) { - const last = content.charCodeAt(endIdx); - const limit = content.charCodeAt(endIdx + 1); - if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) { - return false; - } - } - return true; - } - _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) { + _calculatePhraseMatch(query, pageIndex, pageContent) { let matches = []; let queryLen = query.length; let matchIdx = -queryLen; @@ -4330,14 +4327,11 @@ class PDFFindController { if (matchIdx === -1) { break; } - if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) { - continue; - } matches.push(matchIdx); } this.pageMatches[pageIndex] = matches; } - _calculateWordMatch(query, pageIndex, pageContent, entireWord) { + _calculateWordMatch(query, pageIndex, pageContent) { let matchesWithLength = []; let queryArray = query.match(/\S+/g); for (let i = 0, len = queryArray.length; i < len; i++) { @@ -4349,9 +4343,6 @@ class PDFFindController { if (matchIdx === -1) { break; } - if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) { - continue; - } matchesWithLength.push({ match: matchIdx, matchLength: subqueryLen, @@ -4371,7 +4362,6 @@ class PDFFindController { let query = this._normalize(this.state.query); let caseSensitive = this.state.caseSensitive; let phraseSearch = this.state.phraseSearch; - const entireWord = this.state.entireWord; let queryLen = query.length; if (queryLen === 0) { return; @@ -4381,18 +4371,17 @@ class PDFFindController { query = query.toLowerCase(); } if (phraseSearch) { - this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord); + this._calculatePhraseMatch(query, pageIndex, pageContent); } else { - this._calculateWordMatch(query, pageIndex, pageContent, entireWord); + this._calculateWordMatch(query, pageIndex, pageContent); } this._updatePage(pageIndex); if (this.resumePageIdx === pageIndex) { this.resumePageIdx = null; this._nextPageMatch(); } - const pageMatchesCount = this.pageMatches[pageIndex].length; - if (pageMatchesCount > 0) { - this.matchesCountTotal += pageMatchesCount; + if (this.pageMatches[pageIndex].length > 0) { + this.matchCount += this.pageMatches[pageIndex].length; this._updateUIResultsCount(); } } @@ -4445,7 +4434,7 @@ class PDFFindController { this.hadMatch = false; this.resumePageIdx = null; this.pageMatches = []; - this.matchesCountTotal = 0; + this.matchCount = 0; this.pageMatchesLength = null; for (let i = 0; i < numPages; i++) { this._updatePage(i); @@ -4542,33 +4531,15 @@ class PDFFindController { this._updatePage(this.selected.pageIdx); } } - _requestMatchesCount() { - const { pageIdx, matchIdx } = this.selected; - let current = 0; - if (matchIdx !== -1) { - for (let i = 0; i < pageIdx; i++) { - current += this.pageMatches[i] && this.pageMatches[i].length || 0; - } - current += matchIdx + 1; - } - return { - current, - total: this.matchesCountTotal - }; - } _updateUIResultsCount() { - if (!this.onUpdateResultsCount) { - return; + if (this.onUpdateResultsCount) { + this.onUpdateResultsCount(this.matchCount); } - const matchesCount = this._requestMatchesCount(); - this.onUpdateResultsCount(matchesCount); } _updateUIState(state, previous) { - if (!this.onUpdateState) { - return; + if (this.onUpdateState) { + this.onUpdateState(state, previous, this.matchCount); } - const matchesCount = this._requestMatchesCount(); - this.onUpdateState(state, previous, matchesCount); } } exports.FindState = FindState; @@ -4581,86 +4552,6 @@ exports.PDFFindController = PDFFindController; "use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -const CharacterType = { - SPACE: 0, - ALPHA_LETTER: 1, - PUNCT: 2, - HAN_LETTER: 3, - KATAKANA_LETTER: 4, - HIRAGANA_LETTER: 5, - HALFWIDTH_KATAKANA_LETTER: 6, - THAI_LETTER: 7 -}; -function isAlphabeticalScript(charCode) { - return charCode < 0x2E80; -} -function isAscii(charCode) { - return (charCode & 0xFF80) === 0; -} -function isAsciiAlpha(charCode) { - return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A; -} -function isAsciiDigit(charCode) { - return charCode >= 0x30 && charCode <= 0x39; -} -function isAsciiSpace(charCode) { - return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A; -} -function isHan(charCode) { - return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF; -} -function isKatakana(charCode) { - return charCode >= 0x30A0 && charCode <= 0x30FF; -} -function isHiragana(charCode) { - return charCode >= 0x3040 && charCode <= 0x309F; -} -function isHalfwidthKatakana(charCode) { - return charCode >= 0xFF60 && charCode <= 0xFF9F; -} -function isThai(charCode) { - return (charCode & 0xFF80) === 0x0E00; -} -function getCharacterType(charCode) { - if (isAlphabeticalScript(charCode)) { - if (isAscii(charCode)) { - if (isAsciiSpace(charCode)) { - return CharacterType.SPACE; - } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) { - return CharacterType.ALPHA_LETTER; - } - return CharacterType.PUNCT; - } else if (isThai(charCode)) { - return CharacterType.THAI_LETTER; - } else if (charCode === 0xA0) { - return CharacterType.SPACE; - } - return CharacterType.ALPHA_LETTER; - } - if (isHan(charCode)) { - return CharacterType.HAN_LETTER; - } else if (isKatakana(charCode)) { - return CharacterType.KATAKANA_LETTER; - } else if (isHiragana(charCode)) { - return CharacterType.HIRAGANA_LETTER; - } else if (isHalfwidthKatakana(charCode)) { - return CharacterType.HALFWIDTH_KATAKANA_LETTER; - } - return CharacterType.ALPHA_LETTER; -} -exports.CharacterType = CharacterType; -exports.getCharacterType = getCharacterType; - -/***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - Object.defineProperty(exports, "__esModule", { value: true }); @@ -5032,7 +4923,7 @@ exports.isDestHashesEqual = isDestHashesEqual; exports.isDestArraysEqual = isDestArraysEqual; /***/ }), -/* 19 */ +/* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5366,7 +5257,7 @@ exports.PDFLinkService = PDFLinkService; exports.SimpleLinkService = SimpleLinkService; /***/ }), -/* 20 */ +/* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5507,7 +5398,7 @@ class PDFOutlineViewer { exports.PDFOutlineViewer = PDFOutlineViewer; /***/ }), -/* 21 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5824,7 +5715,7 @@ class PDFPresentationMode { exports.PDFPresentationMode = PDFPresentationMode; /***/ }), -/* 22 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5944,7 +5835,7 @@ class PDFSidebarResizer { exports.PDFSidebarResizer = PDFSidebarResizer; /***/ }), -/* 23 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5957,7 +5848,7 @@ exports.PDFThumbnailViewer = undefined; var _ui_utils = __webpack_require__(2); -var _pdf_thumbnail_view = __webpack_require__(24); +var _pdf_thumbnail_view = __webpack_require__(23); const THUMBNAIL_SCROLL_MARGIN = -19; const THUMBNAIL_SELECTED_CLASS = 'selected'; @@ -6133,7 +6024,7 @@ class PDFThumbnailViewer { exports.PDFThumbnailViewer = PDFThumbnailViewer; /***/ }), -/* 24 */ +/* 23 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -6441,7 +6332,7 @@ class PDFThumbnailView { exports.PDFThumbnailView = PDFThumbnailView; /***/ }), -/* 25 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -6452,7 +6343,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.PDFViewer = undefined; -var _base_viewer = __webpack_require__(26); +var _base_viewer = __webpack_require__(25); var _ui_utils = __webpack_require__(2); @@ -6531,7 +6422,7 @@ class PDFViewer extends _base_viewer.BaseViewer { exports.PDFViewer = PDFViewer; /***/ }), -/* 26 */ +/* 25 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -6546,17 +6437,17 @@ var _ui_utils = __webpack_require__(2); var _pdf_rendering_queue = __webpack_require__(6); -var _annotation_layer_builder = __webpack_require__(27); +var _annotation_layer_builder = __webpack_require__(26); var _pdfjsLib = __webpack_require__(3); var _dom_events = __webpack_require__(10); -var _pdf_page_view = __webpack_require__(28); +var _pdf_page_view = __webpack_require__(27); -var _pdf_link_service = __webpack_require__(19); +var _pdf_link_service = __webpack_require__(18); -var _text_layer_builder = __webpack_require__(29); +var _text_layer_builder = __webpack_require__(28); const DEFAULT_CACHE_SIZE = 10; const ScrollMode = { @@ -7339,7 +7230,7 @@ exports.ScrollMode = ScrollMode; exports.SpreadMode = SpreadMode; /***/ }), -/* 27 */ +/* 26 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7354,7 +7245,7 @@ var _pdfjsLib = __webpack_require__(3); var _ui_utils = __webpack_require__(2); -var _pdf_link_service = __webpack_require__(19); +var _pdf_link_service = __webpack_require__(18); class AnnotationLayerBuilder { constructor({ pageDiv, pdfPage, linkService, downloadManager, imageResourcesPath = '', renderInteractiveForms = false, l10n = _ui_utils.NullL10n }) { @@ -7424,7 +7315,7 @@ exports.AnnotationLayerBuilder = AnnotationLayerBuilder; exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory; /***/ }), -/* 28 */ +/* 27 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7881,7 +7772,7 @@ class PDFPageView { exports.PDFPageView = PDFPageView; /***/ }), -/* 29 */ +/* 28 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8150,7 +8041,7 @@ exports.TextLayerBuilder = TextLayerBuilder; exports.DefaultTextLayerFactory = DefaultTextLayerFactory; /***/ }), -/* 30 */ +/* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8161,11 +8052,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.SecondaryToolbar = undefined; -var _base_viewer = __webpack_require__(26); +var _base_viewer = __webpack_require__(25); var _pdf_cursor_tools = __webpack_require__(4); -var _pdf_single_page_viewer = __webpack_require__(31); +var _pdf_single_page_viewer = __webpack_require__(30); var _ui_utils = __webpack_require__(2); @@ -8428,7 +8319,7 @@ class SecondaryToolbar { exports.SecondaryToolbar = SecondaryToolbar; /***/ }), -/* 31 */ +/* 30 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8439,7 +8330,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.PDFSinglePageViewer = undefined; -var _base_viewer = __webpack_require__(26); +var _base_viewer = __webpack_require__(25); var _ui_utils = __webpack_require__(2); @@ -8553,7 +8444,7 @@ class PDFSinglePageViewer extends _base_viewer.BaseViewer { exports.PDFSinglePageViewer = PDFSinglePageViewer; /***/ }), -/* 32 */ +/* 31 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8738,7 +8629,7 @@ class Toolbar { exports.Toolbar = Toolbar; /***/ }), -/* 33 */ +/* 32 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8776,44 +8667,53 @@ class ViewHistory { this.database = database; }); } - async _writeToStorage() { - let databaseStr = JSON.stringify(this.database); - sessionStorage.setItem('pdfjs.history', databaseStr); + _writeToStorage() { + return new Promise(resolve => { + let databaseStr = JSON.stringify(this.database); + sessionStorage.setItem('pdfjs.history', databaseStr); + resolve(); + }); } - async _readFromStorage() { - return sessionStorage.getItem('pdfjs.history'); + _readFromStorage() { + return new Promise(function (resolve) { + resolve(sessionStorage.getItem('pdfjs.history')); + }); } - async set(name, val) { - await this._initializedPromise; - this.file[name] = val; - return this._writeToStorage(); + set(name, val) { + return this._initializedPromise.then(() => { + this.file[name] = val; + return this._writeToStorage(); + }); } - async setMultiple(properties) { - await this._initializedPromise; - for (let name in properties) { - this.file[name] = properties[name]; - } - return this._writeToStorage(); + setMultiple(properties) { + return this._initializedPromise.then(() => { + for (let name in properties) { + this.file[name] = properties[name]; + } + return this._writeToStorage(); + }); } - async get(name, defaultValue) { - await this._initializedPromise; - let val = this.file[name]; - return val !== undefined ? val : defaultValue; - } - async getMultiple(properties) { - await this._initializedPromise; - let values = Object.create(null); - for (let name in properties) { + get(name, defaultValue) { + return this._initializedPromise.then(() => { let val = this.file[name]; - values[name] = val !== undefined ? val : properties[name]; - } - return values; + return val !== undefined ? val : defaultValue; + }); + } + getMultiple(properties) { + return this._initializedPromise.then(() => { + let values = Object.create(null); + for (let name in properties) { + let val = this.file[name]; + values[name] = val !== undefined ? val : properties[name]; + } + return values; + }); } } exports.ViewHistory = ViewHistory; /***/ }), -/* 34 */ +/* 33 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8824,11 +8724,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.FirefoxCom = exports.DownloadManager = undefined; -__webpack_require__(35); +__webpack_require__(34); var _pdfjsLib = __webpack_require__(3); -var _preferences = __webpack_require__(36); +var _preferences = __webpack_require__(35); var _app = __webpack_require__(1); @@ -8907,12 +8807,12 @@ class DownloadManager { } } class FirefoxPreferences extends _preferences.BasePreferences { - async _writeToStorage(prefObj) { + _writeToStorage(prefObj) { return new Promise(function (resolve) { FirefoxCom.request('setPreferences', prefObj, resolve); }); } - async _readFromStorage(prefObj) { + _readFromStorage(prefObj) { return new Promise(function (resolve) { FirefoxCom.request('getPreferences', prefObj, function (prefStr) { let readPrefs = JSON.parse(prefStr); @@ -8925,21 +8825,22 @@ class MozL10n { constructor(mozL10n) { this.mozL10n = mozL10n; } - async getLanguage() { - return this.mozL10n.getLanguage(); + getLanguage() { + return Promise.resolve(this.mozL10n.getLanguage()); } - async getDirection() { - return this.mozL10n.getDirection(); + getDirection() { + return Promise.resolve(this.mozL10n.getDirection()); } - async get(property, args, fallback) { - return this.mozL10n.get(property, args, fallback); + get(property, args, fallback) { + return Promise.resolve(this.mozL10n.get(property, args, fallback)); } - async translate(element) { + translate(element) { this.mozL10n.translate(element); + return Promise.resolve(); } } (function listenFindEvents() { - const events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange', 'findentirewordchange']; + const events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange']; let handleEvent = function (evt) { if (!_app.PDFViewerApplication.initialized) { return; @@ -8950,13 +8851,12 @@ class MozL10n { query: evt.detail.query, phraseSearch: true, caseSensitive: !!evt.detail.caseSensitive, - entireWord: !!evt.detail.entireWord, highlightAll: !!evt.detail.highlightAll, findPrevious: !!evt.detail.findPrevious }); }; - for (let event of events) { - window.addEventListener(event, handleEvent); + for (let i = 0, len = events.length; i < len; i++) { + window.addEventListener(events[i], handleEvent); } })(); function FirefoxComDataRangeTransport(length, initialData) { @@ -8976,7 +8876,6 @@ _app.PDFViewerApplication.externalServices = { updateFindControlState(data) { FirefoxCom.request('updateFindControlState', data); }, - updateFindMatchesCount(data) {}, initPassiveLoading(callbacks) { let pdfDataRangeTransport; window.addEventListener('message', function windowMessage(e) { @@ -9061,7 +8960,7 @@ exports.DownloadManager = DownloadManager; exports.FirefoxCom = FirefoxCom; /***/ }), -/* 35 */ +/* 34 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9159,7 +9058,7 @@ exports.FirefoxCom = FirefoxCom; })(undefined); /***/ }), -/* 36 */ +/* 35 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9226,63 +9125,66 @@ class BasePreferences { } }); } - async _writeToStorage(prefObj) { - throw new Error('Not implemented: _writeToStorage'); + _writeToStorage(prefObj) { + return Promise.reject(new Error('Not implemented: _writeToStorage')); } - async _readFromStorage(prefObj) { - throw new Error('Not implemented: _readFromStorage'); + _readFromStorage(prefObj) { + return Promise.reject(new Error('Not implemented: _readFromStorage')); } - async reset() { - await this._initializedPromise; - this.prefs = Object.assign(Object.create(null), this.defaults); - return this._writeToStorage(this.defaults); + reset() { + return this._initializedPromise.then(() => { + this.prefs = Object.assign(Object.create(null), this.defaults); + return this._writeToStorage(this.defaults); + }); } - async set(name, value) { - await this._initializedPromise; - let defaultValue = this.defaults[name]; - if (defaultValue === undefined) { - throw new Error(`Set preference: "${name}" is undefined.`); - } else if (value === undefined) { - throw new Error('Set preference: no value is specified.'); - } - let valueType = typeof value; - let defaultType = typeof defaultValue; - if (valueType !== defaultType) { - if (valueType === 'number' && defaultType === 'string') { - value = value.toString(); + set(name, value) { + return this._initializedPromise.then(() => { + if (this.defaults[name] === undefined) { + throw new Error(`Set preference: "${name}" is undefined.`); + } else if (value === undefined) { + throw new Error('Set preference: no value is specified.'); + } + let valueType = typeof value; + let defaultType = typeof this.defaults[name]; + if (valueType !== defaultType) { + if (valueType === 'number' && defaultType === 'string') { + value = value.toString(); + } else { + throw new Error(`Set preference: "${value}" is a ${valueType}, ` + `expected a ${defaultType}.`); + } } else { - throw new Error(`Set preference: "${value}" is a ${valueType}, ` + `expected a ${defaultType}.`); + if (valueType === 'number' && !Number.isInteger(value)) { + throw new Error(`Set preference: "${value}" must be an integer.`); + } } - } else { - if (valueType === 'number' && !Number.isInteger(value)) { - throw new Error(`Set preference: "${value}" must be an integer.`); - } - } - this.prefs[name] = value; - return this._writeToStorage(this.prefs); + this.prefs[name] = value; + return this._writeToStorage(this.prefs); + }); } - async get(name) { - await this._initializedPromise; - let defaultValue = this.defaults[name]; - if (defaultValue === undefined) { - throw new Error(`Get preference: "${name}" is undefined.`); - } else { - let prefValue = this.prefs[name]; - if (prefValue !== undefined) { - return prefValue; + get(name) { + return this._initializedPromise.then(() => { + let defaultValue = this.defaults[name]; + if (defaultValue === undefined) { + throw new Error(`Get preference: "${name}" is undefined.`); + } else { + let prefValue = this.prefs[name]; + if (prefValue !== undefined) { + return prefValue; + } } - } - return defaultValue; + return defaultValue; + }); } - async getAll() { - await this._initializedPromise; - return Object.assign(Object.create(null), this.defaults, this.prefs); + getAll() { + return this._initializedPromise.then(() => { + return Object.assign(Object.create(null), this.defaults, this.prefs); + }); } } exports.BasePreferences = BasePreferences; /***/ }), -/* 37 */ +/* 36 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; diff --git a/browser/extensions/pdfjs/moz.yaml b/browser/extensions/pdfjs/moz.yaml index a2daa0ddd0ca..db7aa89e255d 100644 --- a/browser/extensions/pdfjs/moz.yaml +++ b/browser/extensions/pdfjs/moz.yaml @@ -20,7 +20,7 @@ origin: # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: version 2.0.841 + release: version 2.0.815 # The package's license, where possible using the mnemonic from # https://spdx.org/licenses/ diff --git a/browser/locales/en-US/pdfviewer/viewer.properties b/browser/locales/en-US/pdfviewer/viewer.properties index 39f1a99bcf66..3929482459c4 100644 --- a/browser/locales/en-US/pdfviewer/viewer.properties +++ b/browser/locales/en-US/pdfviewer/viewer.properties @@ -165,16 +165,8 @@ find_next.title=Find the next occurrence of the phrase find_next_label=Next find_highlight=Highlight all find_match_case_label=Match case -find_entire_word_label=Whole words find_reached_top=Reached top of document, continued from bottom find_reached_bottom=Reached end of document, continued from top -# LOCALIZATION NOTE (find_matches_count): "{{current}}" and "{{total}}" will be -# replaced by a number representing the index of the currently active find result, -# respectively a number representing the total number of matches in the document. -find_matches_count={{current}} of {{total}} matches -# LOCALIZATION NOTE (find_matches_count_limit): "{{limit}}" will be replaced by -# a numerical value. -find_matches_count_limit=More than {{limit}} matches find_not_found=Phrase not found # Error panel labels