Bug 1520611 - Add pivot prune prefilter, use it in jsat. r=yzen
authorEitan Isaacson <eitan@monotonous.org>
Thu, 24 Jan 2019 00:23:40 +0000
changeset 515213 8507cbf5c07accbc6bfc4fa0f7f610a4407bc92b
parent 515212 842a7d9f54bbf01448a887271a1488cc06311aee
child 515214 556063466b9865fec4a390594ea8f1d1bc271f95
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs1520611
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520611 - Add pivot prune prefilter, use it in jsat. r=yzen Differential Revision: https://phabricator.services.mozilla.com/D16742
accessible/base/nsAccessiblePivot.cpp
accessible/interfaces/nsIAccessiblePivot.idl
accessible/jsat/Traversal.jsm
accessible/tests/mochitest/jsat/test_traversal.html
--- a/accessible/base/nsAccessiblePivot.cpp
+++ b/accessible/base/nsAccessiblePivot.cpp
@@ -842,16 +842,21 @@ nsresult RuleCache::ApplyFilter(Accessib
     NS_ENSURE_SUCCESS(rv, rv);
     rv = mRule->GetPreFilter(&mPreFilter);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (mPreFilter) {
     uint64_t state = aAccessible->State();
 
+    if ((nsIAccessibleTraversalRule::PREFILTER_PLATFORM_PRUNED & mPreFilter) &&
+        nsAccUtils::MustPrune(aAccessible)) {
+      *aResult |= nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE;
+    }
+
     if ((nsIAccessibleTraversalRule::PREFILTER_INVISIBLE & mPreFilter) &&
         (state & states::INVISIBLE))
       return NS_OK;
 
     if ((nsIAccessibleTraversalRule::PREFILTER_OFFSCREEN & mPreFilter) &&
         (state & states::OFFSCREEN))
       return NS_OK;
 
@@ -874,10 +879,15 @@ nsresult RuleCache::ApplyFilter(Accessib
     bool matchesRole = false;
     for (uint32_t idx = 0; idx < mAcceptRolesLength; idx++) {
       matchesRole = mAcceptRoles[idx] == accessibleRole;
       if (matchesRole) break;
     }
     if (!matchesRole) return NS_OK;
   }
 
-  return mRule->Match(ToXPC(aAccessible), aResult);
+  uint16_t matchResult = nsIAccessibleTraversalRule::FILTER_IGNORE;
+  nsresult rv = mRule->Match(ToXPC(aAccessible), &matchResult);
+  if (NS_SUCCEEDED(rv)) {
+    *aResult |= matchResult;
+  }
+  return rv;
 }
--- a/accessible/interfaces/nsIAccessiblePivot.idl
+++ b/accessible/interfaces/nsIAccessiblePivot.idl
@@ -222,21 +222,21 @@ interface nsIAccessibleTraversalRule : n
   /* Ignore this accessible object */
   const unsigned short FILTER_IGNORE = 0x0;
   /* Accept this accessible object */
   const unsigned short FILTER_MATCH = 0x1;
   /* Don't traverse accessibles children */
   const unsigned short FILTER_IGNORE_SUBTREE = 0x2;
 
   /* Pre-filters */
-  const unsigned long PREFILTER_INVISIBLE     = 0x00000001;
-  const unsigned long PREFILTER_OFFSCREEN     = 0x00000002;
-  const unsigned long PREFILTER_NOT_FOCUSABLE = 0x00000004;
-  const unsigned long PREFILTER_TRANSPARENT   = 0x00000008;
-
+  const unsigned long PREFILTER_INVISIBLE         = 0x00000001;
+  const unsigned long PREFILTER_OFFSCREEN         = 0x00000002;
+  const unsigned long PREFILTER_NOT_FOCUSABLE     = 0x00000004;
+  const unsigned long PREFILTER_TRANSPARENT       = 0x00000008;
+  const unsigned long PREFILTER_PLATFORM_PRUNED   = 0x00000010;
   /**
    * Pre-filter bitfield to filter out obviously ignorable nodes and lighten
    * the load on match().
    */
   readonly attribute unsigned long preFilter;
 
   /**
    * Retrieve a list of roles that the traversal rule should test for. Any node
--- a/accessible/jsat/Traversal.jsm
+++ b/accessible/jsat/Traversal.jsm
@@ -161,25 +161,25 @@ var gSimpleMatchFunc = function gSimpleM
     // the same content that was already presented by its parent.
     return Filters.MATCH |
       Filters.IGNORE_SUBTREE;
   }
 };
 
 var gSimplePreFilter = Prefilters.DEFUNCT |
   Prefilters.INVISIBLE |
-  Prefilters.TRANSPARENT;
+  Prefilters.TRANSPARENT |
+  Prefilters.PLATFORM_PRUNED;
 
 var TraversalRules = { // jshint ignore:line
   Simple: new BaseTraversalRule(gSimpleTraversalRoles, gSimpleMatchFunc),
 
   SimpleOnScreen: new BaseTraversalRule(
     gSimpleTraversalRoles, gSimpleMatchFunc,
-    Prefilters.DEFUNCT | Prefilters.INVISIBLE |
-    Prefilters.TRANSPARENT | Prefilters.OFFSCREEN),
+    gSimplePreFilter | Prefilters.OFFSCREEN),
 
   Anchor: new BaseTraversalRule(
     [Roles.LINK],
     function Anchor_match(aAccessible) {
       // We want to ignore links, only focus named anchors.
       if (Utils.getState(aAccessible).contains(States.LINKED)) {
         return Filters.IGNORE;
       }
--- a/accessible/tests/mochitest/jsat/test_traversal.html
+++ b/accessible/tests/mochitest/jsat/test_traversal.html
@@ -112,23 +112,23 @@
                               "A esoteric weapon wielded by only the most " +
                               "formidable warriors, for its unrelenting strict" +
                               " power is unfathomable.",
                               "• Lists of Programming Languages", "Lisp ",
                               "1. Scheme", "2. Racket", "3. Clojure",
                               "4. Standard Lisp", "link-0", " Lisp",
                               "checkbox-1-5", " LeLisp", "• JavaScript",
                               "heading-5", "image-1", "image-2", "image-3",
-                              "Not actually an image", "link-1", "anchor-1",
-                              "link-2", "anchor-2", "link-3", "3", "1", "4",
-                              "1", "Sunday", "M", "Week 1", "3", "4", "7", "2",
-                              "5 8", "gridcell4", "Just an innocuous separator",
+                              "link-1", "anchor-1", "link-2", "anchor-2",
+                              "link-3", "3", "1", "4", "1", "Sunday", "M",
+                              "Week 1", "3", "4", "7", "2", "5 8", "gridcell4",
                               "Dirty Words", "Meaning", "Mud", "Wet Dirt",
-                              "Dirt", "Messy Stuff", "statusbar-1", "statusbar-2",
-                              "switch-1", "This is a MathML formula ", "math-1",
+                              "Dirt", "Messy Stuff", "statusbar-1",
+                              "statusbar-2", "switch-1",
+                              "This is a MathML formula ", "math-1",
                               "with some text after."]);
 
       queueTraversalSequence(gQueue, docAcc, TraversalRules.Landmark, null,
                              ["header-1", "main-1", "footer-1"]);
 
 
       queueTraversalSequence(gQueue, docAcc, TraversalRules.Control, null,
                              ["input-1-1", "input-1-2", "button-1-1",