orca r4407 - in branches/gnome-2-24: . src/orca/scripts/toolkits/Gecko



Author: joanied
Date: Mon Jan  5 19:08:16 2009
New Revision: 4407
URL: http://svn.gnome.org/viewvc/orca?rev=4407&view=rev

Log:
* src/orca/scripts/toolkits/Gecko/script.py:
  src/orca/scripts/toolkits/Gecko/speech_generator.py:
  Bulk commit of fixes which were committed to trunk last week:

  - Fix for bug #566361 - Orca inappropriately announces the name
    of table cells as part of the context in Firefox 3.2.

  - Fix for bug #566181 - Changes made to Firefox 3.2 caret-moved
    events cause Orca to provide unreliable access during the use
    of the Find toolbar.

  - Fix for bug #566180 - Orca inappropriately announces the name
    and role of (un)ordered list items as part of the context in
    Firefox 3.2.

  - Fix for bug #566073 - Orca provides the "tree level" for items
    in submenus within Firefox 3.x.

  - Fix for bug #565944 - Missing whitespace when the end of line
    braille indicator is followed by an image in FF 3.x.

  - Fix for bug #565886 - Extraneous caret-moved events emitted by
    FF 3.1 cause unnecessary braille updating.



Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/script.py
   branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/speech_generator.py

Modified: branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/script.py
==============================================================================
--- branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/script.py	(original)
+++ branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/script.py	Mon Jan  5 19:08:16 2009
@@ -1117,37 +1117,48 @@
         -offset: The offset with obj where the caret should be positioned
         """
 
+        # At some point in Firefox 3.2 we started getting detail1 values of
+        # -1 for the caret-moved events for unfocused content during a find.
+        # We don't want to base the new caret offset -- or the current line
+        # on this value. We should be able to count on the selection range
+        # instead -- across FF 3.0, 3.1, and 3.2.
+        #
+        enoughSelected = False
+        text = self.queryNonEmptyText(obj)
+        if text and text.getNSelections():
+            [start, end] = text.getSelection(0)
+            offset = max(offset, start)
+            if end - start >= script_settings.minimumFindLength:
+                enoughSelected = True
+
+        # Haing done that, update the caretContext. If the user wants
+        # matches spoken, we also need to if we are on the same line
+        # as before.
+        #
         origObj, origOffset = self.getCaretContext()
         self.setCaretContext(obj, offset)
-        origExtents = self.getExtents(origObj, origOffset - 1, origOffset)
-        newExtents = self.getExtents(obj, offset - 1, offset)
-        text = self.queryNonEmptyText(obj)
-        if script_settings.speakResultsDuringFind and text:
-            nSelections = text.getNSelections()
-            if nSelections:
-                [start, end] = text.getSelection(0)
-                enoughSelected = (end - start) >= \
-                                  script_settings.minimumFindLength
-                lineChanged = not self.onSameLine(origExtents, newExtents)
-
-                # If the user starts backspacing over the text in the
-                # toolbar entry, he/she is indicating they want to perform
-                # a different search. Because madeFindAnnounement may
-                # be set to True, we should reset it -- but only if we
-                # detect the line has also changed.  We're not getting
-                # events from the Find entry, so we have to compare
-                # offsets.
-                #
-                if self.isSameObject(origObj, obj) and (origOffset > offset) \
-                   and lineChanged:
-                    self.madeFindAnnouncement = False
-
-                if enoughSelected:
-                    if lineChanged or not self.madeFindAnnouncement or \
-                       not script_settings.onlySpeakChangedLinesDuringFind:
-                        line = self.getLineContentsAtOffset(obj, offset)
-                        self.speakContents(line)
-                        self.madeFindAnnouncement = True
+        if enoughSelected and script_settings.speakResultsDuringFind:
+            origExtents = self.getExtents(origObj, origOffset - 1, origOffset)
+            newExtents = self.getExtents(obj, offset - 1, offset)
+            lineChanged = not self.onSameLine(origExtents, newExtents)
+
+            # If the user starts backspacing over the text in the
+            # toolbar entry, he/she is indicating they want to perform
+            # a different search. Because madeFindAnnounement may
+            # be set to True, we should reset it -- but only if we
+            # detect the line has also changed.  We're not getting
+            # events from the Find entry, so we have to compare
+            # offsets.
+            #
+            if self.isSameObject(origObj, obj) and (origOffset > offset) \
+               and lineChanged:
+                self.madeFindAnnouncement = False
+
+            if lineChanged or not self.madeFindAnnouncement or \
+               not script_settings.onlySpeakChangedLinesDuringFind:
+                line = self.getLineContentsAtOffset(obj, offset)
+                self.speakContents(line)
+                self.madeFindAnnouncement = True
 
     def sayAll(self, inputEvent):
         """Speaks the contents of the document beginning with the present
