diff --git a/source/virtualBuffers/gecko_ia2.py b/source/virtualBuffers/gecko_ia2.py index 20072036c4e..f8b4003ca98 100755 --- a/source/virtualBuffers/gecko_ia2.py +++ b/source/virtualBuffers/gecko_ia2.py @@ -2,7 +2,7 @@ #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. #See the file COPYING for more details. -#Copyright (C) 2008-2017 NV Access Limited, Babbage B.V. +#Copyright (C) 2008-2017 NV Access Limited, Babbage B.V., Mozilla Corporation from . import VirtualBuffer, VirtualBufferTextInfo, VBufStorage_findMatch_word, VBufStorage_findMatch_notEmpty import treeInterceptorHandler @@ -99,14 +99,29 @@ def _get_shouldPrepare(self): return False return True + def _getExpandedComboBox(self, obj): + """If obj is an item in an expanded combo box, get the combo box. + """ + if not (obj.windowClassName.startswith('Mozilla') and obj.windowStyle & winUser.WS_POPUP): + # This is not a Mozilla popup window, so it can't be an expanded combo box. + return None + if obj.role not in (controlTypes.ROLE_LISTITEM, controlTypes.ROLE_LIST): + return None + parent = obj.parent + # Try a maximum of 2 ancestors, since we might be on the list item or the list. + for i in xrange(2): + obj = obj.parent + if not obj: + return None + if obj.role == controlTypes.ROLE_COMBOBOX: + return obj + return None + def __contains__(self,obj): - #Special code to handle Mozilla combobox lists - if obj.windowClassName.startswith('Mozilla') and winUser.getWindowStyle(obj.windowHandle)&winUser.WS_POPUP: - parent=obj.parent - while parent and parent.windowHandle==obj.windowHandle: - parent=parent.parent - if parent: - obj=parent.parent + # if this is a Mozilla combo box popup, we want to work with the combo box. + combo = self._getExpandedComboBox(obj) + if combo: + obj = combo if not (isinstance(obj,NVDAObjects.IAccessible.IAccessible) and isinstance(obj.IAccessibleObject,IAccessibleHandler.IAccessible2)) or not obj.windowClassName.startswith('Mozilla') or not winUser.isDescendantWindow(self.rootNVDAObject.windowHandle,obj.windowHandle): return False if self.rootNVDAObject.windowHandle==obj.windowHandle: