From 2dc1a2128f50a3189a91a9f9a1f490b761855f3b Mon Sep 17 00:00:00 2001 From: James Teh Date: Tue, 24 Jan 2012 13:54:02 +1000 Subject: [PATCH] In Adobe Reader, some links are no longer treated as containing read-only editable text fields. 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 | 19 +++++++++++++++++-- source/virtualBuffers/adobeAcrobat.py | 5 +++++ user_docs/en/changes.t2t | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/source/NVDAObjects/IAccessible/adobeAcrobat.py b/source/NVDAObjects/IAccessible/adobeAcrobat.py index 3b44eef0a..503af789c 100644 --- a/source/NVDAObjects/IAccessible/adobeAcrobat.py +++ b/source/NVDAObjects/IAccessible/adobeAcrobat.py @@ -179,6 +179,15 @@ class AcrobatSDIWindowClient(IAccessible): self.IAccessibleObject = acc self.invalidateCache() +class BadFocusStates(AcrobatNode): + """An object which reports focus states when it shouldn't. + """ + + def _get_states(self): + states = super(BadFocusStates, self).states + states.difference_update({controlTypes.STATE_FOCUSABLE, controlTypes.STATE_FOCUSED}) + return states + def findExtraOverlayClasses(obj, clsList): """Determine the most appropriate class(es) for Acrobat objects. This works similarly to L{NVDAObjects.NVDAObject.findOverlayClasses} except that it never calls any other findOverlayClasses method. @@ -193,7 +202,13 @@ def findExtraOverlayClasses(obj, clsList): else: clsList.append(RootNode) - elif role == controlTypes.ROLE_EDITABLETEXT and controlTypes.STATE_FOCUSABLE in obj.states: - clsList.append(EditableTextNode) + elif role == controlTypes.ROLE_EDITABLETEXT: + states = obj.states + if {controlTypes.STATE_READONLY, controlTypes.STATE_FOCUSABLE, controlTypes.STATE_LINKED} <= states: + # HACK: Acrobat sets focus states on text nodes beneath links, + # making them appear as read only editable text fields. + clsList.append(BadFocusStates) + elif controlTypes.STATE_FOCUSABLE in states: + clsList.append(EditableTextNode) clsList.append(AcrobatNode) diff --git a/source/virtualBuffers/adobeAcrobat.py b/source/virtualBuffers/adobeAcrobat.py index 9d186856e..41692ffd9 100644 --- a/source/virtualBuffers/adobeAcrobat.py +++ b/source/virtualBuffers/adobeAcrobat.py @@ -28,6 +28,11 @@ class AdobeAcrobat_TextInfo(VirtualBufferTextInfo): states=set(IAccessibleHandler.IAccessibleStatesToNVDAStates[x] for x in [1<