[orca] Force presentation when caret moves due to page up/page down in plain text



commit 0c22042295d009c45229ae3d81764751e21d3d6a
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Sep 4 11:19:37 2017 -0400

    Force presentation when caret moves due to page up/page down in plain text

 src/orca/scripts/web/script.py           |    3 ++-
 src/orca/scripts/web/script_utilities.py |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index b122557..eeb39c5 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -849,6 +849,7 @@ class Script(default.Script):
 
         if not self._lastCommandWasCaretNav \
            and not self._lastCommandWasStructNav \
+           and not self.utilities.isPlainText() \
            and not self.utilities.isContentEditableWithEmbeddedObjects(obj) \
            and not self.utilities.lastInputEventWasCaretNavWithSelection():
             msg = "WEB: updating braille for unhandled navigation type %s" % obj
@@ -1377,7 +1378,7 @@ class Script(default.Script):
             msg = "WEB: Event handled: Caret moved due to scrolling"
             debug.println(debug.LEVEL_INFO, msg, True)
             self.utilities.setCaretContext(obj, offset)
-            orca.setLocusOfFocus(event, obj)
+            orca.setLocusOfFocus(event, obj, force=self.utilities.isPlainText())
             return True
 
         if self.utilities.isContentEditableWithEmbeddedObjects(event.source):
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 62e97d6..4aa2c9c 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -88,6 +88,7 @@ class Utilities(script_utilities.Utilities):
         self._actualLabels = {}
         self._labelTargets = {}
         self._displayedLabelText = {}
+        self._mimeType = {}
         self._roleDescription = {}
         self._shouldFilter = {}
         self._shouldInferLabelFor = {}
@@ -151,6 +152,7 @@ class Utilities(script_utilities.Utilities):
         self._actualLabels = {}
         self._labelTargets = {}
         self._displayedLabelText = {}
+        self._mimeType = {}
         self._roleDescription = {}
         self._shouldFilter = {}
         self._shouldInferLabelFor = {}
@@ -292,6 +294,31 @@ class Utilities(script_utilities.Utilities):
 
         return None
 
+    def isPlainText(self, documentFrame=None):
+        return self.mimeType(documentFrame) == "text/plain"
+
+    def mimeType(self, documentFrame=None):
+        documentFrame = documentFrame or self.documentFrame()
+        rv = self._mimeType.get(hash(documentFrame))
+        if rv is not None:
+            return rv
+
+        try:
+            document = documentFrame.queryDocument()
+            attrs = dict([attr.split(":", 1) for attr in document.getAttributes()])
+        except NotImplementedError:
+            msg = "WEB: %s does not implement document interface" % documentFrame
+            debug.println(debug.LEVEL_INFO, msg, True)
+        except:
+            msg = "ERROR: Exception getting document attributes of %s" % documentFrame
+            debug.println(debug.LEVEL_INFO, msg, True)
+        else:
+            rv = attrs.get("MimeType")
+            msg = "WEB: MimeType of %s is '%s'" % (documentFrame, rv)
+            self._mimeType[hash(documentFrame)] = rv
+
+        return rv
+
     def grabFocusWhenSettingCaret(self, obj):
         try:
             role = obj.getRole()


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