Remove the undocumented PDFJS.enableStats option

In order to simplify things, the undocumented `enableStats` option was removed and `pdfBug` is now instead used to enabled general debugging *and* page request/rendering stats.
Considering that in the default viewer the `stats` was only used when debugging was also enabled, this simplification (code wise) definitely seem worthwhile to me.
This commit is contained in:
Jonas Jenwald 2018-02-13 14:34:29 +01:00
parent 6bc3e1fb93
commit e95c11a7f0
5 changed files with 5 additions and 11 deletions

View File

@ -745,7 +745,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.pageIndex = pageIndex;
this.pageInfo = pageInfo;
this.transport = transport;
this._stats = (getDefaultSetting('enableStats') ?
this._stats = (getDefaultSetting('pdfBug') ?
new StatTimer() : DummyStatTimer);
this.commonObjs = transport.commonObjs;
this.objs = new PDFObjects();

View File

@ -359,8 +359,6 @@ function getDefaultSetting(id) {
return globalSettings ? globalSettings.maxImageSize : -1;
case 'isEvalSupported':
return globalSettings ? globalSettings.isEvalSupported : true;
case 'enableStats':
return !!(globalSettings && globalSettings.enableStats);
default:
throw new Error('Unknown default setting: ' + id);
}

View File

@ -254,7 +254,7 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
PDFJS.workerSrc = '../build/generic/build/pdf.worker.js';
PDFJS.cMapPacked = true;
PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.enableStats = true;
PDFJS.pdfBug = true;
// Set the passed options
this.inflight = options.inflight;

View File

@ -333,8 +333,7 @@ let PDFViewerApplication = {
}
if ('pdfbug' in hashParams) {
PDFJS.pdfBug = true;
let pdfBug = hashParams['pdfbug'];
let enabled = pdfBug.split(',');
let enabled = hashParams['pdfbug'].split(',');
waitOn.push(loadAndEnablePDFBug(enabled));
}
// Locale can be changed only when special debugging flags is present in
@ -1558,7 +1557,6 @@ function loadAndEnablePDFBug(enabledTabs) {
script.onload = function () {
PDFBug.enable(enabledTabs);
PDFBug.init({
PDFJS,
OPS,
}, appConfig.mainContainer);
resolve();
@ -1723,8 +1721,7 @@ function webViewerPageRendered(evt) {
thumbnailView.setImage(pageView);
}
if (PDFJS.pdfBug && typeof Stats !== 'undefined' && Stats.enabled &&
pageView.stats) {
if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
Stats.add(pageNumber, pageView.stats);
}
@ -2013,7 +2010,7 @@ function webViewerPageChanging(evt) {
}
// we need to update stats
if (PDFJS.pdfBug && typeof Stats !== 'undefined' && Stats.enabled) {
if (typeof Stats !== 'undefined' && Stats.enabled) {
let pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
if (pageView && pageView.stats) {
Stats.add(page, pageView.stats);

View File

@ -462,7 +462,6 @@ var Stats = (function Stats() {
manager: null,
init(pdfjsLib) {
this.panel.setAttribute('style', 'padding: 5px;');
pdfjsLib.PDFJS.enableStats = true;
},
enabled: false,
active: false,