From f1e573b0c7b60044e09d9776b96c1407036c64ee Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Thu, 6 Apr 2017 08:43:36 -0400 Subject: [PATCH] Bug 1354081 - Update pdf.js to version 1.7.418. r=bdahl --- browser/extensions/pdfjs/README.mozilla | 2 +- browser/extensions/pdfjs/content/PdfJs.jsm | 10 +++--- .../pdfjs/content/PdfStreamConverter.jsm | 4 ++- browser/extensions/pdfjs/content/build/pdf.js | 30 +++++++++++++----- .../pdfjs/content/build/pdf.worker.js | 7 ++--- .../content/pdfjschildbootstrap-enabled.js | 31 +++++++++++++++++++ .../pdfjs/content/pdfjschildbootstrap.js | 9 +----- .../extensions/pdfjs/content/web/viewer.js | 2 +- 8 files changed, 67 insertions(+), 28 deletions(-) create mode 100644 browser/extensions/pdfjs/content/pdfjschildbootstrap-enabled.js diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index b4d235889572..84c3d5e94b82 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.7.401 +Current extension version is: 1.7.418 diff --git a/browser/extensions/pdfjs/content/PdfJs.jsm b/browser/extensions/pdfjs/content/PdfJs.jsm index 1728c39db0b0..b43c0e9cf5e7 100644 --- a/browser/extensions/pdfjs/content/PdfJs.jsm +++ b/browser/extensions/pdfjs/content/PdfJs.jsm @@ -190,9 +190,9 @@ var PdfJs = { updateRegistration: function updateRegistration() { if (this.enabled) { - this._ensureRegistered(); + this.ensureRegistered(); } else { - this._ensureUnregistered(); + this.ensureUnregistered(); } }, @@ -205,7 +205,7 @@ var PdfJs = { Services.obs.removeObserver(this, TOPIC_PLUGIN_INFO_UPDATED); this._initialized = false; } - this._ensureUnregistered(); + this.ensureUnregistered(); }, _migrate: function migrate() { @@ -324,7 +324,7 @@ var PdfJs = { return !enabledPluginFound; }, - _ensureRegistered: function _ensureRegistered() { + ensureRegistered: function ensureRegistered() { if (this._registered) { return; } @@ -335,7 +335,7 @@ var PdfJs = { this._registered = true; }, - _ensureUnregistered: function _ensureUnregistered() { + ensureUnregistered: function ensureUnregistered() { if (!this._registered) { return; } diff --git a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm index 18b3985c3762..969f2e6bd29e 100644 --- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -33,7 +33,9 @@ const MAX_STRING_PREF_LENGTH = 128; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/NetUtil.jsm"); + +XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", + "resource://gre/modules/NetUtil.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "NetworkManager", "resource://pdf.js/PdfJsNetwork.jsm"); diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index b6df628bc9e8..a80408a4a77f 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -1292,6 +1292,16 @@ var CustomStyle = function CustomStyleClosure() { }; return CustomStyle; }(); +var RenderingCancelledException = function RenderingCancelledException() { + function RenderingCancelledException(msg, type) { + this.message = msg; + this.type = type; + } + RenderingCancelledException.prototype = new Error(); + RenderingCancelledException.prototype.name = 'RenderingCancelledException'; + RenderingCancelledException.constructor = RenderingCancelledException; + return RenderingCancelledException; +}(); var hasCanvasTypedArrays; hasCanvasTypedArrays = function () { return true; @@ -1380,6 +1390,8 @@ function getDefaultSetting(id) { return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL; case 'enableStats': return !!(globalSettings && globalSettings.enableStats); + case 'pdfjsNext': + return !!(globalSettings && globalSettings.pdfjsNext); default: throw new Error('Unknown default setting: ' + id); } @@ -1407,6 +1419,7 @@ exports.isExternalLinkTargetSet = isExternalLinkTargetSet; exports.isValidUrl = isValidUrl; exports.getFilenameFromUrl = getFilenameFromUrl; exports.LinkTarget = LinkTarget; +exports.RenderingCancelledException = RenderingCancelledException; exports.hasCanvasTypedArrays = hasCanvasTypedArrays; exports.getDefaultSetting = getDefaultSetting; exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL; @@ -2068,6 +2081,7 @@ var FontFaceObject = displayFontLoader.FontFaceObject; var FontLoader = displayFontLoader.FontLoader; var CanvasGraphics = displayCanvas.CanvasGraphics; var Metadata = displayMetadata.Metadata; +var RenderingCancelledException = displayDOMUtils.RenderingCancelledException; var getDefaultSetting = displayDOMUtils.getDefaultSetting; var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory; var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory; @@ -3298,7 +3312,7 @@ var InternalRenderTask = function InternalRenderTaskClosure() { cancel: function InternalRenderTask_cancel() { this.running = false; this.cancelled = true; - this.callback('cancelled'); + this.callback(new RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas')); }, operatorListChanged: function InternalRenderTask_operatorListChanged() { if (!this.graphicsReady) { @@ -3363,8 +3377,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { } }; }(); -exports.version = '1.7.401'; -exports.build = '57d9a64c'; +exports.version = '1.7.418'; +exports.build = 'a662d268'; exports.getDocument = getDocument; exports.PDFDataRangeTransport = PDFDataRangeTransport; exports.PDFWorker = PDFWorker; @@ -4331,8 +4345,8 @@ if (!globalScope.PDFJS) { globalScope.PDFJS = {}; } var PDFJS = globalScope.PDFJS; -PDFJS.version = '1.7.401'; -PDFJS.build = '57d9a64c'; +PDFJS.version = '1.7.418'; +PDFJS.build = 'a662d268'; PDFJS.pdfBug = false; if (PDFJS.verbosity !== undefined) { sharedUtil.setVerbosityLevel(PDFJS.verbosity); @@ -4392,6 +4406,7 @@ PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebG PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget; PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel; PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported; +PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext; PDFJS.getDocument = displayAPI.getDocument; PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; PDFJS.PDFWorker = displayAPI.PDFWorker; @@ -6670,8 +6685,8 @@ exports.TilingPattern = TilingPattern; "use strict"; -var pdfjsVersion = '1.7.401'; -var pdfjsBuild = '57d9a64c'; +var pdfjsVersion = '1.7.418'; +var pdfjsBuild = 'a662d268'; var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsDisplayGlobal = __w_pdfjs_require__(8); var pdfjsDisplayAPI = __w_pdfjs_require__(3); @@ -6702,6 +6717,7 @@ exports.createObjectURL = pdfjsSharedUtil.createObjectURL; exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters; exports.shadow = pdfjsSharedUtil.shadow; exports.createBlob = pdfjsSharedUtil.createBlob; +exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException; exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl; exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes; diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index feedd71dc0cf..b8509fc92249 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -27676,9 +27676,6 @@ var Font = function FontClosure() { } glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start]; glyphId = glyphId + delta & 0xFFFF; - if (glyphId === 0) { - continue; - } mappings.push({ charCode: j, glyphId: glyphId @@ -36373,8 +36370,8 @@ exports.Type1Parser = Type1Parser; "use strict"; -var pdfjsVersion = '1.7.401'; -var pdfjsBuild = '57d9a64c'; +var pdfjsVersion = '1.7.418'; +var pdfjsBuild = 'a662d268'; var pdfjsCoreWorker = __w_pdfjs_require__(17); ; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; diff --git a/browser/extensions/pdfjs/content/pdfjschildbootstrap-enabled.js b/browser/extensions/pdfjs/content/pdfjschildbootstrap-enabled.js new file mode 100644 index 000000000000..93a7489213cc --- /dev/null +++ b/browser/extensions/pdfjs/content/pdfjschildbootstrap-enabled.js @@ -0,0 +1,31 @@ +/* Copyright 2014 Mozilla Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/* globals Components, PdfJs, Services */ + +"use strict"; + +/* + * pdfjschildbootstrap-enabled.js loads into the content process to + * take care of initializing our built-in version of pdfjs when + * running remote. It will only be run when PdfJs.enable is true. + */ + +Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://pdf.js/PdfJs.jsm"); + +if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) { + // register various pdfjs factories that hook us into content loading. + PdfJs.ensureRegistered(); +} diff --git a/browser/extensions/pdfjs/content/pdfjschildbootstrap.js b/browser/extensions/pdfjs/content/pdfjschildbootstrap.js index 2a4573ce5dc7..d70c15ed5491 100644 --- a/browser/extensions/pdfjs/content/pdfjschildbootstrap.js +++ b/browser/extensions/pdfjs/content/pdfjschildbootstrap.js @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals Components, PdfjsContentUtils, PdfJs, Services */ +/* globals Components, PdfjsContentUtils */ "use strict"; @@ -21,14 +21,7 @@ * initializing our built-in version of pdfjs when running remote. */ -Components.utils.import("resource://gre/modules/Services.jsm"); -Components.utils.import("resource://pdf.js/PdfJs.jsm"); Components.utils.import("resource://pdf.js/PdfjsContentUtils.jsm"); // init content utils shim pdfjs will use to access privileged apis. PdfjsContentUtils.init(); - -if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) { - // register various pdfjs factories that hook us into content loading. - PdfJs.updateRegistration(); -} diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index e0b1785bf6a4..667758f2fbac 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -4944,7 +4944,7 @@ var PDFPageView = function PDFPageViewClosure() { if (paintTask === self.paintTask) { self.paintTask = null; } - if (error === 'cancelled') { + if (error instanceof pdfjsLib.RenderingCancelledException) { self.error = null; return Promise.resolve(undefined); }