[orca/gnome-3-20] Cache label-related information for web content for performance
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/gnome-3-20] Cache label-related information for web content for performance
- Date: Thu, 21 Apr 2016 12:42:37 +0000 (UTC)
commit 18846627a1570bf43d7e9e01a2a246d910a0eae2
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Apr 20 23:44:14 2016 -0400
Cache label-related information for web content for performance
src/orca/scripts/web/script_utilities.py | 35 ++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 8598908..d83733d 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -73,6 +73,8 @@ class Utilities(script_utilities.Utilities):
self._isUselessImage = {}
self._isParentOfNullChild = {}
self._inferredLabels = {}
+ self._actualLabels = {}
+ self._displayedLabelText = {}
self._roleDescription = {}
self._text = {}
self._tag = {}
@@ -121,6 +123,8 @@ class Utilities(script_utilities.Utilities):
self._isUselessImage = {}
self._isParentOfNullChild = {}
self._inferredLabels = {}
+ self._actualLabels = {}
+ self._displayedLabelText = {}
self._roleDescription = {}
self._tag = {}
self._treatAsDiv = {}
@@ -2357,6 +2361,37 @@ class Utilities(script_utilities.Utilities):
return True
+ def displayedLabel(self, obj):
+ if not (obj and self.inDocumentContent(obj)):
+ return super().displayedLabel(obj)
+
+ rv = self._displayedLabelText.get(hash(obj))
+ if rv is not None:
+ return rv
+
+ labels = self.labelsForObject(obj)
+ strings = [l.name or self.displayedText(l) for l in labels if l is not None]
+ rv = " ".join(strings)
+
+ self._displayedLabelText[hash(obj)] = rv
+ return rv
+
+ def labelsForObject(self, obj):
+ if not obj:
+ return []
+
+ rv = self._actualLabels.get(hash(obj))
+ if rv is not None:
+ return rv
+
+ rv = super().labelsForObject(obj)
+ if not self.inDocumentContent(obj):
+ return rv
+
+ rv = list(filter(lambda x: x and x.getRole() == pyatspi.ROLE_LABEL, rv))
+ self._actualLabels[hash(obj)] = rv
+ return rv
+
def isSpinnerEntry(self, obj):
if not self.inDocumentContent(obj):
return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]