Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 72a1c646b444db9515a67ac1c9edb1651572c90c..2cd136ee826c5735cc566d50b8c0bcd2cca4181d 100644 |
| --- a/pdf/pdfium/pdfium_engine.cc |
| +++ b/pdf/pdfium/pdfium_engine.cc |
| @@ -2077,19 +2077,6 @@ void PDFiumEngine::StartFind(const std::string& text, bool case_sensitive) { |
| if (end_of_search) { |
| // Send the final notification. |
| client_->NotifyNumberOfFindResultsChanged(find_results_.size(), true); |
| - |
| - // When searching is complete, resume finding at a particular index. |
| - // Assuming the user has not clicked the find button in the meanwhile. |
| - if (resume_find_index_.valid() && !current_find_index_.valid()) { |
| - size_t resume_index = resume_find_index_.GetIndex(); |
| - if (resume_index >= find_results_.size()) { |
| - // This might happen if the PDF has some dynamically generated text? |
| - resume_index = 0; |
| - } |
| - current_find_index_.SetIndex(resume_index); |
| - client_->NotifySelectedFindResultChanged(resume_index); |
| - } |
| - resume_find_index_.Invalidate(); |
| } else { |
| pp::CompletionCallback callback = |
| find_factory_.NewCallback(&PDFiumEngine::ContinueFind); |
| @@ -2198,18 +2185,6 @@ void PDFiumEngine::AddFindResult(const PDFiumRange& result) { |
| } |
| find_results_.insert(find_results_.begin() + result_index, result); |
| UpdateTickMarks(); |
| - |
| - if (current_find_index_.valid()) { |
| - if (result_index <= current_find_index_.GetIndex()) { |
| - // Update the current match index |
| - size_t find_index = current_find_index_.IncrementIndex(); |
| - DCHECK_LT(find_index, find_results_.size()); |
| - client_->NotifySelectedFindResultChanged(current_find_index_.GetIndex()); |
| - } |
| - } else if (!resume_find_index_.valid()) { |
| - // Both indices are invalid. Select the first match. |
| - SelectFindResult(true); |
| - } |
| client_->NotifyNumberOfFindResultsChanged(find_results_.size(), false); |
| } |
| @@ -2224,9 +2199,19 @@ bool PDFiumEngine::SelectFindResult(bool forward) { |
| // Move back/forward through the search locations we previously found. |
| size_t new_index; |
| const size_t last_index = find_results_.size() - 1; |
| - if (current_find_index_.valid()) { |
| + |
| + if (resume_find_index_.valid()) { |
| + new_index = resume_find_index_.GetIndex(); |
| + resume_find_index_.Invalidate(); |
| + } else if (current_find_index_.valid()) { |
| size_t current_index = current_find_index_.GetIndex(); |
| if (forward) { |
| + if (current_index >= last_index) { |
|
Lei Zhang
2017/04/24 21:11:12
It feels like if we have to special-case going for
paulmeyer
2017/04/24 21:44:22
Whoops, you're very right. I had meant to put that
|
| + current_find_index_.Invalidate(); |
| + client_->NotifySelectedFindResultChanged(-1); |
| + client_->NotifyNumberOfFindResultsChanged(find_results_.size(), true); |
| + return true; |
| + } |
| new_index = (current_index >= last_index) ? 0 : current_index + 1; |
|
Lei Zhang
2017/04/24 21:11:12
This always evals to: new_index = current_index +
paulmeyer
2017/04/24 21:44:22
Done.
|
| } else { |
| new_index = (current_find_index_.GetIndex() == 0) ? last_index |