[orca] Improve presentation of editable elements
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Improve presentation of editable elements
- Date: Mon, 2 Jan 2017 16:08:47 +0000 (UTC)
commit 30e2c343e94eb7a60cf0d4fe823639dd5063b229
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Jan 2 11:07:28 2017 -0500
Improve presentation of editable elements
.../scripts/toolkits/Gecko/script_utilities.py | 12 +++++++++-
src/orca/scripts/web/braille_generator.py | 3 ++
src/orca/scripts/web/script.py | 14 +++++++----
src/orca/scripts/web/script_utilities.py | 24 +++++++++++++++-----
4 files changed, 41 insertions(+), 12 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 4c8ac91..f96f841 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -42,7 +42,17 @@ class Utilities(web.Utilities):
def __init__(self, script):
super().__init__(script)
- def _attemptBrokenTextRecovery(self):
+ def _attemptBrokenTextRecovery(self, obj):
+ try:
+ state = obj.getState()
+ except:
+ msg = "ERROR: Exception getting state for %s" % obj
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return False
+
+ if state.contains(pyatspi.STATE_EDITABLE):
+ return False
+
return True
def _treatAsLeafNode(self, obj):
diff --git a/src/orca/scripts/web/braille_generator.py b/src/orca/scripts/web/braille_generator.py
index cdca9c3..9036d63 100644
--- a/src/orca/scripts/web/braille_generator.py
+++ b/src/orca/scripts/web/braille_generator.py
@@ -180,6 +180,9 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
return result
def _generateEol(self, obj, **args):
+ if self._script.utilities.isContentEditableWithEmbeddedObjects(obj):
+ return []
+
if obj.getState().contains(pyatspi.STATE_EDITABLE) \
or not self._script.utilities.inDocumentContent(obj):
return super()._generateEol(obj, **args)
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 8e843a5..581d25d 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -728,7 +728,8 @@ class Script(default.Script):
def sayCharacter(self, obj):
"""Speaks the character at the current caret position."""
- if not self._lastCommandWasCaretNav:
+ if not self._lastCommandWasCaretNav \
+ and not self.utilities.isContentEditableWithEmbeddedObjects(obj):
super().sayCharacter(obj)
return
@@ -753,7 +754,8 @@ class Script(default.Script):
def sayWord(self, obj):
"""Speaks the word at the current caret position."""
- if not self._lastCommandWasCaretNav:
+ if not self._lastCommandWasCaretNav \
+ and not self.utilities.isContentEditableWithEmbeddedObjects(obj):
super().sayWord(obj)
return
@@ -766,7 +768,8 @@ class Script(default.Script):
def sayLine(self, obj):
"""Speaks the line at the current caret position."""
- if not (self._lastCommandWasCaretNav or self._lastCommandWasStructNav):
+ if not (self._lastCommandWasCaretNav or self._lastCommandWasStructNav) \
+ and not self.utilities.isContentEditableWithEmbeddedObjects(obj):
super().sayLine(obj)
return
@@ -787,14 +790,15 @@ class Script(default.Script):
debug.println(debug.LEVEL_INFO, "BRAILLE: disabled", True)
return
- if self._inFocusMode or not self.utilities.inDocumentContent():
- msg = "WEB: updating braille for non-browse-mode object %s" % obj
+ if not self.utilities.inDocumentContent(obj):
+ msg = "WEB: updating braille for non-document object %s" % obj
debug.println(debug.LEVEL_INFO, msg, True)
super().updateBraille(obj, **args)
return
if not self._lastCommandWasCaretNav \
and not self._lastCommandWasStructNav \
+ and not self.utilities.isContentEditableWithEmbeddedObjects(obj) \
and not self.utilities.lastInputEventWasCaretNavWithSelection():
msg = "WEB: updating braille for unhandled navigation type %s" % obj
debug.println(debug.LEVEL_INFO, msg, True)
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 6743d9a..9abaea7 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -53,6 +53,7 @@ class Utilities(script_utilities.Utilities):
self._inDocumentContent = {}
self._inTopLevelWebApp = {}
self._isTextBlockElement = {}
+ self._isContentEditableWithEmbeddedObjects = {}
self._isGridDescendant = {}
self._isMenuDescendant = {}
self._isToolBarDescendant = {}
@@ -111,6 +112,7 @@ class Utilities(script_utilities.Utilities):
self._inDocumentContent = {}
self._inTopLevelWebApp = {}
self._isTextBlockElement = {}
+ self._isContentEditableWithEmbeddedObjects = {}
self._isGridDescendant = {}
self._isMenuDescendant = {}
self._isToolBarDescendant = {}
@@ -858,7 +860,7 @@ class Utilities(script_utilities.Utilities):
return string, rangeStart, rangeEnd
- def _attemptBrokenTextRecovery(self):
+ def _attemptBrokenTextRecovery(self, obj):
return False
def _getTextAtOffset(self, obj, offset, boundary):
@@ -908,7 +910,7 @@ class Utilities(script_utilities.Utilities):
string, start, end = text.getTextAtOffset(offset, boundary)
# The above should be all that we need to do, but....
- if not self._attemptBrokenTextRecovery():
+ if not self._attemptBrokenTextRecovery(obj):
s = string.replace(self.EMBEDDED_OBJECT_CHARACTER, "[OBJ]").replace("\n", "\\n")
msg = "WEB: Results for text at offset %i for %s using %s:\n" \
" String: '%s', Start: %i, End: %i.\n" \
@@ -2768,17 +2770,27 @@ class Utilities(script_utilities.Utilities):
return parseResult.fragment
def isContentEditableWithEmbeddedObjects(self, obj):
- if not (obj and obj.getState().contains(pyatspi.STATE_EDITABLE)):
+ if not (obj and self.inDocumentContent(obj)):
return False
+ rv = self._isContentEditableWithEmbeddedObjects.get(hash(obj))
+ if rv is not None:
+ return rv
+
+ rv = False
try:
+ state = obj.getState()
childCount = obj.childCount
except:
- msg = "WEB: Exception getting childCount for %s" % obj
+ msg = "WEB: Exception getting state and childCount for %s" % obj
debug.println(debug.LEVEL_INFO, msg, True)
- return False
+ return rv
- return childCount > 0
+ if state.contains(pyatspi.STATE_EDITABLE):
+ rv = childCount > 0 or self.isLink(obj)
+
+ self._isContentEditableWithEmbeddedObjects[hash(obj)] = rv
+ return rv
@staticmethod
def getHyperlinkRange(obj):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]