[orca] Chromium: Don't bother finding descendants of pre and code elements



commit 98ffbc08afd851ad10be8aa3ccce6bd4c3e65f07
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Nov 13 17:33:54 2019 -0500

    Chromium: Don't bother finding descendants of pre and code elements
    
    These often have a ton of children, all of which are static text leaf
    nodes which were created just to show colored markup. We ignore static
    text leaf nodes anyway, so why waste cycles getting useless descendants?

 src/orca/scripts/toolkits/Chromium/script_utilities.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index 1a88eccb7..c896a3399 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -471,3 +471,16 @@ class Utilities(web.Utilities):
 
     def supportsLandmarkRole(self):
         return True
+
+    def findAllDescendants(self, root, includeIf=None, excludeIf=None):
+        if not root:
+            return []
+
+        # Don't bother if the root is a 'pre' or 'code' element. Those often have
+        # nothing but a TON of static text leaf nodes, which we want to ignore.
+        if self._getTag(root) in ('pre', 'code'):
+            msg = "CHROMIUM: Returning 0 descendants for pre/code %s" % root
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return []
+
+        return super().findAllDescendants(root, includeIf, excludeIf)


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