22#A part of NonVisual Desktop Access (NVDA)
33#This file is covered by the GNU General Public License.
44#See the file COPYING for more details.
5- #Copyright (C) 2008-2019 NV Access Limited, Babbage B.V., Mozilla Corporation
5+ #Copyright (C) 2008-2017 NV Access Limited, Babbage B.V., Mozilla Corporation
66
77from . import VirtualBuffer , VirtualBufferTextInfo , VBufStorage_findMatch_word , VBufStorage_findMatch_notEmpty
88import treeInterceptorHandler
2121import config
2222from NVDAObjects .IAccessible import normalizeIA2TextFormatField , IA2TextTextInfo
2323
24- IA2_RELATION_CONTAINING_DOCUMENT = "containingDocument"
25-
2624class Gecko_ia2_TextInfo (VirtualBufferTextInfo ):
2725
2826 def _getBoundingRectFromOffset (self ,offset ):
@@ -137,56 +135,18 @@ def _get_shouldPrepare(self):
137135 return False
138136 return True
139137
140- def _getEmbedderOfContainingDocument (self , acc ):
141- """Get the embedder of the given object's containing document.
142- For example, if acc is a button inside an iframe, this will return the iframe (embedder).
143- """
144- try :
145- # 1. Get the containing document.
146- if not isinstance (acc , IAccessibleHandler .IAccessible2_2 ):
147- # IAccessible NVDAObjects currently fetch IA2, but we need IA2_2 for relationTargetsOfType.
148- # (Out-of-process, for a single relation, this is cheaper than IA2::relations.)
149- acc = acc .QueryInterface (IAccessibleHandler .IAccessible2_2 )
150- targets , count = acc .relationTargetsOfType (IA2_RELATION_CONTAINING_DOCUMENT , 1 )
151- if count == 0 :
152- return None
153- doc = targets [0 ].QueryInterface (IAccessibleHandler .IAccessible2_2 )
154- # 2. Get its parent (the embedder); e.g. iframe.
155- embedder = doc .accParent
156- if not embedder :
157- return None
158- return embedder .QueryInterface (IAccessibleHandler .IAccessible2_2 )
159- except COMError :
160- return None
161-
162138 def __contains__ (self ,obj ):
163139 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 ):
164140 return False
165- acc = obj .IAccessibleObject
166- accId = obj .IA2UniqueID
167- while True :
168- if not accId :
141+ if self .rootNVDAObject .windowHandle == obj .windowHandle :
142+ ID = obj .IA2UniqueID
143+ if not ID :
169144 # Dead object.
170145 return False
171- if accId == self .rootID :
172- return True
173146 try :
174- self .rootNVDAObject .IAccessibleObject .accChild (accId )
175- # The object is definitely a descendant of the document.
176- break
147+ self .rootNVDAObject .IAccessibleObject .accChild (ID )
177148 except COMError :
178- pass
179- # accChild failed. This might be because the object is in an
180- # out-of-process iframe, in which case the embedder document won't know
181- # about it. Try the embedder iframe.
182- acc = self ._getEmbedderOfContainingDocument (acc )
183- if not acc :
184- return False
185- try :
186- accId = acc .uniqueID
187- except COMError :
188- # Dead object.
189- return False
149+ return ID == self .rootNVDAObject .IA2UniqueID
190150
191151 return not self ._isNVDAObjectInApplication (obj )
192152
@@ -212,8 +172,13 @@ def _get_isAlive(self):
212172 isDefunct = True
213173 return not isDefunct
214174
175+
215176 def getNVDAObjectFromIdentifier (self , docHandle , ID ):
216- return NVDAObjects .IAccessible .getNVDAObjectFromEvent (docHandle , winUser .OBJID_CLIENT , ID )
177+ try :
178+ pacc = self .rootNVDAObject .IAccessibleObject .accChild (ID )
179+ except COMError :
180+ return None
181+ return NVDAObjects .IAccessible .IAccessible (windowHandle = docHandle ,IAccessibleObject = IAccessibleHandler .normalizeIAccessible (pacc ),IAccessibleChildID = 0 )
217182
218183 def getIdentifierFromNVDAObject (self ,obj ):
219184 docHandle = obj .windowHandle
0 commit comments