|
@@ -0,0 +1,41 @@
|
|
|
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
+From: Lei Zhang <[email protected]>
|
|
|
+Date: Tue, 12 Jul 2022 18:52:14 +0000
|
|
|
+Subject: M104: Better define "first result" in PDFiumEngine::AddFindResult().
|
|
|
+
|
|
|
+Currently, changing the PDF layout confuses AddFindResult() and causes
|
|
|
+it to fail a DCHECK(). Adjust AddFindResult() to avoid the failing
|
|
|
+DCHECK().
|
|
|
+
|
|
|
+This is a cherry-pick of https://crrev.com/1021389 without the test
|
|
|
+changes.
|
|
|
+
|
|
|
+Bug: 1339745
|
|
|
+Change-Id: I25c2b6b436700f9aeca4924fef662ad2909f0a8c
|
|
|
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3758626
|
|
|
+Reviewed-by: K. Moon <[email protected]>
|
|
|
+Commit-Queue: Lei Zhang <[email protected]>
|
|
|
+Cr-Commit-Position: refs/branch-heads/5112@{#820}
|
|
|
+Cr-Branched-From: b13d3fe7b3c47a56354ef54b221008afa754412e-refs/heads/main@{#1012729}
|
|
|
+
|
|
|
+diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
|
|
|
+index c015d4b06a44c9121576d14160b84e871081fa33..0afe3c60715c948c7e376f81646c11b29cc01486 100644
|
|
|
+--- a/pdf/pdfium/pdfium_engine.cc
|
|
|
++++ b/pdf/pdfium/pdfium_engine.cc
|
|
|
+@@ -1971,7 +1971,7 @@ void PDFiumEngine::SearchUsingICU(const std::u16string& term,
|
|
|
+ }
|
|
|
+
|
|
|
+ void PDFiumEngine::AddFindResult(const PDFiumRange& result) {
|
|
|
+- bool first_result = find_results_.empty();
|
|
|
++ bool first_result = find_results_.empty() && !resume_find_index_.has_value();
|
|
|
+ // Figure out where to insert the new location, since we could have
|
|
|
+ // started searching midway and now we wrapped.
|
|
|
+ size_t result_index;
|
|
|
+@@ -1988,7 +1988,6 @@ void PDFiumEngine::AddFindResult(const PDFiumRange& result) {
|
|
|
+ UpdateTickMarks();
|
|
|
+ client_->NotifyNumberOfFindResultsChanged(find_results_.size(), false);
|
|
|
+ if (first_result) {
|
|
|
+- DCHECK(!resume_find_index_);
|
|
|
+ DCHECK(!current_find_index_);
|
|
|
+ SelectFindResult(/*forward=*/true);
|
|
|
+ }
|