[webkit-changes] [WebKit/WebKit] 59d121: [UnifiedPDF] PDFDocumentLayout::nearestPageIndexFo...

Sammy Gill noreply at github.com
Fri Mar 29 18:23:15 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 59d1217ce34444006a187f88917be67d5ed8100b
      https://github.com/WebKit/WebKit/commit/59d1217ce34444006a187f88917be67d5ed8100b
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2024-03-29 (Fri, 29 Mar 2024)

  Changed paths:
    M Source/WebCore/platform/graphics/GeometryUtilities.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm

  Log Message:
  -----------
  [UnifiedPDF] PDFDocumentLayout::nearestPageIndexForDocumentPoint sometimes 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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list