Skip to content

Commit

Permalink
Be sure we have the top level document before sanity-checking context
Browse files Browse the repository at this point in the history
  • Loading branch information
joanmarie committed Aug 21, 2019
1 parent e99f07c commit 50ecb8a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/orca/scripts/web/script_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ def getDocumentForObject(self, obj):

return pyatspi.findAncestor(obj, self.isDocument)

def getTopLevelDocumentForObject(self, obj):
document = self.getDocumentForObject(obj)
while document:
ancestor = pyatspi.findAncestor(document, self.isDocument)
if not ancestor or ancestor == document:
break
document = ancestor

return document

def _getDocumentsEmbeddedBy(self, frame):
if not frame:
return []
Expand Down Expand Up @@ -4027,7 +4037,7 @@ def getCaretContext(self, documentFrame=None, getZombieReplicant=False):
return self._getCaretContextViaLocusOfFocus()

context = self._caretContexts.get(hash(documentFrame.parent))
if not context or documentFrame != self.getDocumentForObject(context[0]):
if not context or documentFrame != self.getTopLevelDocumentForObject(context[0]):
obj, offset = self.searchForCaretContext(documentFrame)
elif not getZombieReplicant:
return context
Expand Down

0 comments on commit 50ecb8a

Please sign in to comment.