From 275834ae669321ed409a034254ec1866373f855c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald <jonas.jenwald@gmail.com> Date: Sat, 23 Jun 2018 12:33:36 +0200 Subject: [PATCH 1/2] Clean-up, and add JSDocs to, the `PDFDocumentProxy.loadingParams` method (PR 9830 follow-up) --- src/display/api.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 4463a8973..c2db27f09 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -726,6 +726,11 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { return this.loadingTask.destroy(); }, + /** + * @return {Object} A subset of the current {DocumentInitParameters}, + * which are either needed in the viewer and/or whose default values + * may be affected by the `apiCompatibilityParams`. + */ get loadingParams() { return this.transport.loadingParams; }, @@ -2170,8 +2175,6 @@ var WorkerTransport = (function WorkerTransportClosure() { get loadingParams() { let params = this._params; return shadow(this, 'loadingParams', { - disableRange: params.disableRange, - disableStream: params.disableStream, disableAutoFetch: params.disableAutoFetch, disableCreateObjectURL: params.disableCreateObjectURL, disableFontFace: params.disableFontFace, From c8384061cf85b71f9cc6331a34e92777afcac4e5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald <jonas.jenwald@gmail.com> Date: Sat, 23 Jun 2018 13:01:43 +0200 Subject: [PATCH 2/2] Ensure that the `locale` viewer option is never defined in the (various) extension builds (PR 9493 follow-up) --- web/app.js | 8 +++----- web/app_options.js | 16 +++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/web/app.js b/web/app.js index 9242cf995..f0e33d4f5 100644 --- a/web/app.js +++ b/web/app.js @@ -319,11 +319,9 @@ let PDFViewerApplication = { let enabled = hashParams['pdfbug'].split(','); waitOn.push(loadAndEnablePDFBug(enabled)); } - // Locale can be changed only when special debugging flags is present in - // the hash section of the URL, or development version of viewer is used. - // It is not possible to change locale for Firefox extension builds. - if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') || - !PDFJSDev.test('FIREFOX || MOZCENTRAL')) && 'locale' in hashParams) { + // It is not possible to change locale for the (various) extension builds. + if ((typeof PDFJSDev === 'undefined' || + PDFJSDev.test('!PRODUCTION || GENERIC')) && 'locale' in hashParams) { AppOptions.set('locale', hashParams['locale']); } } diff --git a/web/app_options.js b/web/app_options.js index b9f91b5fd..a6023264d 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -83,11 +83,9 @@ const defaultOptions = { value: './images/', kind: OptionKind.VIEWER, }, - locale: { - /** @type {string} */ - value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'), - kind: OptionKind.VIEWER, - }, + /** + * The `locale` is, conditionally, defined below. + */ maxCanvasPixels: { /** @type {number} */ value: viewerCompatibilityParams.maxCanvasPixels || 16777216, @@ -203,6 +201,14 @@ const defaultOptions = { kind: OptionKind.WORKER, }, }; +if (typeof PDFJSDev === 'undefined' || + PDFJSDev.test('!PRODUCTION || GENERIC')) { + defaultOptions.locale = { + /** @type {string} */ + value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'), + kind: OptionKind.VIEWER, + }; +} const userOptions = Object.create(null);