From de6b0fd12d1bd5e53bd2006e0532de5412bb31aa Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 30 Oct 2018 11:08:16 +0100 Subject: [PATCH] Stop scrolling the document when "Highlight All" is toggled in the findbar (issue 5561) This is consistent with the general, e.g. HTML, search functionality of the Firefox browser. --- web/pdf_find_controller.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index 3c17851242ba5..8da78fe8907bd 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -117,7 +117,9 @@ class PDFFindController { this._dirtyMatch = true; } this._state = state; - this._updateUIState(FindState.PENDING); + if (cmd !== 'findhighlightallchange') { + this._updateUIState(FindState.PENDING); + } this._firstPageCapability.promise.then(() => { // If the document was closed before searching began, or if the search @@ -129,6 +131,7 @@ class PDFFindController { this._extractText(); const findbarClosed = !this._highlightMatches; + const pendingTimeout = !!this._findTimeout; if (this._findTimeout) { clearTimeout(this._findTimeout); @@ -153,6 +156,15 @@ class PDFFindController { if (findbarClosed && this._state.highlightAll) { this._updateAllPages(); } + } else if (cmd === 'findhighlightallchange') { + // If there was a pending search operation, synchronously trigger a new + // search *first* to ensure that the correct matches are highlighted. + if (pendingTimeout) { + this._nextMatch(); + } else { + this._highlightMatches = true; + } + this._updateAllPages(); // Update the highlighting on all active pages. } else { this._nextMatch(); } @@ -217,6 +229,8 @@ class PDFFindController { break; } return false; + case 'findhighlightallchange': + return false; } return true; }