[orca] For web apps: Don't infer labels; do present focus events even if app is busy



commit f117c3b1b2d22daca16d90fd0bcdedc79929179c
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Oct 17 01:36:02 2015 -0400

    For web apps: Don't infer labels; do present focus events even if app is busy

 src/orca/scripts/web/script.py           |    6 +++++
 src/orca/scripts/web/script_utilities.py |   36 ++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 4bc73ac..023f2c1 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1368,6 +1368,12 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg)
             return False
 
+        if self.utilities.inTopLevelWebApp(event.source):
+            msg = "WEB: Event handled: Setting locusOfFocus to event source"
+            debug.println(debug.LEVEL_INFO, msg)
+            orca.setLocusOfFocus(event, event.source)
+            return True
+
         if document.getState().contains(pyatspi.STATE_BUSY):
             msg = "WEB: Document is busy. Updating locusOfFocus quietly."
             debug.println(debug.LEVEL_INFO, msg)
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index c53955e..2062a18 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -48,6 +48,7 @@ class Utilities(script_utilities.Utilities):
         self._currentAttrs = {}
         self._caretContexts = {}
         self._inDocumentContent = {}
+        self._inTopLevelWebApp = {}
         self._isTextBlockElement = {}
         self._isGridDescendant = {}
         self._isLayoutOnly = {}
@@ -92,6 +93,7 @@ class Utilities(script_utilities.Utilities):
     def clearCachedObjects(self):
         debug.println(debug.LEVEL_INFO, "WEB: cleaning up cached objects")
         self._inDocumentContent = {}
+        self._inTopLevelWebApp = {}
         self._isTextBlockElement = {}
         self._isGridDescendant = {}
         self._isLayoutOnly = {}
@@ -1281,6 +1283,37 @@ class Utilities(script_utilities.Utilities):
 
         return contents
 
+    def inTopLevelWebApp(self, obj=None):
+        if not obj:
+            obj = orca_state.locusOfFocus
+
+        rv = self._inTopLevelWebApp.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        document = self.getDocumentForObject(obj)
+        if not document and self.isDocument(obj):
+            document = obj
+
+        rv = self.isTopLevelWebApp(document)
+        self._inTopLevelWebApp[hash(obj)] = rv
+        return rv
+
+    def isTopLevelWebApp(self, obj):
+        try:
+            role = obj.getRole()
+        except:
+            msg = "WEB: Exception getting role for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            return False
+
+        if role == pyatspi.ROLE_EMBEDDED and not self.getDocumentForObject(obj.parent):
+            msg = "WEB: %s is top-level web application" % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            return True
+
+        return False
+
     def isFocusModeWidget(self, obj):
         try:
             role = obj.getRole()
@@ -2180,9 +2213,8 @@ class Utilities(script_utilities.Utilities):
         if self._script.inSayAll():
             return False
 
-        if not self.inDocumentContent():
+        if not self.inDocumentContent() or self.inTopLevelWebApp():
             return False
-
         try:
             role = obj.getRole()
         except:


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