[orca] Work around missing text-selection-changed events for Firefox find



commit 07ce432fde5faf0d01c83705de69365ac648123b
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Nov 21 12:31:38 2017 -0500

    Work around missing text-selection-changed events for Firefox find

 src/orca/scripts/web/script.py |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 0b1ca2b..67ca614 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -610,11 +610,14 @@ class Script(default.Script):
         if not (text and text.getNSelections()):
             return
 
-        context = self.utilities.getCaretContext(documentFrame=None)
+        document = self.utilities.getDocumentForObject(obj)
+        if not document:
+            return
 
+        context = self.utilities.getCaretContext(documentFrame=document)
         start, end = text.getSelection(0)
         offset = max(offset, start)
-        self.utilities.setCaretContext(obj, offset, documentFrame=None)
+        self.utilities.setCaretContext(obj, offset, documentFrame=document)
         if end - start < _settingsManager.getSetting('findResultsMinimumLength'):
             return
 
@@ -624,7 +627,7 @@ class Script(default.Script):
 
         if self._madeFindAnnouncement \
            and verbosity == settings.FIND_SPEAK_IF_LINE_CHANGED \
-           and not self.utilities.contextsAreOnSameLine(context, (obj, offset)):
+           and self.utilities.contextsAreOnSameLine(context, (obj, offset)):
             return
 
         contents = self.utilities.getLineContentsAtOffset(obj, offset)
@@ -1333,14 +1336,10 @@ class Script(default.Script):
             return True
 
         if self.utilities.inFindToolbar():
-            if not self._madeFindAnnouncement:
-                msg = "WEB: Event handled: Presenting find results"
-                debug.println(debug.LEVEL_INFO, msg, True)
-                self.presentFindResults(event.source, event.detail1)
-            else:
-                self.utilities.setCaretContext(event.source, event.detail1)
-                msg = "WEB: Event handled: Setting context to source and offset"
-                debug.println(debug.LEVEL_INFO, msg, True)
+            msg = "WEB: Event handled: Presenting find results"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            self.presentFindResults(event.source, event.detail1)
+            self._saveFocusedObjectInfo(orca_state.locusOfFocus)
             return True
 
         if self.utilities.eventIsAutocompleteNoise(event):
@@ -1959,13 +1958,6 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg, True)
             return False
 
-        if self.utilities.inFindToolbar():
-            msg = "WEB: Event handled: Presenting find results"
-            debug.println(debug.LEVEL_INFO, msg, True)
-            self.presentFindResults(event.source, -1)
-            self._saveFocusedObjectInfo(orca_state.locusOfFocus)
-            return True
-
         if not self.utilities.inDocumentContent(orca_state.locusOfFocus):
             msg = "WEB: Event ignored: locusOfFocus (%s) is not in document content" \
                   % orca_state.locusOfFocus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]