Remove unused StructTreeLayerBuilder
constructor parameter
Also change the "private" methods into properly private ones.
This commit is contained in:
parent
67e1c37e0f
commit
cd72818438
@ -144,18 +144,10 @@ class DefaultAnnotationEditorLayerFactory {
|
|||||||
*/
|
*/
|
||||||
class DefaultStructTreeLayerFactory {
|
class DefaultStructTreeLayerFactory {
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} CreateStructTreeLayerBuilderParameters
|
|
||||||
* @property {PDFPageProxy} pdfPage
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {CreateStructTreeLayerBuilderParameters}
|
|
||||||
* @returns {StructTreeLayerBuilder}
|
* @returns {StructTreeLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createStructTreeLayerBuilder({ pdfPage }) {
|
createStructTreeLayerBuilder() {
|
||||||
return new StructTreeLayerBuilder({
|
return new StructTreeLayerBuilder();
|
||||||
pdfPage,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,15 +280,9 @@ class IPDFXfaLayerFactory {
|
|||||||
*/
|
*/
|
||||||
class IPDFStructTreeLayerFactory {
|
class IPDFStructTreeLayerFactory {
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} CreateStructTreeLayerBuilderParameters
|
|
||||||
* @property {PDFPageProxy} pdfPage
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {CreateStructTreeLayerBuilderParameters}
|
|
||||||
* @returns {StructTreeLayerBuilder}
|
* @returns {StructTreeLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createStructTreeLayerBuilder({ pdfPage }) {}
|
createStructTreeLayerBuilder() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -873,7 +873,7 @@ class PDFPageView {
|
|||||||
};
|
};
|
||||||
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
|
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
|
||||||
this.structTreeLayer =
|
this.structTreeLayer =
|
||||||
this.structTreeLayerFactory.createStructTreeLayerBuilder({ pdfPage });
|
this.structTreeLayerFactory.createStructTreeLayerBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
div.setAttribute("data-loaded", true);
|
div.setAttribute("data-loaded", true);
|
||||||
|
@ -1794,18 +1794,10 @@ class PDFViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} CreateStructTreeLayerBuilderParameters
|
|
||||||
* @property {PDFPageProxy} pdfPage
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {CreateStructTreeLayerBuilderParameters}
|
|
||||||
* @returns {StructTreeLayerBuilder}
|
* @returns {StructTreeLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createStructTreeLayerBuilder({ pdfPage }) {
|
createStructTreeLayerBuilder() {
|
||||||
return new StructTreeLayerBuilder({
|
return new StructTreeLayerBuilder();
|
||||||
pdfPage,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
|
|
||||||
|
|
||||||
const PDF_ROLE_TO_HTML_ROLE = {
|
const PDF_ROLE_TO_HTML_ROLE = {
|
||||||
// Document level structure types
|
// Document level structure types
|
||||||
Document: null, // There's a "document" role, but it doesn't make sense here.
|
Document: null, // There's a "document" role, but it doesn't make sense here.
|
||||||
@ -73,24 +71,12 @@ const PDF_ROLE_TO_HTML_ROLE = {
|
|||||||
|
|
||||||
const HEADING_PATTERN = /^H(\d+)$/;
|
const HEADING_PATTERN = /^H(\d+)$/;
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} StructTreeLayerBuilderOptions
|
|
||||||
* @property {PDFPageProxy} pdfPage
|
|
||||||
*/
|
|
||||||
|
|
||||||
class StructTreeLayerBuilder {
|
class StructTreeLayerBuilder {
|
||||||
/**
|
|
||||||
* @param {StructTreeLayerBuilderOptions} options
|
|
||||||
*/
|
|
||||||
constructor({ pdfPage }) {
|
|
||||||
this.pdfPage = pdfPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
render(structTree) {
|
render(structTree) {
|
||||||
return this._walk(structTree);
|
return this.#walk(structTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setAttributes(structElement, htmlElement) {
|
#setAttributes(structElement, htmlElement) {
|
||||||
if (structElement.alt !== undefined) {
|
if (structElement.alt !== undefined) {
|
||||||
htmlElement.setAttribute("aria-label", structElement.alt);
|
htmlElement.setAttribute("aria-label", structElement.alt);
|
||||||
}
|
}
|
||||||
@ -102,7 +88,7 @@ class StructTreeLayerBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_walk(node) {
|
#walk(node) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -119,16 +105,16 @@ class StructTreeLayerBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setAttributes(node, element);
|
this.#setAttributes(node, element);
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
if (node.children.length === 1 && "id" in node.children[0]) {
|
if (node.children.length === 1 && "id" in node.children[0]) {
|
||||||
// Often there is only one content node so just set the values on the
|
// Often there is only one content node so just set the values on the
|
||||||
// parent node to avoid creating an extra span.
|
// parent node to avoid creating an extra span.
|
||||||
this._setAttributes(node.children[0], element);
|
this.#setAttributes(node.children[0], element);
|
||||||
} else {
|
} else {
|
||||||
for (const kid of node.children) {
|
for (const kid of node.children) {
|
||||||
element.append(this._walk(kid));
|
element.append(this.#walk(kid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user