[orca] Web: Ensure we present caret-moved events after Alt+Tabbing into web app



commit 6285d4103449bc529d45e11987848698ca6d7604
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Jun 12 16:34:08 2021 +0200

    Web: Ensure we present caret-moved events after Alt+Tabbing into web app
    
    One of the checks we do when determining whether or not to present a
    caret-moved event is see if it came from the current document by
    getting the ancestor document of the locusOfFocus and the ancestor
    document of the event source. If the user Alt+Tabbed into an application
    and no focus event was emitted, the locusOfFocus will be the window
    itself and not have any ancestor document. This will cause presentation
    of caret-moved events to fail.
    
    To handle this condition, we should use the active document as the
    locusOfFocus document when the locusOfFocus is a window. This, however,
    may not be enough to fix the bug: The active document is retrieved via
    the embeds relationship on the window or, failing that being implemented,
    from the top down. As a result, we can still get a document mismatch
    when the event source is inside a nested document (which can happen in
    web apps such as VSCode). Therefore, when the locusOfFocus is the active
    window, we also need to retrieve the topmost document of the event source
    to ensure we're comparing the right objects.

 src/orca/scripts/web/script_utilities.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 0d1c832fb..426366581 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -4398,8 +4398,16 @@ class Utilities(script_utilities.Utilities):
         return True
 
     def eventIsFromLocusOfFocusDocument(self, event):
-        source = self.getDocumentForObject(event.source)
-        focus = self.getDocumentForObject(orca_state.locusOfFocus)
+        if orca_state.locusOfFocus == orca_state.activeWindow:
+            focus = self.activeDocument()
+            source = self.getTopLevelDocumentForObject(event.source)
+        else:
+            focus = self.getDocumentForObject(orca_state.locusOfFocus)
+            source = self.getDocumentForObject(event.source)
+
+        msg = "WEB: Event doc: %s. Focus doc: %s." % (source, focus)
+        debug.println(debug.LEVEL_INFO, msg, True)
+
         if not (source and focus):
             return False
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]