1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Create the borderStyle of inferred links lazily (PR 19110 follow-up)

Given that most inferred links will overlap existing LinkAnnotations, creating a lot of unused `borderStyle` objects seem unnecessary.
Hence we can move that into the `AnnotationLayer.prototype.addLinkAnnotations` method instead, which also allows us to slightly reduce the API-surface.
This commit is contained in:
Jonas Jenwald 2025-02-10 10:03:28 +01:00
parent e608daed9f
commit fba5f3c237
5 changed files with 24 additions and 21 deletions

View file

@ -3254,6 +3254,8 @@ class AnnotationLayer {
parent: this,
};
for (const data of annotations) {
data.borderStyle ||= AnnotationLayer._defaultBorderStyle;
elementParams.data = data;
const element = AnnotationElementFactory.create(elementParams);
@ -3329,6 +3331,24 @@ class AnnotationLayer {
getEditableAnnotation(id) {
return this.#editableAnnotations.get(id);
}
/**
* @private
*/
static get _defaultBorderStyle() {
return shadow(
this,
"_defaultBorderStyle",
Object.freeze({
width: 1,
rawWidth: 1,
style: AnnotationBorderStyleType.SOLID,
dashArray: [3],
horizontalCornerRadius: 0,
verticalCornerRadius: 0,
})
);
}
}
export {

View file

@ -24,7 +24,6 @@
import {
AbortException,
AnnotationBorderStyleType,
AnnotationEditorParamsType,
AnnotationEditorType,
AnnotationMode,
@ -92,7 +91,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING || GENERIC")) {
export {
AbortException,
AnnotationBorderStyleType,
AnnotationEditorLayer,
AnnotationEditorParamsType,
AnnotationEditorType,