[orca] Remove isUselessObject() and its use from the Gecko script



commit 4b79a454461c964896150dc47c685967c0bcf94a
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Aug 9 21:21:29 2014 -0400

    Remove isUselessObject() and its use from the Gecko script
    
    It is extremely old, buggy, and no longer needed.

 src/orca/scripts/toolkits/Gecko/script.py          |   88 +-------------------
 .../scripts/toolkits/Gecko/script_utilities.py     |   11 ---
 .../toolkits/Gecko/structural_navigation.py        |    7 --
 src/orca/structural_navigation.py                  |   14 +---
 4 files changed, 2 insertions(+), 118 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index de59afb..bc9482b 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -1985,83 +1985,6 @@ class Script(default.Script):
 
             return True
 
-    def isUselessObject(self, obj):
-        """Returns true if the given object is an obj that doesn't
-        have any meaning associated with it and it is not inside a
-        link."""
-
-        if not obj:
-            return True
-
-        useless = False
-
-        textObj = self.utilities.queryNonEmptyText(obj)
-        if not textObj and obj.getRole() == pyatspi.ROLE_PARAGRAPH:
-            # Under these circumstances, this object is useless even
-            # if it is the child of a link.
-            #
-            return True
-        elif obj.getRole() in [pyatspi.ROLE_IMAGE, \
-                               pyatspi.ROLE_TABLE_CELL, \
-                               pyatspi.ROLE_SECTION]:
-            text = self.utilities.displayedText(obj)
-            if (not text) or (len(text) == 0):
-                text = self.utilities.displayedLabel(obj)
-                if (not text) or (len(text) == 0):
-                    useless = True
-
-        if useless:
-            link = self.utilities.ancestorWithRole(
-                obj, [pyatspi.ROLE_LINK], [pyatspi.ROLE_DOCUMENT_FRAME])
-            if link:
-                if obj.getRole() == pyatspi.ROLE_IMAGE:
-                    # If this object had alternative text and/or a title,
-                    # we wouldn't be here. We need to determine if this
-                    # image is indeed worth presenting and not a duplicate
-                    # piece of information. See Facebook's timeline and/or
-                    # bug 584540.
-                    #
-                    for child in obj.parent:
-                        if self.utilities.displayedText(child):
-                            # Some other sibling is presenting information.
-                            # We'll treat this image as useless.
-                            #
-                            break
-                    else:
-                        # No other siblings are presenting information.
-                        #
-                        if obj.parent.getRole() == pyatspi.ROLE_LINK:
-                            if not link.name:
-                                # If no siblings are presenting information,
-                                # but the link had a name, then we'd know we
-                                # had text along with the image(s). Given the
-                                # lack of name, we'll treat the first image as
-                                # the useful one and ignore the rest.
-                                #
-                                useless = obj.getIndexInParent() > 0
-                        else:
-                            # The image must be in a paragraph or section or
-                            # heading or something else that might result in
-                            # it being on its own line.
-                            #
-                            textObj = \
-                                self.utilities.queryNonEmptyText(obj.parent)
-                            if textObj:
-                                text = textObj.getText(0, -1)
-                                text = text.replace(\
-                                    self.EMBEDDED_OBJECT_CHARACTER, "").strip()
-                                if not text:
-                                    # There's no other text on this line inside
-                                    # of this link. We don't want to skip over
-                                    # this line, so we'll treat the first image
-                                    # as useful.
-                                    #
-                                    useless = obj.getIndexInParent() > 0
-                else:
-                    useless = False
-
-        return useless
-
     def pursueForFlatReview(self, obj):
         """Determines if we should look any further at the object
         for flat review."""
@@ -3099,9 +3022,7 @@ class Script(default.Script):
                 toAdd = [x for x in toAdd if x not in objects]
                 objects.extend(toAdd)
                 done = not toAdd
-            elif (nextObj.getRole() in [pyatspi.ROLE_SECTION,
-                                        pyatspi.ROLE_TABLE_CELL] \
-                  and self.isUselessObject(nextObj)):
+            elif nextObj.getRole() in [pyatspi.ROLE_SECTION, pyatspi.ROLE_TABLE_CELL]:
                 toAdd = self.utilities.getObjectsFromEOCs(nextObj, nOffset, boundary)
                 toAdd = [x for x in toAdd if x not in objects]
                 done = True
@@ -3216,13 +3137,6 @@ class Script(default.Script):
                 if len(contents) > 1 and not len(string):
                     continue
 
-            # If it is a "useless" image (i.e. not a link, no associated
-            # text), ignore it, unless it's the only thing here.
-            #
-            elif role == pyatspi.ROLE_IMAGE and self.isUselessObject(obj) \
-                 and len(contents) > 1:
-                continue
-
             # If the focused item is a checkbox or a radio button for which
             # we had to infer the label, odds are that the inferred label is
             # immediately to the right. Under these circumstances, we'll
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py 
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 4ad5528..81c4cac 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -259,17 +259,6 @@ class Utilities(script_utilities.Utilities):
 
         return False
 
-    def isLayoutOnly(self, obj):
-        """Returns True if the given object is for layout purposes only."""
-
-        if self._script.isUselessObject(obj):
-            debug.println(debug.LEVEL_FINEST,
-                          "Object deemed to be useless: %s" % obj)
-            return True
-
-        else:
-            return script_utilities.Utilities.isLayoutOnly(self, obj)
-
     def isPasswordText(self, obj):
         """Returns True if we should treat this object as password text."""
 
diff --git a/src/orca/scripts/toolkits/Gecko/structural_navigation.py 
b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
index 3ea9741..ed518c9 100644
--- a/src/orca/scripts/toolkits/Gecko/structural_navigation.py
+++ b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
@@ -133,13 +133,6 @@ class GeckoStructuralNavigation(structural_navigation.StructuralNavigation):
 
         self._script.setCaretPosition(obj, characterOffset)
 
-    def _isUselessObject(self, obj):
-        """Returns true if the given object is an obj that doesn't
-        have any meaning associated with it.
-        """
-
-        return self._script.isUselessObject(obj)
-
     #####################################################################
     #                                                                   #
     # Methods for presenting objects                                    #
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index d3ec421..e9853ee 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -1204,17 +1204,6 @@ class StructuralNavigation:
 
         return False
 
-    def _isUselessObject(self, obj):
-        """Returns True if the accessible object obj is an object
-        that doesn't have any meaning associated with it. Individual
-        scripts should override this method as needed.  Gecko does.
-
-        Arguments:
-        - obj: the accessible object of interest.
-        """
-
-        return False
-
     #########################################################################
     #                                                                       #
     # Methods for Presenting Objects                                        #
@@ -2179,8 +2168,7 @@ class StructuralNavigation:
             except:
                 characterCount = 0
 
-            if characterCount > settings.largeObjectTextLength \
-               and not self._isUselessObject(obj):
+            if characterCount > settings.largeObjectTextLength:
                 isMatch = True
 
         return isMatch


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