Skip to content

Commit

Permalink
Add conversion between index spaces
Browse files Browse the repository at this point in the history
The lack of conversion was causing an offset error because some of the
numbers being used were in the character list index space and some of
them were in the text buffer index space. This CL combined with
https://pdfium-review.googlesource.com/c/pdfium/+/20014 in PDFium
resolves outstanding issues with Find highlights in PDFs with control
characters in the text body.

BUG=chromium:654578

Change-Id: I5f600a59926f137ed0a0901711a3ff57d3e42e34
Reviewed-on: https://chromium-review.googlesource.com/801310
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520666}
  • Loading branch information
zoddicus authored and Commit Bot committed Nov 30, 2017
1 parent f3c2fcc commit 99088a4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pdf/pdfium/pdfium_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,9 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term,
for (const auto& result : results) {
// Need to map the indexes from the page text, which may have generated
// characters like space etc, to character indices from the page.
int temp_start = result.start_index + character_to_start_searching_from;
int text_to_start_searching_from = FPDFText_GetTextIndexFromCharIndex(
pages_[current_page]->GetTextPage(), character_to_start_searching_from);
int temp_start = result.start_index + text_to_start_searching_from;
int start = FPDFText_GetCharIndexFromTextIndex(
pages_[current_page]->GetTextPage(), temp_start);
int end = FPDFText_GetCharIndexFromTextIndex(
Expand Down

0 comments on commit 99088a4

Please sign in to comment.