Bug 1581589 - Return null in GetAccessibleOrContainer for text leafs of unrendered maps. r=Jamie
authorEitan Isaacson <eitan@monotonous.org>
Thu, 26 Sep 2019 01:51:45 +0000
changeset 495022 104db8d4ae416cfadd5b259848e68fe54b95ed6e
parent 495021 1387b2c480b55ecca3fbdf62bd7649dafc62438d
child 495023 887394ac57bcb1e499bbf069de2b673e2e09f8f9
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1581589
milestone71.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 1581589 - Return null in GetAccessibleOrContainer for text leafs of unrendered maps. r=Jamie Differential Revision: https://phabricator.services.mozilla.com/D47185
accessible/generic/DocAccessible.cpp
accessible/tests/mochitest/treeupdate/test_whitespace.html
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -1188,16 +1188,26 @@ Accessible* DocAccessible::GetAccessible
           if (!parentFrameContent ||
               !parentFrameContent->IsXULElement(nsGkAtoms::tabpanels)) {
             return nullptr;
           }
         }
       }
     }
 
+    // Check if node is in zero-sized map
+    if (aNoContainerIfPruned && currNode->IsHTMLElement(nsGkAtoms::map)) {
+      if (nsIFrame* frame = currNode->AsContent()->GetPrimaryFrame()) {
+        if (nsLayoutUtils::GetAllInFlowRectsUnion(frame, frame->GetParent())
+                .IsEmpty()) {
+          return nullptr;
+        }
+      }
+    }
+
     if (Accessible* accessible = GetAccessible(currNode)) {
       return accessible;
     }
   }
 
   return nullptr;
 }
 
--- a/accessible/tests/mochitest/treeupdate/test_whitespace.html
+++ b/accessible/tests/mochitest/treeupdate/test_whitespace.html
@@ -130,25 +130,39 @@
         testAccessibleTree(this.topNode, tree);
       };
 
       this.getID = function appendImg_getID() {
         return "insert img into internal container";
       };
     }
 
+  function dontCreateMapWhiteSpace() {
+    const tree = { SECTION: [ { role: ROLE_TEXT_LEAF, name: "x" }, { TABLE: [ { ROW: [] }] } ] };
+    testAccessibleTree("container3", tree);
+
+    getNode("b").align = "Right";
+    document.body.offsetTop; // Flush layout.
+    window.windowUtils.advanceTimeAndRefresh(100);
+
+    testAccessibleTree("container3", tree);
+    window.windowUtils.restoreNormalRefresh();
+  }
+
     // //////////////////////////////////////////////////////////////////////////
     // Test
 
     // gA11yEventDumpID = "eventdump"; // debug stuff
     // gA11yEventDumpToConsole = true;
 
     var gQueue = null;
 
     function doTest() {
+      dontCreateMapWhiteSpace();
+
       gQueue = new eventQueue();
 
       gQueue.push(new removeImg());
       gQueue.push(new insertImg());
 
       gQueue.invoke(); // SimpleTest.finish() will be called in the end
     }
 
@@ -170,11 +184,17 @@
   </pre>
 
   <!-- Whitespace between the div and img tags will be inconsistent depending
        on the image cache state and what optimizations layout was able to
        apply. -->
   <div id="container1"><img src="../moz.png">  <img id="img1" src="../moz.png">  <img src="../moz.png"></div>
   <div><a id="container2"></a> <a><img src="../moz.png"></a></div>
 
+  <div id="container3">
+    <div id="c3_inner" role="presentation">
+      x<map> </map><table id="b"><tr></tr></table>
+    </div>
+  </div>
+
   <div id="eventdump"></div>
 </body>
 </html>