[Annotations] Widget annotations must be in front of the other ones (bug 1883609)
This commit is contained in:
parent
f1272ee435
commit
4e1b96c781
@ -4964,4 +4964,5 @@ export {
|
|||||||
getQuadPoints,
|
getQuadPoints,
|
||||||
MarkupAnnotation,
|
MarkupAnnotation,
|
||||||
PopupAnnotation,
|
PopupAnnotation,
|
||||||
|
WidgetAnnotation,
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,11 @@ import {
|
|||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import { AnnotationFactory, PopupAnnotation } from "./annotation.js";
|
import {
|
||||||
|
AnnotationFactory,
|
||||||
|
PopupAnnotation,
|
||||||
|
WidgetAnnotation,
|
||||||
|
} from "./annotation.js";
|
||||||
import {
|
import {
|
||||||
collectActions,
|
collectActions,
|
||||||
getInheritableProperty,
|
getInheritableProperty,
|
||||||
@ -766,19 +770,26 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sortedAnnotations = [];
|
const sortedAnnotations = [];
|
||||||
let popupAnnotations;
|
let popupAnnotations, widgetAnnotations;
|
||||||
// Ensure that PopupAnnotations are handled last, since they depend on
|
// Ensure that PopupAnnotations are handled last, since they depend on
|
||||||
// their parent Annotation in the display layer; fixes issue 11362.
|
// their parent Annotation in the display layer; fixes issue 11362.
|
||||||
for (const annotation of await Promise.all(annotationPromises)) {
|
for (const annotation of await Promise.all(annotationPromises)) {
|
||||||
if (!annotation) {
|
if (!annotation) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (annotation instanceof WidgetAnnotation) {
|
||||||
|
(widgetAnnotations ||= []).push(annotation);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (annotation instanceof PopupAnnotation) {
|
if (annotation instanceof PopupAnnotation) {
|
||||||
(popupAnnotations ||= []).push(annotation);
|
(popupAnnotations ||= []).push(annotation);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sortedAnnotations.push(annotation);
|
sortedAnnotations.push(annotation);
|
||||||
}
|
}
|
||||||
|
if (widgetAnnotations) {
|
||||||
|
sortedAnnotations.push(...widgetAnnotations);
|
||||||
|
}
|
||||||
if (popupAnnotations) {
|
if (popupAnnotations) {
|
||||||
sortedAnnotations.push(...popupAnnotations);
|
sortedAnnotations.push(...popupAnnotations);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,35 @@ describe("Annotation highlight", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Check that widget annotations are in front of highlight ones", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("bug1883609.pdf", "[data-annotation-id='23R']");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must click on widget annotations", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
for (const i of [23, 22, 14]) {
|
||||||
|
await page.click(`[data-annotation-id='${i}R']`);
|
||||||
|
await page.waitForFunction(
|
||||||
|
id =>
|
||||||
|
document.activeElement ===
|
||||||
|
document.querySelector(`#pdfjs_internal_id_${id}R`),
|
||||||
|
{},
|
||||||
|
i
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Checkbox annotation", () => {
|
describe("Checkbox annotation", () => {
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -633,3 +633,4 @@
|
|||||||
!issue17671.pdf
|
!issue17671.pdf
|
||||||
!bug1868759.pdf
|
!bug1868759.pdf
|
||||||
!issue17730.pdf
|
!issue17730.pdf
|
||||||
|
!bug1883609.pdf
|
||||||
|
BIN
test/pdfs/bug1883609.pdf
Executable file
BIN
test/pdfs/bug1883609.pdf
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user