@@ -1266,6 +1277,16 @@
             locusOfFocusState = pyatspi.StateSet()
             locusOfFocusState = locusOfFocusState.raw()
 
+        # Find out if the caret really moved. Firefox 3.1 gives us caret-moved
+        # events when certain focusable objects first get focus. If we haven't
+        # really moved, there's no point in updating braille again -- which is
+        # what we'll wind up doing if this event reaches the default script.
+        #
+        [obj, characterOffset] = self.getCaretContext()
+        if max(0, characterOffset) == event.detail1 \
+           and self.isSameObject(obj, event.source):
+            return
+
         if isinstance(orca_state.lastInputEvent, input_event.KeyboardEvent):
             string = orca_state.lastNonModifierKeyEvent.event_string
             if self.useCaretNavigationModel(orca_state.lastInputEvent):
@@ -1317,7 +1338,8 @@
                 if event.detail1 == 0 and not string in ["Left", "Home"] \
                    or eventSourceRole in [pyatspi.ROLE_PAGE_TAB,
                                           pyatspi.ROLE_LIST_ITEM,
-                                          pyatspi.ROLE_MENU_ITEM]:
+                                          pyatspi.ROLE_MENU_ITEM,
+                                          pyatspi.ROLE_PUSH_BUTTON]:
                     # A focus:/object:state-changed:focused event should
                     # pick up this case.
                     #
@@ -2168,7 +2190,8 @@
                 if line.regions[-1].__class__ == regions[0].__class__ \
                    or line.regions[-1].__class__ in [braille.Component,
                                                      braille.Region] \
-                   or lastObj.getRole() == pyatspi.ROLE_IMAGE:
+                   or lastObj.getRole() == pyatspi.ROLE_IMAGE \
+                   or obj.getRole() == pyatspi.ROLE_IMAGE:
                     line.addRegion(braille.Region(" "))
 
                 # The above check will catch table cells with uniform
@@ -3412,7 +3435,8 @@
         object attribute 'level'.  To be consistent with default.getNodeLevel()
         this value is 0-based (Gecko return is 1-based) """
 
-        if obj is None or obj.getRole() == pyatspi.ROLE_HEADING:
+        if obj is None or obj.getRole() == pyatspi.ROLE_HEADING \
+           or obj.parent.getRole() == pyatspi.ROLE_MENU:
             return -1
 
         try:

Modified: branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/speech_generator.py
==============================================================================
--- branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/speech_generator.py	(original)
+++ branches/gnome-2-24/src/orca/scripts/toolkits/Gecko/speech_generator.py	Mon Jan  5 19:08:16 2009
@@ -653,12 +653,17 @@
 
         # Skip items of unknown rolenames, menu bars, labels with 
         # children, and autocompletes.  (With autocompletes, we
-        # wind up speaking the text object)
+        # wind up speaking the text object). Beginning with Firefox
+        # 3.2, list items have names corresponding with their text.
+        # This results in getDisplayedText returning actual text
+        # and the parent list item being spoken when it should not
+        # be. So we'll take list items out of the context.
         #
         skipRoles = [pyatspi.ROLE_UNKNOWN,
                      pyatspi.ROLE_MENU_BAR,
                      pyatspi.ROLE_LABEL,
-                     pyatspi.ROLE_AUTOCOMPLETE]
+                     pyatspi.ROLE_AUTOCOMPLETE,
+                     pyatspi.ROLE_LIST_ITEM]
 
         # Stop if we get to a document frame or an internal frame.
         #
@@ -693,12 +698,21 @@
             # Also skip the parent if its accessible text is a single 
             # EMBEDDED_OBJECT_CHARACTER: Script.getDisplayedText will
             # end up coming back to the child of an object for the text
-            # if an object's text contains a single EOC.
+            # if an object's text contains a single EOC. In addition,
+            # beginning with Firefox 3.2, a table cell may derive its
+            # accessible name from focusable objects it contains (e.g.
+            # links, form fields). getDisplayedText will return the
+            # object's name in this case (because of the presence of
+            # the EOC and other characters). This causes us to be
+            # chatty. So if it's a table cell which contains an EOC,
+            # we will also skip the parent.
             #
             parentText = self._script.queryNonEmptyText(parent)
             if parentText:
                 unicodeText = parentText.getText(0, -1).decode("UTF-8")
-                if unicodeText == self._script.EMBEDDED_OBJECT_CHARACTER:
+                if self._script.EMBEDDED_OBJECT_CHARACTER in unicodeText \
+                   and (len(unicodeText) == 1 \
+                        or role == pyatspi.ROLE_TABLE_CELL):
                     parent = parent.parent
                     continue
 



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