Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UnifiedPDF] PDFDocumentLayout::nearestPageIndexForDocumentPoint some…
…times returns the incorrect page index https://bugs.webkit.org/show_bug.cgi?id=271777 rdar://125502090 Reviewed by Abrar Rahman Protyasha. The current heuristic worked well for the purposes of next/previous page context menu navigation, but it likely will not be sufficient to adopt anywhere else. In order to make this much more precise in two up mode, we need to rework the heuristic. There are two main changes: 1.) Now iterate over the pairs of pages rather than individual ones. This makes the rest of the logic much more intuitive since in two up mode we are almost always working with pairs of pages. There are cases where we may only have one page, but this is handled naturally by the fact that the second page in PairedPageLayoutBounds is optional. 2.) Instead of picking the page with the closer x coordinate after determining the pair of pages to consider, we should instead compare the distance from the point in document space to various points on the pages. In particular, we should compare the distance to the corners of the page and to the side of the page it is next to (if possible). The smallest distance between all of these points should represent the page closest to the point in question. One other change I made is related to the logic when the document point is below the PDF. In this case we should perform the same type of logic with the last pages instead of blindly returning the last page index like we were doing before. * Source/WebCore/platform/graphics/GeometryUtilities.h: * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm: (WebKit::PDFDocumentLayout::nearestPageIndexForDocumentPoint const): Canonical link: https://commits.webkit.org/276852@main
- Loading branch information