Merge pull request #14583 from calixteman/buttons
[Annotations] Show buttons even if they've no actions
This commit is contained in:
commit
3fdf2ba4e3
@ -563,36 +563,29 @@ class AnnotationElement {
|
|||||||
|
|
||||||
class LinkAnnotationElement extends AnnotationElement {
|
class LinkAnnotationElement extends AnnotationElement {
|
||||||
constructor(parameters, options = null) {
|
constructor(parameters, options = null) {
|
||||||
const isRenderable = !!(
|
|
||||||
parameters.data.url ||
|
|
||||||
parameters.data.dest ||
|
|
||||||
parameters.data.action ||
|
|
||||||
parameters.data.isTooltipOnly ||
|
|
||||||
parameters.data.resetForm ||
|
|
||||||
(parameters.data.actions &&
|
|
||||||
(parameters.data.actions.Action ||
|
|
||||||
parameters.data.actions["Mouse Up"] ||
|
|
||||||
parameters.data.actions["Mouse Down"]))
|
|
||||||
);
|
|
||||||
super(parameters, {
|
super(parameters, {
|
||||||
isRenderable,
|
isRenderable: true,
|
||||||
ignoreBorder: !!options?.ignoreBorder,
|
ignoreBorder: !!options?.ignoreBorder,
|
||||||
createQuadrilaterals: true,
|
createQuadrilaterals: true,
|
||||||
});
|
});
|
||||||
|
this.isTooltipOnly = parameters.data.isTooltipOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data, linkService } = this;
|
const { data, linkService } = this;
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
|
let isBound = false;
|
||||||
|
|
||||||
if (data.url) {
|
if (data.url) {
|
||||||
linkService.addLinkAttributes(link, data.url, data.newWindow);
|
linkService.addLinkAttributes(link, data.url, data.newWindow);
|
||||||
|
isBound = true;
|
||||||
} else if (data.action) {
|
} else if (data.action) {
|
||||||
this._bindNamedAction(link, data.action);
|
this._bindNamedAction(link, data.action);
|
||||||
|
isBound = true;
|
||||||
} else if (data.dest) {
|
} else if (data.dest) {
|
||||||
this._bindLink(link, data.dest);
|
this._bindLink(link, data.dest);
|
||||||
|
isBound = true;
|
||||||
} else {
|
} else {
|
||||||
let hasClickAction = false;
|
|
||||||
if (
|
if (
|
||||||
data.actions &&
|
data.actions &&
|
||||||
(data.actions.Action ||
|
(data.actions.Action ||
|
||||||
@ -601,14 +594,16 @@ class LinkAnnotationElement extends AnnotationElement {
|
|||||||
this.enableScripting &&
|
this.enableScripting &&
|
||||||
this.hasJSActions
|
this.hasJSActions
|
||||||
) {
|
) {
|
||||||
hasClickAction = true;
|
|
||||||
this._bindJSAction(link, data);
|
this._bindJSAction(link, data);
|
||||||
|
isBound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.resetForm) {
|
if (data.resetForm) {
|
||||||
this._bindResetFormAction(link, data.resetForm);
|
this._bindResetFormAction(link, data.resetForm);
|
||||||
} else if (!hasClickAction) {
|
isBound = true;
|
||||||
|
} else if (this.isTooltipOnly && !isBound) {
|
||||||
this._bindLink(link, "");
|
this._bindLink(link, "");
|
||||||
|
isBound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +618,10 @@ class LinkAnnotationElement extends AnnotationElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.container.className = "linkAnnotation";
|
this.container.className = "linkAnnotation";
|
||||||
this.container.appendChild(link);
|
if (isBound) {
|
||||||
|
this.container.appendChild(link);
|
||||||
|
}
|
||||||
|
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2528,7 +2526,9 @@ class AnnotationLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { firstChild } = element;
|
const { firstChild } = element;
|
||||||
if (firstChild.nodeName === "CANVAS") {
|
if (!firstChild) {
|
||||||
|
element.appendChild(canvas);
|
||||||
|
} else if (firstChild.nodeName === "CANVAS") {
|
||||||
element.replaceChild(canvas, firstChild);
|
element.replaceChild(canvas, firstChild);
|
||||||
} else {
|
} else {
|
||||||
element.insertBefore(canvas, firstChild);
|
element.insertBefore(canvas, firstChild);
|
||||||
|
1
test/pdfs/bug1737260.pdf.link
Normal file
1
test/pdfs/bug1737260.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://bugzilla.mozilla.org/attachment.cgi?id=9247258
|
@ -6528,5 +6528,13 @@
|
|||||||
"value": "1"
|
"value": "1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{ "id": "bug1737260",
|
||||||
|
"file": "pdfs/bug1737260.pdf",
|
||||||
|
"md5": "8bd4f810d30972764b07ae141a4afbc4",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq",
|
||||||
|
"annotations": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user