Some web fixes.
This commit is contained in:
@@ -131,7 +131,7 @@ class Script(default.Script):
|
||||
|
||||
focus = cthulhu_state.locusOfFocus
|
||||
inApp = AXObject.get_application(focus) == self.app if focus else False
|
||||
inDoc = self.utilities.inDocumentContent(focus)
|
||||
inDoc = self._focusInDocumentContent()
|
||||
suspend = not (inDoc and inApp)
|
||||
reason = f"script activation, not in document content in this app: {suspend}"
|
||||
|
||||
@@ -179,6 +179,13 @@ class Script(default.Script):
|
||||
tokens = ["WEB: Navigation suspended:", suspend, reason]
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
|
||||
def _focusInDocumentContent(self):
|
||||
focus = cthulhu_state.locusOfFocus
|
||||
if not focus or AXObject.is_dead(focus):
|
||||
return False
|
||||
|
||||
return self.utilities.getDocumentForObject(focus) is not None
|
||||
|
||||
def getAppKeyBindings(self):
|
||||
"""Returns the application-specific keybindings for this script."""
|
||||
|
||||
@@ -1211,13 +1218,18 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
if self._navSuspended:
|
||||
if debugOutput:
|
||||
msg = "WEB: Not using caret navigation: navigation suspended."
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
inDoc = self._focusInDocumentContent()
|
||||
|
||||
if not self.utilities.inDocumentContent():
|
||||
if self._navSuspended:
|
||||
if inDoc:
|
||||
self._setNavigationSuspended(False, "focus confirmed in document content")
|
||||
else:
|
||||
if debugOutput:
|
||||
msg = "WEB: Not using caret navigation: navigation suspended."
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
if not inDoc:
|
||||
if debugOutput:
|
||||
tokens = ["WEB: Not using caret navigation: locusOfFocus",
|
||||
cthulhu_state.locusOfFocus, "is not in document content."]
|
||||
@@ -1251,13 +1263,18 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
if self._navSuspended:
|
||||
if debugOutput:
|
||||
msg = "WEB: Not using structural navigation: navigation suspended."
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
inDoc = self._focusInDocumentContent()
|
||||
|
||||
if not self.utilities.inDocumentContent():
|
||||
if self._navSuspended:
|
||||
if inDoc:
|
||||
self._setNavigationSuspended(False, "focus confirmed in document content")
|
||||
else:
|
||||
if debugOutput:
|
||||
msg = "WEB: Not using structural navigation: navigation suspended."
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
if not inDoc:
|
||||
if debugOutput:
|
||||
tokens = ["WEB: Not using structural navigation: locusOfFocus",
|
||||
cthulhu_state.locusOfFocus, "is not in document content."]
|
||||
|
||||
@@ -324,6 +324,10 @@ class Utilities(script_utilities.Utilities):
|
||||
and AXDocument.get_uri(obj)
|
||||
)
|
||||
|
||||
focusDoc = self.getTopLevelDocumentForObject(cthulhu_state.locusOfFocus)
|
||||
if focusDoc and AXObject.is_dead(focusDoc):
|
||||
focusDoc = None
|
||||
|
||||
if len(documents) == 1:
|
||||
document = documents[0]
|
||||
if documentHasUri(document):
|
||||
@@ -335,12 +339,16 @@ class Utilities(script_utilities.Utilities):
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
return fallback
|
||||
|
||||
if focusDoc and documentHasUri(focusDoc):
|
||||
tokens = ["WEB: Single showing document lacks URI, using focus-based document:", focusDoc]
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
return focusDoc
|
||||
|
||||
return document
|
||||
|
||||
# If multiple documents are showing (e.g., multi-tab browser), use the
|
||||
# locus of focus to determine which document is currently active.
|
||||
if documents:
|
||||
focusDoc = self.getTopLevelDocumentForObject(cthulhu_state.locusOfFocus)
|
||||
if focusDoc in documents and documentHasUri(focusDoc):
|
||||
tokens = ["WEB: Multiple showing documents, using focus-based document:", focusDoc]
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
|
||||
Reference in New Issue
Block a user