Merge pull request #9835 from Snuffleupagus/api-loadingParams-cleanup

Clean-up the `PDFDocumentProxy.loadingParams` method in the API, and the `locale` viewer option
This commit is contained in:
Tim van der Meij 2018-06-23 16:46:31 +02:00 committed by GitHub
commit a6830fd414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 12 deletions

View File

@ -726,6 +726,11 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return this.loadingTask.destroy(); 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() { get loadingParams() {
return this.transport.loadingParams; return this.transport.loadingParams;
}, },
@ -2170,8 +2175,6 @@ var WorkerTransport = (function WorkerTransportClosure() {
get loadingParams() { get loadingParams() {
let params = this._params; let params = this._params;
return shadow(this, 'loadingParams', { return shadow(this, 'loadingParams', {
disableRange: params.disableRange,
disableStream: params.disableStream,
disableAutoFetch: params.disableAutoFetch, disableAutoFetch: params.disableAutoFetch,
disableCreateObjectURL: params.disableCreateObjectURL, disableCreateObjectURL: params.disableCreateObjectURL,
disableFontFace: params.disableFontFace, disableFontFace: params.disableFontFace,

View File

@ -319,11 +319,9 @@ let PDFViewerApplication = {
let enabled = hashParams['pdfbug'].split(','); let enabled = hashParams['pdfbug'].split(',');
waitOn.push(loadAndEnablePDFBug(enabled)); waitOn.push(loadAndEnablePDFBug(enabled));
} }
// Locale can be changed only when special debugging flags is present in // It is not possible to change locale for the (various) extension builds.
// the hash section of the URL, or development version of viewer is used. if ((typeof PDFJSDev === 'undefined' ||
// It is not possible to change locale for Firefox extension builds. PDFJSDev.test('!PRODUCTION || GENERIC')) && 'locale' in hashParams) {
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ||
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) && 'locale' in hashParams) {
AppOptions.set('locale', hashParams['locale']); AppOptions.set('locale', hashParams['locale']);
} }
} }

View File

@ -83,11 +83,9 @@ const defaultOptions = {
value: './images/', value: './images/',
kind: OptionKind.VIEWER, kind: OptionKind.VIEWER,
}, },
locale: { /**
/** @type {string} */ * The `locale` is, conditionally, defined below.
value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'), */
kind: OptionKind.VIEWER,
},
maxCanvasPixels: { maxCanvasPixels: {
/** @type {number} */ /** @type {number} */
value: viewerCompatibilityParams.maxCanvasPixels || 16777216, value: viewerCompatibilityParams.maxCanvasPixels || 16777216,
@ -203,6 +201,14 @@ const defaultOptions = {
kind: OptionKind.WORKER, 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); const userOptions = Object.create(null);