Closed Bug 1020254 Opened 10 years ago Closed 4 years ago

Searching for the same word twice in a pdf is not working properly.

Categories

(Firefox :: PDF Viewer, defect, P3)

x86
macOS
defect

Tracking

()

VERIFIED FIXED
81 Branch
Tracking Status
firefox81 --- verified

People

(Reporter: VarCat, Assigned: mcccs)

References

Details

(Whiteboard: [pdfjs-c-ff-integration][pdfjs-d-text-search])

Attachments

(1 file)

Environment:
FF 30RC
Build id: 20140603140158
OS: Mac Os X 10.8.5, Ubuntu 12.10 x32

STR:

1. Open http://www.scala-lang.org/docu/files/ScalaByExample.pdf
2. Search for "smoothly"
3. Click on the pdf and search again for "smoothly"
4. Repeat step 3 until the search is broken

This is the regression window of the issue:

Last good revision: 58eca03214a6 (2014-02-28)
First bad revision: 8abc76dedec2 (2014-03-01)
Pushlog:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=58eca03214a6&tochange=8abc76dedec2
Could you explain/extend steps 3 and 4? Provide more details about which controls are used and what does "broken" mean.
Flags: needinfo?(catalin.varga)
I should give more clear steps to reproduce:

1. Open http://www.scala-lang.org/docu/files/ScalaByExample.pdf
2. Search for any word.
3. Set the focus on the pdf page.
4. Search(CTRL+F) again for the same word as in step 2.
5. Repeat steps 3-4 until the search in not working anymore( the searched word is not found in the pdf even if it exists in the pdf).
Flags: needinfo?(catalin.varga)
Priority: -- → P3
Whiteboard: [pdfjs-c-ff-integration][pdfjs-d-text-search]

Suggested patch:

diff -r 3ad2fc2915b1 toolkit/content/widgets/findbar.js
--- a/toolkit/content/widgets/findbar.js	Sat Jul 25 03:14:44 2020 +0000
+++ b/toolkit/content/widgets/findbar.js	Sun Jul 26 14:52:24 2020 +0100
@@ -184,7 +184,7 @@
           this._hadValue = true;
           this._willfullyDeleted = false;
         }
-        this._find(value);
+        this._browser.finder.clipboardSearchString = value;
       });
 
       this._findField.addEventListener("keypress", event => {
diff -r 3ad2fc2915b1 toolkit/modules/Finder.jsm
--- a/toolkit/modules/Finder.jsm	Sat Jul 25 03:14:44 2020 +0000
+++ b/toolkit/modules/Finder.jsm	Sun Jul 26 14:52:24 2020 +0100
@@ -3,7 +3,9 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-var EXPORTED_SYMBOLS = ["Finder", "GetClipboardSearchString"];
+var EXPORTED_SYMBOLS = [
+  "Finder", "GetClipboardSearchString", "SetClipboardSearchString"
+];
 
 const { XPCOMUtils } = ChromeUtils.import(
   "resource://gre/modules/XPCOMUtils.jsm"
@@ -143,14 +145,7 @@
   },
 
   set clipboardSearchString(aSearchString) {
-    if (!aSearchString || !Clipboard.supportsFindClipboard()) {
-      return;
-    }
-
-    ClipboardHelper.copyStringToClipboard(
-      aSearchString,
-      Ci.nsIClipboard.kFindClipboard
-    );
+    SetClipboardSearchString(aSearchString);
   },
 
   set caseSensitive(aSensitive) {
@@ -826,3 +821,15 @@
 
   return searchString;
 }
+
+function SetClipboardSearchString(aSearchString) {
+  console.log("Saving")
+  if (!aSearchString || !Clipboard.supportsFindClipboard()) {
+    return;
+  }
+
+  ClipboardHelper.copyStringToClipboard(
+    aSearchString,
+    Ci.nsIClipboard.kFindClipboard
+  );
+}
diff -r 3ad2fc2915b1 toolkit/modules/FinderParent.jsm
--- a/toolkit/modules/FinderParent.jsm	Sat Jul 25 03:14:44 2020 +0000
+++ b/toolkit/modules/FinderParent.jsm	Sun Jul 26 14:52:24 2020 +0100
@@ -23,6 +23,12 @@
 
 ChromeUtils.defineModuleGetter(
   this,
+  "SetClipboardSearchString",
+  "resource://gre/modules/Finder.jsm"
+);
+
+ChromeUtils.defineModuleGetter(
+  this,
   "Rect",
   "resource://gre/modules/Geometry.jsm"
 );
@@ -231,6 +237,10 @@
     return GetClipboardSearchString(this._browser.loadContext);
   },
 
+  set clipboardSearchString(aSearchString) {
+    SetClipboardSearchString(aSearchString);
+  },
+
   set caseSensitive(aSensitive) {
     this._caseSensitive = aSensitive;
     this.sendMessageToAllContexts("Finder:CaseSensitive", {

(Minus the line with console.log("Saving"))

Assignee: nobody → mcccs
Status: NEW → ASSIGNED
Attachment #9166538 - Attachment description: Bug 1020254 - Save the find string to the clipboard every time it is updated. r=mikedeboer → Bug 1020254 - Save the find string to the clipboard every time it is updated.
Attachment #9166538 - Attachment is obsolete: true
Attachment #9166538 - Attachment is obsolete: false
Attachment #9166538 - Attachment description: Bug 1020254 - Save the find string to the clipboard every time it is updated. → Bug 1020254 - PDFParent should set the find clipboard. r=mikedeboer
Pushed by nerli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1c19feaebe28
PDFParent should set the find clipboard. r=mikedeboer
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Flags: qe-verify+

Hi mcccs! I followed the steps from comment 2 on macOS 10.15, using an affected Nightly build 2020-08-15 (I couldn't open such old builds from mid 2014), but the search term is always found on the pdf sample in my case.

I'm wondering if these steps are still accurate, could you please let me know, so we can verify this fix?

Flags: needinfo?(mcccs)

Hello, here are the steps I followed:

  • Open a non-PDF page and Command + F and enter a word that is found in the page
  • In a new tab open a PDF page and Command + F and enter a word that is found in the PDF
  • Hit Command + F
  • The textbox will be filled with the word from the non-PDF page which is unexpected since we intended to find the next occurrence of the text last entered.

PS: I have no idea how this has ever been reproducible on Linux. I have tried the 2014 Firefox on a Linux and could not reproduce it. The patch I made fixes a macOS-specific problem so I believe the issue had never existed on Linux. Of the commits in the pushlog, the 5 most suspicious ones (consecutive) added a feature for macOS only.

Flags: needinfo?(mcccs)

Great, thank you! I was able to reproduce the issue as well with your steps on mac 10.15, using an affected Nightly build from 2020-08-17.

The issue is verified as fixed on latest Beta 81.0b9, under mac 10.15.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: