Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 8 additions & 34 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class AnnotationFactory {

if (
collectByType &&
!collectByType.has(AnnotationType[subtype.toUpperCase()])
!collectByType.has(AnnotationType[subtype?.toUpperCase()])
) {
return null;
}
Expand Down Expand Up @@ -660,7 +660,8 @@ function getTransformMatrix(rect, bbox, matrix) {

class Annotation {
constructor(params) {
const { dict, xref, annotationGlobals, ref, orphanFields } = params;
const { annotationGlobals, dict, orphanFields, ref, subtype, xref } =
params;
const parentRef = orphanFields?.get(ref);
if (parentRef) {
dict.set("Parent", parentRef);
Expand Down Expand Up @@ -694,6 +695,7 @@ class Annotation {

// Expose public properties using a data object.
this.data = {
annotationType: AnnotationType[subtype?.toUpperCase()],
annotationFlags: this.flags,
borderStyle: this.borderStyle,
color: this.color,
Expand All @@ -705,7 +707,7 @@ class Annotation {
id: params.id,
modificationDate: this.modificationDate,
rect: this.rectangle,
subtype: params.subtype,
subtype,
hasOwnCanvas: false,
noRotate: !!(this.flags & AnnotationFlag.NOROTATE),
noHTML: isLocked && isContentLocked,
Expand Down Expand Up @@ -1873,7 +1875,6 @@ class WidgetAnnotation extends Annotation {
const data = this.data;
this._needAppearances = params.needAppearances;

data.annotationType = AnnotationType.WIDGET;
if (data.fieldName === undefined) {
data.fieldName = this._constructFieldName(dict);
}
Expand Down Expand Up @@ -3856,7 +3857,6 @@ class TextAnnotation extends MarkupAnnotation {
this.data.noHTML = false;

const { dict } = params;
this.data.annotationType = AnnotationType.TEXT;

if (this.data.hasAppearance) {
this.data.name = "NoIcon";
Expand All @@ -3881,7 +3881,6 @@ class LinkAnnotation extends Annotation {
super(params);

const { dict, annotationGlobals } = params;
this.data.annotationType = AnnotationType.LINK;

// A link is never rendered on the main canvas so we must render its HTML
// version.
Expand Down Expand Up @@ -3913,7 +3912,6 @@ class PopupAnnotation extends Annotation {
super(params);

const { dict } = params;
this.data.annotationType = AnnotationType.POPUP;

// A pop-up is never rendered on the main canvas so we must render its HTML
// version.
Expand Down Expand Up @@ -4006,7 +4004,6 @@ class FreeTextAnnotation extends MarkupAnnotation {
this.data.noHTML = false;

const { annotationGlobals, evaluatorOptions, xref } = params;
this.data.annotationType = AnnotationType.FREETEXT;
this.setDefaultAppearance(params);
this._hasAppearance = !!this.appearance;

Expand Down Expand Up @@ -4235,7 +4232,6 @@ class LineAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.LINE;
this.data.hasOwnCanvas = this.data.noRotate;
this.data.noHTML = false;

Expand Down Expand Up @@ -4303,7 +4299,6 @@ class SquareAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.SQUARE;
this.data.hasOwnCanvas = this.data.noRotate;
this.data.noHTML = false;

Expand Down Expand Up @@ -4352,7 +4347,6 @@ class CircleAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.CIRCLE;

if (!this.appearance) {
// The default stroke color is black.
Expand Down Expand Up @@ -4416,7 +4410,6 @@ class PolylineAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.POLYLINE;
this.data.hasOwnCanvas = this.data.noRotate;
this.data.noHTML = false;
this.data.vertices = null;
Expand Down Expand Up @@ -4502,22 +4495,10 @@ class PolylineAnnotation extends MarkupAnnotation {
}
}

class PolygonAnnotation extends PolylineAnnotation {
constructor(params) {
// Polygons are specific forms of polylines, so reuse their logic.
super(params);

this.data.annotationType = AnnotationType.POLYGON;
}
}
// Polygons are specific forms of polylines, so reuse their logic.
class PolygonAnnotation extends PolylineAnnotation {}

class CaretAnnotation extends MarkupAnnotation {
constructor(params) {
super(params);

this.data.annotationType = AnnotationType.CARET;
}
}
class CaretAnnotation extends MarkupAnnotation {}

class InkAnnotation extends MarkupAnnotation {
constructor(params) {
Expand All @@ -4527,7 +4508,6 @@ class InkAnnotation extends MarkupAnnotation {
this.data.noHTML = false;

const { dict, xref } = params;
this.data.annotationType = AnnotationType.INK;
this.data.inkLists = [];
this.data.isEditable = !this.data.noHTML;
// We want to be able to add mouse listeners to the annotation.
Expand Down Expand Up @@ -4805,7 +4785,6 @@ class HighlightAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.HIGHLIGHT;
this.data.isEditable = !this.data.noHTML;
// We want to be able to add mouse listeners to the annotation.
this.data.noHTML = false;
Expand Down Expand Up @@ -4949,7 +4928,6 @@ class UnderlineAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.UNDERLINE;

const quadPoints = (this.data.quadPoints = getQuadPoints(dict, null));
if (quadPoints) {
Expand Down Expand Up @@ -4989,7 +4967,6 @@ class SquigglyAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.SQUIGGLY;

const quadPoints = (this.data.quadPoints = getQuadPoints(dict, null));
if (quadPoints) {
Expand Down Expand Up @@ -5035,7 +5012,6 @@ class StrikeOutAnnotation extends MarkupAnnotation {
super(params);

const { dict, xref } = params;
this.data.annotationType = AnnotationType.STRIKEOUT;

const quadPoints = (this.data.quadPoints = getQuadPoints(dict, null));
if (quadPoints) {
Expand Down Expand Up @@ -5077,7 +5053,6 @@ class StampAnnotation extends MarkupAnnotation {
constructor(params) {
super(params);

this.data.annotationType = AnnotationType.STAMP;
this.data.hasOwnCanvas = this.data.noRotate;
this.data.isEditable = !this.data.noHTML;
// We want to be able to add mouse listeners to the annotation.
Expand Down Expand Up @@ -5296,7 +5271,6 @@ class FileAttachmentAnnotation extends MarkupAnnotation {
const { dict } = params;
const file = new FileSpec(dict.get("FS"));

this.data.annotationType = AnnotationType.FILEATTACHMENT;
this.data.hasOwnCanvas = this.data.noRotate;
this.data.noHTML = false;
this.data.file = file.serializable;
Expand Down
Loading