More web optimizations.

This commit is contained in:
Storm Dragon
2026-07-22 13:26:18 -04:00
parent 1249aa791c
commit 17f196e530
2 changed files with 373 additions and 5 deletions
+22 -5
View File
@@ -173,8 +173,12 @@ class Script(default.Script):
obj,
offset,
focusOverride=None,
):
if not self.utilities.lastInputEventWasCaretNavWithSelection():
isCaretSelection: bool | None = None,
) -> bool:
if isCaretSelection is None:
isCaretSelection = self.utilities.lastInputEventWasCaretNavWithSelection()
if not isCaretSelection:
return False
if focusOverride is not None:
@@ -3181,6 +3185,8 @@ class Script(default.Script):
debug.printMessage(debug.LEVEL_INFO, msg, True)
return False
reason = AXUtilitiesEvent.get_text_event_reason(event)
if not self.utilities.inDocumentContent(cthulhu_state.locusOfFocus):
tokens = ["WEB: Event ignored: locusOfFocus", cthulhu_state.locusOfFocus,
"is not in document content"]
@@ -3208,8 +3214,18 @@ class Script(default.Script):
debug.printMessage(debug.LEVEL_INFO, msg, True)
return True
if self.utilities.lastInputEventWasCaretNavWithSelection() \
and not AXText.get_selected_ranges(event.source):
selectionReasons = (
TextEventReason.SELECTION_BY_CHARACTER,
TextEventReason.SELECTION_BY_LINE,
TextEventReason.SELECTION_BY_PARAGRAPH,
TextEventReason.SELECTION_BY_PAGE,
TextEventReason.SELECTION_BY_WORD,
TextEventReason.SELECTION_TO_FILE_BOUNDARY,
TextEventReason.SELECTION_TO_LINE_BOUNDARY,
TextEventReason.UNSPECIFIED_SELECTION,
)
isSelectionReason = reason in selectionReasons
if isSelectionReason and not AXText.get_selected_ranges(event.source):
document = self.utilities.getTopLevelDocumentForObject(event.source)
obj, offset = self.utilities.getCaretContext(document, False, False)
focusOffset = AXText.get_caret_offset(event.source)
@@ -3219,6 +3235,7 @@ class Script(default.Script):
obj,
offset,
focusOverride=(event.source, focusOffset),
isCaretSelection=True,
):
msg = "WEB: Event handled: synthetic selection from event source"
debug.printMessage(debug.LEVEL_INFO, msg, True)
@@ -3239,7 +3256,7 @@ class Script(default.Script):
offset = AXText.get_caret_offset(event.source)
char = AXText.get_substring(event.source, offset, offset + 1)
if char == self.EMBEDDED_OBJECT_CHARACTER \
and not self.utilities.lastInputEventWasCaretNavWithSelection() \
and not isSelectionReason \
and not self.utilities.lastInputEventWasCommand():
msg = "WEB: Ignoring: Not selecting and event offset is at embedded object"
debug.printMessage(debug.LEVEL_INFO, msg, True)