[orca/gnome-3-6] Fix for bug 677320 - Cannot perform braille scrolling amongst objects in WebKitGtk content



commit b7d6a28e4e25024be131199e432e3bf25c615da5
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Aug 6 20:53:12 2012 +0200

    Fix for bug 677320 - Cannot perform braille scrolling amongst objects in WebKitGtk content
    
    Note: This fix solves the reported problem of WebKitGtk objects not being
    something one can scroll amongst. There are still refinements which need
    to be made pending user feedback and related braille bugs since discovered
    which need to be fixed.

 .../toolkits/WebKitGtk/braille_generator.py        |    3 +-
 src/orca/scripts/toolkits/WebKitGtk/script.py      |   62 ++++++++++++++++++++
 .../scripts/toolkits/WebKitGtk/script_utilities.py |   42 +++++++++++++
 3 files changed, 105 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/WebKitGtk/braille_generator.py b/src/orca/scripts/toolkits/WebKitGtk/braille_generator.py
index 5dfd852..ef7c431 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/braille_generator.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/braille_generator.py
@@ -88,8 +88,7 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
         previous object with focus.
         """
 
-        role = args.get('role', obj.getRole())
-        if role == pyatspi.ROLE_LINK:
+        if self._script.utilities.isWebKitGtk(obj):
             return []
 
         return braille_generator.BrailleGenerator._generateAncestors(
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 3172b3a..5b3f538 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -108,6 +108,36 @@ class Script(default.Script):
                 #
                 _("Speaks entire document."))
 
+        self.inputEventHandlers["panBrailleLeftHandler"] = \
+            input_event.InputEventHandler(
+                Script.panBrailleLeft,
+                # Translators: a refreshable braille display is an
+                # external hardware device that presents braille
+                # character to the user.  There are a limited number
+                # of cells on the display (typically 40 cells).  Orca
+                # provides the feature to build up a longer logical
+                # line and allow the user to press buttons on the
+                # braille display so they can pan left and right over
+                # this line.
+                #
+                _("Pans the braille display to the left."),
+                False) # Do not enable learn mode for this action
+
+        self.inputEventHandlers["panBrailleRightHandler"] = \
+            input_event.InputEventHandler(
+                Script.panBrailleRight,
+                # Translators: a refreshable braille display is an
+                # external hardware device that presents braille
+                # character to the user.  There are a limited number
+                # of cells on the display (typically 40 cells).  Orca
+                # provides the feature to build up a longer logical
+                # line and allow the user to press buttons on the
+                # braille display so they can pan left and right over
+                # this line.
+                #
+                _("Pans the braille display to the right."),
+                False) # Do not enable learn mode for this action
+
     def getToolkitKeyBindings(self):
         """Returns the toolkit-specific keybindings for this script."""
 
@@ -493,6 +523,38 @@ class Script(default.Script):
 
         return child, index
 
+    def panBrailleLeft(self, inputEvent=None, panAmount=0):
+        """In document content, we want to use the panning keys to browse the
+        entire document.
+        """
+
+        if self.flatReviewContext \
+           or not self.isBrailleBeginningShowing() \
+           or not self.utilities.isWebKitGtk(orca_state.locusOfFocus):
+            return default.Script.panBrailleLeft(self, inputEvent, panAmount)
+
+        obj = self.utilities.findPreviousObject(orca_state.locusOfFocus)
+        orca.setLocusOfFocus(None, obj, notifyScript=False)
+        self.updateBraille(obj)
+
+        return True
+
+    def panBrailleRight(self, inputEvent=None, panAmount=0):
+        """In document content, we want to use the panning keys to browse the
+        entire document.
+        """
+
+        if self.flatReviewContext \
+           or not self.isBrailleEndShowing() \
+           or not self.utilities.isWebKitGtk(orca_state.locusOfFocus):
+            return default.Script.panBrailleRight(self, inputEvent, panAmount)
+
+        obj = self.utilities.findNextObject(orca_state.locusOfFocus)
+        orca.setLocusOfFocus(None, obj, notifyScript=False)
+        self.updateBraille(obj)
+
+        return True
+
     def sayAll(self, inputEvent):
         """Speaks the contents of the document beginning with the present
         location.  Overridden in this script because the sayAll could have
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py b/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
index 5dee35f..1859d30 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script_utilities.py
@@ -168,3 +168,45 @@ class Utilities(script_utilities.Utilities):
         objects = [x for x in objects if x[1] < x[2]]
 
         return objects
+
+    def findPreviousObject(self, obj):
+        """Finds the object before this one."""
+
+        if not obj:
+            return None
+
+        if obj.getRole() == pyatspi.ROLE_LINK:
+            obj = obj.parent
+
+        index = obj.getIndexInParent() - 1
+        if not (0 <= index < obj.parent.childCount - 1):
+            obj = obj.parent
+            index = obj.childCount - 1
+
+        try:
+            prevObj = obj.parent[index]
+        except:
+            prevObj = obj
+
+        return prevObj
+
+    def findNextObject(self, obj):
+        """Finds the object after this one."""
+
+        if not obj:
+            return None
+
+        if obj.getRole() == pyatspi.ROLE_LINK:
+            obj = obj.parent
+
+        index = obj.getIndexInParent() + 1
+        if not (0 < index < obj.parent.childCount):
+            obj = obj.parent
+            index = obj.getIndexInParent() + 1
+
+        try:
+            nextObj = obj.parent[index]
+        except:
+            nextObj = None
+
+        return nextObj



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