0

[PDF] Remove PDFiumEngine::SearchUsingPDFium()

This code has been dead for a decade. Stop keeping it around.

Change-Id: I70c258b79cce082a74497f60ccf52a530881f279
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6580718
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1464309}
This commit is contained in:
Lei Zhang
2025-05-22 12:40:34 -07:00
committed by Chromium LUCI CQ
parent 846e2245ce
commit 27cd7de162
2 changed files with 5 additions and 53 deletions

@ -1942,19 +1942,11 @@ void PDFiumEngine::StartFind(const std::u16string& text, bool case_sensitive) {
int current_page = next_page_to_search_;
if (pages_[current_page]->available()) {
// Don't use PDFium to search for now, since it doesn't support unicode
// text. Leave the code for now to avoid bit-rot, in case it's fixed later.
// The extra parens suppress a -Wunreachable-code warning.
if ((false)) {
SearchUsingPDFium(text, case_sensitive, first_search,
character_to_start_searching_from, current_page);
} else {
SearchUsingICU(
text, case_sensitive, first_search, character_to_start_searching_from,
last_character_index_to_search_, current_page, last_page_to_search_,
base::BindRepeating(&PDFiumEngine::AddFindResult,
weak_factory_.GetWeakPtr()));
}
SearchUsingICU(
text, case_sensitive, first_search, character_to_start_searching_from,
last_character_index_to_search_, current_page, last_page_to_search_,
base::BindRepeating(&PDFiumEngine::AddFindResult,
weak_factory_.GetWeakPtr()));
if (!IsPageVisible(current_page))
pages_[current_page]->Unload();
@ -1998,38 +1990,6 @@ void PDFiumEngine::StartFind(const std::u16string& text, bool case_sensitive) {
}
}
void PDFiumEngine::SearchUsingPDFium(const std::u16string& term,
bool case_sensitive,
bool first_search,
int character_to_start_searching_from,
int current_page) {
// Find all the matches in the current page.
unsigned long flags = case_sensitive ? FPDF_MATCHCASE : 0;
FPDF_SCHHANDLE find =
FPDFText_FindStart(pages_[current_page]->GetTextPage(),
reinterpret_cast<const unsigned short*>(term.c_str()),
flags, character_to_start_searching_from);
// Note: since we search one page at a time, we don't find matches across
// page boundaries. We could do this manually ourself, but it seems low
// priority since Reader itself doesn't do it.
while (FPDFText_FindNext(find)) {
PDFiumRange result(pages_[current_page].get(),
FPDFText_GetSchResultIndex(find),
FPDFText_GetSchCount(find));
if (!first_search && last_character_index_to_search_ != -1 &&
result.page_index() == last_page_to_search_ &&
result.char_index() >= last_character_index_to_search_) {
break;
}
AddFindResult(std::move(result));
}
FPDFText_FindClose(find);
}
void PDFiumEngine::SearchUsingICU(const std::u16string& term,
bool case_sensitive,
bool first_search,

@ -781,14 +781,6 @@ class PDFiumEngine : public DocumentLoader::Client, public IFSDK_PAUSE {
// Inserts a find result into `find_results_`, which is sorted.
void AddFindResult(PDFiumRange result);
// Search a page using PDFium's methods. Doesn't work with unicode. This
// function is just kept arount in case PDFium code is fixed.
void SearchUsingPDFium(const std::u16string& term,
bool case_sensitive,
bool first_search,
int character_to_start_searching_from,
int current_page);
// Search a page ourself using ICU.
void SearchUsingICU(const std::u16string& term,
bool case_sensitive,