Bug 1581589 - Return null in GetAccessibleOrContainer for text leafs of unrendered maps. r?Jamie! a=lizzard
authorEitan Isaacson <eitan@monotonous.org>
Thu, 26 Sep 2019 04:51:45 +0300
changeset 552319 0d52451711522294346a175a1fac66859ad9f889
parent 552318 ecedb785928494238ece6311e003e96e9eb763fb
child 552320 14d183a559e0c667e43c904e4740d657dcd92de9
push id12143
push usershindli@mozilla.com
push dateWed, 09 Oct 2019 08:42:51 +0000
treeherdermozilla-beta@ce231a76c7bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie, lizzard
bugs1581589
milestone70.0
Bug 1581589 - Return null in GetAccessibleOrContainer for text leafs of unrendered maps. r?Jamie! a=lizzard 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
@@ -1171,16 +1171,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>