[api-minor] Remove the structTreeLayerFactory in the viewer

Please note that this functionality has never really mattered for the Firefox PDF Viewer, the GENERIC viewer, or even the "simpleviewer"/"singlepageviewer" component-examples. Hence, in practice this means that only the "pageviewer" component-example[1] have ever really utilized this.

Using factories to initialize various layers in the viewer, rather than simply invoking the relevant code directly, seems (at least to me) like a somewhat roundabout way of doing things.
Not only does this lead to more code, both to write and maintain, but since many of the layers have common parameters (e.g. an `AnnotationStorage`-instance) there's also some duplication.

Hence this patch, which removes the `structTreeLayerFactory` and instead uses a lookup-function in the `PDFPageView`-class to access the external viewer-properties as necessary.
Note that this should even be an improvement for the "pageviewer" component-example, since most layers will now work by default rather than require manual configuration.

---
[1] In practice we generally suggest using the "simpleviewer", or "singlepageviewer", since it does *most* things out-of-the-box and given that a lot of functionality really require *a viewer* and not just a single page in order to work.
This commit is contained in:
Jonas Jenwald 2022-12-06 23:43:09 +01:00
parent ca69da735e
commit f1d1f6edfd
5 changed files with 13 additions and 55 deletions

View file

@ -17,8 +17,6 @@
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
// eslint-disable-next-line max-len
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
// eslint-disable-next-line max-len
/** @typedef {import("./struct_tree_builder").StructTreeLayerBuilder} StructTreeLayerBuilder */
/** @typedef {import("./text_highlighter").TextHighlighter} TextHighlighter */
// eslint-disable-next-line max-len
/** @typedef {import("./text_layer_builder").TextLayerBuilder} TextLayerBuilder */
@ -198,16 +196,6 @@ class IPDFXfaLayerFactory {
createXfaLayerBuilder({ pageDiv, pdfPage, annotationStorage = null }) {}
}
/**
* @interface
*/
class IPDFStructTreeLayerFactory {
/**
* @returns {StructTreeLayerBuilder}
*/
createStructTreeLayerBuilder() {}
}
/**
* @interface
*/
@ -278,7 +266,6 @@ export {
IDownloadManager,
IL10n,
IPDFLinkService,
IPDFStructTreeLayerFactory,
IPDFTextLayerFactory,
IPDFXfaLayerFactory,
IRenderableView,