OSDN Git Service

In Adobe Reader, some links are no longer treated as containing read-only editable...
authorJames Teh <jamie@jantrid.net>
Tue, 24 Jan 2012 03:54:02 +0000 (13:54 +1000)
committerJames Teh <jamie@jantrid.net>
Tue, 24 Jan 2012 03:54:02 +0000 (13:54 +1000)
This was occurring because Acrobat incorrectly exposes the focusable/focused states on text nodes beneath links, so we now scrap those states if the linked state is present.

source/NVDAObjects/IAccessible/adobeAcrobat.py
source/virtualBuffers/adobeAcrobat.py
user_docs/en/changes.t2t

index 3b44eef..503af78 100644 (file)
@@ -179,6 +179,15 @@ class AcrobatSDIWindowClient(IAccessible):
                self.IAccessibleObject = acc\r
                self.invalidateCache()\r
 \r
+class BadFocusStates(AcrobatNode):\r
+       """An object which reports focus states when it shouldn't.\r
+       """\r
+\r
+       def _get_states(self):\r
+               states = super(BadFocusStates, self).states\r
+               states.difference_update({controlTypes.STATE_FOCUSABLE, controlTypes.STATE_FOCUSED})\r
+               return states\r
+\r
 def findExtraOverlayClasses(obj, clsList):\r
        """Determine the most appropriate class(es) for Acrobat objects.\r
        This works similarly to L{NVDAObjects.NVDAObject.findOverlayClasses} except that it never calls any other findOverlayClasses method.\r
@@ -193,7 +202,13 @@ def findExtraOverlayClasses(obj, clsList):
                else:\r
                        clsList.append(RootNode)\r
 \r
-       elif role == controlTypes.ROLE_EDITABLETEXT and controlTypes.STATE_FOCUSABLE in obj.states:\r
-               clsList.append(EditableTextNode)\r
+       elif role == controlTypes.ROLE_EDITABLETEXT:\r
+               states = obj.states\r
+               if {controlTypes.STATE_READONLY, controlTypes.STATE_FOCUSABLE, controlTypes.STATE_LINKED} <= states:\r
+                       # HACK: Acrobat sets focus states on text nodes beneath links,\r
+                       # making them appear as read only editable text fields.\r
+                       clsList.append(BadFocusStates)\r
+               elif controlTypes.STATE_FOCUSABLE in states:\r
+                       clsList.append(EditableTextNode)\r
 \r
        clsList.append(AcrobatNode)\r
index 9d18685..41692ff 100644 (file)
@@ -28,6 +28,11 @@ class AdobeAcrobat_TextInfo(VirtualBufferTextInfo):
 \r
                states=set(IAccessibleHandler.IAccessibleStatesToNVDAStates[x] for x in [1<<y for y in xrange(32)] if int(attrs.get('IAccessible::state_%s'%x,0)) and x in IAccessibleHandler.IAccessibleStatesToNVDAStates)\r
 \r
+               if role == controlTypes.ROLE_EDITABLETEXT and {controlTypes.STATE_READONLY, controlTypes.STATE_FOCUSABLE, controlTypes.STATE_LINKED} <= states:\r
+                       # HACK: Acrobat sets focus states on text nodes beneath links,\r
+                       # making them appear as read only editable text fields.\r
+                       states.difference_update({controlTypes.STATE_FOCUSABLE, controlTypes.STATE_FOCUSED})\r
+\r
                attrs['role']=role\r
                attrs['states']=states\r
                if level:\r
index 5feb968..95bee5b 100644 (file)
@@ -52,6 +52,7 @@ Highlights of this release include features for more fluent reading of braille;
 - The report title command works correctly again in Adobe Reader.\r
 - With automatic focus mode for focus changes enabled, focus mode is now correctly used for focused table cells; e.g. in ARIA grids. (#1763)\r
 - In iTunes, position information in certain lists is now reported correctly.\r
+- In Adobe Reader, some links are no longer treated as containing read-only editable text fields.\r
 \r
 \r
 == Changes for Developers ==\r