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

[Annotations] Widget annotations must be in front of the other ones (bug 1883609)

This commit is contained in:
Calixte Denizet 2024-03-05 16:20:16 +01:00
parent f1272ee435
commit 4e1b96c781
5 changed files with 44 additions and 2 deletions

View file

@ -4964,4 +4964,5 @@ export {
getQuadPoints,
MarkupAnnotation,
PopupAnnotation,
WidgetAnnotation,
};

View file

@ -30,7 +30,11 @@ import {
Util,
warn,
} from "../shared/util.js";
import { AnnotationFactory, PopupAnnotation } from "./annotation.js";
import {
AnnotationFactory,
PopupAnnotation,
WidgetAnnotation,
} from "./annotation.js";
import {
collectActions,
getInheritableProperty,
@ -766,19 +770,26 @@ class Page {
}
const sortedAnnotations = [];
let popupAnnotations;
let popupAnnotations, widgetAnnotations;
// Ensure that PopupAnnotations are handled last, since they depend on
// their parent Annotation in the display layer; fixes issue 11362.
for (const annotation of await Promise.all(annotationPromises)) {
if (!annotation) {
continue;
}
if (annotation instanceof WidgetAnnotation) {
(widgetAnnotations ||= []).push(annotation);
continue;
}
if (annotation instanceof PopupAnnotation) {
(popupAnnotations ||= []).push(annotation);
continue;
}
sortedAnnotations.push(annotation);
}
if (widgetAnnotations) {
sortedAnnotations.push(...widgetAnnotations);
}
if (popupAnnotations) {
sortedAnnotations.push(...popupAnnotations);
}