Proxy global PDFJS.verbosity to properly configure shared/util.
This commit is contained in:
parent
a8e5912cb1
commit
2fa4dd6f40
@ -462,6 +462,10 @@ var WorkerMessageHandler = {
|
||||
});
|
||||
});
|
||||
|
||||
handler.on('configure', function wphConfigure(data) {
|
||||
setVerbosityLevel(data.verbosity);
|
||||
});
|
||||
|
||||
handler.on('GetDocRequest', function wphSetupDoc(data) {
|
||||
return WorkerMessageHandler.createDocumentHandler(data, port);
|
||||
});
|
||||
@ -696,9 +700,6 @@ var WorkerMessageHandler = {
|
||||
cMapOptions: cMapOptions
|
||||
};
|
||||
|
||||
// TODO move it to the worker options synchronization place (vs document).
|
||||
setVerbosityLevel(data.verbosity);
|
||||
|
||||
getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
|
||||
if (terminated) {
|
||||
// We were in a process of setting up the manager, but it got
|
||||
|
@ -48,6 +48,7 @@ var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||
var combineUrl = sharedUtil.combineUrl;
|
||||
var error = sharedUtil.error;
|
||||
var deprecated = sharedUtil.deprecated;
|
||||
var getVerbosityLevel = sharedUtil.getVerbosityLevel;
|
||||
var info = sharedUtil.info;
|
||||
var isArrayBuffer = sharedUtil.isArrayBuffer;
|
||||
var isSameOrigin = sharedUtil.isSameOrigin;
|
||||
@ -200,17 +201,6 @@ PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ?
|
||||
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
|
||||
false : PDFJS.useOnlyCssZoom);
|
||||
|
||||
/**
|
||||
* Controls the logging level.
|
||||
* The constants from PDFJS.VERBOSITY_LEVELS should be used:
|
||||
* - errors
|
||||
* - warnings [default]
|
||||
* - infos
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.verbosity = (PDFJS.verbosity === undefined ?
|
||||
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity);
|
||||
|
||||
/**
|
||||
* The maximum supported canvas size in total pixels e.g. width * height.
|
||||
* The default value is 4096 * 4096. Use -1 for no limit.
|
||||
@ -456,7 +446,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
||||
cMapPacked: PDFJS.cMapPacked,
|
||||
disableFontFace: PDFJS.disableFontFace,
|
||||
disableCreateObjectURL: PDFJS.disableCreateObjectURL,
|
||||
verbosity: PDFJS.verbosity,
|
||||
postMessageTransfers: PDFJS.postMessageTransfers,
|
||||
}).then(function (workerId) {
|
||||
if (worker.destroyed) {
|
||||
@ -1327,6 +1316,10 @@ var PDFWorker = (function PDFWorkerClosure() {
|
||||
PDFJS.postMessageTransfers = false;
|
||||
}
|
||||
this._readyCapability.resolve();
|
||||
// Send global PDFJS setting, e.g. verbosity level.
|
||||
messageHandler.send('configure', {
|
||||
verbosity: getVerbosityLevel()
|
||||
});
|
||||
} else {
|
||||
this._setupFakeWorker();
|
||||
messageHandler.destroy();
|
||||
|
@ -50,6 +50,13 @@
|
||||
if (PDFJS.verbosity !== undefined) {
|
||||
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
|
||||
}
|
||||
delete PDFJS.verbosity;
|
||||
Object.defineProperty(PDFJS, 'verbosity', {
|
||||
get: function () { return sharedUtil.getVerbosityLevel(); },
|
||||
set: function (level) { sharedUtil.setVerbosityLevel(level); },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
|
||||
PDFJS.OPS = sharedUtil.OPS;
|
||||
|
@ -27,6 +27,16 @@ function PDFJS() {
|
||||
// Mock class constructor. See src/display/api.js.
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the logging level.
|
||||
* The constants from PDFJS.VERBOSITY_LEVELS should be used:
|
||||
* - errors
|
||||
* - warnings [default]
|
||||
* - infos
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.warnings;
|
||||
|
||||
/**
|
||||
* Represents the eventual result of an asynchronous operation.
|
||||
* @external Promise
|
||||
|
Loading…
Reference in New Issue
Block a user