From fa3c69da647b8896daf216cfd1d08184c5427611 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Thu, 7 Jan 2016 18:32:09 -0500 Subject: [PATCH] Bug 1237815 - Update pdf.js to version 1.3.161. r=bdahl --- browser/extensions/pdfjs/README.mozilla | 2 +- browser/extensions/pdfjs/content/build/pdf.js | 184 +++++++- .../pdfjs/content/build/pdf.worker.js | 445 +++++++++++++----- .../extensions/pdfjs/content/web/viewer.css | 5 +- .../extensions/pdfjs/content/web/viewer.js | 10 +- 5 files changed, 486 insertions(+), 160 deletions(-) diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index db63218fe502..7abd6fea6f99 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,3 +1,3 @@ This is the pdf.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 1.3.142 +Current extension version is: 1.3.161 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index d755008d375f..61801b1ce97d 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -13,21 +13,32 @@ * limitations under the License. */ /* jshint globalstrict: false */ -/* globals PDFJS, global */ +/* umdutils ignore */ -// Initializing PDFJS global object (if still undefined) -if (typeof PDFJS === 'undefined') { - (typeof window !== 'undefined' ? window : - typeof global !== 'undefined' ? global : this).PDFJS = {}; -} - -PDFJS.version = '1.3.142'; -PDFJS.build = 'e8db825'; - -(function pdfjsWrapper() { +(function (root, factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { +define('pdfjs-dist/build/pdf', ['exports'], factory); + } else if (typeof exports !== 'undefined') { + factory(exports); + } else { +factory((root.pdfjsDistBuildPdf = {})); + } +}(this, function (exports) { // Use strict in our context only - users might not want it 'use strict'; +var pdfjsVersion = '1.3.161'; +var pdfjsBuild = '4a215f0'; + + var pdfjsFilePath = + typeof document !== 'undefined' && document.currentScript ? + document.currentScript.src : null; + + var pdfjsLibs = {}; + + (function pdfjsWrapper() { + (function (root, factory) { @@ -49,6 +60,13 @@ PDFJS.build = 'e8db825'; globalScope.PDFJS = {}; } + if (typeof pdfjsVersion !== 'undefined') { + globalScope.PDFJS.version = pdfjsVersion; + } + if (typeof pdfjsVersion !== 'undefined') { + globalScope.PDFJS.build = pdfjsBuild; + } + globalScope.PDFJS.pdfBug = false; exports.globalScope = globalScope; @@ -598,6 +616,16 @@ var XRefParseException = (function XRefParseExceptionClosure() { return XRefParseException; })(); +var NullCharactersRegExp = /\x00/g; + +function removeNullCharacters(str) { + if (typeof str !== 'string') { + warn('The argument for removeNullCharacters must be a string.'); + return str; + } + return str.replace(NullCharactersRegExp, ''); +} +PDFJS.removeNullCharacters = removeNullCharacters; function bytesToString(bytes) { assert(bytes !== null && typeof bytes === 'object' && @@ -1462,6 +1490,7 @@ exports.log2 = log2; exports.readInt8 = readInt8; exports.readUint16 = readUint16; exports.readUint32 = readUint32; +exports.removeNullCharacters = removeNullCharacters; exports.shadow = shadow; exports.string32 = string32; exports.stringToBytes = stringToBytes; @@ -1484,6 +1513,7 @@ var AnnotationType = sharedUtil.AnnotationType; var Util = sharedUtil.Util; var isExternalLinkTargetSet = sharedUtil.isExternalLinkTargetSet; var LinkTargetStringMap = sharedUtil.LinkTargetStringMap; +var removeNullCharacters = sharedUtil.removeNullCharacters; var warn = sharedUtil.warn; var CustomStyle = displayDOMUtils.CustomStyle; @@ -1523,9 +1553,18 @@ AnnotationElementFactory.prototype = case AnnotationType.POPUP: return new PopupAnnotationElement(parameters); + case AnnotationType.HIGHLIGHT: + return new HighlightAnnotationElement(parameters); + case AnnotationType.UNDERLINE: return new UnderlineAnnotationElement(parameters); + case AnnotationType.SQUIGGLY: + return new SquigglyAnnotationElement(parameters); + + case AnnotationType.STRIKEOUT: + return new StrikeOutAnnotationElement(parameters); + default: throw new Error('Unimplemented annotation type "' + subtype + '"'); } @@ -1674,7 +1713,8 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() { this.container.className = 'linkAnnotation'; var link = document.createElement('a'); - link.href = link.title = this.data.url || ''; + link.href = link.title = (this.data.url ? + removeNullCharacters(this.data.url) : ''); if (this.data.url && isExternalLinkTargetSet()) { link.target = LinkTargetStringMap[PDFJS.externalLinkTarget]; @@ -2054,6 +2094,33 @@ var PopupElement = (function PopupElementClosure() { return PopupElement; })(); +/** + * @class + * @alias HighlightAnnotationElement + */ +var HighlightAnnotationElement = ( + function HighlightAnnotationElementClosure() { + function HighlightAnnotationElement(parameters) { + AnnotationElement.call(this, parameters); + } + + Util.inherit(HighlightAnnotationElement, AnnotationElement, { + /** + * Render the highlight annotation's HTML element in the empty container. + * + * @public + * @memberof HighlightAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function HighlightAnnotationElement_render() { + this.container.className = 'highlightAnnotation'; + return this.container; + } + }); + + return HighlightAnnotationElement; +})(); + /** * @class * @alias UnderlineAnnotationElement @@ -2081,6 +2148,59 @@ var UnderlineAnnotationElement = ( return UnderlineAnnotationElement; })(); +/** + * @class + * @alias SquigglyAnnotationElement + */ +var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() { + function SquigglyAnnotationElement(parameters) { + AnnotationElement.call(this, parameters); + } + + Util.inherit(SquigglyAnnotationElement, AnnotationElement, { + /** + * Render the squiggly annotation's HTML element in the empty container. + * + * @public + * @memberof SquigglyAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function SquigglyAnnotationElement_render() { + this.container.className = 'squigglyAnnotation'; + return this.container; + } + }); + + return SquigglyAnnotationElement; +})(); + +/** + * @class + * @alias StrikeOutAnnotationElement + */ +var StrikeOutAnnotationElement = ( + function StrikeOutAnnotationElementClosure() { + function StrikeOutAnnotationElement(parameters) { + AnnotationElement.call(this, parameters); + } + + Util.inherit(StrikeOutAnnotationElement, AnnotationElement, { + /** + * Render the strikeout annotation's HTML element in the empty container. + * + * @public + * @memberof StrikeOutAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function StrikeOutAnnotationElement_render() { + this.container.className = 'strikeoutAnnotation'; + return this.container; + } + }); + + return StrikeOutAnnotationElement; +})(); + /** * @typedef {Object} AnnotationLayerParameters * @property {PageViewport} viewport @@ -5699,10 +5819,10 @@ exports.createScratchCanvas = createScratchCanvas; { factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, - root.pdfjsSharedGlobal); + root.pdfjsDisplayMetadata, root.pdfjsSharedGlobal); } }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, - sharedGlobal, amdRequire) { + displayMetadata, sharedGlobal, amdRequire) { var InvalidPDFException = sharedUtil.InvalidPDFException; var MessageHandler = sharedUtil.MessageHandler; @@ -5726,6 +5846,7 @@ var FontFaceObject = displayFontLoader.FontFaceObject; var FontLoader = displayFontLoader.FontLoader; var CanvasGraphics = displayCanvas.CanvasGraphics; var createScratchCanvas = displayCanvas.createScratchCanvas; +var Metadata = displayMetadata.Metadata; var PDFJS = sharedGlobal.PDFJS; var globalScope = sharedGlobal.globalScope; @@ -6844,6 +6965,13 @@ var PDFPageProxy = (function PDFPageProxyClosure() { var PDFWorker = (function PDFWorkerClosure() { var nextFakeWorkerId = 0; + function getWorkerSrc() { + if (PDFJS.workerSrc) { + return PDFJS.workerSrc; + } + error('No PDFJS.workerSrc specified'); + } + // Loads worker code into main thread. function setupFakeWorkerGlobal() { if (!PDFJS.fakeWorkerFilesLoadedCapability) { @@ -6852,7 +6980,7 @@ var PDFWorker = (function PDFWorkerClosure() { // other files and resolves the promise. In production only the // pdf.worker.js file is needed. var loader = fakeWorkerFilesLoader || function (callback) { - Util.loadScript(PDFJS.workerSrc, callback); + Util.loadScript(getWorkerSrc(), callback); }; loader(function () { PDFJS.fakeWorkerFilesLoadedCapability.resolve(); @@ -6892,10 +7020,7 @@ var PDFWorker = (function PDFWorkerClosure() { // Right now, the requirement is, that an Uint8Array is still an // Uint8Array as it arrives on the worker. (Chrome added this with v.15.) if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') { - var workerSrc = PDFJS.workerSrc; - if (!workerSrc) { - error('No PDFJS.workerSrc specified'); - } + var workerSrc = getWorkerSrc(); try { // Some versions of FF can't create a worker on localhost, see: @@ -7447,7 +7572,7 @@ var WorkerTransport = (function WorkerTransportClosure() { then(function transportMetadata(results) { return { info: results[0], - metadata: (results[1] ? new PDFJS.Metadata(results[1]) : null) + metadata: (results[1] ? new Metadata(results[1]) : null) }; }); }, @@ -7780,7 +7905,22 @@ exports.PDFPageProxy = PDFPageProxy; })); -}).call((typeof window === 'undefined') ? this : window); - + }).call(pdfjsLibs); + + exports.PDFJS = pdfjsLibs.pdfjsSharedGlobal.PDFJS; + + exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument; + exports.PDFDataRangeTransport = + pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport; + exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer; + exports.AnnotationLayer = + pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer; + exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle; + exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses; + exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException; + exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException; + exports.UnexpectedResponseException = + pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException; +})); diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index c9f591376529..3cf8ea8ced5d 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -13,21 +13,32 @@ * limitations under the License. */ /* jshint globalstrict: false */ -/* globals PDFJS, global */ +/* umdutils ignore */ -// Initializing PDFJS global object (if still undefined) -if (typeof PDFJS === 'undefined') { - (typeof window !== 'undefined' ? window : - typeof global !== 'undefined' ? global : this).PDFJS = {}; -} - -PDFJS.version = '1.3.142'; -PDFJS.build = 'e8db825'; - -(function pdfjsWrapper() { +(function (root, factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { +define('pdfjs-dist/build/pdf.worker', ['exports'], factory); + } else if (typeof exports !== 'undefined') { + factory(exports); + } else { +factory((root.pdfjsDistBuildPdfWorker = {})); + } +}(this, function (exports) { // Use strict in our context only - users might not want it 'use strict'; +var pdfjsVersion = '1.3.161'; +var pdfjsBuild = '4a215f0'; + + var pdfjsFilePath = + typeof document !== 'undefined' && document.currentScript ? + document.currentScript.src : null; + + var pdfjsLibs = {}; + + (function pdfjsWrapper() { + (function (root, factory) { @@ -8738,6 +8749,13 @@ exports.Metrics = Metrics; globalScope.PDFJS = {}; } + if (typeof pdfjsVersion !== 'undefined') { + globalScope.PDFJS.version = pdfjsVersion; + } + if (typeof pdfjsVersion !== 'undefined') { + globalScope.PDFJS.build = pdfjsBuild; + } + globalScope.PDFJS.pdfBug = false; exports.globalScope = globalScope; @@ -9637,6 +9655,16 @@ var XRefParseException = (function XRefParseExceptionClosure() { return XRefParseException; })(); +var NullCharactersRegExp = /\x00/g; + +function removeNullCharacters(str) { + if (typeof str !== 'string') { + warn('The argument for removeNullCharacters must be a string.'); + return str; + } + return str.replace(NullCharactersRegExp, ''); +} +PDFJS.removeNullCharacters = removeNullCharacters; function bytesToString(bytes) { assert(bytes !== null && typeof bytes === 'object' && @@ -10501,6 +10529,7 @@ exports.log2 = log2; exports.readInt8 = readInt8; exports.readUint16 = readUint16; exports.readUint32 = readUint32; +exports.removeNullCharacters = removeNullCharacters; exports.shadow = shadow; exports.string32 = string32; exports.stringToBytes = stringToBytes; @@ -24015,6 +24044,9 @@ var HINTING_ENABLED = false; // to control analysis of seac charstrings. var SEAC_ANALYSIS_ENABLED = false; +// Maximum subroutine call depth of type 2 chartrings. Matches OTS. +var MAX_SUBR_NESTING = 10; + var FontFlags = { FixedPitch: 1, Serif: 2, @@ -30044,10 +30076,7 @@ var CFFParser = (function CFFParserClosure() { cff.isCIDFont = topDict.hasName('ROS'); var charStringOffset = topDict.getByName('CharStrings'); - var charStringsAndSeacs = this.parseCharStrings(charStringOffset); - cff.charStrings = charStringsAndSeacs.charStrings; - cff.seacs = charStringsAndSeacs.seacs; - cff.widths = charStringsAndSeacs.widths; + var charStringIndex = this.parseIndex(charStringOffset).obj; var fontMatrix = topDict.getByName('FontMatrix'); if (fontMatrix) { @@ -30075,19 +30104,30 @@ var CFFParser = (function CFFParserClosure() { // cid fonts don't have an encoding encoding = null; charset = this.parseCharsets(topDict.getByName('charset'), - cff.charStrings.count, cff.strings, true); + charStringIndex.count, cff.strings, true); cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), - cff.charStrings.count); + charStringIndex.count); } else { charset = this.parseCharsets(topDict.getByName('charset'), - cff.charStrings.count, cff.strings, false); + charStringIndex.count, cff.strings, false); encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset); } + cff.charset = charset; cff.encoding = encoding; + var charStringsAndSeacs = this.parseCharStrings( + charStringIndex, + topDict.privateDict.subrsIndex, + globalSubrIndex.obj, + cff.fdSelect, + cff.fdArray); + cff.charStrings = charStringsAndSeacs.charStrings; + cff.seacs = charStringsAndSeacs.seacs; + cff.widths = charStringsAndSeacs.widths; + return cff; }, parseHeader: function CFFParser_parseHeader() { @@ -30262,118 +30302,201 @@ var CFFParser = (function CFFParserClosure() { } return cffDict; }, - parseCharStrings: function CFFParser_parseCharStrings(charStringOffset) { - var charStrings = this.parseIndex(charStringOffset).obj; + parseCharString: function CFFParser_parseCharString(state, data, + localSubrIndex, + globalSubrIndex) { + if (state.callDepth > MAX_SUBR_NESTING) { + return false; + } + var stackSize = state.stackSize; + var stack = state.stack; + + var length = data.length; + + for (var j = 0; j < length;) { + var value = data[j++]; + var validationCommand = null; + if (value === 12) { + var q = data[j++]; + if (q === 0) { + // The CFF specification state that the 'dotsection' command + // (12, 0) is deprecated and treated as a no-op, but all Type2 + // charstrings processors should support them. Unfortunately + // the font sanitizer don't. As a workaround the sequence (12, 0) + // is replaced by a useless (0, hmoveto). + data[j - 2] = 139; + data[j - 1] = 22; + stackSize = 0; + } else { + validationCommand = CharstringValidationData12[q]; + } + } else if (value === 28) { // number (16 bit) + stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16; + j += 2; + stackSize++; + } else if (value === 14) { + if (stackSize >= 4) { + stackSize -= 4; + if (SEAC_ANALYSIS_ENABLED) { + state.seac = stack.slice(stackSize, stackSize + 4); + return false; + } + } + validationCommand = CharstringValidationData[value]; + } else if (value >= 32 && value <= 246) { // number + stack[stackSize] = value - 139; + stackSize++; + } else if (value >= 247 && value <= 254) { // number (+1 bytes) + stack[stackSize] = (value < 251 ? + ((value - 247) << 8) + data[j] + 108 : + -((value - 251) << 8) - data[j] - 108); + j++; + stackSize++; + } else if (value === 255) { // number (32 bit) + stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) | + (data[j + 2] << 8) | data[j + 3]) / 65536; + j += 4; + stackSize++; + } else if (value === 19 || value === 20) { + state.hints += stackSize >> 1; + // skipping right amount of hints flag data + j += (state.hints + 7) >> 3; + stackSize %= 2; + validationCommand = CharstringValidationData[value]; + } else if (value === 10 || value === 29) { + var subrsIndex; + if (value === 10) { + subrsIndex = localSubrIndex; + } else { + subrsIndex = globalSubrIndex; + } + if (!subrsIndex) { + validationCommand = CharstringValidationData[value]; + warn('Missing subrsIndex for ' + validationCommand.id); + return false; + } + var bias = 32768; + if (subrsIndex.count < 1240) { + bias = 107; + } else if (subrsIndex.count < 33900) { + bias = 1131; + } + var subrNumber = stack[--stackSize] + bias; + if (subrNumber < 0 || subrNumber >= subrsIndex.count) { + validationCommand = CharstringValidationData[value]; + warn('Out of bounds subrIndex for ' + validationCommand.id); + return false; + } + state.stackSize = stackSize; + state.callDepth++; + var valid = this.parseCharString(state, subrsIndex.get(subrNumber), + localSubrIndex, globalSubrIndex); + if (!valid) { + return false; + } + state.callDepth--; + stackSize = state.stackSize; + continue; + } else if (value === 11) { + state.stackSize = stackSize; + return true; + } else { + validationCommand = CharstringValidationData[value]; + } + if (validationCommand) { + if (validationCommand.stem) { + state.hints += stackSize >> 1; + } + if ('min' in validationCommand) { + if (!state.undefStack && stackSize < validationCommand.min) { + warn('Not enough parameters for ' + validationCommand.id + + '; actual: ' + stackSize + + ', expected: ' + validationCommand.min); + return false; + } + } + if (state.firstStackClearing && validationCommand.stackClearing) { + state.firstStackClearing = false; + // the optional character width can be found before the first + // stack-clearing command arguments + stackSize -= validationCommand.min; + if (stackSize >= 2 && validationCommand.stem) { + // there are even amount of arguments for stem commands + stackSize %= 2; + } else if (stackSize > 1) { + warn('Found too many parameters for stack-clearing command'); + } + if (stackSize > 0 && stack[stackSize - 1] >= 0) { + state.width = stack[stackSize - 1]; + } + } + if ('stackDelta' in validationCommand) { + if ('stackFn' in validationCommand) { + validationCommand.stackFn(stack, stackSize); + } + stackSize += validationCommand.stackDelta; + } else if (validationCommand.stackClearing) { + stackSize = 0; + } else if (validationCommand.resetStack) { + stackSize = 0; + state.undefStack = false; + } else if (validationCommand.undefStack) { + stackSize = 0; + state.undefStack = true; + state.firstStackClearing = false; + } + } + } + state.stackSize = stackSize; + return true; + }, + parseCharStrings: function CFFParser_parseCharStrings(charStrings, + localSubrIndex, + globalSubrIndex, + fdSelect, + fdArray) { var seacs = []; var widths = []; var count = charStrings.count; for (var i = 0; i < count; i++) { var charstring = charStrings.get(i); - - var stackSize = 0; - var stack = []; - var undefStack = true; - var hints = 0; + var state = { + callDepth: 0, + stackSize: 0, + stack: [], + undefStack: true, + hints: 0, + firstStackClearing: true, + seac: null, + width: null + }; var valid = true; - var data = charstring; - var length = data.length; - var firstStackClearing = true; - for (var j = 0; j < length;) { - var value = data[j++]; - var validationCommand = null; - if (value === 12) { - var q = data[j++]; - if (q === 0) { - // The CFF specification state that the 'dotsection' command - // (12, 0) is deprecated and treated as a no-op, but all Type2 - // charstrings processors should support them. Unfortunately - // the font sanitizer don't. As a workaround the sequence (12, 0) - // is replaced by a useless (0, hmoveto). - data[j - 2] = 139; - data[j - 1] = 22; - stackSize = 0; - } else { - validationCommand = CharstringValidationData12[q]; - } - } else if (value === 28) { // number (16 bit) - stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16; - j += 2; - stackSize++; - } else if (value === 14) { - if (stackSize >= 4) { - stackSize -= 4; - if (SEAC_ANALYSIS_ENABLED) { - seacs[i] = stack.slice(stackSize, stackSize + 4); - valid = false; - } - } - validationCommand = CharstringValidationData[value]; - } else if (value >= 32 && value <= 246) { // number - stack[stackSize] = value - 139; - stackSize++; - } else if (value >= 247 && value <= 254) { // number (+1 bytes) - stack[stackSize] = (value < 251 ? - ((value - 247) << 8) + data[j] + 108 : - -((value - 251) << 8) - data[j] - 108); - j++; - stackSize++; - } else if (value === 255) { // number (32 bit) - stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) | - (data[j + 2] << 8) | data[j + 3]) / 65536; - j += 4; - stackSize++; - } else if (value === 19 || value === 20) { - hints += stackSize >> 1; - j += (hints + 7) >> 3; // skipping right amount of hints flag data - stackSize %= 2; - validationCommand = CharstringValidationData[value]; - } else { - validationCommand = CharstringValidationData[value]; + var localSubrToUse = null; + if (fdSelect && fdArray.length) { + var fdIndex = fdSelect.getFDIndex(i); + if (fdIndex === -1) { + warn('Glyph index is not in fd select.'); + valid = false; } - if (validationCommand) { - if (validationCommand.stem) { - hints += stackSize >> 1; - } - if ('min' in validationCommand) { - if (!undefStack && stackSize < validationCommand.min) { - warn('Not enough parameters for ' + validationCommand.id + - '; actual: ' + stackSize + - ', expected: ' + validationCommand.min); - valid = false; - break; - } - } - if (firstStackClearing && validationCommand.stackClearing) { - firstStackClearing = false; - // the optional character width can be found before the first - // stack-clearing command arguments - stackSize -= validationCommand.min; - if (stackSize >= 2 && validationCommand.stem) { - // there are even amount of arguments for stem commands - stackSize %= 2; - } else if (stackSize > 1) { - warn('Found too many parameters for stack-clearing command'); - } - if (stackSize > 0 && stack[stackSize - 1] >= 0) { - widths[i] = stack[stackSize - 1]; - } - } - if ('stackDelta' in validationCommand) { - if ('stackFn' in validationCommand) { - validationCommand.stackFn(stack, stackSize); - } - stackSize += validationCommand.stackDelta; - } else if (validationCommand.stackClearing) { - stackSize = 0; - } else if (validationCommand.resetStack) { - stackSize = 0; - undefStack = false; - } else if (validationCommand.undefStack) { - stackSize = 0; - undefStack = true; - firstStackClearing = false; - } + if (fdIndex >= fdArray.length) { + warn('Invalid fd index for glyph index.'); + valid = false; } + if (valid) { + localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex; + } + } else if (localSubrIndex) { + localSubrToUse = localSubrIndex; + } + if (valid) { + valid = this.parseCharString(state, charstring, localSubrToUse, + globalSubrIndex); + } + if (state.width !== null) { + widths[i] = state.width; + } + if (state.seac !== null) { + seacs[i] = state.seac; } if (!valid) { // resetting invalid charstring to single 'endchar' @@ -30868,6 +30991,14 @@ var CFFFDSelect = (function CFFFDSelectClosure() { this.fdSelect = fdSelect; this.raw = raw; } + CFFFDSelect.prototype = { + getFDIndex: function CFFFDSelect_get(glyphIndex) { + if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) { + return -1; + } + return this.fdSelect[glyphIndex]; + } + }; return CFFFDSelect; })(); @@ -34555,10 +34686,8 @@ var Pattern = (function PatternClosure() { var Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to -// support extend. Number.MIN_VALUE appears to be too small and breaks the -// extend. 1e-7 works in FF but chrome seems to use an even smaller sized number -// internally so we have to go bigger. -Shadings.SMALL_NUMBER = 1e-2; +// support extend. Number.MIN_VALUE is too small and breaks the extend. +Shadings.SMALL_NUMBER = 1e-6; // Radial and axial shading have very similar implementations // If needed, the implementations can be broken into two classes @@ -38295,9 +38424,18 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { case 'Popup': return new PopupAnnotation(parameters); + case 'Highlight': + return new HighlightAnnotation(parameters); + case 'Underline': return new UnderlineAnnotation(parameters); + case 'Squiggly': + return new SquigglyAnnotation(parameters); + + case 'StrikeOut': + return new StrikeOutAnnotation(parameters); + default: warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation'); @@ -38988,6 +39126,22 @@ var PopupAnnotation = (function PopupAnnotationClosure() { return PopupAnnotation; })(); +var HighlightAnnotation = (function HighlightAnnotationClosure() { + function HighlightAnnotation(parameters) { + Annotation.call(this, parameters); + + this.data.annotationType = AnnotationType.HIGHLIGHT; + this.data.hasHtml = true; + + // PDF viewers completely ignore any border styles. + this.data.borderStyle.setWidth(0); + } + + Util.inherit(HighlightAnnotation, Annotation, {}); + + return HighlightAnnotation; +})(); + var UnderlineAnnotation = (function UnderlineAnnotationClosure() { function UnderlineAnnotation(parameters) { Annotation.call(this, parameters); @@ -39004,6 +39158,38 @@ var UnderlineAnnotation = (function UnderlineAnnotationClosure() { return UnderlineAnnotation; })(); +var SquigglyAnnotation = (function SquigglyAnnotationClosure() { + function SquigglyAnnotation(parameters) { + Annotation.call(this, parameters); + + this.data.annotationType = AnnotationType.SQUIGGLY; + this.data.hasHtml = true; + + // PDF viewers completely ignore any border styles. + this.data.borderStyle.setWidth(0); + } + + Util.inherit(SquigglyAnnotation, Annotation, {}); + + return SquigglyAnnotation; +})(); + +var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() { + function StrikeOutAnnotation(parameters) { + Annotation.call(this, parameters); + + this.data.annotationType = AnnotationType.STRIKEOUT; + this.data.hasHtml = true; + + // PDF viewers completely ignore any border styles. + this.data.borderStyle.setWidth(0); + } + + Util.inherit(StrikeOutAnnotation, Annotation, {}); + + return StrikeOutAnnotation; +})(); + exports.Annotation = Annotation; exports.AnnotationBorderStyle = AnnotationBorderStyle; exports.AnnotationFactory = AnnotationFactory; @@ -40418,7 +40604,10 @@ exports.WorkerMessageHandler = WorkerMessageHandler; })); -}).call((typeof window === 'undefined') ? this : window); - + }).call(pdfjsLibs); + + exports.PDFJS = pdfjsLibs.pdfjsSharedGlobal.PDFJS; + +})); diff --git a/browser/extensions/pdfjs/content/web/viewer.css b/browser/extensions/pdfjs/content/web/viewer.css index 3840d307a55f..5efce997653f 100644 --- a/browser/extensions/pdfjs/content/web/viewer.css +++ b/browser/extensions/pdfjs/content/web/viewer.css @@ -129,7 +129,10 @@ padding-top: 0.2em; } -.annotationLayer .underlineAnnotation { +.annotationLayer .highlightAnnotation, +.annotationLayer .underlineAnnotation, +.annotationLayer .squigglyAnnotation, +.annotationLayer .strikeoutAnnotation { cursor: pointer; } diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index b5676d28223c..6b7bd7f0fe9b 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -52,12 +52,6 @@ var MAX_AUTO_SCALE = 1.25; var SCROLLBAR_PADDING = 40; var VERTICAL_PADDING = 5; -var NullCharactersRegExp = /\x00/g; - -function removeNullCharacters(str) { - return str.replace(NullCharactersRegExp, ''); -} - function getFileName(url) { var anchor = url.indexOf('#'); var query = url.indexOf('?'); @@ -5828,7 +5822,7 @@ var PDFOutlineView = (function PDFOutlineViewClosure() { div.className = 'outlineItem'; var element = document.createElement('a'); this._bindLink(element, item); - element.textContent = removeNullCharacters(item.title); + element.textContent = PDFJS.removeNullCharacters(item.title); div.appendChild(element); if (item.items.length > 0) { @@ -5932,7 +5926,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() { div.className = 'attachmentsItem'; var button = document.createElement('button'); this._bindLink(button, item.content, filename); - button.textContent = removeNullCharacters(filename); + button.textContent = PDFJS.removeNullCharacters(filename); div.appendChild(button); this.container.appendChild(div); }