[orca] Work on bgo #608149 - Orca's caret navigation for Firefox is broken effective the 30th Sept build of



commit 0ba78478e0dea9f2cc16f8ed92d436d6ecfcd1d5
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sun Feb 7 21:07:22 2010 -0500

    Work on bgo #608149 - Orca's caret navigation for Firefox is broken effective the 30th Sept build of FF 3.6
    
    This implements a new setting, which is enabled by default: Grab focus on
    objects when navigating. This setting, when enabled, causes Orca to work
    like it always has been. If this setting is disabled, it will address
    the primary problem reported in this bug.

 src/orca/scripts/toolkits/Gecko/script.py          |   36 +++++++++++++++++++-
 src/orca/scripts/toolkits/Gecko/script_settings.py |    6 +++
 2 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 7fe92bf..ca235bc 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -107,6 +107,7 @@ class Script(default.Script):
         self.speakCellSpanCheckButton = None
         self.speakResultsDuringFindCheckButton = None
         self.structuralNavigationCheckButton = None
+        self.grabFocusOnAncestorCheckButton = None
 
         # _caretNavigationFunctions are functions that represent fundamental
         # ways to move the caret (e.g., by the arrow keys).
@@ -842,6 +843,23 @@ class Script(default.Script):
         gtk.ToggleButton.set_active(self.structuralNavigationCheckButton,
                                     self.structuralNavigation.enabled)
 
+        # Translators: Orca has had to implement its own caret navigation
+        # model to work around issues in Gecko/Firefox. In certain versions
+        # of Firefox, we must perform a focus grab on each object being
+        # navigated in order for things to work as expected; in other
+        # versions of Firefox, we must avoid doing so in order for things
+        # to work as expected. We cannot identify with certainty which
+        # situation the user is in, so we must provide this as an option
+        # within Orca.
+        #
+        label = _("_Grab focus on objects when navigating")
+        self.grabFocusOnAncestorCheckButton = gtk.CheckButton(label)
+        gtk.Widget.show(self.grabFocusOnAncestorCheckButton)
+        gtk.Box.pack_start(generalVBox, self.grabFocusOnAncestorCheckButton,
+                           False, False, 0)
+        gtk.ToggleButton.set_active(self.grabFocusOnAncestorCheckButton,
+                                    script_settings.grabFocusOnAncestor)
+
         # Translators: when the user arrows up and down in HTML content,
         # it is some times beneficial to always position the cursor at the
         # beginning of the line rather than guessing the position directly
@@ -1048,6 +1066,10 @@ class Script(default.Script):
                          % (prefix, value))
         script_settings.structuralNavigationEnabled = value
 
+        value = self.grabFocusOnAncestorCheckButton.get_active()
+        prefs.writelines("%s.grabFocusOnAncestor = %s\n" % (prefix, value))
+        script_settings.grabFocusOnAncestor = value
+
         value = self.arrowToLineBeginningCheckButton.get_active()
         prefs.writelines("%s.arrowToLineBeginning = %s\n" % (prefix, value))
         script_settings.arrowToLineBeginning = value
@@ -5947,7 +5969,11 @@ class Script(default.Script):
             # of something such as a text area and back into the
             # document content.
             #
-            self._objectForFocusGrab = obj
+            if script_settings.grabFocusOnAncestor:
+                self._objectForFocusGrab = obj
+            else:
+                self._objectForFocusGrab = None
+
             while self._objectForFocusGrab and obj:
                 role = self._objectForFocusGrab.getRole()
 
@@ -5973,6 +5999,14 @@ class Script(default.Script):
 
                 self._objectForFocusGrab = self._objectForFocusGrab.parent
 
+            # [[[JD - I *think* we still want to do a focus grab, even with
+            # the issues identified in bug 608149. Nothing bad should result
+            # from grabbing focus on a non-focusable object. But I might be
+            # wrong.]]]
+            #
+            if obj and not self._objectForFocusGrab:
+                obj.queryComponent().grabFocus()
+
             if self._objectForFocusGrab:
                 # [[[See https://bugzilla.mozilla.org/show_bug.cgi?id=363214.
                 # We need to set focus on the parent of the document frame.]]]
diff --git a/src/orca/scripts/toolkits/Gecko/script_settings.py b/src/orca/scripts/toolkits/Gecko/script_settings.py
index 387df9d..b80c464 100644
--- a/src/orca/scripts/toolkits/Gecko/script_settings.py
+++ b/src/orca/scripts/toolkits/Gecko/script_settings.py
@@ -68,3 +68,9 @@ minimumFindLength = 4
 # that may be too verbose so it's configurable.
 #
 onlySpeakChangedLinesDuringFind = False
+
+# Whether we should grab focus on a focusable ancestor when setting
+# the caret position. See bug 608149. We'll default to True for now
+# because most Orca users are not using the impacted versions of FF.
+#
+grabFocusOnAncestor = True



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