Merge pull request #17026 from Snuffleupagus/layerProperties-Object
Convert `layerProperties` to an Object (PR 15811 follow-up)
This commit is contained in:
commit
52862893f5
@ -80,29 +80,27 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
|||||||
* with user defined ones in order to improve readability in high contrast
|
* with user defined ones in order to improve readability in high contrast
|
||||||
* mode.
|
* mode.
|
||||||
* @property {IL10n} [l10n] - Localization service.
|
* @property {IL10n} [l10n] - Localization service.
|
||||||
* @property {function} [layerProperties] - The function that is used to lookup
|
* @property {Object} [layerProperties] - The object that is used to lookup
|
||||||
* the necessary layer-properties.
|
* the necessary layer-properties.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MAX_CANVAS_PIXELS = compatibilityParams.maxCanvasPixels || 16777216;
|
const MAX_CANVAS_PIXELS = compatibilityParams.maxCanvasPixels || 16777216;
|
||||||
|
|
||||||
const DEFAULT_LAYER_PROPERTIES = () => {
|
const DEFAULT_LAYER_PROPERTIES =
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("COMPONENTS")) {
|
typeof PDFJSDev === "undefined" || !PDFJSDev.test("COMPONENTS")
|
||||||
return null;
|
? null
|
||||||
}
|
: {
|
||||||
return {
|
annotationEditorUIManager: null,
|
||||||
annotationEditorUIManager: null,
|
annotationStorage: null,
|
||||||
annotationStorage: null,
|
downloadManager: null,
|
||||||
downloadManager: null,
|
enableScripting: false,
|
||||||
enableScripting: false,
|
fieldObjectsPromise: null,
|
||||||
fieldObjectsPromise: null,
|
findController: null,
|
||||||
findController: null,
|
hasJSActionsPromise: null,
|
||||||
hasJSActionsPromise: null,
|
get linkService() {
|
||||||
get linkService() {
|
return new SimpleLinkService();
|
||||||
return new SimpleLinkService();
|
},
|
||||||
},
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implements {IRenderableView}
|
* @implements {IRenderableView}
|
||||||
@ -322,7 +320,7 @@ class PDFPageView {
|
|||||||
new TextHighlighter({
|
new TextHighlighter({
|
||||||
pageIndex: this.id - 1,
|
pageIndex: this.id - 1,
|
||||||
eventBus: this.eventBus,
|
eventBus: this.eventBus,
|
||||||
findController: this.#layerProperties().findController,
|
findController: this.#layerProperties.findController,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -871,7 +869,7 @@ class PDFPageView {
|
|||||||
fieldObjectsPromise,
|
fieldObjectsPromise,
|
||||||
hasJSActionsPromise,
|
hasJSActionsPromise,
|
||||||
linkService,
|
linkService,
|
||||||
} = this.#layerProperties();
|
} = this.#layerProperties;
|
||||||
|
|
||||||
this._annotationCanvasMap ||= new Map();
|
this._annotationCanvasMap ||= new Map();
|
||||||
this.annotationLayer = new AnnotationLayerBuilder({
|
this.annotationLayer = new AnnotationLayerBuilder({
|
||||||
@ -989,7 +987,7 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.annotationEditorLayer) {
|
if (!this.annotationEditorLayer) {
|
||||||
const { annotationEditorUIManager } = this.#layerProperties();
|
const { annotationEditorUIManager } = this.#layerProperties;
|
||||||
|
|
||||||
if (!annotationEditorUIManager) {
|
if (!annotationEditorUIManager) {
|
||||||
return;
|
return;
|
||||||
@ -1018,7 +1016,7 @@ class PDFPageView {
|
|||||||
|
|
||||||
if (pdfPage.isPureXfa) {
|
if (pdfPage.isPureXfa) {
|
||||||
if (!this.xfaLayer) {
|
if (!this.xfaLayer) {
|
||||||
const { annotationStorage, linkService } = this.#layerProperties();
|
const { annotationStorage, linkService } = this.#layerProperties;
|
||||||
|
|
||||||
this.xfaLayer = new XfaLayerBuilder({
|
this.xfaLayer = new XfaLayerBuilder({
|
||||||
pageDiv: div,
|
pageDiv: div,
|
||||||
|
@ -35,6 +35,7 @@ import {
|
|||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
PixelsPerInch,
|
PixelsPerInch,
|
||||||
PromiseCapability,
|
PromiseCapability,
|
||||||
|
shadow,
|
||||||
version,
|
version,
|
||||||
} from "pdfjs-lib";
|
} from "pdfjs-lib";
|
||||||
import {
|
import {
|
||||||
@ -549,9 +550,9 @@ class PDFViewer {
|
|||||||
return this.pdfDocument ? this._pagesCapability.promise : null;
|
return this.pdfDocument ? this._pagesCapability.promise : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#layerProperties() {
|
get _layerProperties() {
|
||||||
const self = this;
|
const self = this;
|
||||||
return {
|
return shadow(this, "_layerProperties", {
|
||||||
get annotationEditorUIManager() {
|
get annotationEditorUIManager() {
|
||||||
return self.#annotationEditorUIManager;
|
return self.#annotationEditorUIManager;
|
||||||
},
|
},
|
||||||
@ -576,7 +577,7 @@ class PDFViewer {
|
|||||||
get linkService() {
|
get linkService() {
|
||||||
return self.linkService;
|
return self.linkService;
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -870,7 +871,6 @@ class PDFViewer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const layerProperties = this.#layerProperties.bind(this);
|
|
||||||
const viewerElement =
|
const viewerElement =
|
||||||
this._scrollMode === ScrollMode.PAGE ? null : this.viewer;
|
this._scrollMode === ScrollMode.PAGE ? null : this.viewer;
|
||||||
const scale = this.currentScale;
|
const scale = this.currentScale;
|
||||||
@ -911,7 +911,7 @@ class PDFViewer {
|
|||||||
maxCanvasPixels: this.maxCanvasPixels,
|
maxCanvasPixels: this.maxCanvasPixels,
|
||||||
pageColors: this.pageColors,
|
pageColors: this.pageColors,
|
||||||
l10n: this.l10n,
|
l10n: this.l10n,
|
||||||
layerProperties,
|
layerProperties: this._layerProperties,
|
||||||
});
|
});
|
||||||
this._pages.push(pageView);
|
this._pages.push(pageView);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user