1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28:06 +02:00

Move the disableAutoFetch option from the global PDFJS object and into getDocument instead

One additional complication with removing this option from the global `PDFJS` object, is that the viewer currently needs to check `disableAutoFetch` in a couple of places. To address this I'm thus proposing adding a getter in `PDFDocumentProxy`, to allow checking the *actually* used values for a particular `getDocument` invocation.
This commit is contained in:
Jonas Jenwald 2018-02-17 22:08:45 +01:00
parent c7c583583b
commit 69d7191034
7 changed files with 38 additions and 22 deletions

View file

@ -207,7 +207,7 @@ let PDFViewerApplication = {
PDFJS.disableStream = value;
}),
preferences.get('disableAutoFetch').then(function resolved(value) {
PDFJS.disableAutoFetch = value;
AppOptions.set('disableAutoFetch', value);
}),
preferences.get('disableFontFace').then(function resolved(value) {
if (AppOptions.get('disableFontFace') === true) {
@ -266,7 +266,8 @@ let PDFViewerApplication = {
PDFJS.disableStream = (hashParams['disablestream'] === 'true');
}
if ('disableautofetch' in hashParams) {
PDFJS.disableAutoFetch = (hashParams['disableautofetch'] === 'true');
AppOptions.set('disableAutoFetch',
hashParams['disableautofetch'] === 'true');
}
if ('disablefontface' in hashParams) {
AppOptions.set('disableFontFace',
@ -933,7 +934,11 @@ let PDFViewerApplication = {
// the loading bar will not be completely filled, nor will it be hidden.
// To prevent displaying a partially filled loading bar permanently, we
// hide it when no data has been loaded during a certain amount of time.
if (PDFJS.disableAutoFetch && percent) {
const disableAutoFetch = this.pdfDocument ?
this.pdfDocument.loadingParams['disableAutoFetch'] :
AppOptions.get('disableAutoFetch');
if (disableAutoFetch && percent) {
if (this.disableAutoFetchLoadingBarTimeout) {
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
this.disableAutoFetchLoadingBarTimeout = null;

View file

@ -139,6 +139,11 @@ const defaultOptions = {
'../external/bcmaps/' : '../web/cmaps/'),
kind: OptionKind.API,
},
disableAutoFetch: {
/** @type {boolean} */
value: false,
kind: OptionKind.API,
},
disableFontFace: {
/** @type {boolean} */
value: false,

View file

@ -13,7 +13,6 @@
* limitations under the License.
*/
import { createPromiseCapability, PDFJS } from 'pdfjs-lib';
import {
CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, isValidRotation,
MAX_AUTO_SCALE, NullL10n, PresentationModeState, RendererType,
@ -21,6 +20,7 @@ import {
} from './ui_utils';
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
import { AnnotationLayerBuilder } from './annotation_layer_builder';
import { createPromiseCapability } from 'pdfjs-lib';
import { getGlobalEventBus } from './dom_events';
import { PDFPageView } from './pdf_page_view';
import { SimpleLinkService } from './pdf_link_service';
@ -408,7 +408,7 @@ class BaseViewer {
// starts to create the correct size canvas. Wait until one page is
// rendered so we don't tie up too many resources early on.
onePageRenderedCapability.promise.then(() => {
if (PDFJS.disableAutoFetch) {
if (pdfDocument.loadingParams['disableAutoFetch']) {
// XXX: Printing is semi-broken with auto fetch disabled.
pagesCapability.resolve();
return;