[orca] Web: Skip useless empty elements when seeking first context in document



commit 069a8cee5a55ddd3ee20ebfae58a3565d55967fa
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jan 6 13:58:57 2021 +0100

    Web: Skip useless empty elements when seeking first context in document
    
    There shouldn't be useless empty elements at the top of a document. But
    authors, along with Thunderbird.... Therefore when seeking the first
    context in the document (e.g. when pressing Ctrl+Home), start with the
    first child that isn't a useless empty element.

 src/orca/scripts/web/script_utilities.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 741ce7f67..61c9b5666 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -4826,6 +4826,13 @@ class Utilities(script_utilities.Utilities):
             debug.println(debug.LEVEL_INFO, msg, True)
             return obj, offset
 
+        if self.isDocument(obj):
+            while self.isUselessEmptyElement(child):
+                msg = "WEB: Child %s of %s at offset %i cannot be context." % (child, obj, offset)
+                debug.println(debug.LEVEL_INFO, msg, True)
+                offset += 1
+                child = self.getChildAtOffset(obj, offset)
+
         if self.isListItemMarker(child):
             msg = "WEB: First caret context for %s, %i is %s, %i (skip list item marker child)" % \
                 (obj, offset, obj, offset + 1)
@@ -4841,7 +4848,7 @@ class Utilities(script_utilities.Utilities):
                 return nextObj, nextOffset
 
         if not self._canHaveCaretContext(child):
-            msg = "WEB: Child cannot be context. Returning %s, %i unchanged." % (obj, offset)
+            msg = "WEB: Child cannot be context. Returning %s, %i." % (obj, offset)
             debug.println(debug.LEVEL_INFO, msg, True)
             return obj, offset
 


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