[PDF] Remove PDFiumEngine::pages()
This recently added accessor is actually not necessary, as callers can use PDFiumEngine::GetNumberOfPages() and GetPage() instead. Change-Id: Icfeaaa5e41e42537c543532d32745d10abdf6750 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6220286 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Juan Mojica <juanmojica@google.com> Cr-Commit-Position: refs/heads/main@{#1413862}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e88a14147b
commit
c82e0ee274
@ -510,11 +510,6 @@ class PDFiumEngine : public DocumentLoader::Client, public IFSDK_PAUSE {
|
||||
int page_to_search,
|
||||
AddSearchResultCallback add_result_callback);
|
||||
|
||||
// Returns all the pages in the PDF.
|
||||
const std::vector<std::unique_ptr<PDFiumPage>>& pages() const {
|
||||
return pages_;
|
||||
}
|
||||
|
||||
private:
|
||||
// This helper class is used to detect the difference in selection between
|
||||
// construction and destruction. At destruction, it invalidates all the
|
||||
|
@ -47,7 +47,7 @@ void AddTextFragmentSuffixResult(
|
||||
const int suffix_boundary_count =
|
||||
suffix_result.char_index() - suffix_boundary_start;
|
||||
const auto suffix_boundary =
|
||||
PDFiumRange(engine->pages()[before_suffix_range.page_index()].get(),
|
||||
PDFiumRange(engine->GetPage(before_suffix_range.page_index()),
|
||||
suffix_boundary_start, suffix_boundary_count);
|
||||
|
||||
for (const auto& c : suffix_boundary.GetText()) {
|
||||
@ -98,8 +98,8 @@ void AddTextFragmentStartResult(
|
||||
const int boundary_start = prefix_end;
|
||||
const int boundary_count = start_result.char_index() - prefix_end;
|
||||
const auto boundary =
|
||||
PDFiumRange(engine->pages()[start_result.page_index()].get(),
|
||||
boundary_start, boundary_count);
|
||||
PDFiumRange(engine->GetPage(start_result.page_index()), boundary_start,
|
||||
boundary_count);
|
||||
for (const auto& c : boundary.GetText()) {
|
||||
if (!base::IsUnicodeWhitespace(c)) {
|
||||
return;
|
||||
@ -171,7 +171,7 @@ void PDFiumTextFragmentFinder::StartTextFragmentSearch(
|
||||
// If StartTextFragmentSearch() gets called before `engine_` has any page
|
||||
// information (i.e. before the first call to LoadDocument has happened).
|
||||
// Handle this case.
|
||||
if (engine_->pages().empty()) {
|
||||
if (engine_->GetNumberOfPages() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -192,8 +192,7 @@ void PDFiumTextFragmentFinder::FindTextFragmentPrefix(
|
||||
text_fragment_prefixes_.clear();
|
||||
const auto prefix_unicode = base::UTF8ToUTF16(fragment.prefix());
|
||||
for (int current_page = page_to_start_search_from;
|
||||
current_page < static_cast<int>(engine_->pages().size());
|
||||
current_page++) {
|
||||
current_page < engine_->GetNumberOfPages(); current_page++) {
|
||||
last_unsearched_page_ = current_page + 1;
|
||||
engine_->SearchForFragment(
|
||||
prefix_unicode,
|
||||
@ -217,8 +216,7 @@ void PDFiumTextFragmentFinder::FindTextFragmentStart(
|
||||
// the text fragment. In this case, searching for the start term itself should
|
||||
// be adequate.
|
||||
if (text_fragment_prefixes_.empty()) {
|
||||
for (int current_page = 0;
|
||||
current_page < static_cast<int>(engine_->pages().size());
|
||||
for (int current_page = 0; current_page < engine_->GetNumberOfPages();
|
||||
current_page++) {
|
||||
engine_->SearchForFragment(
|
||||
start_unicode,
|
||||
@ -272,7 +270,7 @@ void PDFiumTextFragmentFinder::FindTextFragmentStart(
|
||||
// prefix, search again for the text fragment prefix in case the fragment is
|
||||
// actually on an unsearched page.
|
||||
if (text_fragment_starts_.empty() && !fragment.prefix().empty() &&
|
||||
last_unsearched_page_ < static_cast<int>(engine_->pages().size())) {
|
||||
last_unsearched_page_ < engine_->GetNumberOfPages()) {
|
||||
FindTextFragmentPrefix(fragment, last_unsearched_page_);
|
||||
}
|
||||
}
|
||||
@ -306,7 +304,7 @@ void PDFiumTextFragmentFinder::FindTextFragmentEnd(
|
||||
// If no text end was found and the fragment contains a prefix, search again
|
||||
// for the text fragment prefix in case the fragment is on an unsearched page.
|
||||
if (!text_fragment_end_ && !fragment.prefix().empty() &&
|
||||
last_unsearched_page_ < static_cast<int>(engine_->pages().size())) {
|
||||
last_unsearched_page_ < engine_->GetNumberOfPages()) {
|
||||
FindTextFragmentPrefix(fragment, last_unsearched_page_);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user