Take fill-alpha into account with default icons for FileAttachment annotations (issue 16800)
This commit is contained in:
parent
15c21d7758
commit
e2819d0c67
@ -4652,6 +4652,12 @@ class FileAttachmentAnnotation extends MarkupAnnotation {
|
||||
const name = dict.get("Name");
|
||||
this.data.name =
|
||||
name instanceof Name ? stringToPDFString(name.name) : "PushPin";
|
||||
|
||||
const fillAlpha = dict.get("ca");
|
||||
this.data.fillAlpha =
|
||||
typeof fillAlpha === "number" && fillAlpha >= 0 && fillAlpha <= 1
|
||||
? fillAlpha
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2798,8 +2798,9 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
||||
render() {
|
||||
this.container.classList.add("fileAttachmentAnnotation");
|
||||
|
||||
const { data } = this;
|
||||
let trigger;
|
||||
if (this.data.hasAppearance) {
|
||||
if (data.hasAppearance || data.fillAlpha === 0) {
|
||||
trigger = document.createElement("div");
|
||||
} else {
|
||||
// Unfortunately it seems that it's not clearly specified exactly what
|
||||
@ -2809,18 +2810,26 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
||||
// Additional names may be supported as well. Default value: PushPin.
|
||||
trigger = document.createElement("img");
|
||||
trigger.src = `${this.imageResourcesPath}annotation-${
|
||||
/paperclip/i.test(this.data.name) ? "paperclip" : "pushpin"
|
||||
/paperclip/i.test(data.name) ? "paperclip" : "pushpin"
|
||||
}.svg`;
|
||||
|
||||
if (data.fillAlpha && data.fillAlpha < 1) {
|
||||
trigger.style = `filter: opacity(${Math.round(
|
||||
data.fillAlpha * 100
|
||||
)}%);`;
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||
this.container.classList.add("hasFillAlpha");
|
||||
}
|
||||
}
|
||||
}
|
||||
trigger.classList.add("popupTriggerArea");
|
||||
trigger.addEventListener("dblclick", this._download.bind(this));
|
||||
this.#trigger = trigger;
|
||||
|
||||
if (
|
||||
!this.data.popupRef &&
|
||||
(this.data.titleObj?.str ||
|
||||
this.data.contentsObj?.str ||
|
||||
this.data.richText)
|
||||
!data.popupRef &&
|
||||
(data.titleObj?.str || data.contentsObj?.str || data.richText)
|
||||
) {
|
||||
this._createPopup();
|
||||
}
|
||||
|
@ -33,11 +33,16 @@
|
||||
:is(.linkAnnotation, .buttonWidgetAnnotation.pushButton):not(.hasBorder)
|
||||
> a,
|
||||
.annotationLayer .popupTriggerArea::after,
|
||||
.annotationLayer .fileAttachmentAnnotation .popupTriggerArea {
|
||||
.annotationLayer
|
||||
.fileAttachmentAnnotation:not(.hasFillAlpha)
|
||||
.popupTriggerArea {
|
||||
opacity: 0.2;
|
||||
background: rgba(255, 255, 0, 1);
|
||||
box-shadow: 0 2px 10px rgba(255, 255, 0, 1);
|
||||
}
|
||||
.annotationLayer .fileAttachmentAnnotation.hasFillAlpha {
|
||||
outline: 2px solid yellow;
|
||||
}
|
||||
|
||||
.annotationLayer .hasClipPath::after {
|
||||
box-shadow: none;
|
||||
|
1
test/pdfs/issue16800.pdf.link
Normal file
1
test/pdfs/issue16800.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/mozilla/pdf.js/files/12287878/TS354.Week.2.slides.pdf
|
@ -6270,6 +6270,16 @@
|
||||
"type": "eq",
|
||||
"annotations": true
|
||||
},
|
||||
{ "id": "issue16800",
|
||||
"file": "pdfs/issue16800.pdf",
|
||||
"md5": "771bc170a55f923d7903af28ccca196c",
|
||||
"link": true,
|
||||
"rounds": 1,
|
||||
"firstPage": 2,
|
||||
"lastPage": 2,
|
||||
"type": "eq",
|
||||
"annotations": true
|
||||
},
|
||||
{ "id": "issue14117",
|
||||
"file": "pdfs/issue14117.pdf",
|
||||
"md5": "9b1c33ad2f59f4e723c258e863149abf",
|
||||
|
Loading…
Reference in New Issue
Block a user