Bug 1254526 - Filter out empty text nodes from narrate queue. r=Gijs
authorEitan Isaacson <eitan@monotonous.org>
Wed, 09 Mar 2016 12:31:25 -0800
changeset 288326 5b6bcc1fec089df9ab8a72dca6abc9d74b81e12c
parent 288325 fa1daaba023bb75fcb6fe9509d71a5d658e6d92c
child 288327 940a177ba6a4875625482f17d52da5608bd1a2dd
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1254526
milestone48.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 1254526 - Filter out empty text nodes from narrate queue. r=Gijs MozReview-Commit-ID: 6g53pWcNtGN
toolkit/components/narrate/Narrator.jsm
--- a/toolkit/components/narrate/Narrator.jsm
+++ b/toolkit/components/narrate/Narrator.jsm
@@ -61,24 +61,30 @@ Narrator.prototype = {
         // are not interesting since their text already appears in their
         // parent's textContent.
         acceptNode: function(node) {
           if (this._matches.has(node.parentNode)) {
             // Reject sub-trees of accepted nodes.
             return nf.FILTER_REJECT;
           }
 
+          if (!/\S/.test(node.textContent)) {
+            // Reject nodes with no text.
+            return nf.FILTER_REJECT;
+          }
+
           let bb = wu.getBoundsWithoutFlushing(node);
           if (!bb.width || !bb.height) {
-            // Skip non-rendered nodes.
+            // Skip non-rendered nodes. We don't reject because a zero-sized
+            // container can still have visible, "overflowed", content.
             return nf.FILTER_SKIP;
           }
 
           for (let c = node.firstChild; c; c = c.nextSibling) {
-            if (c.nodeType == c.TEXT_NODE && !!c.textContent.match(/\S/)) {
+            if (c.nodeType == c.TEXT_NODE && /\S/.test(c.textContent)) {
               // If node has a non-empty text child accept it.
               this._matches.add(node);
               return nf.FILTER_ACCEPT;
             }
           }
 
           return nf.FILTER_SKIP;
         }