Skip to content

Commit

Permalink
[UnifiedPDF] PDFDocumentLayout::indexForPage should use equivalent PD…
Browse files Browse the repository at this point in the history
…FKit API.

https://bugs.webkit.org/show_bug.cgi?id=282219
rdar://138139244

Reviewed by Aditya Keerthi.

After some discussion it turns out that we should not have our own indexForPage
implementation on top of other PDFKit APIs and instead we should just unconditionally
adopt the equivalent API provided by PDFKit. This was causing some issues with find in
certain PDFs and using [PDFDocument indexForPage] resolves these issues.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::indexForPage const):

Canonical link: https://commits.webkit.org/285823@main
  • Loading branch information
sammygill committed Oct 29, 2024
1 parent 750c53c commit 2b2a4b0
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@

auto PDFDocumentLayout::indexForPage(RetainPtr<PDFPage> page) const -> std::optional<PageIndex>
{
for (PageIndex pageIndex = 0; pageIndex < [m_pdfDocument pageCount]; ++pageIndex) {
if (page == [m_pdfDocument pageAtIndex:pageIndex])
return pageIndex;
}
return std::nullopt;

auto pageIndex = [m_pdfDocument indexForPage:page.get()];
if (pageIndex == NSNotFound)
return { };
return pageIndex;
}

PDFDocumentLayout::PageIndex PDFDocumentLayout::nearestPageIndexForDocumentPoint(FloatPoint documentSpacePoint, const std::optional<PDFLayoutRow>& visibleRow) const
Expand Down

0 comments on commit 2b2a4b0

Please sign in to comment.